From f9d78c0c5755da5a7fe15b65254d2a06a36cc1e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Oct 2014 18:04:13 +0200 Subject: [PATCH] Fix: edit event New: Can use color of type of event into dictionnary. --- htdocs/comm/action/card.php | 19 +++++++++++-------- htdocs/comm/action/peruser.php | 23 ++++++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 772e3e05622..970eb1d4725 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -89,14 +89,16 @@ $hookmanager->initHooks(array('actioncard')); */ // Remove user to assigned list -if (! empty($_POST['removedassigned'])) +if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') { - $idtoremove=$_POST['removedassigned']; + $idtoremove=GETPOST('removedassigned'); + if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1); else $tmpassigneduserids=array(); + foreach ($tmpassigneduserids as $key => $val) { - if ($val['id'] == $idtoremove) unset($tmpassigneduserids[$key]); + if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]); } //var_dump($_POST['removedassigned']);exit; $_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids); @@ -357,7 +359,7 @@ if ($action == 'update') $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); - $object->fk_action = dol_getIdFromCode($db, $_POST["actioncode"], 'c_actioncomm'); + $object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm'); $object->label = GETPOST("label"); $object->datep = $datep; $object->datef = $datef; @@ -366,10 +368,10 @@ if ($action == 'update') $object->fulldayevent= GETPOST("fullday")?1:0; $object->location = GETPOST('location'); $object->socid = GETPOST("socid"); - $object->contactid = GETPOST("contactid"); + $object->contactid = GETPOST("contactid",'int'); //$object->societe->id = $_POST["socid"]; // deprecated //$object->contact->id = $_POST["contactid"]; // deprecated - $object->fk_project = GETPOST("projectid"); + $object->fk_project = GETPOST("projectid",'int'); $object->note = GETPOST("note"); $object->pnote = GETPOST("note"); $object->fk_element = GETPOST("fk_element"); @@ -611,7 +613,7 @@ if ($action == 'create') print ''; - // Type d'action actifs + // Type of event if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; - // Type + // Type of event if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; } + else print ''; // Title print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").''; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 4452351d8c2..f20fe750d33 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -601,8 +601,13 @@ else } // Load array of colors by type -// TODO $colorsbytype=array(); +$sql="SELECT code, color FROM ".MAIN_DB_PREFIX."c_actioncomm"; +$resql=$db->query($sql); +while ($obj = $db->fetch_object($resql)) +{ + $colorsbytype[$obj->code]=$obj->color; +} // Loop on each user to show calendar $todayarray=dol_getdate($now,'fast'); @@ -707,14 +712,15 @@ $db->close(); * @param int $showinfo Add extended information (used by day view) * @param int $minheight Minimum height for each event. 60px by default. * @param boolean $showheader Show header + * @param array $colorsbytype Array with colors by type * @return void */ -function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false) +function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array()) { global $db; global $user, $conf, $langs, $hookmanager, $action; global $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form - global $theme_datacolor; + global $theme_datacolor; // Array with a list of different we can use (come from theme) global $cachethirdparties, $cachecontacts, $colorindexused; global $begin_h, $end_h; @@ -757,12 +763,13 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if (in_array($user->id, $keysofuserassigned)) { $nummytasks++; $cssclass='family_mytasks'; - $color=$event->type_color; + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; } else if ($event->type_code == 'ICALEVENT') { $numical++; - if (! empty($event->icalname)) { + if (! empty($event->icalname)) + { if (! isset($numicals[dol_string_nospecial($event->icalname)])) { $numicals[dol_string_nospecial($event->icalname)] = 0; } @@ -779,7 +786,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & else { $numother++; $cssclass='family_other'; + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; } + if ($color < 0) // Color was not forced. Set color according to color index. { // Define color index if not yet defined @@ -865,8 +874,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['string']=$event->label; $cases1[$h][$event->id]['typecode']=$event->type_code; $cases2[$h][$event->id]['typecode']=$event->type_code; - $cases1[$h][$event->id]['color']='009900'; - $cases2[$h][$event->id]['color']='009900'; + $cases1[$h][$event->id]['color']=$color; + $cases2[$h][$event->id]['color']=$color; } } $i++;
'.$langs->trans("Type").''; @@ -863,13 +865,14 @@ if ($id > 0) // Ref print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Type").''; $formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto"); print '