Merge branch '11.0_SupplierOrder_ValidateMassAction' of github.com:atm-gregr/dolibarr into NEW/develop_SupplierOrder_ValidateMassAction

This commit is contained in:
atm-gregr 2021-09-09 10:49:05 +02:00
commit b88a16b563
2 changed files with 62 additions and 2 deletions

View File

@ -135,7 +135,7 @@ if (!$sortorder) {
}
if ($search_status == '') {
$search_status = -1;
$search_status = -5;
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -245,7 +245,7 @@ if (empty($reshook)) {
$search_multicurrency_montant_tva = '';
$search_multicurrency_montant_ttc = '';
$search_project_ref = '';
$search_status = -1;
$search_status = '';
$search_date_order_startday = '';
$search_date_order_startmonth = '';
$search_date_order_startyear = '';
@ -277,9 +277,51 @@ if (empty($reshook)) {
$objectlabel = 'SupplierOrders';
$permissiontoread = $user->rights->fournisseur->commande->lire;
$permissiontodelete = $user->rights->fournisseur->commande->supprimer;
$permissiontovalidate = $user->rights->fournisseur->commande->creer;
$uploaddir = $conf->fournisseur->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($action == 'validate' && $permissiontovalidate)
{
if (GETPOST('confirm') == 'yes')
{
$objecttmp = new CommandeFournisseur($db);
$db->begin();
$error = 0;
foreach ($toselect as $checked)
{
if ($objecttmp->fetch($checked))
{
if ($objecttmp->statut == 0)
{
$objecttmp->date_commande = dol_now();
$result = $objecttmp->valid($user);
if ($result >= 0)
{
// If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step
if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $objecttmp->hasProductsOrServices(1)))
{
$result = $objecttmp->approve($user);
setEventMessages($langs->trans("SupplierOrderValidatedAndApproved"), array($objecttmp->ref));
} else {
setEventMessages($langs->trans("SupplierOrderValidated"), array($objecttmp->ref));
}
}
else
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
}
}
}
}
if (!$error) $db->commit();
else $db->rollback();
}
}
// Mass action to generate vendor bills
if ($massaction == 'confirm_createsupplierbills') {
$orders = GETPOST('toselect', 'array');
@ -947,6 +989,18 @@ if ($resql) {
'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
if ($permissiontovalidate) {
if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE))
{
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove");
}
else
{
$arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate");
}
}
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
$arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier");
}
@ -986,6 +1040,10 @@ if ($resql) {
$trackid = 'sord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($massaction == 'prevalidate') {
print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1);
}
if ($massaction == 'createbills') {
//var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';

View File

@ -124,6 +124,8 @@ SupplierOrderReceivedInDolibarr=Purchase Order %s received %s
SupplierOrderSubmitedInDolibarr=Purchase Order %s submitted
SupplierOrderClassifiedBilled=Purchase Order %s set billed
OtherOrders=Other orders
SupplierOrderValidatedAndApproved=Supplier order is validated and approved : %s
SupplierOrderValidated=Supplier order is validated : %s
##### Types de contacts #####
TypeContact_commande_internal_SALESREPFOLL=Representative following-up sales order
TypeContact_commande_internal_SHIPPING=Representative following-up shipping