From f48c9903757771fc3897bbf4b5044eda1db70598 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Thu, 23 Jun 2022 17:47:56 +0200 Subject: [PATCH 1/8] adding dropdown menu in case of a lot of buttons in project --- htdocs/projet/card.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0cfe126d69b..3193c410679 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1318,46 +1318,52 @@ if ($action == 'create' && $user->rights->projet->creer) { // Add button to create objects from project if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { + print''; + //print''; } // Clone From 259224c3bef96b19f4d63a88d3502800b4bf6b8f Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 2 Jul 2022 18:48:35 +0200 Subject: [PATCH 2/8] NEW : Recurrent events on agenda v1 --- htdocs/comm/action/card.php | 322 +++++++++++++++++---------------- htdocs/langs/en_US/agenda.lang | 4 +- htdocs/langs/fr_FR/agenda.lang | 4 +- 3 files changed, 177 insertions(+), 153 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 351ab9212bc..ac943350819 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -409,93 +409,130 @@ if (empty($reshook) && $action == 'add') { $error++; } + + if (!$error) { $db->begin(); - // Creation of action/event - $idaction = $object->create($user); + $dayoffset = 0; + $monthoffset = 0; - if ($idaction > 0) { - if (!$object->error) { - // Category association - $categories = GETPOST('categories', 'array'); - $object->setCategories($categories); + // If event is recurrent + $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + if ($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday")) { + $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOST("limitmonth", 'int'), GETPOST("limitday", 'int'), GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser'); + if (GETPOST('recurrulefreq') == 'DAILY') { + $dayoffset = 1; + } elseif (GETPOST('recurrulefreq') == 'WEEKLY') { + $dayoffset = 7; + } elseif (GETPOST('recurrulefreq') == 'MONTHLY') { + $monthoffset = 1; + } + } else { // If event is not recurrent, limit date is the date of the event + $repeateventlimitdate = $datep; + } - unset($_SESSION['assignedtouser']); + while ($datep <= $repeateventlimitdate) { + $finalobject = clone $object; - $moreparam = ''; - if ($user->id != $object->userownerid) { - $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. - } - // Create reminders - if ($addreminder == 'on') { - $actionCommReminder = new ActionCommReminder($db); + $finalobject->datep = $datep; + $finalobject->datef = $datef; + // Creation of action/event + $idaction = $finalobject->create($user); - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + if ($idaction > 0) { + if (!$finalobject->error) { + // Category association + $categories = GETPOST('categories', 'array'); + $finalobject->setCategories($categories); - $actionCommReminder->dateremind = $dateremind; - $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->offsetunit = $offsetunit; - $actionCommReminder->offsetvalue = $offsetvalue; - $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_actioncomm = $object->id; - if ($remindertype == 'email') { - $actionCommReminder->fk_email_template = $modelmail; + unset($_SESSION['assignedtouser']); + + $moreparam = ''; + if ($user->id != $finalobject->userownerid) { + $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. } - // the notification must be created for every user assigned to the event - foreach ($object->userassigned as $userassigned) { - $actionCommReminder->fk_user = $userassigned['id']; - $res = $actionCommReminder->create($user); + // Create reminders + if ($addreminder == 'on') { + $actionCommReminder = new ActionCommReminder($db); - if ($res <= 0) { - // If error - $db->rollback(); - $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); - $action = 'create'; $donotclearsession = 1; - break; + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + + $actionCommReminder->dateremind = $dateremind; + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_actioncomm = $finalobject->id; + if ($remindertype == 'email') { + $actionCommReminder->fk_email_template = $modelmail; + } + + // the notification must be created for every user assigned to the event + foreach ($finalobject->userassigned as $userassigned) { + $actionCommReminder->fk_user = $userassigned['id']; + $res = $actionCommReminder->create($user); + + if ($res <= 0) { + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans('ErrorReminderActionCommCreation'); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + break; + } } } - } - // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. - /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; - $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; - $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; - */ - $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; + // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. + /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; + $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; + $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; + */ + $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; - if ($error) { + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } else { + // If error $db->rollback(); - } else { - $db->commit(); + $langs->load("errors"); + $error = $langs->trans($finalobject->error); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; } - - if (!empty($backtopage)) { - dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - } elseif ($idaction) { - header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); - } else { - header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); - } - exit; } else { - // If error $db->rollback(); - $langs->load("errors"); - $error = $langs->trans($object->error); - setEventMessages($error, null, 'errors'); + setEventMessages($finalobject->error, $finalobject->errors, 'errors'); $action = 'create'; $donotclearsession = 1; } - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'create'; $donotclearsession = 1; + + // If event is not recurrent, we stop here + if (!($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday"))) { + break; + } + + // increment date for recurrent events + $datep = dol_time_plus_duree($datep, $dayoffset, 'd'); + $datep = dol_time_plus_duree($datep, $monthoffset, 'm'); + $datef = dol_time_plus_duree($datef, $dayoffset, 'd'); + $datef = dol_time_plus_duree($datef, $monthoffset, 'm'); } + if (!empty($backtopage)) { + dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + } elseif ($idaction) { + header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); + } else { + header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); + } + exit; } } @@ -917,9 +954,10 @@ $arrayrecurrulefreq = array( 'no'=>$langs->trans("OnceOnly"), 'MONTHLY'=>$langs->trans("EveryMonth"), 'WEEKLY'=>$langs->trans("EveryWeek"), - //'DAYLY'=>$langs->trans("EveryDay") + 'DAILY'=>$langs->trans("EveryDay") ); + $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); @@ -1038,44 +1076,26 @@ if ($action == 'create') { print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; $selectedrecurrulefreq = 'no'; - $selectedrecurrulebymonthday = ''; - $selectedrecurrulebyday = ''; - if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { - $selectedrecurrulefreq = $reg[1]; - } - if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebymonthday = $reg[1]; - } - if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebyday = $reg[1]; - } print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); - // If recurrulefreq is MONTHLY - print ''; - // If recurrulefreq is WEEKLY - print ''; - //print ''; - } + // // Recurring event + // $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + // if ($userepeatevent) { + // // Repeat + // //print ''; + // print '        
'; + // print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); + // print ''; + // $selectedrecurrulefreq = 'no'; + // $selectedrecurrulebymonthday = ''; + // $selectedrecurrulebyday = ''; + // if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { + // $selectedrecurrulefreq = $reg[1]; + // } + // if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { + // $selectedrecurrulebymonthday = $reg[1]; + // } + // if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { + // $selectedrecurrulebyday = $reg[1]; + // } + // print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); + // // If recurrulefreq is MONTHLY + // print ''; + // // If recurrulefreq is WEEKLY + // print ''; + // print ''; + // print '
'; + // //print ''; + // } print ''; // Date start - end diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 272ec22df5c..410537acbc1 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -135,7 +135,7 @@ AgendaUrlOptionsNotAdmin=logina=!%s to restrict output to actions not own AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s (owner and others). AgendaUrlOptionsProject=project=__PROJECT_ID__ to restrict output to actions linked to project __PROJECT_ID__. AgendaUrlOptionsNotAutoEvent=notactiontype=systemauto to exclude automatic events. -AgendaUrlOptionsIncludeHolidays=includeholidays=1 to include events of holidays. +AgendaUrlOptionsIncludeHolidays=includeholidays=1 to include events of holidays. AgendaShowBirthdayEvents=Birthdays of contacts AgendaHideBirthdayEvents=Hide birthdays of contacts Busy=Busy @@ -159,6 +159,7 @@ DateActionBegin=Start event date ConfirmCloneEvent=Are you sure you want to clone the event %s? RepeatEvent=Repeat event OnceOnly=Once only +EveryDay=Every day EveryWeek=Every week EveryMonth=Every month DayOfMonth=Day of month @@ -174,3 +175,4 @@ AddReminder=Create an automatic reminder notification for this event ErrorReminderActionCommCreation=Error creating the reminder notification for this event BrowserPush=Browser Popup Notification ActiveByDefault=Enabled by default +Until=until \ No newline at end of file diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 65e06587e88..a589163dfad 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -96,7 +96,7 @@ PRODUCT_MODIFYInDolibarr=Produit %s modifié PRODUCT_DELETEInDolibarr=Produit%ssupprimé HOLIDAY_CREATEInDolibarr=Demande de congé %s créée HOLIDAY_MODIFYInDolibarr=Demande de congé %s modifiée -HOLIDAY_APPROVEInDolibarr=Demande de congé %s approuvée +HOLIDAY_APPROVEInDolibarr=Demande de congé %s approuvée HOLIDAY_VALIDATEInDolibarr=Demande de congé %s validée HOLIDAY_DELETEInDolibarr=Demande de congé %s supprimée EXPENSE_REPORT_CREATEInDolibarr=Note de frais %s créée @@ -157,6 +157,7 @@ DateActionBegin=Date début événément ConfirmCloneEvent=Êtes-vous sûr de vouloir cloner cet événement %s ? RepeatEvent=Evénement répétitif OnceOnly=Une seule fois +EveryDay=Chaque jour EveryWeek=Chaque semaine EveryMonth=Chaque mois DayOfMonth=Jour du mois @@ -172,3 +173,4 @@ AddReminder=Créer une notification de rappel automatique pour cet événement ErrorReminderActionCommCreation=Erreur lors de la création de la notification de rappel pour cet événement BrowserPush=Notification par Popup navigateur ActiveByDefault=Activé par défaut +Until=jusqu'à From 572f1f0feefc1c6e2d7a9474a414282d10a4d4db Mon Sep 17 00:00:00 2001 From: Faustin Date: Thu, 7 Jul 2022 00:07:15 +0200 Subject: [PATCH 3/8] NEW : Recurrent events on agenda v2 --- htdocs/comm/action/card.php | 351 ++++++++++++++++++++++++++---------- 1 file changed, 253 insertions(+), 98 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index ac943350819..6701b8e367f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -414,117 +414,229 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $db->begin(); - $dayoffset = 0; - $monthoffset = 0; + + + // Creation of action/event + $idaction = $object->create($user); + + if ($idaction > 0) { + if (!$object->error) { + // Category association + $categories = GETPOST('categories', 'array'); + $object->setCategories($categories); + + unset($_SESSION['assignedtouser']); + + $moreparam = ''; + if ($user->id != $object->userownerid) { + $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. + } + + // Create reminders + if ($addreminder == 'on') { + $actionCommReminder = new ActionCommReminder($db); + + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + + $actionCommReminder->dateremind = $dateremind; + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_actioncomm = $object->id; + if ($remindertype == 'email') { + $actionCommReminder->fk_email_template = $modelmail; + } + + // the notification must be created for every user assigned to the event + foreach ($object->userassigned as $userassigned) { + $actionCommReminder->fk_user = $userassigned['id']; + $res = $actionCommReminder->create($user); + + if ($res <= 0) { + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans('ErrorReminderActionCommCreation'); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + break; + } + } + } + + // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. + /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; + $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; + $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; + */ + $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; + + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + + // if (!empty($backtopage)) { + // dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + // header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + // } elseif ($idaction) { + // header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); + // } else { + // header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); + // } + // exit; + } else { + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans($object->error); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + } + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; $donotclearsession = 1; + } + + $selectedrecurrulefreq = 'no'; + $selectedrecurrulebymonthday = ''; + $selectedrecurrulebyday = ''; + $object->recurrule = GETPOSTISSET('recurrulefreq') ? "FREQ=".GETPOST('recurrulefreq', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYMONTHDAY') ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYDAY') ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; + + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) { + $selectedrecurrulefreq = $reg1[1]; + } + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { + $selectedrecurrulebymonthday = $reg2[1]; + } + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { + $selectedrecurrulebyday = $reg3[1]; + } // If event is recurrent $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); - if ($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday")) { - $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOST("limitmonth", 'int'), GETPOST("limitday", 'int'), GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser'); - if (GETPOST('recurrulefreq') == 'DAILY') { - $dayoffset = 1; - } elseif (GETPOST('recurrulefreq') == 'WEEKLY') { + if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq != 'no') { + // We set first date of recurrence and offsets + if ($selectedrecurrulefreq == 'WEEKLY' && !empty($selectedrecurrulebyday)) { + $firstdatearray = dol_get_first_day_week(GETPOST("apday", 'int'), GETPOST("apmonth", 'int'), GETPOST("apyear", 'int')); + $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstdatearray['month'], $firstdatearray['first_day'], $firstdatearray['year'], $tzforfullday ? $tzforfullday : 'tzuser'); + $datep = dol_time_plus_duree($datep, $selectedrecurrulebyday + 6, 'd');//We begin the week after $dayoffset = 7; - } elseif (GETPOST('recurrulefreq') == 'MONTHLY') { + $monthoffset = 0; + } elseif ($selectedrecurrulefreq == 'MONTHLY' && !empty($selectedrecurrulebymonthday)) { + $firstday = $selectedrecurrulebymonthday; + $firstmonth = GETPOST("apday") > $selectedrecurrulebymonthday ? GETPOST("apmonth", 'int') + 1 : GETPOST("apmonth", 'int');//We begin the week after + $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstmonth, $firstday, GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser'); + $dayoffset = 0; $monthoffset = 1; + } else { + $error++; } - } else { // If event is not recurrent, limit date is the date of the event - $repeateventlimitdate = $datep; - } + // End date + $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth", 'int') ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser'); + // Set date of end of event + $deltatime = num_between_day($object->datep, $datep); + $datef = dol_time_plus_duree($datef, $deltatime, 'd'); - while ($datep <= $repeateventlimitdate) { - $finalobject = clone $object; + while ($datep <= $repeateventlimitdate && !$error) { + $finalobject = clone $object; - $finalobject->datep = $datep; - $finalobject->datef = $datef; - // Creation of action/event - $idaction = $finalobject->create($user); + $finalobject->datep = $datep; + $finalobject->datef = $datef; + // Creation of action/event + $idaction = $finalobject->create($user); - if ($idaction > 0) { - if (!$finalobject->error) { - // Category association - $categories = GETPOST('categories', 'array'); - $finalobject->setCategories($categories); + if ($idaction > 0) { + if (!$finalobject->error) { + // Category association + $categories = GETPOST('categories', 'array'); + $finalobject->setCategories($categories); - unset($_SESSION['assignedtouser']); + unset($_SESSION['assignedtouser']); - $moreparam = ''; - if ($user->id != $finalobject->userownerid) { - $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. - } - - // Create reminders - if ($addreminder == 'on') { - $actionCommReminder = new ActionCommReminder($db); - - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); - - $actionCommReminder->dateremind = $dateremind; - $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->offsetunit = $offsetunit; - $actionCommReminder->offsetvalue = $offsetvalue; - $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_actioncomm = $finalobject->id; - if ($remindertype == 'email') { - $actionCommReminder->fk_email_template = $modelmail; + $moreparam = ''; + if ($user->id != $finalobject->userownerid) { + $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. } - // the notification must be created for every user assigned to the event - foreach ($finalobject->userassigned as $userassigned) { - $actionCommReminder->fk_user = $userassigned['id']; - $res = $actionCommReminder->create($user); + // Create reminders + if ($addreminder == 'on') { + $actionCommReminder = new ActionCommReminder($db); - if ($res <= 0) { - // If error - $db->rollback(); - $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); - $action = 'create'; $donotclearsession = 1; - break; + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + + $actionCommReminder->dateremind = $dateremind; + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_actioncomm = $finalobject->id; + if ($remindertype == 'email') { + $actionCommReminder->fk_email_template = $modelmail; + } + + // the notification must be created for every user assigned to the event + foreach ($finalobject->userassigned as $userassigned) { + $actionCommReminder->fk_user = $userassigned['id']; + $res = $actionCommReminder->create($user); + + if ($res <= 0) { + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans('ErrorReminderActionCommCreation'); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + break; + } } } - } - // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. - /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; - $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; - $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; - */ - $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; + // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. + /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; + $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; + $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; + */ + $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; - if ($error) { - $db->rollback(); + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } } else { - $db->commit(); + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans($finalobject->error); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; } } else { - // If error $db->rollback(); - $langs->load("errors"); - $error = $langs->trans($finalobject->error); - setEventMessages($error, null, 'errors'); + setEventMessages($finalobject->error, $finalobject->errors, 'errors'); $action = 'create'; $donotclearsession = 1; } - } else { - $db->rollback(); - setEventMessages($finalobject->error, $finalobject->errors, 'errors'); - $action = 'create'; $donotclearsession = 1; - } - // If event is not recurrent, we stop here - if (!($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday"))) { - break; - } + // If event is not recurrent, we stop here + if (!($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday"))) { + break; + } - // increment date for recurrent events - $datep = dol_time_plus_duree($datep, $dayoffset, 'd'); - $datep = dol_time_plus_duree($datep, $monthoffset, 'm'); - $datef = dol_time_plus_duree($datef, $dayoffset, 'd'); - $datef = dol_time_plus_duree($datef, $monthoffset, 'm'); + // increment date for recurrent events + $datep = dol_time_plus_duree($datep, $dayoffset, 'd'); + $datep = dol_time_plus_duree($datep, $monthoffset, 'm'); + $datef = dol_time_plus_duree($datef, $dayoffset, 'd'); + $datef = dol_time_plus_duree($datef, $monthoffset, 'm'); + } } - if (!empty($backtopage)) { + if (!empty($backtopage) && !$error) { dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); } elseif ($idaction) { @@ -1075,35 +1187,78 @@ if ($action == 'create') { print '        
'; print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; + $selectedrecurrulefreq = 'no'; + $selectedrecurrulebymonthday = ''; + $selectedrecurrulebyday = ''; + $object->recurrule = GETPOSTISSET('recurrulefreq') ? "FREQ=".GETPOST('recurrulefreq', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYMONTHDAY') ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYDAY') ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; + + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) { + $selectedrecurrulefreq = $reg1[1]; + } + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { + $selectedrecurrulebymonthday = $reg2[1]; + } + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { + $selectedrecurrulebyday = $reg3[1]; + } + print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); + // print ''; // For recursive event + + + // If recurrulefreq is MONTHLY + print ''; + // If recurrulefreq is WEEKLY + print ''; + // limit date $repeateventlimitdate = $repeateventlimitdate ? $repeateventlimitdate : ''; print ''; - print ''; + }); + '; print '
'; //print ''; } From 0da4360b9fb77db7130aa514077aa8aac8025ec5 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Mon, 11 Jul 2022 17:30:11 +0200 Subject: [PATCH 4/8] almost done --- htdocs/core/lib/functions.lib.php | 17 +++++++++------ htdocs/projet/card.php | 36 +++++++++++++++---------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bf41b5a624a..e7c0244387f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10343,6 +10343,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param string $actionType default, delete, danger * @param string $url the url for link * @param string $id attribute id of button + * @param bboolean $isDropdown is dropdown button * @param int $userRight user action right * // phpcs:disable * @param array $params = [ // Various params for future : recommended rather than adding more function arguments @@ -10363,16 +10364,20 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * // phpcs:enable * @return string html button */ -function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array()) +function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $isDropdown = false, $userRight = 1, $params = array()) { global $hookmanager, $action, $object, $langs; - $class = 'butAction'; - if ($actionType == 'danger' || $actionType == 'delete') { - $class = 'butActionDelete'; - if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken(); + //var_dump($isDropdown); + if ($isDropdown) + $class = "dropdown-item"; + else { + $class = 'butAction'; + if ($actionType == 'danger' || $actionType == 'delete') { + $class = 'butActionDelete'; + if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken(); + } } - $attr = array( 'class' => $class, 'href' => empty($url) ? '' : $url, diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 3193c410679..0864a5b53f6 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1316,56 +1316,56 @@ if ($action == 'create' && $user->rights->projet->creer) { } } - // Add button to create objects from project + if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { - print'"; + print ""; } - // Clone if ($user->rights->projet->creer) { if ($userWrite > 0) { From 87b80912df6308562e68c50a2c37fe3bc8ba2a42 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 19 Jul 2022 20:35:03 +0200 Subject: [PATCH 5/8] merge --- htdocs/comm/action/card.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index eef679b7141..8d1f75c4990 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1195,15 +1195,16 @@ if ($action == 'create') { $object->recurrule .= GETPOSTISSET('BYMONTHDAY') ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; $object->recurrule .= GETPOSTISSET('BYDAY') ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; - $reg1 = array(); - if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) { - $selectedrecurrulefreq = $reg1[1]; + + $reg = array(); + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { + $selectedrecurrulefreq = $reg[1]; } - if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { - $selectedrecurrulebymonthday = $reg2[1]; + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) { + $selectedrecurrulebymonthday = $reg[1]; } - if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { - $selectedrecurrulebyday = $reg3[1]; + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { + $selectedrecurrulebyday = $reg[1]; } print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); From 1f9afaadb1df40589d622570ef7199b9a64a8b1f Mon Sep 17 00:00:00 2001 From: Faustin Date: Wed, 20 Jul 2022 13:08:28 +0200 Subject: [PATCH 6/8] Removing daily event for the moment --- htdocs/comm/action/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 8d1f75c4990..1ab81b01bd7 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1065,8 +1065,8 @@ $formproject = new FormProjets($db); $arrayrecurrulefreq = array( 'no'=>$langs->trans("OnceOnly"), 'MONTHLY'=>$langs->trans("EveryMonth"), - 'WEEKLY'=>$langs->trans("EveryWeek"), - 'DAILY'=>$langs->trans("EveryDay") + 'WEEKLY'=>$langs->trans("EveryWeek") + // 'DAILY'=>$langs->trans("EveryDay") ); From 873745a178ab3bdca28cff576ea4e998d25f53be Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Mon, 25 Jul 2022 20:13:54 +0200 Subject: [PATCH 7/8] I included the boolean in the `$params` and resolved the margin issue. --- htdocs/core/lib/functions.lib.php | 8 ++++---- htdocs/projet/card.php | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e7c0244387f..3df96d4e057 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10343,7 +10343,6 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * @param string $actionType default, delete, danger * @param string $url the url for link * @param string $id attribute id of button - * @param bboolean $isDropdown is dropdown button * @param int $userRight user action right * // phpcs:disable * @param array $params = [ // Various params for future : recommended rather than adding more function arguments @@ -10359,17 +10358,18 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'modal' => true, // true|false to display dialog as a modal (with dark background) + * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) * ], * ] * // phpcs:enable * @return string html button */ -function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $isDropdown = false, $userRight = 1, $params = array()) +function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array()) { global $hookmanager, $action, $object, $langs; - //var_dump($isDropdown); - if ($isDropdown) + //var_dump($params); + if ($params['isDropdown']) $class = "dropdown-item"; else { $class = 'butAction'; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0864a5b53f6..7353323b60d 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1319,48 +1319,48 @@ if ($action == 'create' && $user->rights->projet->creer) { if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { print'