From 1395a9ff8f72deb8ef70601bb60f35d5840e8fd9 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 23 Jun 2023 16:32:01 +0200 Subject: [PATCH] New : mass modification of status for coferenceorbooth --- .../conferenceorbooth_list.php | 53 +++++++++++++++++++ htdocs/langs/en_US/eventorganization.lang | 6 +++ 2 files changed, 59 insertions(+) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 49940ef7881..e9b1c0d01cd 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -223,6 +223,42 @@ if (empty($reshook)) { $uploaddir = $conf->eventorganization->dir_output; include DOL_DOCUMENT_ROOT.'/eventorganization/core/actions_massactions_mail.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if ($permissiontoadd && (($action == 'setstatus' && $confirm == "yes") || $massaction == 'setstatus')) { + $db->begin(); + $error = 0;$nbok = 0; + $objecttmp = new $objectclass($db); + foreach ($toselect as $key => $idselect) { + $result = $objecttmp->fetch($idselect); + if ($result > 0) { + $objecttmp->status = GETPOST("statusmassaction", 'int'); + $result = $objecttmp->update($user); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error ++; + break; + } + } + if (empty($error)) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsUpdated", $nbok), null, 'mesgs'); + } elseif ($nbok > 0) { + setEventMessages($langs->trans("RecordUpdated", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("NoRecordUpdated"), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } + } } @@ -680,6 +716,9 @@ $arrayofmassactions = array( if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } +if (!empty($permissiontoadd)) { + $arrayofmassactions['presetstatus'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("ModifyStatus"); +} if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } @@ -716,6 +755,20 @@ $trackid = 'conferenceorbooth_'.$object->id; $withmaindocfilemail = 0; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +if ($massaction == 'presetstatus') { + $formquestion = array(); + $statuslist[$objecttmp::STATUS_DRAFT] = $objecttmp->LibStatutEvent($objecttmp::STATUS_DRAFT); + $statuslist[$objecttmp::STATUS_SUGGESTED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_SUGGESTED); + $statuslist[$objecttmp::STATUS_CONFIRMED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_CONFIRMED); + $statuslist[$objecttmp::STATUS_NOT_QUALIFIED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_NOT_QUALIFIED); + $statuslist[$objecttmp::STATUS_DONE] = $objecttmp->LibStatutEvent($objecttmp::STATUS_DONE); + $statuslist[$objecttmp::STATUS_CANCELED] = $objecttmp->LibStatutEvent($objecttmp::STATUS_CANCELED); + $formquestion[] = array('type' => 'other', + 'name' => 'affectedcommercial', + 'label' => $form->editfieldkey('ModifyStatus', 'status_id', '', $object, 0), + 'value' => $form->selectarray('statusmassaction', $statuslist, GETPOST('statusmassaction'))); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmModifyStatus"), $langs->trans("ConfirmModifyStatusQuestion", count($toselect)), "setstatus", $formquestion, 1, 0, 200, 500, 1); +} if ($search_all) { $setupstring = ''; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 894c9de4f13..4c9fd31b896 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -175,3 +175,9 @@ NoPublicActionsAllowedForThisEvent=No public actions are open to public for this MaxNbOfAttendees=Max number of attendees DateStartEvent=Event start date DateEndEvent=Event end date +ModifyStatus=Modify status +ConfirmModifyStatus=Confirm status modification +ConfirmModifyStatusQuestion=Are you sure you want to modify the %s selected record(s)? +RecordsUpdated = %s Records updated +RecordUpdated = Record updated +NoRecordUpdated = No Record updated \ No newline at end of file