New : mass modification of status for coferenceorbooth

This commit is contained in:
Hystepik 2023-06-23 16:32:01 +02:00
parent e95d2d5468
commit 1395a9ff8f
2 changed files with 59 additions and 0 deletions

View file

@ -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 = '';

View file

@ -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