From d6113acfc8eee6b8abc25db9e36c3021a9695815 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 2 Sep 2020 15:20:10 +0200 Subject: [PATCH] action presign/prevalidate + action sign/validate + Traductions --- htdocs/comm/propal/list.php | 100 +++++++++++++++++++++++++++++++++ htdocs/langs/fr_FR/propal.lang | 12 ++++ 2 files changed, 112 insertions(+) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 6710ac56b58..e89f7b5540a 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,45 @@ if ($resql) $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($massaction == 'prevalidate') + { + $cpt = 0; + $refs = array(); + $ids = array(); + foreach ($toselect as $checked){ + $sqlp = "SELECT ref, rowid FROM " . MAIN_DB_PREFIX . "propal WHERE rowid = " .$checked." AND rowid NOT IN"; + $sqlp .= " (SELECT fk_propal FROM " . MAIN_DB_PREFIX . "propaldet)"; + $resqlp = $db->query($sqlp); + if ($resqlp){ + $objp = $db->fetch_object($resqlp); + if ($db->num_rows($resqlp)){ + $cpt++; + $refs[] = $objp->ref; + $ids[] = $objp->rowid; + } + } else { + dol_print_error($db); + } + } + if ($cpt > 0) + { + if($cpt==1) setEventMessage($langs->trans('Warning').', '.$cpt.' '.$langs->trans('PropNoProductOrService'), 'warnings'); + if ($cpt>1) setEventMessage($langs->trans('Warning').', '.$cpt.' '.$langs->trans('PropsNoProductOrService'), 'warnings'); + $cpt2 = 0; + foreach ($ids as $r) + { + setEventMessage("".$refs[$cpt2]."", 'warnings'); + $cpt2++; + } + } + 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,6 +1311,65 @@ 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'){ + foreach ($toselect as $checked){ + $sql = "SELECT ref, fk_statut AS statut FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$checked; + $resql = $db->query($sql); + if ($resql){ + $obj = $db->fetch_object($resql); + $ref = substr($obj->ref, 1, 4); + if ($ref == 'PROV') { + $numref = $object->getNextNumRef($soc); + if (empty($numref)) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + $numref = $obj->ref; + } + if ($obj->statut == 0){ + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 1, ref ='".$numref."' WHERE rowid = ".$checked; + $resql = $db->query($sql); + if ($resql){ + setEventMessage($numref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + dol_print_error($db); + } + }else { + setEventMessage($numref." ".$langs->trans('IsNotADraft'), 'errors'); + } + } else { + dol_print_error($db); + } + } + } + } + + if ($action == "sign") { + if (GETPOST('confirm') == 'yes'){ + foreach ($toselect as $checked) { + $sqlp = "SELECT ref, fk_statut AS statut FROM " . MAIN_DB_PREFIX . "propal WHERE rowid = " . $checked; + $resqlp = $db->query($sqlp); + if ($resqlp) { + $objp = $db->fetch_object($resqlp); + if ($objp->statut == 1) { + $sqlp = "UPDATE " . MAIN_DB_PREFIX . "propal SET fk_statut = 2 WHERE rowid = " . $checked; + $resqlp = $db->query($sqlp); + if ($resqlp) { + setEventMessage($objp->ref . " " . $langs->trans('Signed'), 'mesgs'); + } else { + dol_print_error($db); + } + } else { + setEventMessage($objp->ref . " " . $langs->trans('CantBeSign'), 'errors'); + } + } else { + dol_print_error($db); + } + } + } + } } else { dol_print_error($db); } diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index fea0bcd75f0..63508c00582 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -85,3 +85,15 @@ 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é +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