diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4c1a06a9a5d..78adb797b88 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -300,7 +300,42 @@ if ($action == 'validate' && $permissiontoadd) { foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 0) { - if ($objecttmp->valid($user)) { + if (!empty($objecttmp->fk_warehouse)){ + $idwarehouse = $objecttmp->fk_warehouse; + }else{ + $idwarehouse = 0; + } + if ($objecttmp->valid($user, $idwarehouse)) { + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; + } + }else{ + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } +} +if ($action == 'shipped' && $permissiontoadd) { + if (GETPOST('confirm') == 'yes') { + $objecttmp = new $objectclass($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->statut == 1) { + if ($objecttmp->cloture($user)) { setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); @@ -780,24 +815,23 @@ if ($resql) { 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), ); - if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A - if ($permissiontovalidate) { - $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); - } + if ($permissiontovalidate) { + $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); } if ($permissiontosendbymail) { $arrayofmassactions['presend'] = img_picto('', 'email').' '.$langs->trans("SendByMail"); } + if ($permissiontoclose) { + $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert').' '.$langs->trans("ClassifyShipped"); + } if ($permissiontocancel) { $arrayofmassactions['cancelorders'] = img_picto('', 'close_title').' '.$langs->trans("Cancel"); } if ($user->rights->facture->creer) { $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } - if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A - if ($permissiontoclose) { - $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); - } + if ($permissiontoclose) { + $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); } if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete').' '.$langs->trans("Delete"); @@ -838,6 +872,9 @@ if ($resql) { if ($massaction == 'prevalidate') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } + if ($massaction == 'preshipped') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("CloseOrder"), $langs->trans("ConfirmCloseOrder"), "shipped", null, '', 0, 200, 500, 1); + } if ($massaction == 'createbills') { //var_dump($_REQUEST);