Retours PR Standard

This commit is contained in:
Adrien Raze 2020-09-03 09:51:49 +02:00
parent d6113acfc8
commit 675fe05808

View File

@ -1312,32 +1312,17 @@ if ($resql)
print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
if ($action == 'validate'){ if ($action == 'validate') {
if (GETPOST('confirm') == 'yes'){ if (GETPOST('confirm') == 'yes') {
foreach ($toselect as $checked){ $tmpproposal = new Propal($db);
$sql = "SELECT ref, fk_statut AS statut FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$checked; foreach ($toselect as $checked) {
$resql = $db->query($sql); $tmpproposal->fetch($checked);
if ($resql){ if ($tmpproposal->fetch($checked)) {
$obj = $db->fetch_object($resql); if ($tmpproposal->statut == 0) {
$ref = substr($obj->ref, 1, 4); $tmpproposal->valid($user);
if ($ref == 'PROV') { setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs');
$numref = $object->getNextNumRef($soc);
if (empty($numref)) {
setEventMessages($object->error, $object->errors, 'errors');
}
} else { } else {
$numref = $obj->ref; setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors');
}
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 { } else {
dol_print_error($db); dol_print_error($db);
@ -1347,22 +1332,21 @@ if ($resql)
} }
if ($action == "sign") { if ($action == "sign") {
if (GETPOST('confirm') == 'yes'){ if (GETPOST('confirm') == 'yes') {
$tmpproposal = new Propal($db);
foreach ($toselect as $checked) { foreach ($toselect as $checked) {
$sqlp = "SELECT ref, fk_statut AS statut FROM " . MAIN_DB_PREFIX . "propal WHERE rowid = " . $checked; $tmpproposal->fetch($checked);
$resqlp = $db->query($sqlp); if ($tmpproposal->fetch($checked)) {
if ($resqlp) { if ($tmpproposal->statut == 1) {
$objp = $db->fetch_object($resqlp);
if ($objp->statut == 1) {
$sqlp = "UPDATE " . MAIN_DB_PREFIX . "propal SET fk_statut = 2 WHERE rowid = " . $checked; $sqlp = "UPDATE " . MAIN_DB_PREFIX . "propal SET fk_statut = 2 WHERE rowid = " . $checked;
$resqlp = $db->query($sqlp); $resqlp = $db->query($sqlp);
if ($resqlp) { if ($resqlp) {
setEventMessage($objp->ref . " " . $langs->trans('Signed'), 'mesgs'); setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs');
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} else { } else {
setEventMessage($objp->ref . " " . $langs->trans('CantBeSign'), 'errors'); setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors');
} }
} else { } else {
dol_print_error($db); dol_print_error($db);