Skip to content

Commit

Permalink
Qual: Standardisation of code. Clean some code.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 24, 2008
1 parent 8ce7d51 commit 72d107a
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 256 deletions.
6 changes: 3 additions & 3 deletions htdocs/comm/propal.php
Expand Up @@ -647,9 +647,9 @@

if ($_POST['action'] == 'classin')
{
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
$propal->set_project($user, $_POST['projetidp']);
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
$propal->setProject($_POST['projetidp']);
}

// Conditions de reglement
Expand Down
24 changes: 3 additions & 21 deletions htdocs/commande/commande.class.php
Expand Up @@ -36,8 +36,10 @@
*/
class Commande extends CommonObject
{
var $db ;
var $db;
var $error;
var $element='commande';
var $table_element='commande';

var $id ;

Expand Down Expand Up @@ -1997,26 +1999,6 @@ function delete()
}
}

/**
* \brief Classer la commande dans un projet
* \param cat_id Id du projet
*/
function classin($cat_id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
$sql .= " WHERE rowid = $this->id;";

if ($this->db->query($sql) )
{
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}


/**
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
Expand Down
13 changes: 8 additions & 5 deletions htdocs/commande/fiche.php
Expand Up @@ -18,15 +18,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/

/**
\file htdocs/commande/fiche.php
\ingroup commande
\brief Fiche commande client
\version $Revision$
\version $Id$
*/

require('./pre.inc.php');
Expand Down Expand Up @@ -121,11 +119,11 @@
}

// Categorisation dans projet
if ($_POST['action'] == 'classin' && $user->rights->commande->creer)
if ($_POST['action'] == 'classin')
{
$commande = new Commande($db);
$commande->fetch($_GET['id']);
$commande->classin($_POST['projetid']);
$commande->setProject($_POST['projetid']);
}

// Ajout commande
Expand Down Expand Up @@ -708,6 +706,11 @@
}
}


/*
* View
*/

llxHeader('',$langs->trans('Order'),'Commande');

$html = new Form($db);
Expand Down
31 changes: 31 additions & 0 deletions htdocs/commonobject.class.php
Expand Up @@ -562,6 +562,37 @@ function getListContactId($source='external')
return $contactAlreadySelected;
}


/**
* \brief Link ekement with a project
* \param projid Project id to link element to
* \return int <0 if KO, >0 if OK
*/
function setProject($projid)
{
if (! $this->table_element)
{
dolibarr_syslog("CommonObject::setProject was called on objet with property table_element not defined");
return -1;
}

$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
if ($projid) $sql.= ' SET fk_projet = '.$projid;
else $sql.= ' SET fk_projet = NULL';
$sql.= ' WHERE rowid = '.$this->id;

dolibarr_syslog("CommonObject::set_project sql=".$sql);
if ($this->db->query($sql))
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}

}

?>
9 changes: 1 addition & 8 deletions htdocs/compta/facture.php
Expand Up @@ -171,7 +171,7 @@
{
$facture = new Facture($db);
$facture->fetch($_GET['facid']);
$facture->classin($_POST['projetid']);
$facture->setProject($_POST['projetid']);
}

if ($_POST['action'] == 'setmode')
Expand Down Expand Up @@ -233,13 +233,6 @@
}
}

if ($_POST['action'] == 'classin')
{
$facture = new Facture($db);
$facture->fetch($_GET['facid']);
$facture->classin($_POST['projetid']);
}

if ($_POST['action'] == 'set_ref_client')
{
$facture = new Facture($db);
Expand Down
25 changes: 2 additions & 23 deletions htdocs/contrat/contrat.class.php
Expand Up @@ -36,7 +36,9 @@
class Contrat extends CommonObject
{
var $db;
var $error;
var $element='contrat';
var $table_element='contrat';

var $id;
var $ref;
Expand Down Expand Up @@ -907,29 +909,6 @@ function update_price()
}


/**
* \brief Classe le contrat dans un projet
* \param projid Id du projet dans lequel classer le contrat
*/
function classin($projid)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat";
if ($projid) $sql.= " SET fk_projet = $projid";
else $sql.= " SET fk_projet = NULL";
$sql.= " WHERE rowid = ".$this->id;

if ($this->db->query($sql))
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}


/**
* \brief Mets à jour les commentaires privés
* \param note Commentaire
Expand Down
6 changes: 3 additions & 3 deletions htdocs/contrat/fiche.php
Expand Up @@ -169,7 +169,7 @@
{
$contrat = new Contrat($db);
$contrat->fetch($_GET["id"]);
$contrat->classin($_POST["projetid"]);
$contrat->setProject($_POST["projetid"]);
}

if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
Expand Down Expand Up @@ -1067,7 +1067,7 @@
/*
* Ajouter une ligne produit/service
*/
if ($user->rights->contrat->creer && $contrat->statut == 0)
if ($user->rights->contrat->creer && ($contrat->statut == 0 || $conf->global->CONTRAT_EDITWHENVALIDATED))
{
print '<br>';
print '<table class="noborder" width="100%">'; // Array with (n*2)+1 lines
Expand Down Expand Up @@ -1169,7 +1169,7 @@
{
print '<div class="tabsAction">';

if (($contrat->statut == 0 || $conf->global->CONTRAT_EDITWHENVALIDATED) && $nbofservices)
if ($contrat->statut == 0 && $nbofservices)
{
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
}
Expand Down
33 changes: 7 additions & 26 deletions htdocs/expedition/expedition.class.php
Expand Up @@ -17,16 +17,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/

/**
\file htdocs/expedition/expedition.class.php
\ingroup expedition
\brief Fichier de la classe de gestion des expeditions
\version $Revision$
\version $Id$
*/

require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
Expand All @@ -41,6 +38,10 @@
class Expedition extends CommonObject
{
var $db;
var $error;
var $element="expedition";
var $table_element="expedition";

var $id;
var $socid;
var $brouillon;
Expand All @@ -55,8 +56,8 @@ class Expedition extends CommonObject
*
*/
function Expedition($DB)
{
global $langs;
{
global $langs;

$this->db = $DB;
$this->lignes = array();
Expand Down Expand Up @@ -541,26 +542,6 @@ function delete()
}
}

/**
* Classe la commande
*
*
*/
function classin($cat_id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
$sql .= " WHERE rowid = $this->id;";

if ($this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}


/**
* \brief Positionne modele derniere generation
Expand Down

0 comments on commit 72d107a

Please sign in to comment.