Now fetch for User class use id like other classes.

This commit is contained in:
Laurent Destailleur 2010-05-05 17:36:20 +00:00
parent b0a065ce02
commit e4bba520f7
22 changed files with 48 additions and 67 deletions

View File

@ -771,8 +771,7 @@ class Adherent extends CommonObject
// This member is linked with a user, so we also update users informations // This member is linked with a user, so we also update users informations
// if this is an update. // if this is an update.
$luser=new User($this->db); $luser=new User($this->db);
$luser->id=$this->user_id; $result=$luser->fetch($this->user_id);
$result=$luser->fetch();
if ($result >= 0) if ($result >= 0)
{ {

View File

@ -130,8 +130,7 @@ if ($objectid > 0)
$act->societe=$company; $act->societe=$company;
$author=new User($db); $author=new User($db);
$author->id=$act->author->id; $author->fetch($act->author->id);
$author->fetch();
$act->author=$author; $act->author=$author;
$contact=new Contact($db); $contact=new Contact($db);

View File

@ -1337,8 +1337,7 @@ else
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = commande_prepare_head($commande); $head = commande_prepare_head($commande);
dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order');

View File

@ -139,8 +139,7 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = commande_prepare_head($commande); $head = commande_prepare_head($commande);
dol_fiche_head($head, 'accountancy', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'accountancy', $langs->trans("CustomerOrder"), 0, 'order');

View File

@ -1978,8 +1978,7 @@ else
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($fac->user_author)
{ {
$author->id = $fac->user_author; $author->fetch($fac->user_author);
$author->fetch();
} }
$facidnext=$fac->getIdReplacingInvoice(); $facidnext=$fac->getIdReplacingInvoice();

View File

@ -74,8 +74,7 @@ if ($_GET["facid"] > 0)
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($fac->user_author)
{ {
$author->id = $fac->user_author; $author->fetch($fac->user_author);
$author->fetch();
} }
$head = facture_prepare_head($fac); $head = facture_prepare_head($fac);

View File

@ -2221,7 +2221,8 @@ class Facture extends CommonObject
global $conf, $db, $langs; global $conf, $db, $langs;
$langs->load("bills"); $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'; $conf->global->FACTURE_ADDON='mod_facture_terre';
} }
@ -2253,7 +2254,11 @@ class Facture extends CommonObject
} }
//print "xx".$mybool.$dir.$file."-".$classname; //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(); $obj = new $classname();
@ -2267,7 +2272,7 @@ class Facture extends CommonObject
else else
{ {
dol_print_error($db,"Facture::getNextNumRef ".$obj->error); dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return ""; return '';
} }
} }

View File

@ -339,8 +339,7 @@ else
$soc = new Societe($db, $fac->socid); $soc = new Societe($db, $fac->socid);
$soc->fetch($fac->socid); $soc->fetch($fac->socid);
$author = new User($db); $author = new User($db);
$author->id = $fac->user_author; $author->fetch($fac->user_author);
$author->fetch();
print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre); print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre);
print '<br>'; print '<br>';

View File

@ -110,8 +110,7 @@ if ($_GET["facid"] > 0)
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($fac->user_author)
{ {
$author->id = $fac->user_author; $author->fetch($fac->user_author);
$author->fetch();
} }
$head = facture_prepare_head($fac); $head = facture_prepare_head($fac);

View File

@ -649,16 +649,13 @@ else
$nbofservices=sizeof($contrat->lignes); $nbofservices=sizeof($contrat->lignes);
$author = new User($db); $author = new User($db);
$author->id = $contrat->user_author_id; $author->fetch($contrat->user_author_id);
$author->fetch();
$commercial_signature = new User($db); $commercial_signature = new User($db);
$commercial_signature->id = $contrat->commercial_signature_id; $commercial_signature->fetch($contrat->commercial_signature_id);
$commercial_signature->fetch();
$commercial_suivi = new User($db); $commercial_suivi = new User($db);
$commercial_suivi->id = $contrat->commercial_suivi_id; $commercial_suivi->fetch($contrat->commercial_suivi_id);
$commercial_suivi->fetch();
$head = contract_prepare_head($contrat); $head = contract_prepare_head($contrat);

