diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 619203c4dca..db59fd5f942 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -472,6 +472,8 @@ if ($resql) 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), + 'prevalidate'=>$langs->trans("Validate"), + 'presign'=>$langs->trans("Sign"), ); if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close"); @@ -502,6 +504,16 @@ if ($resql) $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($massaction == 'prevalidate') + { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + } + + if ($massaction == 'presign') + { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1); + } + if ($sall) { foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -1270,10 +1282,72 @@ if ($resql) $delallowed = $user->rights->propal->creer; print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + + if ($action == 'validate') { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 0) { + if ($tmpproposal->valid($user)){ + setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors'); + $error++; + } + } + dol_print_error($db); + $error++; + } + if ($error){ + $db->rollback(); + } else { + $db->commit(); + } + } + } + + if ($action == "sign") { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 1) { + $tmpproposal->statut = 2; + if ($tmpproposal->update($user)) { + setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs'); + } else { + dol_print_error($db); + $error++; + } + } else { + setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors'); + $error++; + } + } else { + dol_print_error($db); + $error++; + } + } + if ($error){ + $db->rollback(); + } else { + $db->commit(); + } + } + } } else { - dol_print_error($db); + dol_print_error($db); } -// End of page -llxFooter(); -$db->close(); + // End of page + llxFooter(); + $db->close(); diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index fea0bcd75f0..03981e2b17d 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -85,3 +85,16 @@ ProposalCustomerSignature=Cachet, Date, Signature et mention "Bon pour Accord" ProposalsStatisticsSuppliers=Statistiques de propositions commerciales CaseFollowedBy=Affaire suivie par SignedOnly=Signé seulement +IsNotADraft = n'est pas un brouillon +PassedInOpenStatus = passé au statut "ouvert" +CantBeSign = ne peut pas être signée +Sign = Signer +Signed = signé +CantBeSign = ne peut pas être signé +CantBeValidated = Ne peut pas être validé +ConfirmMassValidation = Confirmer la validation ? +ConfirmMassSignature = Confirmer la signature ? +ConfirmMassValidationQuestion = Voulez-vous confirmer la validation des devis brouillons selectionnés ? +ConfirmMassSignatureQuestion = Voulez-vous confirmer la signature des devis ouvert selectionnés ? +PropNoProductOrService = devis ne contient pas de produits ni de services +PropsNoProductOrService = devis ne contiennent pas de produits ni de services