clean code

This commit is contained in:
Frédéric FRANCE 2023-02-06 22:50:36 +01:00
parent e5a1b226f3
commit 3238d82386
3 changed files with 88 additions and 212 deletions

View File

@ -100,14 +100,37 @@ class CommandeFournisseur extends CommonOrder
*/
public $ref;
/**
* @var string ref supplier
*/
public $ref_supplier;
/**
* @var string ref supplier
* @deprecated
* @see $ref_supplier
*/
public $ref_fourn;
public $brouillon;
/**
* @var int
*/
public $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Ordered/Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
// -> 6=Canceled -> (reopen) 2=Approved
// -> 9=Refused -> (reopen) 1=Validated
// Note: billed or not is on another field "billed"
public $statuts; // List of status
/**
* @var array List of status
*/
public $statuts;
/**
* @var array List of status short
*/
public $statuts_short;
public $billed;
@ -169,7 +192,12 @@ class CommandeFournisseur extends CommonOrder
*/
public $lines = array();
//Add for supplier_proposal
/**
* @var CommandeFournisseurLigne
*/
public $line;
// Add for supplier_proposal
public $origin;
public $origin_id;
public $linked_objects = array();
@ -389,9 +417,9 @@ class CommandeFournisseur extends CommonOrder
$this->ref_supplier = $obj->ref_supplier;
$this->socid = $obj->fk_soc;
$this->fourn_id = $obj->fk_soc;
$this->statut = $obj->fk_statut;
$this->status = $obj->fk_statut;
$this->billed = $obj->billed;
$this->statut = $obj->fk_statut;
$this->status = $obj->fk_statut;
$this->billed = $obj->billed;
$this->user_author_id = $obj->fk_user_author;
$this->user_valid_id = $obj->fk_user_valid;
$this->user_approve_id = $obj->fk_user_approve;
@ -587,10 +615,10 @@ class CommandeFournisseur extends CommonOrder
// Multicurrency
$line->fk_multicurrency = $objp->fk_multicurrency;
$line->multicurrency_code = $objp->multicurrency_code;
$line->multicurrency_subprice = $objp->multicurrency_subprice;
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$line->multicurrency_subprice = $objp->multicurrency_subprice;
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$line->special_code = $objp->special_code;
$line->fk_parent_line = $objp->fk_parent_line;
@ -877,38 +905,21 @@ class CommandeFournisseur extends CommonOrder
global $langs, $conf, $user, $hookmanager;
$result = '';
$label = '';
if ($user->hasRight("fournisseur", "commande", "read")) {
$label = '<u class="paddingrightonly">'.$langs->trans("SupplierOrder").'</u>';
if (isset($this->statut)) {
$label .= ' '.$this->getLibStatut(5);
}
if (!empty($this->ref)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
}
if (!empty($this->ref_supplier)) {
$label .= '<br><b>'.$langs->trans('RefSupplier').':</b> '.$this->ref_supplier;
}
if (!empty($this->total_ht)) {
$label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_tva)) {
$label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_ttc)) {
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->date)) {
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
}
if (!empty($this->delivery_date)) {
$label .= '<br><b>'.$langs->trans('DeliveryDate').':</b> '.dol_print_date($this->delivery_date, 'dayhour');
}
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$picto = 'order';
$label = implode($this->getTooltipContentArray($params));
$url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id;
if ($option !== 'nolink') {
@ -923,18 +934,6 @@ class CommandeFournisseur extends CommonOrder
}
$linkclose = '';
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowOrder");
@ -3702,6 +3701,14 @@ class CommandeFournisseurLigne extends CommonOrderLine
* @var string
*/
public $ref_supplier;
/**
* @var string ref supplier
* @deprecated
* @see $ref_supplier
*/
public $ref_fourn;
public $remise;

View File