View File

@ -268,8 +268,7 @@ if ($_GET["action"] == 'create')
$soc->fetch($object->socid); $soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
$author->id = $object->user_author_id; $author->fetch($object->user_author_id);
$author->fetch();
if ($conf->stock->enabled) $entrepot = new Entrepot($db); if ($conf->stock->enabled) $entrepot = new Entrepot($db);

View File

@ -147,8 +147,7 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = commande_prepare_head($commande); $head = commande_prepare_head($commande);
dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order');

View File

@ -103,8 +103,7 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($commande);

View File

@ -134,9 +134,8 @@ if ($id > 0 || ! empty($ref))
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($commande);

View File

@ -546,8 +546,7 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($commande);

View File

@ -61,8 +61,7 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
llxHeader('',$langs->trans("History"),"CommandeFournisseur"); llxHeader('',$langs->trans("History"),"CommandeFournisseur");

View File

@ -86,8 +86,7 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($commande);

View File

@ -110,8 +110,8 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Creation du livreur //Creation du livreur
$idcontact = $object->commande->getIdContact('internal','LIVREUR'); $idcontact = $object->commande->getIdContact('internal','LIVREUR');
$this->livreur = new User($this->db,$idcontact[0]); $this->livreur = new User($this->db);
if ($idcontact[0]) $this->livreur->fetch(); if ($idcontact[0]) $this->livreur->fetch($idcontact[0]);
// Definition de $dir et $file // Definition de $dir et $file

View File

@ -98,8 +98,7 @@ function dol_print_object_info($object)
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->id=$object->user_creation; $userstatic->fetch($object->user_creation);
$userstatic->fetch();
print $userstatic->getNomUrl(1); print $userstatic->getNomUrl(1);
} }
print '<br>'; print '<br>';
@ -120,8 +119,7 @@ function dol_print_object_info($object)
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->id=$object->user_modification; $userstatic->fetch($object->user_modification);
$userstatic->fetch();
print $userstatic->getNomUrl(1); print $userstatic->getNomUrl(1);
} }
print '<br>'; print '<br>';
@ -142,8 +140,7 @@ function dol_print_object_info($object)
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->id=$object->user_validation; $userstatic->fetch($object->user_validation);
$userstatic->fetch();
print $userstatic->getNomUrl(1); print $userstatic->getNomUrl(1);
} }
print '<br>'; print '<br>';
@ -164,8 +161,7 @@ function dol_print_object_info($object)
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->id=$object->user_cloture; $userstatic->fetch($object->user_cloture);
$userstatic->fetch();
print $userstatic->getNomUrl(1); print $userstatic->getNomUrl(1);
} }
print '<br>'; print '<br>';
@ -186,8 +182,7 @@ function dol_print_object_info($object)
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->id=$object->user_rappro; $userstatic->fetch($object->user_rappro);
$userstatic->fetch();
print $userstatic->getNomUrl(1); print $userstatic->getNomUrl(1);
} }
print '<br>'; print '<br>';

View File

@ -216,8 +216,7 @@ if ($_GET["action"] == 'create')
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($commande->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->fetch($commande->user_author_id);
$author->fetch();
if (!$conf->expedition_bon->enabled && $conf->stock->enabled) if (!$conf->expedition_bon->enabled && $conf->stock->enabled)
{ {

View File

@ -562,7 +562,6 @@ if ($_REQUEST["amount"] == 'membersubscription')
else else
{ {
$subscription=new Cotisation($db); $subscription=new Cotisation($db);
//$result=$subscription->fetch();
} }
$amount=$subscription->total_ttc; $amount=$subscription->total_ttc;

View File

@ -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() function delete()
{ {
@ -634,7 +635,7 @@ class User extends CommonObject
$this->db->begin(); $this->db->begin();
$this->fetch(); $this->fetch($this->id);
// Supprime droits // Supprime droits
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id;