Skip to content

Commit

Permalink
Fix: edit event
Browse files Browse the repository at this point in the history
New: Can use color of type of event into dictionnary.
  • Loading branch information
eldy committed Oct 3, 2014
1 parent e7a9447 commit f9d78c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
19 changes: 11 additions & 8 deletions htdocs/comm/action/card.php
Expand Up @@ -89,14 +89,16 @@
*/

// 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);
Expand Down Expand Up @@ -357,7 +359,7 @@
$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;
Expand All @@ -366,10 +368,10 @@
$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");
Expand Down Expand Up @@ -611,7 +613,7 @@ function setdatefields()

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>';
Expand Down Expand Up @@ -863,13 +865,14 @@ function setdatefields()
// 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>';
Expand Down
23 changes: 16 additions & 7 deletions htdocs/comm/action/peruser.php
Expand Up @@ -601,8 +601,13 @@
}

// 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');
Expand Down Expand Up @@ -707,14 +712,15 @@
* @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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit f9d78c0

Please sign in to comment.