From e4bba520f71be361612979c102f393ecd2fec562 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 5 May 2010 17:36:20 +0000 Subject: [PATCH] Now fetch for User class use id like other classes. --- htdocs/adherents/class/adherent.class.php | 3 +-- htdocs/comm/action/document.php | 3 +-- htdocs/commande/fiche.php | 3 +-- htdocs/compta/commande/fiche.php | 11 +++++------ htdocs/compta/facture.php | 3 +-- htdocs/compta/facture/apercu.php | 3 +-- htdocs/compta/facture/class/facture.class.php | 11 ++++++++--- htdocs/compta/facture/fiche-rec.php | 3 +-- htdocs/compta/facture/prelevement.php | 3 +-- htdocs/contrat/fiche.php | 17 +++++++---------- htdocs/expedition/fiche.php | 3 +-- htdocs/expedition/shipment.php | 3 +-- htdocs/fourn/commande/dispatch.php | 3 +-- htdocs/fourn/commande/document.php | 5 ++--- htdocs/fourn/commande/fiche.php | 7 +++---- htdocs/fourn/commande/history.php | 3 +-- htdocs/fourn/commande/note.php | 3 +-- .../pdf/pdf_expedition_merou.modules.php | 4 ++-- htdocs/lib/functions2.lib.php | 15 +++++---------- htdocs/livraison/fiche.php | 3 +-- htdocs/public/paybox/newpayment.php | 1 - htdocs/user/class/user.class.php | 5 +++-- 22 files changed, 48 insertions(+), 67 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 61ce837d60c..c7b15aa7bcb 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -771,8 +771,7 @@ class Adherent extends CommonObject // This member is linked with a user, so we also update users informations // if this is an update. $luser=new User($this->db); - $luser->id=$this->user_id; - $result=$luser->fetch(); + $result=$luser->fetch($this->user_id); if ($result >= 0) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 1f84efa4249..95837799558 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -130,8 +130,7 @@ if ($objectid > 0) $act->societe=$company; $author=new User($db); - $author->id=$act->author->id; - $author->fetch(); + $author->fetch($act->author->id); $act->author=$author; $contact=new Contact($db); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1f7784e905b..c6f97ed89a4 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1337,8 +1337,7 @@ else $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); $head = commande_prepare_head($commande); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php index 2438637df7d..5a3a76478f9 100644 --- a/htdocs/compta/commande/fiche.php +++ b/htdocs/compta/commande/fiche.php @@ -139,8 +139,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); $head = commande_prepare_head($commande); dol_fiche_head($head, 'accountancy', $langs->trans("CustomerOrder"), 0, 'order'); @@ -150,7 +149,7 @@ if ($id > 0 || ! empty($ref)) */ $nbrow=7; if ($conf->projet->enabled) $nbrow++; - + //Local taxes if ($mysoc->pays_code=='ES' && $conf->global->MAIN_FEATURES_LEVEL >= 1) { @@ -375,8 +374,8 @@ if ($id > 0 || ! empty($ref)) print '<td align="right">'.price($propal->total_localtax2).'</td>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; } - } - + } + // Total TTC print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; @@ -580,7 +579,7 @@ if ($id > 0 || ! empty($ref)) * Linked object block */ $commande->load_object_linked($commande->id,$commande->element); - + foreach($commande->linked_object as $object => $objectid) { if($conf->$object->enabled && $object != $commande->element) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 103b3961510..a7a07f35d7c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1978,8 +1978,7 @@ else $author = new User($db); if ($fac->user_author) { - $author->id = $fac->user_author; - $author->fetch(); + $author->fetch($fac->user_author); } $facidnext=$fac->getIdReplacingInvoice(); diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php index 72ab25a1af3..85fb4b7d740 100644 --- a/htdocs/compta/facture/apercu.php +++ b/htdocs/compta/facture/apercu.php @@ -74,8 +74,7 @@ if ($_GET["facid"] > 0) $author = new User($db); if ($fac->user_author) { - $author->id = $fac->user_author; - $author->fetch(); + $author->fetch($fac->user_author); } $head = facture_prepare_head($fac); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2ae7ef1d3dd..fec912c296d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2221,7 +2221,8 @@ class Facture extends CommonObject global $conf, $db, $langs; $langs->load("bills"); - if (empty($conf->global->FACTURE_ADDON)) + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->FACTURE_ADDON) || $conf->global->FACTURE_ADDON=='terre') { $conf->global->FACTURE_ADDON='mod_facture_terre'; } @@ -2253,7 +2254,11 @@ class Facture extends CommonObject } //print "xx".$mybool.$dir.$file."-".$classname; - if (! $mybool) dol_print_error('',"Failed to include file ".$file); + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } $obj = new $classname(); @@ -2267,7 +2272,7 @@ class Facture extends CommonObject else { dol_print_error($db,"Facture::getNextNumRef ".$obj->error); - return ""; + return ''; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 38e4b8f5d98..8ce412a5dd2 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -339,8 +339,7 @@ else $soc = new Societe($db, $fac->socid); $soc->fetch($fac->socid); $author = new User($db); - $author->id = $fac->user_author; - $author->fetch(); + $author->fetch($fac->user_author); print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre); print '<br>'; diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index e5b93a2f8f4..0411f05bfa3 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -110,8 +110,7 @@ if ($_GET["facid"] > 0) $author = new User($db); if ($fac->user_author) { - $author->id = $fac->user_author; - $author->fetch(); + $author->fetch($fac->user_author); } $head = facture_prepare_head($fac); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 07eaef34c36..01f26de6018 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -649,16 +649,13 @@ else $nbofservices=sizeof($contrat->lignes); $author = new User($db); - $author->id = $contrat->user_author_id; - $author->fetch(); + $author->fetch($contrat->user_author_id); $commercial_signature = new User($db); - $commercial_signature->id = $contrat->commercial_signature_id; - $commercial_signature->fetch(); + $commercial_signature->fetch($contrat->commercial_signature_id); $commercial_suivi = new User($db); - $commercial_suivi->id = $contrat->commercial_suivi_id; - $commercial_suivi->fetch(); + $commercial_suivi->fetch($contrat->commercial_suivi_id); $head = contract_prepare_head($contrat); @@ -1329,16 +1326,16 @@ else print "</div>"; print '<br>'; } - + /* * Linked object block */ $contrat->load_object_linked($contrat->id,$contrat->element); - + if (! empty($contrat->linked_object)) { print '<table width="100%"><tr><td width="50%" valign="top">'; - + foreach($contrat->linked_object as $object => $objectid) { if($conf->$object->enabled && $object != $contrat->element) @@ -1346,7 +1343,7 @@ else $somethingshown=$contrat->showLinkedObjectBlock($object,$objectid,$somethingshown); } } - + print '</td><td valign="top" width="50%">'; print '</td></tr></table>'; } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index e83d9281a1f..8f99886fc12 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -268,8 +268,7 @@ if ($_GET["action"] == 'create') $soc->fetch($object->socid); $author = new User($db); - $author->id = $object->user_author_id; - $author->fetch(); + $author->fetch($object->user_author_id); if ($conf->stock->enabled) $entrepot = new Entrepot($db); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 63b20da6a2d..259d3c6aef4 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -147,8 +147,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); $head = commande_prepare_head($commande); dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order'); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 167c00e8a10..67a40dcdf59 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -103,8 +103,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); $head = ordersupplier_prepare_head($commande); diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 07040129482..3b034ab03d6 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -134,9 +134,8 @@ if ($id > 0 || ! empty($ref)) $soc = new Societe($db); $soc->fetch($commande->socid); - $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author = new User($db); + $author->fetch($commande->user_author_id); $head = ordersupplier_prepare_head($commande); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 28f462cffbf..fb7277cac2b 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -546,8 +546,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); $head = ordersupplier_prepare_head($commande); @@ -637,14 +636,14 @@ if ($id > 0 || ! empty($ref)) */ $nbrow=8; if ($conf->projet->enabled) $nbrow++; - + //Local taxes if ($mysoc->pays_code=='ES' && $conf->global->MAIN_FEATURES_LEVEL >= 1) { if($mysoc->localtax1_assuj=="1") $nbrow++; if($mysoc->localtax2_assuj=="1") $nbrow++; } - + print '<table class="border" width="100%">'; // Ref diff --git a/htdocs/fourn/commande/history.php b/htdocs/fourn/commande/history.php index 073d3e5c351..066332e726b 100644 --- a/htdocs/fourn/commande/history.php +++ b/htdocs/fourn/commande/history.php @@ -61,8 +61,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); llxHeader('',$langs->trans("History"),"CommandeFournisseur"); diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index d071c17a09b..6abcae8d6bc 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -86,8 +86,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); $head = ordersupplier_prepare_head($commande); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php index 9f545f2fed9..5aa8fd9fc6f 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php @@ -110,8 +110,8 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Creation du livreur $idcontact = $object->commande->getIdContact('internal','LIVREUR'); - $this->livreur = new User($this->db,$idcontact[0]); - if ($idcontact[0]) $this->livreur->fetch(); + $this->livreur = new User($this->db); + if ($idcontact[0]) $this->livreur->fetch($idcontact[0]); // Definition de $dir et $file diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index d9f84314f33..ac59bd5735a 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -98,8 +98,7 @@ function dol_print_object_info($object) else { $userstatic=new User($db); - $userstatic->id=$object->user_creation; - $userstatic->fetch(); + $userstatic->fetch($object->user_creation); print $userstatic->getNomUrl(1); } print '<br>'; @@ -120,8 +119,7 @@ function dol_print_object_info($object) else { $userstatic=new User($db); - $userstatic->id=$object->user_modification; - $userstatic->fetch(); + $userstatic->fetch($object->user_modification); print $userstatic->getNomUrl(1); } print '<br>'; @@ -142,8 +140,7 @@ function dol_print_object_info($object) else { $userstatic=new User($db); - $userstatic->id=$object->user_validation; - $userstatic->fetch(); + $userstatic->fetch($object->user_validation); print $userstatic->getNomUrl(1); } print '<br>'; @@ -164,8 +161,7 @@ function dol_print_object_info($object) else { $userstatic=new User($db); - $userstatic->id=$object->user_cloture; - $userstatic->fetch(); + $userstatic->fetch($object->user_cloture); print $userstatic->getNomUrl(1); } print '<br>'; @@ -186,8 +182,7 @@ function dol_print_object_info($object) else { $userstatic=new User($db); - $userstatic->id=$object->user_rappro; - $userstatic->fetch(); + $userstatic->fetch($object->user_rappro); print $userstatic->getNomUrl(1); } print '<br>'; diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 1465a12055f..63bffa7f0ac 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -216,8 +216,7 @@ if ($_GET["action"] == 'create') $soc = new Societe($db); $soc->fetch($commande->socid); $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author->fetch($commande->user_author_id); if (!$conf->expedition_bon->enabled && $conf->stock->enabled) { diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 71e6358b699..3087205c68a 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -562,7 +562,6 @@ if ($_REQUEST["amount"] == 'membersubscription') else { $subscription=new Cotisation($db); - //$result=$subscription->fetch(); } $amount=$subscription->total_ttc; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index aa2a19d7474..b9b668f990f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -626,7 +626,8 @@ class User extends CommonObject /** - * \brief Supprime completement un utilisateur + * \brief Delete the user + * \param int <0 if KO, >0 if OK */ function delete() { @@ -634,7 +635,7 @@ class User extends CommonObject $this->db->begin(); - $this->fetch(); + $this->fetch($this->id); // Supprime droits $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id; -- GitLab