Fix: edit event

New: Can use color of type of event into dictionnary.
This commit is contained in:
Laurent Destailleur 2014-10-03 18:04:13 +02:00
parent e7a9447d94
commit f9d78c0c57
2 changed files with 27 additions and 15 deletions

View File

@ -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 '<table class="border" width="100%">';
// Type d'action actifs
// Type of event
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print '<tr><td width="30%"><span class="fieldrequired">'.$langs->trans("Type").'</span></b></td><td>';
@ -863,13 +865,14 @@ if ($id > 0)
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$object->id.'</td></tr>';
// Type
// Type of event
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
$formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
print '</td></tr>';
}
else print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">';
// Title
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" size="50" value="'.$object->label.'"></td></tr>';

View File

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