Standardize code

This commit is contained in:
Laurent Destailleur 2018-04-21 15:46:55 +02:00
parent 411949a6bb
commit 912d5c53f2
14 changed files with 108 additions and 115 deletions

View File

@ -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(

View File

@ -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;
}

View File

@ -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');
}
}

View File

@ -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)
{

View File

@ -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 '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
return '<span class="hideonsmartphone">'.$this->statuts_short[$statut].' </span>'.img_picto($this->statuts[$statut],$this->statuts_logo[$statut]);
if ($mode == 6)
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
return '<span class="hideonsmartphone">'.$this->statuts[$statut].' </span>'.img_picto($this->statuts[$statut],$this->statuts_logo[$statut]);
return '';
}

View File

@ -380,6 +380,7 @@ if ($resql)
if (! empty($arrayfields['f.fk_statut']['checked']))
{
print '<td class="liste_titre" align="right">';
$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);

View File

@ -255,6 +255,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
// Status
print '<tr><td align="left">'.$langs->trans("Status").'</td><td align="left">';
$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);

View File

@ -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';

View File

@ -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();
}

View File

@ -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 '<br><div class="center">';
print $langs->trans("Comment") . ' : ';
@ -844,7 +844,7 @@ if ($id > 0 || ! empty($ref)) {
}
// date
print '<td>' . dol_print_date($objp->datec) . '</td>';
print "</tr>\n";
$i ++;

View File

@ -187,9 +187,8 @@ if ($resql)
{
$row = $db->fetch_row($resql);
print '<tr class="oddeven">';
print '<td>'.$langs->trans($commandestatic->statuts[$row[1]]).'</td>';
print '<td>'.$commandestatic->LibStatut($row[1]).'</td>';
print '<td align="right"><a href="list.php?statut='.$row[1].'">'.$row[0].' '.$commandestatic->LibStatut($row[1],3).'</a></td>';
print "</tr>\n";

View File

@ -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");

View File

@ -57,7 +57,6 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// 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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Orders").'</td><td align="center">'.$langs->trans("Nb").'</td><td>&nbsp;</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
{
$row = $db->fetch_row($resql);
print '<tr class="oddeven">';
print '<td>'.$langs->trans($commande->statuts[$row[1]]).'</td>';
print '<td>'.$commandestatic->LibStatut($row[1]).'</td>';
print '<td align="center">'.$row[0].'</td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?statut='.$row[1].'">'.$commande->LibStatut($row[1],3).'</a></td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?statut='.$row[1].'">'.$commandestatic->LibStatut($row[1],3).'</a></td>';
print "</tr>\n";
$i++;

View File

@ -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;
}