diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index eed16b40234..581ea45c4eb 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2130,7 +2130,7 @@ if ($action == 'create') { // Send if (empty($user->socid)) { - if ($object->statut == 1) { + if ($object->status == $object::STATUS_VALIDATED) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) { print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle', '', true, $params); } else { @@ -2139,7 +2139,7 @@ if ($action == 'create') { } } - if ($object->statut == 0 && $nbofservices) { + if ($object->status == $object::STATUS_DRAFT && $nbofservices) { if ($user->rights->contrat->creer) { print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken(), '', true, $params); } else { @@ -2147,7 +2147,7 @@ if ($action == 'create') { print dolGetButtonAction($langs->trans('Validate'), '', 'default', '#', '', false, $params); } } - if ($object->statut == 1) { + if ($object->status == $object::STATUS_VALIDATED) { if ($user->rights->contrat->creer) { print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', true, $params); } else { @@ -2156,24 +2156,26 @@ if ($action == 'create') { } } - if (isModEnabled('commande') && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) { - $langs->load("orders"); - if ($user->hasRight('commande', 'creer')) { - print dolGetButtonAction($langs->trans('CreateOrder'), '', 'default', DOL_URL_ROOT.'/commande/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params); - } else { - $params['attr']['title'] = $langs->trans("NotEnoughPermissions"); - print dolGetButtonAction($langs->trans('CreateOrder'), '', 'default', '#', '', false, $params); - } + // Create ... buttons + $arrayofcreatebutton = array(); + if (isModEnabled('commande') && $object->status > 0 && $object->nbofservicesclosed < $nbofservices) { + $arrayofcreatebutton[] = array( + 'url' => '/commande/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, + 'label' => $langs->trans('CreateOrder'), + 'lang' => 'orders', + 'perm' => $user->hasRight('commande', 'creer') + ); } - - if (isModEnabled('facture') && $object->statut > 0) { - $langs->load("bills"); - if ($user->hasRight('facture', 'creer')) { - print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params); - } else { - $params['attr']['title'] = $langs->trans("NotEnoughPermissions"); - print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', '#', '', false, $params); - } + if (isModEnabled('facture') && $object->status > 0) { + $arrayofcreatebutton[] = array( + 'url' => '/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, + 'label' => $langs->trans('CreateBill'), + 'lang' => 'orders', + 'perm' => $user->hasRight('facture', 'creer') + ); + } + if (count($arrayofcreatebutton)) { + print dolGetButtonAction($langs->trans("Create"), '', 'default', $arrayofcreatebutton, '', true, $params); } if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ceb4eb39ade..bf63fbf261d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -662,7 +662,7 @@ class Contrat extends CommonObject */ public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { - $sql = "SELECT rowid, statut, ref, fk_soc,"; + $sql = "SELECT rowid, statut as status, ref, fk_soc,"; $sql .= " ref_supplier, ref_customer,"; $sql .= " ref_ext,"; $sql .= " entity,"; @@ -705,7 +705,8 @@ class Contrat extends CommonObject $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; $this->entity = $obj->entity; - $this->statut = $obj->statut; + $this->statut = $obj->status; + $this->status = $obj->status; $this->date_contrat = $this->db->jdate($obj->datecontrat); $this->date_creation = $this->db->jdate($obj->datecontrat); @@ -793,7 +794,7 @@ class Contrat extends CommonObject // Selects contract lines related to a product $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref, p.fk_product_type as product_type,"; - $sql .= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; + $sql .= " d.rowid, d.fk_contrat, d.statut as status, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; $sql .= " d.total_ht,"; $sql .= " d.total_tva,"; $sql .= " d.total_localtax1,"; @@ -840,7 +841,8 @@ class Contrat extends CommonObject $line->localtax1_type = $objp->localtax1_type; $line->localtax2_type = $objp->localtax2_type; $line->subprice = $objp->subprice; - $line->statut = $objp->statut; + $line->statut = $objp->status; + $line->status = $objp->status; $line->remise_percent = $objp->remise_percent; $line->price_ht = $objp->price_ht; $line->price = $objp->price_ht; // For backward compatibility diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cff33fee2cc..68ef2d80cf3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11058,7 +11058,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param string $label Label or tooltip of button. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text. * @param string $text Optional : short label on button. Can be escaped HTML content or full simple text. * @param string $actionType 'default', 'delete', 'danger', 'email', ... - * @param string|array $url Url for link or array of subbutton description + * @param string|array $url Url for link or array of subbutton description ('label'=>, 'url'=>, 'lang'=>, 'perm'=> ) * @param string $id Attribute id of button * @param int|boolean $userRight User action right * // phpcs:disable @@ -11091,12 +11091,11 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = $out .= ''.$label.''; $out .= '