mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Merge the "Create ..." buttons on contract into one.
This commit is contained in:
parent
35e4565ccc
commit
18d013a6f7
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 .= '<a style="margin-right: auto;" class="dropdown-toggle butAction" data-toggle="dropdown">'.$label.'</a>';
|
||||
$out .= '<div class="dropdown-content">';
|
||||
foreach ($url as $subbutton) {
|
||||
if ($subbutton['enabled'] && $subbutton['perm']) {
|
||||
if (!empty($subbutton['lang'])) {
|
||||
$langs->load($subbutton['lang']);
|
||||
}
|
||||
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])), '', 1, array('isDropDown' => true));
|
||||
if (!empty($subbutton['lang'])) {
|
||||
$langs->load($subbutton['lang']);
|
||||
}
|
||||
$tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage']));
|
||||
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], array('isDropDown' => true));
|
||||
}
|
||||
$out .= "</div>";
|
||||
$out .= "</div>";
|
||||
|
|
@ -11104,14 +11103,17 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
|
|||
return $out;
|
||||
}
|
||||
|
||||
// If $url is a simple link
|
||||
// Here, $url is a simple link
|
||||
|
||||
if (!empty($params['isDropdown']))
|
||||
$class = "dropdown-item";
|
||||
else {
|
||||
$class = 'butAction';
|
||||
if ($actionType == 'danger' || $actionType == 'delete') {
|
||||
$class = 'butActionDelete';
|
||||
if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken();
|
||||
if (!empty($url) && strpos($url, 'token=') === false) {
|
||||
$url .= '&token='.newToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
$attr = array(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user