@ -2821,47 +2821,21 @@ class FactureFournisseur extends CommonInvoice
if ($this->type == self::TYPE_DEPOSIT) {
$picto .= 'd'; // Deposit invoice
}
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'moretitle' => $moretitle,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("SupplierInvoice").'</u>';
if ($this->type == self::TYPE_REPLACEMENT) {
$label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("InvoiceReplace").'</u>';
} elseif ($this->type == self::TYPE_CREDIT_NOTE) {
$label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("CreditNote").'</u>';
} elseif ($this->type == self::TYPE_DEPOSIT) {
$label = '<u class="paddingrightonly">'.$langs->transnoentitiesnoconv("Deposit").'</u>';
}
if (isset($this->status)) {
$alreadypaid = -1;
if (isset($this->alreadypaid)) {
$alreadypaid = $this->alreadypaid;
}
$label .= ' '.$this->getLibStatut(5, $alreadypaid);
}
if (!empty($this->ref)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
}
if (!empty($this->ref_supplier)) {
$label .= '<br><b>'.$langs->trans('RefSupplier').':</b> '.$this->ref_supplier;
}
if (!empty($this->label)) {
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
}
if (!empty($this->date)) {
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
}
if (!empty($this->total_ht)) {
$label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_tva)) {
$label .= '<br><b>'.$langs->trans('AmountVAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
}
if (!empty($this->total_ttc)) {
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
}
if ($moretitle) {
$label .= ' - '.$moretitle;
}
$label = implode($this->getTooltipContentArray($params));
$ref = $this->ref;
if (empty($ref)) {
@ -2869,19 +2843,6 @@ class FactureFournisseur extends CommonInvoice
}
$linkclose = '';
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'moretitle' => $moretitle,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowSupplierInvoice");

View File

@ -2607,7 +2607,7 @@ class Societe extends CommonObject
{
global $conf, $langs, $user;
$langs->loadLangs(['companies, commercial']);
$langs->loadLangs(['companies', 'commercial']);
$datas = [];
@ -2621,9 +2621,6 @@ class Societe extends CommonObject
return ['optimize' => $langs->trans("ShowCompany")];
}
$label = '';
$label2 = '';
if (!empty($this->logo) && class_exists('Form')) {
$photo = '<div class="photointooltip floatright">';
$photo .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
@ -2787,122 +2784,45 @@ class Societe extends CommonObject
$name .= ' ('.$this->name_alias.')';
}
$result = ''; $label = ''; $label2 = '';
$linkstart = ''; $linkend = '';
if (!empty($this->logo) && class_exists('Form')) {
$label .= '<div class="photointooltip floatright">';
$label .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
$label .= '</div>';
//$label .= '<div style="clear: both;"></div>';
} elseif (!empty($this->logo_squarred) && class_exists('Form')) {
/*$label.= '<div class="photointooltip">';
$label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
$label.= '</div><div style="clear: both;"></div>';*/
$result = '';
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$label .= '<div class="centpercent">';
$label = implode($this->getTooltipContentArray($params));
$linkstart = '';
$linkend = '';
if ($option == 'customer' || $option == 'compta' || $option == 'category') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Customer").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id;
} elseif ($option == 'prospect' && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Prospect").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id;
} elseif ($option == 'supplier' || $option == 'category_supplier') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Supplier").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id;
} elseif ($option == 'agenda') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ThirdParty").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/agenda.php?socid='.$this->id;
} elseif ($option == 'project') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ThirdParty").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/project.php?socid='.$this->id;
} elseif ($option == 'margin') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ThirdParty").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$this->id.'&type=1';
} elseif ($option == 'contact') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ThirdParty").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/contact.php?socid='.$this->id;
} elseif ($option == 'ban') {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ThirdParty").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$this->id;
}
// By default
if (empty($linkstart)) {
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ThirdParty").'</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$this->id;
}
if (isset($this->status)) {
$label .= ' '.$this->getLibStatut(5);
}
if (isset($this->client) && isset($this->fournisseur)) {
$label .= ' &nbsp; ';
$label .= $this->getTypeUrl(1);
}
$label .= '<br><b>'.$langs->trans('Name').':</b> '.dol_escape_htmltag($this->name);
if (!empty($this->name_alias)) {
$label .= ' ('.dol_escape_htmltag($this->name_alias).')';
}
if ($this->email) {
$label .= '<br>'.img_picto('', 'email', 'class="pictofixedwidth"').$this->email;
}
if (!empty($this->phone) || !empty($this->fax)) {
$phonelist = array();
if ($this->phone) {
$phonelist[] = dol_print_phone($this->phone, $this->country_code, $this->id, 0, '', '&nbsp', 'phone');
}
if ($this->fax) {
$phonelist[] = dol_print_phone($this->fax, $this->country_code, $this->id, 0, '', '&nbsp', 'fax');
}
$label .= '<br>'.implode('&nbsp;', $phonelist);
}
if (!empty($this->address)) {
$label2 .= '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs); // Address + country
} elseif (!empty($this->country_code)) {
$label2 .= '<br><b>'.$langs->trans('Country').':</b> '.$this->country_code;
}
if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false)) {
$label2 .= '<br><b>'.$langs->trans('VATIntra').':</b> '.dol_escape_htmltag($this->tva_intra);
}
if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP)) {
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false && $langs->trans('ProfId1'.$this->country_code) != '-') {
$label2 .= '<br><b>'.$langs->trans('ProfId1'.$this->country_code).':</b> '.$this->idprof1;
}
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false && $langs->trans('ProfId2'.$this->country_code) != '-') {
$label2 .= '<br><b>'.$langs->trans('ProfId2'.$this->country_code).':</b> '.$this->idprof2;
}
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false && $langs->trans('ProfId3'.$this->country_code) != '-') {
$label2 .= '<br><b>'.$langs->trans('ProfId3'.$this->country_code).':</b> '.$this->idprof3;
}
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false && $langs->trans('ProfId4'.$this->country_code) != '-') {
$label2 .= '<br><b>'.$langs->trans('ProfId4'.$this->country_code).':</b> '.$this->idprof4;
}
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false && $langs->trans('ProfId5'.$this->country_code) != '-') {
$label2 .= '<br><b>'.$langs->trans('ProfId5'.$this->country_code).':</b> '.$this->idprof5;
}
if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false && $langs->trans('ProfId6'.$this->country_code) != '-') {
$label2 .= '<br><b>'.$langs->trans('ProfId6'.$this->country_code).':</b> '.$this->idprof6;
}
}
if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3)) {
$label2 .= '<br><b>'.$langs->trans('CustomerCode').':</b> '.$this->code_client;
}
if (!empty($this->code_fournisseur) && $this->fournisseur) {
$label2 .= '<br><b>'.$langs->trans('SupplierCode').':</b> '.$this->code_fournisseur;
}
if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) {
$label2 .= '<br><b>'.$langs->trans('CustomerAccountancyCode').':</b> '.($this->code_compta ? $this->code_compta : $this->code_compta_client);
}
if (isModEnabled('accounting') && $this->fournisseur) {
$label2 .= '<br><b>'.$langs->trans('SupplierAccountancyCode').':</b> '.$this->code_compta_fournisseur;
}
$label .= ($label2 ? '<br>'.$label2 : '').'</div>';
// Add type of canvas
$linkstart .= (!empty($this->canvas) ? '&canvas='.$this->canvas : '');
@ -2917,18 +2837,6 @@ class Societe extends CommonObject
$linkstart .= '"';
$linkclose = '';
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowCompany");