From e45bbb622a9f6c0f201335ac42fc0f308bdb8150 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Mar 2012 01:09:39 +0100 Subject: [PATCH] Fix: Some fix and uniformize code for extra parameters. --- htdocs/adherents/card_subscriptions.php | 173 +++++++++++----------- htdocs/adherents/class/adherent.class.php | 8 +- htdocs/adherents/fiche.php | 14 +- htdocs/product/fiche.php | 12 +- htdocs/public/members/public_card.php | 51 ++++--- htdocs/societe/soc.php | 4 +- 6 files changed, 132 insertions(+), 130 deletions(-) diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index a831ec46a2e..8d33ae52e5a 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -42,8 +42,8 @@ $langs->load("mails"); // Security check if (! $user->rights->adherent->cotisation->lire) accessforbidden(); -$adh = new Adherent($db); -$adho = new ExtraFields($db); +$object = new Adherent($db); +$extrafields = new ExtraFields($db); $adht = new AdherentType($db); $errmsg=''; @@ -57,18 +57,18 @@ $typeid=GETPOST('typeid'); if ($rowid) { // Load member - $result = $adh->fetch($rowid); + $result = $object->fetch($rowid); // Define variables to know what current user can do on users $canadduser=($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member - if ($adh->user_id) + if ($object->user_id) { - // $user est le user qui edite, $adh->user_id est l'id de l'utilisateur lies au membre edite - $caneditfielduser=( (($user->id == $adh->user_id) && $user->rights->user->self->creer) - || (($user->id != $adh->user_id) && $user->rights->user->user->creer) ); - $caneditpassworduser=( (($user->id == $adh->user_id) && $user->rights->user->self->password) - || (($user->id != $adh->user_id) && $user->rights->user->user->password) ); + // $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite + $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer) + || (($user->id != $object->user_id) && $user->rights->user->user->creer) ); + $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password) + || (($user->id != $object->user_id) && $user->rights->user->user->password) ); } } @@ -93,7 +93,7 @@ if ($action == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $use { // Creation user $company = new Societe($db); - $result=$company->create_from_member($adh,$_POST["companyname"]); + $result=$company->create_from_member($object,$_POST["companyname"]); if ($result < 0) { @@ -108,7 +108,7 @@ if ($action == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $use } else { - $errmsg=$adh->error; + $errmsg=$object->error; } } @@ -117,7 +117,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights $error=0; if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { - if ($_POST["userid"] != $user->id && $_POST["userid"] != $adh->user_id) + if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { $error++; $mesg='
'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'
'; @@ -126,10 +126,10 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights if (! $error) { - if ($_POST["userid"] != $adh->user_id) // If link differs from currently in database + if ($_POST["userid"] != $object->user_id) // If link differs from currently in database { - $result=$adh->setUserId($_POST["userid"]); - if ($result < 0) dol_print_error($adh->db,$adh->error); + $result=$object->setUserId($_POST["userid"]); + if ($result < 0) dol_print_error($object->db,$object->error); $_POST['action']=''; $action=''; } @@ -141,7 +141,7 @@ if ($action == 'setsocid') $error=0; if (! $error) { - if (GETPOST('socid','int') != $adh->fk_soc) // If link differs from currently in database + if (GETPOST('socid','int') != $object->fk_soc) // If link differs from currently in database { $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql.=" WHERE fk_soc = '".GETPOST('socid','int')."'"; @@ -162,8 +162,8 @@ if ($action == 'setsocid') if (! $error) { - $result=$adh->setThirdPartyId(GETPOST('socid','int')); - if ($result < 0) dol_print_error($adh->db,$adh->error); + $result=$object->setThirdPartyId(GETPOST('socid','int')); + if ($result < 0) dol_print_error($object->db,$object->error); $_POST['action']=''; $action=''; } @@ -177,8 +177,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ $langs->load("banks"); - $result=$adh->fetch($rowid); - $result=$adht->fetch($adh->typeid); + $result=$object->fetch($rowid); + $result=$adht->fetch($object->typeid); // Subscription informations $datecotisation=0; @@ -268,12 +268,12 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ $db->begin(); // Create subscription - $crowid=$adh->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $option); + $crowid=$object->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $option); if ($crowid <= 0) { $error++; - $errmsg=$adh->error; - $errmsgs=$adh->errors; + $errmsg=$object->error; + $errmsgs=$object->errors; } if (! $error) @@ -291,7 +291,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ $insertid=$acct->addline($dateop, $operation, $label, $cotisation, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { - $inserturlid=$acct->add_url_line($insertid, $adh->id, DOL_URL_ROOT.'/adherents/fiche.php?rowid=', $adh->getFullname($langs), 'member'); + $inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/fiche.php?rowid=', $object->getFullname($langs), 'member'); if ($inserturlid > 0) { // Met a jour la table cotisation @@ -327,7 +327,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ $invoice=new Facture($db); $customer=new Societe($db); - $result=$customer->fetch($adh->fk_soc); + $result=$customer->fetch($object->fk_soc); if ($result <= 0) { $errmsg=$customer->error; @@ -347,7 +347,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ $errmsg='ErrorNoPaymentTermRECEPFound'; } } - $invoice->socid=$adh->fk_soc; + $invoice->socid=$object->fk_soc; $invoice->date=$datecotisation; $result=$invoice->create($user); @@ -434,13 +434,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ if (! $error) { // Send confirmation Email - if ($adh->email && $_POST["sendmail"]) + if ($object->email && $_POST["sendmail"]) { - $subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); - $texttosend=$adh->makeSubstitution($adht->getMailOnSubscription()); + $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); + $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); - $result=$adh->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1); - if ($result < 0) $errmsg=$adh->error; + $result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1); + if ($result < 0) $errmsg=$object->error; } $_POST["cotisation"]=''; @@ -466,16 +466,14 @@ llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adh if ($rowid) { - $result=$adh->fetch($rowid); - $result=$adh->fetch_optionals($rowid); + $res=$object->fetch($rowid,$ref); + if ($res < 0) { dol_print_error($db,$object->error); exit; } + //$res=$object->fetch_optionals($object->id,$extralabels); + //if ($res < 0) { dol_print_error($db); exit; } - $adht->fetch($adh->typeid); + $adht->fetch($object->typeid); - // fetch optionals attributes and labels - $adho->fetch_optionals(); - - - $head = member_prepare_head($adh); + $head = member_prepare_head($object); dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user'); @@ -485,27 +483,27 @@ if ($rowid) print '
'; print ''; - print ''; + print ''; print ''; // Ref print ''; print ''; - $showphoto=''; + $showphoto=''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; + print ''; print $showphoto; $showphoto=''; print ''; } // Morphy - print ''; + print ''; print $showphoto; $showphoto=''; print ''; @@ -513,34 +511,34 @@ if ($rowid) print '\n"; // Company - print ''; + print ''; // Civility - print ''; + print ''; print ''; // Name - print ''; + print ''; print ''; // Firstname - print ''; + print ''; print ''; // Status - print ''; + print ''; // Date end subscription print ''; @@ -551,29 +549,29 @@ if ($rowid) print '
'.$langs->trans("Ref").''; - print $form->showrefnav($adh,'rowid'); + print $form->showrefnav($object,'rowid'); print '
'.$form->showphoto('memberphoto',$adh).''.$form->showphoto('memberphoto',$object).'
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Nature").''.$adh->getmorphylib().'
'.$langs->trans("Nature").''.$object->getmorphylib().'
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Company").''.$adh->societe.'
'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("UserTitle").''.$adh->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("Lastname").''.$adh->lastname.' 
'.$langs->trans("Lastname").''.$object->lastname.' 
'.$langs->trans("Firstname").''.$adh->firstname.' 
'.$langs->trans("Firstname").''.$object->firstname.' 
'.$langs->trans("Status").''.$adh->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("SubscriptionEndDate").''; - if ($adh->datefin) + if ($object->datefin) { - print dol_print_date($adh->datefin,'day'); - if ($adh->datefin < ($now - $conf->adherent->cotisation->warning_delay) && $adh->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + print dol_print_date($object->datefin,'day'); + if ($object->datefin < ($now - $conf->adherent->cotisation->warning_delay) && $object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie } else { print $langs->trans("SubscriptionNotReceived"); - if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie } print '
'; - if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print ''; + if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrThirdParty"); print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'
'; print ''; if ($_GET['action'] == 'editthirdparty') { $htmlname='socid'; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; print '
'; - print $form->select_company($adh->fk_soc,'socid','',1); + print $form->select_company($object->fk_soc,'socid','',1); print '
'; } else { - if ($adh->fk_soc) + if ($object->fk_soc) { $company=new Societe($db); - $result=$company->fetch($adh->fk_soc); + $result=$company->fetch($object->fk_soc); print $company->getNomUrl(1); } else @@ -589,7 +587,7 @@ if ($rowid) print ''; - if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer) print ''; + if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrUser"); print 'id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'
'; print ''; if ($_GET['action'] == 'editlogin') @@ -597,15 +595,15 @@ if ($rowid) /*$include=array(); if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { - $include=array($adh->user_id,$user->id); + $include=array($object->user_id,$user->id); }*/ - print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'userid',''); + print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid',''); } else { - if ($adh->user_id) + if ($object->user_id) { - print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'none'); + print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); } @@ -631,7 +629,7 @@ if ($rowid) { print '
'; - if ($adh->statut > 0) print ''.$langs->trans("AddSubscription").""; + if ($object->statut > 0) print ''.$langs->trans("AddSubscription").""; else print ''.$langs->trans("AddSubscription").''; print "
\n"; @@ -723,7 +721,7 @@ if ($rowid) if ($conf->paypal->enabled) { include_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'); - print showPaypalPaymentUrl('membersubscription',$adh->ref); + print showPaypalPaymentUrl('membersubscription',$object->ref); } } @@ -741,7 +739,7 @@ if ($rowid) $bankviainvoice=0; // Option to write via invoice is on by default $invoiceonly=0; if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && (empty($_POST['paymentsave']) || $_POST["paymentsave"] == 'bankdirect')) $bankdirect=1; - if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled && $adh->fk_soc) $bankviainvoice=1; + if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled && $object->fk_soc) $bankviainvoice=1; print "\n\n\n"; @@ -792,20 +790,20 @@ if ($rowid) // Confirm create third party if ($_GET["action"] == 'create_thirdparty') { - $name = $adh->getFullName($langs); + $name = $object->getFullName($langs); if (! empty($name)) { - if ($adh->societe) $name.=' ('.$adh->societe.')'; + if ($object->societe) $name.=' ('.$object->societe.')'; } else { - $name=$adh->societe; + $name=$object->societe; } // Create a form array $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); if ($ret == 'html') print '
'; } @@ -814,7 +812,7 @@ if ($rowid) print ''; print ''; print ''; - print ''; + print ''; print ''; print "\n"; @@ -837,9 +835,9 @@ if ($rowid) } if (! $datefrom) { - if ($adh->datefin > 0) + if ($object->datefin > 0) { - $datefrom=dol_time_plus_duree($adh->datefin,1,'d'); + $datefrom=dol_time_plus_duree($object->datefin,1,'d'); } else { @@ -876,9 +874,9 @@ if ($rowid) if ($conf->banque->enabled || $conf->facture->enabled) { $company=new Societe($db); - if ($adh->fk_soc) + if ($object->fk_soc) { - $result=$company->fetch($adh->fk_soc); + $result=$company->fetch($object->fk_soc); } // Title payments @@ -897,13 +895,13 @@ if ($rowid) if ($conf->societe->enabled && $conf->facture->enabled) { print 'fk_soc) || empty($bankviainvoice)) print ' disabled="disabled"'; + if (empty($object->fk_soc) || empty($bankviainvoice)) print ' disabled="disabled"'; print '> '.$langs->trans("MoreActionInvoiceOnly"); - if ($adh->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else { print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; + print ' - '; print $langs->trans("CreateDolibarrThirdParty"); print ')'; } @@ -912,13 +910,13 @@ if ($rowid) if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled) { print 'fk_soc) || empty($bankviainvoice)) print ' disabled="disabled"'; + if (empty($object->fk_soc) || empty($bankviainvoice)) print ' disabled="disabled"'; print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($adh->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else { print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; + print ' - '; print $langs->trans("CreateDolibarrThirdParty"); print ')'; } @@ -962,22 +960,22 @@ if ($rowid) print ''; print '
'.$langs->trans("SendAcknowledgementByMail").''; - if (! $adh->email) + if (! $object->email) { print $langs->trans("NoEMail"); } else { $adht = new AdherentType($db); - $adht->fetch($adh->typeid); + $adht->fetch($object->typeid); - $subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); - $texttosend=$adh->makeSubstitution($adht->getMailOnSubscription()); + $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); + $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="checked"':'').'>'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; - $helpcontent.=''.$langs->trans("MailRecipient").': '.$adh->email.'
'."\n"; + $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent.=''.$langs->trans("Subject").':
'."\n"; $helpcontent.=$subjecttosend."\n"; $helpcontent.="
"; @@ -1010,7 +1008,8 @@ else print $langs->trans("ErrorRecordNotFound"); } -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 176a8b3efb3..105c4c2485e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1435,6 +1435,12 @@ class Adherent extends CommonObject $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); + if (! $mydb->ok) + { + $this->error=$mydb->lasterror(); + return 0; + } + $result = $mydb->query($query); if ($result) { @@ -1443,7 +1449,7 @@ class Adherent extends CommonObject } else { - $this->error=$mydb->error(); + $this->error=$mydb->lasterror(); return 0; } } diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 56e51914e7d..0f756e5eaf2 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -99,7 +99,6 @@ $hookmanager->initHooks(array('membercard')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error=0; @@ -613,15 +612,15 @@ if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm * View */ +$form = new Form($db); +$formcompany = new FormCompany($db); + // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('member'); $help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('',$langs->trans("Member"),$help_url); -$form = new Form($db); -$formcompany = new FormCompany($db); - $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($action == 'create') @@ -821,10 +820,9 @@ if ($action == 'edit') * ********************************************/ - //$object = new Adherent($db); $res=$object->fetch($rowid); if ($res < 0) { dol_print_error($db,$object->error); exit; } - //$res=$object->fetch_optionals($rowid,$extralabels); + //$res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } $adht = new AdherentType($db); @@ -1060,8 +1058,8 @@ if ($rowid && $action != 'edit') //$object = new Adherent($db); $res=$object->fetch($rowid); if ($res < 0) { dol_print_error($db,$object->error); exit; } - //$res=$object->fetch_optionals($rowid,$extralabels); - //if ($res < 0) { dol_print_error($db); exit; } + $res=$object->fetch_optionals($object->id,$extralabels); + if ($res < 0) { dol_print_error($db); exit; } $adht = new AdherentType($db); $res=$adht->fetch($object->typeid); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index b24bce1e703..d310325d019 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -664,6 +664,7 @@ llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl); $form = new Form($db); $formproduct = new FormProduct($db); +$object=new Product($db); if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) @@ -862,14 +863,11 @@ else else if ($id || $ref) { - $object=new Product($db); $res=$object->fetch($id,$ref); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($id,$extralabels); + $res=$object->fetch_optionals($object->id,$extralabels); - /* - * Fiche en mode edition - */ + // Fiche en mode edition if ($action == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer)) { $type = $langs->trans('Product'); @@ -1031,9 +1029,7 @@ else print ''; } - /* - * Fiche en mode visu - */ + // Fiche en mode visu else { $head=product_prepare_head($object, $user); diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index b0ae5a8832b..7835d1e3055 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2007-2011 Laurent Destailleur + * Copyright (C) 2007-2012 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,7 +41,9 @@ $langs->load("companies"); $langs->load("other"); $rowid=$_GET["id"]; -$adho = new ExtraFields($db); +$object = new Adherent($db); +$extrafields = new ExtraFields($db); + /* @@ -51,6 +53,7 @@ $adho = new ExtraFields($db); // None + /* * View */ @@ -58,17 +61,16 @@ $adho = new ExtraFields($db); llxHeaderVierge($langs->trans("MemberCard")); // fetch optionals attributes and labels -$adho->fetch_name_optionals_label(); +$extralabels=$extrafields->fetch_name_optionals_label('member'); if ($rowid > 0) { - $adh = new Adherent($db); - $adh->id = $rowid; - $adh->fetch($rowid); - $adh->fetch_optionals($rowid); + $res=$object->fetch($id,$ref); + if ($res < 0) { dol_print_error($db,$object->error); exit; } + $res=$object->fetch_optionals($object->id,$extralabels); print_titre($langs->trans("MemberCard")); - if (empty($adh->public)) + if (empty($object->public)) { print $langs->trans("ErrorThisMemberIsNotPublic"); } @@ -76,44 +78,45 @@ if ($rowid > 0) { print ''; - print '\n"; + print '\n"; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - if (isset($adh->photo) && $adh->photo !=''){ - print ''; + if (isset($object->photo) && $object->photo !=''){ + print ''; } - // foreach($adho->attribute_label as $key=>$value){ - // print "\n"; + // foreach($objecto->attribute_label as $key=>$value){ + // print "\n"; // } - print ''; + print ''; print '
'.$langs->trans("Type").''.$adh->type."
'.$langs->trans("Type").''.$object->type."
'.$langs->trans("Person").''.$adh->morphy.'
'.$langs->trans("Person").''.$object->morphy.'
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Firstname").''.$object->firstname.' 
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Lastname").''.$object->lastname.' 
'.$langs->trans("Company").''.$adh->societe.' 
'.$langs->trans("Company").''.$object->societe.' 
'.$langs->trans("Address").''.nl2br($adh->adresse).' 
'.$langs->trans("Address").''.nl2br($object->address).' 
'.$langs->trans("Zip").' '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.' 
'.$langs->trans("Zip").' '.$langs->trans("Town").''.$object->zip.' '.$object->town.' 
'.$langs->trans("Country").''.$adh->pays.' 
'.$langs->trans("Country").''.$object->pays.' 
'.$langs->trans("EMail").''.$adh->email.' 
'.$langs->trans("EMail").''.$object->email.' 
'.$langs->trans("Birthday").''.$adh->naiss.' 
'.$langs->trans("Birthday").''.$object->naiss.' 
URL Photo'."photo\">photo\">".' 
URL Photo'."photo\">photo\">".' 
$value".$adh->array_options["options_$key"]." 
$value".$object->array_options["options_$key"]." 
'.$langs->trans("Comments").''.nl2br($adh->note).'
'.$langs->trans("Comments").''.nl2br($object->note).'
'; } } -$db->close(); llxFooterVierge(); +$db->close(); + /** diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 44879bbb723..ec22772fab2 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -992,7 +992,7 @@ else $object = new Societe($db); $res=$object->fetch($socid); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($socid,$extralabels); + $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } // Load object modCodeTiers @@ -1440,7 +1440,7 @@ else $object = new Societe($db); $res=$object->fetch($socid); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($socid,$extralabels); + $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; }