';
+ 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 '
id.'&action=valid">';
+ print $tmpbuttonlabel;
+ print '';
}
-
- print '
id.'&action=valid">';
- 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 '
id.'&action=reopen&token='.newToken().'">'.$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 '
id.'&action=approve">'.$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 '
id.'&action=reopen&token='.newToken().'">'.$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 '
id.'&action=approve2">'.$langs->trans("Approve2Order").'';
+ print '
id.'&action=approve">'.$langs->trans("ApproveOrder").'';
}
} else {
- print '
'.$langs->trans("Approve2Order").'';
+ print '
'.$langs->trans("ApproveOrder").'';
}
}
- }
- // Refuse
- if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) {
- if ($usercanapprove || $usercanapprovesecond) {
- print '
id.'&action=refuse">'.$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 '
id.'&action=approve2">'.$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 '
id.'&action=refuse">'.$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 '
id.'&action=presend&mode=init#formmailbeforetitle">'.$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 '
id.'&action=reopen&token='.newToken().'">'.$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 '
id.'&action=reopen&token='.newToken().'">'.$langs->trans("Disapprove").'';
+ }
+ }
+ }
+ if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) {
if ($usercanorder) {
- print '
id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'';
+ print '
id.'&action=reopen&token='.newToken().'">'.$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 '
id.'&action=reopen&token='.newToken().'">'.$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 '
id.'&action=reopen&token='.newToken().'">'.$langs->trans("Disapprove").'';
- }
- }
- }
- if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) {
- if ($usercanorder) {
- print '
id.'&action=reopen&token='.newToken().'">'.$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 '
id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("ClassifyBilled").'';
- } else {
- if (!empty($object->linkedObjectsIds['invoice_supplier'])) {
- if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
- print '
id.'&action=classifybilled&token='.newToken().'">'.$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 '
id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("ClassifyBilled").'';
+ } else {
+ if (!empty($object->linkedObjectsIds['invoice_supplier'])) {
+ if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
+ print '
id.'&action=classifybilled&token='.newToken().'">'.$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 '
id.'&action=webservice&token='.newToken().'&mode=init">'.$langs->trans('CreateRemoteOrder').'';
+ }
+
+ // Clone
+ if ($usercancreate) {
+ print '
'.$langs->trans("ToClone").'';
+ }
+
+ // Cancel
+ if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) {
+ if ($usercanorder) {
+ print '
id.'&action=cancel">'.$langs->trans("CancelOrder").'';
+ }
+ }
+
+ // Delete
+ if (!empty($usercandelete)) {
+ if ($hasreception) {
+ print '
'.$langs->trans("Delete").'';
+ } else {
+ print '
id.'&action=delete&token='.newToken().'">'.$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 '
id.'&action=webservice&token='.newToken().'&mode=init">'.$langs->trans('CreateRemoteOrder').'';
- }
+ print "
';
- }
-
- // Cancel
- if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) {
- if ($usercanorder) {
- print '
';
- }
- }
-
- // Delete
- if (!empty($usercandelete)) {
- if ($hasreception) {
- print '