mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
FIX list of visible type of event was not correctly filtered
FIX Error management on mass action "Approve holiday"
This commit is contained in:
parent
c45d6a3bc7
commit
f4cb5810a7
|
|
@ -186,35 +186,55 @@ class CActionComm
|
|||
|
||||
$qualified = 1;
|
||||
|
||||
// $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto
|
||||
// $obj->type can be 'system', 'systemauto', 'module', 'moduleauto', 'xxx', 'xxxauto'
|
||||
// Note: type = system... than type of event is added among other standard events.
|
||||
// type = module... then type of event is grouped into module defined into module = myobject@mymodule. Example: Event organization or external modules
|
||||
// type = xxx... then type of event is added into list as a new flat value (not grouped). Example: Agefod external module
|
||||
if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) {
|
||||
$qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO)
|
||||
}
|
||||
|
||||
if ($qualified && !empty($obj->module)) {
|
||||
if ($obj->module == 'invoice' && empty($conf->facture->enabled) && empty($user->facture->lire)) {
|
||||
$qualified = 0;
|
||||
//var_dump($obj->type.' '.$obj->module.' '); var_dump($user->rights->facture->lire);
|
||||
$qualified = 0;
|
||||
// Special cases
|
||||
if ($obj->module == 'invoice' && !empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) {
|
||||
$qualified = 1;
|
||||
}
|
||||
if ($obj->module == 'order' && empty($conf->commande->enabled) && empty($user->commande->lire)) {
|
||||
$qualified = 0;
|
||||
if ($obj->module == 'order' && !empty($conf->commande->enabled) && empty($user->rights->commande->lire)) {
|
||||
$qualified = 1;
|
||||
}
|
||||
if ($obj->module == 'propal' && empty($conf->propal->enabled) && empty($user->propale->lire)) {
|
||||
$qualified = 0;
|
||||
if ($obj->module == 'propal' && !empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) {
|
||||
$qualified = 1;
|
||||
}
|
||||
if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && empty($user->fournisseur->facture->lire)) || (!empty($conf->supplier_invoice->enabled) && empty($user->supplier_invoice->lire)))) {
|
||||
$qualified = 0;
|
||||
if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (!empty($conf->rights->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire)))) {
|
||||
$qualified = 1;
|
||||
}
|
||||
if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && empty($user->fournisseur->commande->lire)) || (empty($conf->supplier_order->enabled) && empty($user->supplier_order->lire)))) {
|
||||
$qualified = 0;
|
||||
if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (empty($conf->rights->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)))) {
|
||||
$qualified = 1;
|
||||
}
|
||||
if ($obj->module == 'shipping' && empty($conf->expedition->enabled) && empty($user->expedition->lire)) {
|
||||
$qualified = 0;
|
||||
if ($obj->module == 'shipping' && !empty($conf->expedition->enabled) && !empty($user->rights->expedition->lire)) {
|
||||
$qualified = 1;
|
||||
}
|
||||
if (preg_match('/@eventorganization/', $obj->module) && empty($conf->eventorganization->enabled) && empty($user->eventorganization->read)) {
|
||||
$qualified = 0;
|
||||
// For the generic case with type = 'module...' and module = 'myobject@mymodule'
|
||||
$regs = array();
|
||||
if (preg_match('/^module/', $obj->type)) {
|
||||
if (preg_match('/^(.+)@(.+)$/', $obj->module, $regs)) {
|
||||
$tmpobject = $regs[1];
|
||||
$tmpmodule = $regs[2];
|
||||
//var_dump($user->$tmpmodule);
|
||||
if ($tmpmodule && isset($conf->$tmpmodule) && !empty($conf->$tmpmodule->enabled) && (!empty($user->rights->$tmpmodule->read) || !empty($user->rights->$tmpmodule->lire) || !empty($user->rights->$tmpmodule->$tmpobject->read) || !empty($user->rights->$tmpmodule->$tmpobject->lire))) {
|
||||
$qualified = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!preg_match('/^system/', $obj->type) && isset($conf->{$obj->module}) && empty($conf->{$obj->module}->enabled)) {
|
||||
$qualified = 0;
|
||||
// For the case type is not 'system...' neither 'module', we just check module is on
|
||||
if (! in_array($obj->type, array('system', 'systemauto', 'module', 'moduleauto'))) {
|
||||
$tmpmodule = $obj->module;
|
||||
//var_dump($tmpmodule);
|
||||
if ($tmpmodule && isset($conf->$tmpmodule) && !empty($conf->$tmpmodule->enabled)) {
|
||||
$qualified = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,10 +49,11 @@ if (empty($conf->global->AGENDA_EXT_NB)) {
|
|||
}
|
||||
$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
|
||||
|
||||
$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
|
||||
$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
|
||||
$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
|
||||
$showbirthday = empty($conf->use_javascript_ajax) ?GETPOST("showbirthday", "int") : 1;
|
||||
$check_holiday = GETPOST('check_holiday', 'int');
|
||||
$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
|
||||
$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
|
||||
$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
|
||||
$showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1;
|
||||
|
||||
// If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user.
|
||||
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
|
||||
|
|
@ -207,16 +208,16 @@ if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') {
|
|||
}
|
||||
|
||||
/*
|
||||
if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
||||
$event = new ActionComm($db);
|
||||
$event->fetch($actionid);
|
||||
$event->fetch_optionals();
|
||||
$event->fetch_userassigned();
|
||||
$event->oldcopy = clone $event;
|
||||
if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
||||
$event = new ActionComm($db);
|
||||
$event->fetch($actionid);
|
||||
$event->fetch_optionals();
|
||||
$event->fetch_userassigned();
|
||||
$event->oldcopy = clone $event;
|
||||
|
||||
$result = $event->delete();
|
||||
}
|
||||
*/
|
||||
$result = $event->delete();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -579,10 +580,10 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
|
|||
$s .= '</script>'."\n";
|
||||
|
||||
// Local calendar
|
||||
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' </div>';
|
||||
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" value="1" checked disabled> '.$langs->trans("LocalAgenda").' </div>';
|
||||
|
||||
// Holiday calendar
|
||||
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" class="check_holiday"><label for="check_holiday"> <span class="check_holiday_text">'.$langs->trans("Holidays").'</span></label> </div>';
|
||||
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" class="check_holiday"'.($check_holiday ? ' checked' : '').'><label for="check_holiday"> <span class="check_holiday_text">'.$langs->trans("Holidays").'</span></label> </div>';
|
||||
|
||||
// External calendars
|
||||
if (is_array($showextcals) && count($showextcals) > 0) {
|
||||
|
|
@ -607,13 +608,13 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
|
|||
foreach ($showextcals as $val) {
|
||||
$htmlname = md5($val['name']);
|
||||
|
||||
if (!empty($val['default'])) {
|
||||
if (!empty($val['default']) || GETPOST('check_ext'.$htmlname, 'int')) {
|
||||
$default = "checked";
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
|
||||
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" '.$default.'> <label for="check_ext'.$htmlname.'">'.$val['name'].'</label> </div>';
|
||||
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" value="1" '.$default.'> <label for="check_ext'.$htmlname.'">'.$val['name'].'</label> </div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -847,6 +848,7 @@ if ($resql) {
|
|||
|
||||
$event->fk_project = $obj->fk_project;
|
||||
|
||||
$event->socid = $obj->fk_soc;
|
||||
$event->thirdparty_id = $obj->fk_soc;
|
||||
$event->contact_id = $obj->fk_contact;
|
||||
|
||||
|
|
@ -894,13 +896,13 @@ if ($resql) {
|
|||
$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); // $mois, $jour, $annee has been set for user tz
|
||||
$daykeyend = dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend, 'gmt'); // $moisend, $jourend, $anneeend has been set for user tz
|
||||
/*
|
||||
print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'<br>';
|
||||
print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'<br>';
|
||||
print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'<br>';
|
||||
print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'<br>';
|
||||
print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'<br>';
|
||||
print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'<br>';
|
||||
*/
|
||||
print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'<br>';
|
||||
print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'<br>';
|
||||
print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'<br>';
|
||||
print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'<br>';
|
||||
print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'<br>';
|
||||
print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'<br>';
|
||||
*/
|
||||
do {
|
||||
//if ($event->id==408)
|
||||
//print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'gmt').' - '.dol_print_date($event->datep, 'dayhour', 'gmt').' '.dol_print_date($event->datef, 'dayhour', 'gmt').'<br>';
|
||||
|
|
@ -1996,7 +1998,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
|
|||
if ($event->type_code != 'ICALEVENT') {
|
||||
$savlabel = $event->label ? $event->label : $event->libelle;
|
||||
$event->label = $titletoshow;
|
||||
$event->libelle = $titletoshow;
|
||||
$event->libelle = $titletoshow; // deprecatd
|
||||
// Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user.
|
||||
$titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : '');
|
||||
$titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0);
|
||||
|
|
|
|||
|
|
@ -1579,17 +1579,20 @@ if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $
|
|||
$nbok = 0;
|
||||
foreach ($toselect as $toselectid) {
|
||||
$result = $objecttmp->fetch($toselectid);
|
||||
if ($result>0) {
|
||||
if ($objecttmp->statut == Holiday::STATUS_VALIDATED && $user->id == $objecttmp->fk_validator) {
|
||||
if ($result > 0) {
|
||||
if ($objecttmp->statut != Holiday::STATUS_VALIDATED) {
|
||||
setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $langs->transnoentitiesnoconv('Validated')), null, 'warnings');
|
||||
continue;
|
||||
}
|
||||
if ($user->id == $objecttmp->fk_validator) {
|
||||
$objecttmp->oldcopy = dol_clone($objecttmp);
|
||||
|
||||
$objecttmp->date_valid = dol_now();
|
||||
$objecttmp->fk_user_valid = $user->id;
|
||||
$objecttmp->statut = Holiday::STATUS_APPROVED;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$verif = $objecttmp->approve($user);
|
||||
|
||||
if ($verif <= 0) {
|
||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||
$error++;
|
||||
|
|
@ -1664,14 +1667,9 @@ if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
$nbok++;
|
||||
} else {
|
||||
$db->rollback();
|
||||
$action = '';
|
||||
}
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans('ErrorNotApproverForHoliday', $objecttmp->ref), null, 'errors');
|
||||
}
|
||||
} else {
|
||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||
|
|
@ -1683,7 +1681,7 @@ if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $
|
|||
if (!$error) {
|
||||
if ($nbok > 1) {
|
||||
setEventMessages($langs->trans("RecordsApproved", $nbok), null, 'mesgs');
|
||||
} else {
|
||||
} elseif ($nbok == 1) {
|
||||
setEventMessages($langs->trans("RecordAproved"), null, 'mesgs');
|
||||
}
|
||||
$db->commit();
|
||||
|
|
|
|||
|
|
@ -5037,7 +5037,7 @@ class Form
|
|||
$formconfirm .= '<td class="valid">'.$question.'</td>';
|
||||
$formconfirm .= '<td class="valid center">';
|
||||
$formconfirm .= $this->selectyesno("confirm", $newselectedchoice, 0, false, 0, 0, 'marginleftonly marginrightonly');
|
||||
$formconfirm .= '<input class="button valignmiddle confirmvalidatebutton" type="submit" value="'.$langs->trans("Validate").'">';
|
||||
$formconfirm .= '<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="'.$langs->trans("Validate").'">';
|
||||
$formconfirm .= '</td>';
|
||||
$formconfirm .= '</tr>'."\n";
|
||||
|
||||
|
|
|
|||
|
|
@ -212,14 +212,14 @@ if ($massaction == 'presend') {
|
|||
}
|
||||
|
||||
if ($massaction == 'preenable') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassEnabling"), $langs->trans("ConfirmMassEnablingQuestion", count($toselect)), "enable", null, '', 0, 200, 500, 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassEnabling"), $langs->trans("ConfirmMassEnablingQuestion", count($toselect)), "enable", null, 'yes', 0, 200, 500, 1);
|
||||
}
|
||||
if ($massaction == 'predisable') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDisabling"), $langs->trans("ConfirmMassDisablingQuestion", count($toselect)), "disable", null, '', 0, 200, 500, 1);
|
||||
}
|
||||
|
||||
if ($massaction == 'preapproveleave') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, '', 0, 200, 500, 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, 'yes', 0, 200, 500, 1);
|
||||
}
|
||||
|
||||
// Allow Pre-Mass-Action hook (eg for confirmation dialog)
|
||||
|
|
|
|||
|
|
@ -1083,7 +1083,9 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
|
|||
if (empty($include_users)) {
|
||||
print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
|
||||
} else {
|
||||
$defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); // Will work only if supervisor has permission to approve so is inside include_users
|
||||
// Defined default approver (the forced approved of user or the supervisor if no forced value defined)
|
||||
// Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users
|
||||
$defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
|
||||
if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) {
|
||||
$defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ ErrorNotInDictionaryPaymentConditions=Not in Payment Terms Dictionary, please mo
|
|||
ErrorIsNotADraft=%s is not a draft
|
||||
ErrorExecIdFailed=Can't execute command "id"
|
||||
ErrorBadCharIntoLoginName=Unauthorized character in the login name
|
||||
ErrorNotApproverForHoliday=You are not the approver for leave %s
|
||||
|
||||
# Warnings
|
||||
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ class modMyModule extends DolibarrModules
|
|||
$sql = array();
|
||||
|
||||
// Document templates
|
||||
$moduledir = 'mymodule';
|
||||
$moduledir = dol_sanitizeFileName('mymodule');
|
||||
$myTmpObjects = array();
|
||||
$myTmpObjects['MyObject'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
|
||||
|
||||
|
|
@ -441,8 +441,8 @@ class modMyModule extends DolibarrModules
|
|||
continue;
|
||||
}
|
||||
if ($myTmpObjectArray['includerefgeneration']) {
|
||||
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
|
||||
$dirodt = DOL_DATA_ROOT.'/doctemplates/mymodule';
|
||||
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_myobjects.odt';
|
||||
$dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir;
|
||||
$dest = $dirodt.'/template_myobjects.odt';
|
||||
|
||||
if (file_exists($src) && !file_exists($dest)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user