From 912d5c53f2bb3d603cd557bd33af1c89c357e321 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 15:46:55 +0200 Subject: [PATCH] Standardize code --- htdocs/comm/propal/card.php | 7 ++- htdocs/comm/propal/class/propal.class.php | 12 ++-- .../class/bonprelevement.class.php | 60 +++++++++---------- htdocs/don/class/don.class.php | 30 ++++++---- htdocs/fichinter/class/fichinter.class.php | 57 +++++++++--------- htdocs/fichinter/list.php | 1 + htdocs/fichinter/stats/index.php | 1 + .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 26 +++----- htdocs/fourn/commande/dispatch.php | 4 +- htdocs/fourn/commande/index.php | 3 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/index.php | 7 +-- .../class/supplier_proposal.class.php | 11 ++-- 14 files changed, 108 insertions(+), 115 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8be7fa249b8..004b32a83fc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1745,11 +1745,12 @@ if ($action == 'create') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->labelstatut [2],3=>$object->labelstatut [3])), - array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) + array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) ); - if (! empty($conf->notification->enabled)) { + if (! empty($conf->notification->enabled)) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $formquestion = array_merge($formquestion, array( diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9cdf621bef9..b6e9d1411c5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -142,9 +142,9 @@ class Propal extends CommonObject public $cond_reglement_code; public $mode_reglement_code; - public $remise; - public $remise_percent; - public $remise_absolue; + public $remise = 0; + public $remise_percent = 0; + public $remise_absolue = 0; public $fk_address; public $address_type; public $address; @@ -198,6 +198,7 @@ class Propal extends CommonObject */ const STATUS_BILLED = 4; // Todo rename into STATUS_CLOSE ? + /** * Constructor * @@ -210,12 +211,11 @@ class Propal extends CommonObject global $conf,$langs; $this->db = $db; + $this->socid = $socid; $this->id = $propalid; + $this->products = array(); - $this->remise = 0; - $this->remise_percent = 0; - $this->remise_absolue = 0; $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 57cf518db16..245b25be3b6 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -99,14 +99,6 @@ class BonPrelevement extends CommonObject $this->methodes_trans[0] = "Internet"; $this->_fetched = 0; - - - $langs->load("withdrawals"); - $this->labelstatut[0]=$langs->trans("StatusWaiting"); - $this->labelstatut[1]=$langs->trans("StatusTrans"); - $this->labelstatut[2]=$langs->trans("StatusCredited"); - - return 1; } /** @@ -1310,14 +1302,14 @@ class BonPrelevement extends CommonObject */ // SEPA Initialisation $CrLf = "\n"; - + $now = dol_now(); - + $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); $date_actu = $now; if (!empty($executiondate)) $date_actu=$executiondate; - + $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); $fileDebiteurSection = ''; @@ -1890,48 +1882,52 @@ class BonPrelevement extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + if (empty($this->labelstatut)) + { + global $langs; + $langs->load("withdrawals"); + $this->labelstatut[0]=$langs->trans("StatusWaiting"); + $this->labelstatut[1]=$langs->trans("StatusTrans"); + $this->labelstatut[2]=$langs->trans("StatusCredited"); + } if ($mode == 0) { - return $langs->trans($this->labelstatut[$statut]); + return $this->labelstatut[$statut]; } - if ($mode == 1) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + return $this->labelstatut[$statut]; } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6'); } if ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } if ($mode == 5) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } if ($mode == 6) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 4be83ffa30a..78e3a57f436 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -52,6 +52,10 @@ class Don extends CommonObject var $fk_typepayment; var $num_payment; var $date_valid; + var $modepaymentid = 0; + + var $labelstatut; + var $labelstatutshort; /** * @deprecated @@ -59,6 +63,7 @@ class Don extends CommonObject */ var $commentaire; + /** * Constructor * @@ -69,17 +74,6 @@ class Don extends CommonObject global $langs; $this->db = $db; - $this->modepaymentid = 0; - - $langs->load("donations"); - $this->labelstatut[-1]=$langs->trans("Canceled"); - $this->labelstatut[0]=$langs->trans("DonationStatusPromiseNotValidated"); - $this->labelstatut[1]=$langs->trans("DonationStatusPromiseValidated"); - $this->labelstatut[2]=$langs->trans("DonationStatusPaid"); - $this->labelstatutshort[-1]=$langs->trans("Canceled"); - $this->labelstatutshort[0]=$langs->trans("DonationStatusPromiseNotValidatedShort"); - $this->labelstatutshort[1]=$langs->trans("DonationStatusPromiseValidatedShort"); - $this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort"); } @@ -103,7 +97,19 @@ class Don extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + if (empty($this->labelstatut) || empty($this->labelstatushort)) + { + global $langs; + $langs->load("donations"); + $this->labelstatut[-1]=$langs->trans("Canceled"); + $this->labelstatut[0]=$langs->trans("DonationStatusPromiseNotValidated"); + $this->labelstatut[1]=$langs->trans("DonationStatusPromiseValidated"); + $this->labelstatut[2]=$langs->trans("DonationStatusPaid"); + $this->labelstatutshort[-1]=$langs->trans("Canceled"); + $this->labelstatutshort[0]=$langs->trans("DonationStatusPromiseNotValidatedShort"); + $this->labelstatutshort[1]=$langs->trans("DonationStatusPromiseValidatedShort"); + $this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort"); + } if ($mode == 0) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 9f596e61279..25f2e691265 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -55,9 +55,10 @@ class Fichinter extends CommonObject var $datet; var $datem; var $duration; - var $statut; // 0=draft, 1=validated, 2=invoiced, 3=Terminate + var $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate var $description; - var $fk_contrat; + var $fk_contrat = 0; + var $fk_project = 0; var $extraparams=array(); var $lines = array(); @@ -87,24 +88,8 @@ class Fichinter extends CommonObject function __construct($db) { $this->db = $db; - $this->products = array(); - $this->fk_project = 0; - $this->fk_contrat = 0; - $this->statut = 0; - // List of language codes for status - $this->statuts[0]='Draft'; - $this->statuts[1]='Validated'; - $this->statuts[2]='StatusInterInvoiced'; - $this->statuts[3]='Done'; - $this->statuts_short[0]='Draft'; - $this->statuts_short[1]='Validated'; - $this->statuts_short[2]='StatusInterInvoiced'; - $this->statuts_short[3]='Done'; - $this->statuts_logo[0]='statut0'; - $this->statuts_logo[1]='statut1'; - $this->statuts_logo[2]='statut6'; - $this->statuts_logo[3]='statut6'; + $this->products = array(); } /** @@ -634,22 +619,40 @@ class Fichinter extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + // Init/load array of translation of status + if (empty($this->statuts) || empty($this->statuts_short)) + { + global $langs; + $langs->load("fichinter"); + + $this->statuts[0]=$langs->trans('Draft'); + $this->statuts[1]=$langs->trans('Validated'); + $this->statuts[2]=$langs->trans('StatusInterInvoiced'); + $this->statuts[3]=$langs->trans('Done'); + $this->statuts_short[0]=$langs->trans('Draft'); + $this->statuts_short[1]=$langs->trans('Validated'); + $this->statuts_short[2]=$langs->trans('StatusInterInvoiced'); + $this->statuts_short[3]=$langs->trans('Done'); + $this->statuts_logo[0]='statut0'; + $this->statuts_logo[1]='statut1'; + $this->statuts_logo[2]='statut6'; + $this->statuts_logo[3]='statut6'; + } if ($mode == 0) - return $langs->trans($this->statuts[$statut]); + return $this->statuts[$statut]; if ($mode == 1) - return $langs->trans($this->statuts_short[$statut]); + return $this->statuts_short[$statut]; if ($mode == 2) - return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]).' '.$langs->trans($this->statuts_short[$statut]); + return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts_short[$statut]; if ($mode == 3) - return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]); + return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]); if ($mode == 4) - return img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]); + return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts[$statut]; if ($mode == 5) - return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); + return ''.$this->statuts_short[$statut].' '.img_picto($this->statuts[$statut],$this->statuts_logo[$statut]); if ($mode == 6) - return ''.$langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); + return ''.$this->statuts[$statut].' '.img_picto($this->statuts[$statut],$this->statuts_logo[$statut]); return ''; } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 025296c6b0d..9f4d14f0669 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -380,6 +380,7 @@ if ($resql) if (! empty($arrayfields['f.fk_statut']['checked'])) { print ''; + $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus=$objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 1c0ba5764ed..7f45be6a624 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -255,6 +255,7 @@ print '
'; print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); // Status print ''.$langs->trans("Status").''; + $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus=$objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('object_status', $liststatus, $object_status, 1, 0, 0, '', 1); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4b795862e9b..676dd8d542c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -189,7 +189,7 @@ class CommandeFournisseur extends CommonOrder $this->db = $db; $this->products = array(); - // List of language codes for status + // TODO Move in LibStatut $this->statuts[0] = 'StatusOrderDraft'; $this->statuts[1] = 'StatusOrderValidated'; $this->statuts[2] = 'StatusOrderApproved'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 3f8fee2d5ad..7d8b09a17ce 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -89,16 +89,16 @@ class FactureFournisseur extends CommonInvoice public $tms; // Last update date public $date; // Invoice date public $date_echeance; // Max payment date - public $amount; - public $remise; - public $tva; + public $amount=0; + public $remise=0; + public $tva=0; public $localtax1; public $localtax2; - public $total_ht; - public $total_tva; - public $total_localtax1; - public $total_localtax2; - public $total_ttc; + public $total_ht=0; + public $total_tva=0; + public $total_localtax1=0; + public $total_localtax2=0; + public $total_ttc=0; /** * @deprecated * @see note_private, note_public @@ -202,16 +202,6 @@ class FactureFournisseur extends CommonInvoice { $this->db = $db; - $this->amount = 0; - $this->remise = 0; - $this->tva = 0; - $this->total_localtax1 = 0; - $this->total_localtax2 = 0; - $this->total_ht = 0; - $this->total_tva = 0; - $this->total_ttc = 0; - $this->propalid = 0; - $this->products = array(); } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 837e32f9ff6..1e35af900e6 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -701,7 +701,7 @@ if ($id > 0 || ! empty($ref)) { if ($nbproduct) { - $checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($object->statuts[5])); + $checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); print '
'; print $langs->trans("Comment") . ' : '; @@ -844,7 +844,7 @@ if ($id > 0 || ! empty($ref)) { } // date print '' . dol_print_date($objp->datec) . ''; - + print "\n"; $i ++; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index ca395d0cf47..412f0c94b09 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -187,9 +187,8 @@ if ($resql) { $row = $db->fetch_row($resql); - print ''; - print ''.$langs->trans($commandestatic->statuts[$row[1]]).''; + print ''.$commandestatic->LibStatut($row[1]).''; print ''.$row[0].' '.$commandestatic->LibStatut($row[1],3).''; print "\n"; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index c2d60a73ea3..f0c5acdcf3e 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -472,7 +472,7 @@ if ($status) { if ($status == '1,2,3') $title.=' - '.$langs->trans("StatusOrderToProcessShort"); if ($status == '6,7') $title.=' - '.$langs->trans("StatusOrderCanceled"); - else $title.=' - '.$langs->trans($commandestatic->statuts[$status]); + else $title.=' - '.$commandestatic->LibStatut($status); } if ($search_billed > 0) $title.=' - '.$langs->trans("Billed"); diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 8f34077ab34..e353739790d 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -57,7 +57,6 @@ print '
'; // Orders -$commande = new CommandeFournisseur($db); $sql = "SELECT count(cf.rowid), cf.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; @@ -76,17 +75,15 @@ if ($resql) print ''; print ''; print "\n"; - $var=True; while ($i < $num) { $row = $db->fetch_row($resql); - print ''; - print ''; + print ''; print ''; - print ''; + print ''; print "\n"; $i++; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index fbbbce0f9a8..b88d24070c6 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -124,9 +124,9 @@ class SupplierProposal extends CommonObject var $cond_reglement_code; var $mode_reglement_code; - var $remise; - var $remise_percent; - var $remise_absolue; + var $remise = 0; + var $remise_percent = 0; + var $remise_absolue = 0; var $products=array(); var $extraparams=array(); @@ -185,12 +185,11 @@ class SupplierProposal extends CommonObject global $conf,$langs; $this->db = $db; + $this->socid = $socid; $this->id = $supplier_proposalid; + $this->products = array(); - $this->remise = 0; - $this->remise_percent = 0; - $this->remise_absolue = 0; }
'.$langs->trans("Orders").''.$langs->trans("Nb").' 
'.$langs->trans($commande->statuts[$row[1]]).''.$commandestatic->LibStatut($row[1]).''.$row[0].''.$commande->LibStatut($row[1],3).''.$commandestatic->LibStatut($row[1],3).'