diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index eb3a29bb3e9..ff3a6db84f1 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2020,12 +2020,15 @@ if ($action == 'create') { print dol_get_fiche_end(); + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } /* * Buttons */ - - if ($user->socid == 0) { + if ($user->socid == 0 && $action != 'presend' && $action != 'editline') { print '
'; $parameters = array(); @@ -2137,11 +2140,6 @@ if ($action == 'create') { print "
"; } - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - if ($action != 'presend') { print '
'; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8ac65f6cac3..c6bde160440 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2439,206 +2439,208 @@ if ($action == 'create') { * Buttons for actions */ - if ($user->socid == 0 && $action != 'editline' && $action != 'delete') { - print '
'; + if ($user->socid == 0 && $action != 'delete') { - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) { - $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. + if ($action != 'makeorder' && $action != 'presend' && $action != 'editline') { + print '
'; - // Validate - if ($object->statut == 0 && $num > 0) { - if ($usercanvalidate) { - $tmpbuttonlabel = $langs->trans('Validate'); - if ($usercanapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) { - $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { + $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. + + // Validate + if ($object->statut == 0 && $num > 0) { + if ($usercanvalidate) { + $tmpbuttonlabel = $langs->trans('Validate'); + if ($usercanapprove && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) { + $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + } + + print ''; + print $tmpbuttonlabel; + print ''; } - - print ''; - print $tmpbuttonlabel; - print ''; } - } - // Create event - /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. - { - print ''; - }*/ + // Create event + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + { + print ''; + }*/ - // Modify - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanorder) { - print ''.$langs->trans("Modify").''; - } - } - - // Approve - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanapprove) { - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) { - print ''.$langs->trans("ApproveOrder").''; - } else { - print ''.$langs->trans("ApproveOrder").''; - } - } else { - print ''.$langs->trans("ApproveOrder").''; - } - } - - // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { + // Modify if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanapprovesecond) { - if (!empty($object->user_approve_id2)) { - print ''.$langs->trans("Approve2Order").''; + if ($usercanorder) { + print ''.$langs->trans("Modify").''; + } + } + + // Approve + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanapprove) { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) { + print ''.$langs->trans("ApproveOrder").''; } else { - print ''.$langs->trans("Approve2Order").''; + print ''.$langs->trans("ApproveOrder").''; } } else { - print ''.$langs->trans("Approve2Order").''; + print ''.$langs->trans("ApproveOrder").''; } } - } - // Refuse - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanapprove || $usercanapprovesecond) { - print ''.$langs->trans("RefuseOrder").''; - } else { - print ''.$langs->trans("RefuseOrder").''; + // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanapprovesecond) { + if (!empty($object->user_approve_id2)) { + print ''.$langs->trans("Approve2Order").''; + } else { + print ''.$langs->trans("Approve2Order").''; + } + } else { + print ''.$langs->trans("Approve2Order").''; + } + } } - } - // Send - if (empty($user->socid)) { - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) { + // Refuse + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { + if ($usercanapprove || $usercanapprovesecond) { + print ''.$langs->trans("RefuseOrder").''; + } else { + print ''.$langs->trans("RefuseOrder").''; + } + } + + // Send + if (empty($user->socid)) { + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) { + if ($usercanorder) { + print ''.$langs->trans('SendMail').''; + } + } + } + + // Reopen + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { + $buttonshown = 0; + if (!$buttonshown && $usercanapprove) { + if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) { + print ''.$langs->trans("Disapprove").''; + $buttonshown++; + } + } + if (!$buttonshown && $usercanapprovesecond && !empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { + if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) { + print ''.$langs->trans("Disapprove").''; + } + } + } + if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) { if ($usercanorder) { - print ''.$langs->trans('SendMail').''; + print ''.$langs->trans("ReOpen").''; } } - } - // Reopen - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { - $buttonshown = 0; - if (!$buttonshown && $usercanapprove) { - if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) - || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) { - print ''.$langs->trans("Disapprove").''; - $buttonshown++; - } - } - if (!$buttonshown && $usercanapprovesecond && !empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { - if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) - || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) { - print ''.$langs->trans("Disapprove").''; - } - } - } - if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) { - if ($usercanorder) { - print ''.$langs->trans("ReOpen").''; - } - } - - // Ship - $hasreception = 0; - if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { - $labelofbutton = $langs->trans('ReceiveProducts'); - if ($conf->reception->enabled) { - $labelofbutton = $langs->trans("CreateReception"); - if (!empty($object->linkedObjects['reception'])) { - foreach ($object->linkedObjects['reception'] as $element) { - if ($element->statut >= 0) { - $hasreception = 1; - break; + // Ship + $hasreception = 0; + if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { + $labelofbutton = $langs->trans('ReceiveProducts'); + if ($conf->reception->enabled) { + $labelofbutton = $langs->trans("CreateReception"); + if (!empty($object->linkedObjects['reception'])) { + foreach ($object->linkedObjects['reception'] as $element) { + if ($element->statut >= 0) { + $hasreception = 1; + break; + } } } } - } - if (in_array($object->statut, array(3, 4, 5))) { - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceive) { - print ''; - } else { - print ''; - } - } - } - - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { - if ($usercanorder) { - print ''; - } else { - print ''; - } - } - - // Classify received (this does not record reception) - if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { - if ($usercanreceive) { - print ''; - } - } - - // Create bill - //if (isModEnabled('facture')) - //{ - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled - if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { - print ''.$langs->trans("CreateBill").''; - } - } - //} - - // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) - if ($usercancreate && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) { // statut 2 means approved - if (!isModEnabled('facture')) { - print ''.$langs->trans("ClassifyBilled").''; - } else { - if (!empty($object->linkedObjectsIds['invoice_supplier'])) { - if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { - print ''.$langs->trans("ClassifyBilled").''; + if (in_array($object->statut, array(3, 4, 5))) { + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceive) { + print ''; + } else { + print ''; } + } + } + + if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { + if ($usercanorder) { + print ''; } else { - print ''.$langs->trans("ClassifyBilled").''; + print ''; + } + } + + // Classify received (this does not record reception) + if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { + if ($usercanreceive) { + print ''; + } + } + + // Create bill + //if (isModEnabled('facture')) + //{ + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled + if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { + print ''.$langs->trans("CreateBill").''; + } + } + //} + + // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) + if ($usercancreate && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) { // statut 2 means approved + if (!isModEnabled('facture')) { + print ''.$langs->trans("ClassifyBilled").''; + } else { + if (!empty($object->linkedObjectsIds['invoice_supplier'])) { + if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) { + print ''.$langs->trans("ClassifyBilled").''; + } + } else { + print ''.$langs->trans("ClassifyBilled").''; + } + } + } + + // Create a remote order using WebService only if module is activated + if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) { // 2 means accepted + print ''.$langs->trans('CreateRemoteOrder').''; + } + + // Clone + if ($usercancreate) { + print ''.$langs->trans("ToClone").''; + } + + // Cancel + if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { + if ($usercanorder) { + print ''.$langs->trans("CancelOrder").''; + } + } + + // Delete + if (!empty($usercandelete)) { + if ($hasreception) { + print ''.$langs->trans("Delete").''; + } else { + print ''.$langs->trans("Delete").''; } } } - // Create a remote order using WebService only if module is activated - if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) { // 2 means accepted - print ''.$langs->trans('CreateRemoteOrder').''; - } + print "
"; - // Clone - if ($usercancreate) { - print ''.$langs->trans("ToClone").''; - } - - // Cancel - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { - if ($usercanorder) { - print ''.$langs->trans("CancelOrder").''; - } - } - - // Delete - if (!empty($usercandelete)) { - if ($hasreception) { - print ''.$langs->trans("Delete").''; - } else { - print ''.$langs->trans("Delete").''; - } - } } - print "
"; - - - if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'makeorder') { // Set status to ordered (action=commande) print ''."\n"; @@ -2674,7 +2676,12 @@ if ($action == 'create') { print "
"; } - if ($action != 'makeorder') { + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'makeorder' && $action != 'presend' ) { print '
'; // Generated documents @@ -2923,11 +2930,6 @@ if ($action == 'create') { } } - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - // Presend form $modelmail = 'order_supplier_send'; $defaulttopic = 'SendOrderRef';