day_name[0] = $GLOBALS['mod_strings']['LBL_MONDAY']; $this->day_name[1] = $GLOBALS['mod_strings']['LBL_TUESDAY']; $this->day_name[2] = $GLOBALS['mod_strings']['LBL_WEDNESDAY']; $this->day_name[3] = $GLOBALS['mod_strings']['LBL_THURSDAY']; $this->day_name[4] = $GLOBALS['mod_strings']['LBL_FRIDAY']; $this->day_name[5] = $GLOBALS['mod_strings']['LBL_SATURDAY']; $this->day_name[6] = $GLOBALS['mod_strings']['LBL_SUNDAY']; //print_r($this->day_name); $this->day_name_short[0] = $GLOBALS['mod_strings']['LBL_SHORT_MONDAY']; $this->day_name_short[1] = $GLOBALS['mod_strings']['LBL_SHORT_TUESDAY']; $this->day_name_short[2] = $GLOBALS['mod_strings']['LBL_SHORT_WEDNESDAY']; $this->day_name_short[3] = $GLOBALS['mod_strings']['LBL_SHORT_THURSDAY']; $this->day_name_short[4] = $GLOBALS['mod_strings']['LBL_SHORT_FRIDAY']; $this->day_name_short[5] = $GLOBALS['mod_strings']['LBL_SHORT_SATURDAY']; $this->day_name_short[6] = $GLOBALS['mod_strings']['LBL_SHORT_SUNDAY']; $GLOBALS['mod_strings'] = $tmp; } function navArray() { if ($this->month == 12) { $year = $this->year + 1; $arr['next'] = $year . "-01"; } else { $month = $this->month + 1; $arr['next'] = $this->year . "-" . $month; } if ($this->month == 1) { $year = $this->year - 1; $arr['prev'] = $year . "-12"; } else { $month = $this->month - 1; $arr['prev'] = $this->year . "-" . $month; } return $arr; } function showNav() { $arr = $this->navArray(); $html = ''; $html.=''; $html.='
'; $html.=$this->monthByNo((int) $this->month) . ' ' . $this->year; $html.='

'; return $html; } function showNavDay() { $tomorrow = date("Y-m-d", @mktime(0, 0, 0, $this->month, $this->day, $this->year) + 24 * 3600); $yesterday = date("Y-m-d", @mktime(0, 0, 0, $this->month, $this->day, $this->year) - 24 * 3600); $html = ''; $html.=''; $html.='
'; $html.=$this->day . ' ' . $this->monthByNo((int) $this->month) . ' ' . $this->year; $html.='

'; return $html; } function showNavMiniCalendar() { $arr = $this->navArray(); $html = ''; $html.=''; $html.='
'; $html.=$this->monthByNo((int) $this->month) . ' ' . $this->year; $html.='

'; return $html; } function showFooter() { $html = '
'; $html.=''; $html.=''; global $app_list_strings; $html.=''; $html.='
'; $html.=$GLOBALS['mod_strings']['LBL_USER'] . ': ' . $GLOBALS['mod_strings']['LBL_ACTIVITIES'] . ': '; $html.='' . $GLOBALS['mod_strings']['LBL_STATUS'] . ': 

'; return $html; } function showFooterMiniCalendar() { $html = '
'; $html.=''; $html.=''; $html.=''; $html.='
'; $html.=$GLOBALS['mod_strings']['LBL_USER'] . ': ' . $GLOBALS['mod_strings']['LBL_ACTIVITIES'] . ': '; $html.='' . $GLOBALS['mod_strings']['LBL_STATUS'] . ': 

'; return $html; } function daysInMonth($month, $year) { $days = 31; while (!checkdate($month, $days, $year)) $days--; return $days; } function getNoOfWeek($month, $year, $day) { $no = strftime("%W", mktime(0, 0, 0, $month, $day, $year)) + 1; return $no; } function noDayInWeek($month, $year, $day = 1) { $d = date("w", mktime(0, 0, 0, $month, $day, $year)); $nod = array( 0 => 6, 1 => 0, 2 => 1, 3 => 2, 4 => 3, 5 => 4, 6 => 5, ); $dayd = $nod[$d]; return $dayd; } function dayByNo($no) { $days = $this->day_name; return $days[$no]; } function monthByNo($no) { $months = array( 1 => $GLOBALS['mod_strings']['LBL_JANUARY'], 2 => $GLOBALS['mod_strings']['LBL_FEBRUARY'], 3 => $GLOBALS['mod_strings']['LBL_MARCH'], 4 => $GLOBALS['mod_strings']['LBL_APRIL'], 5 => $GLOBALS['mod_strings']['LBL_MAY'], 6 => $GLOBALS['mod_strings']['LBL_JUNE'], 7 => $GLOBALS['mod_strings']['LBL_JULY'], 8 => $GLOBALS['mod_strings']['LBL_AUGUST'], 9 => $GLOBALS['mod_strings']['LBL_SEPTEMBER'], 10 => $GLOBALS['mod_strings']['LBL_OCTOBER'], 11 => $GLOBALS['mod_strings']['LBL_NOVEMBER'], 12 => $GLOBALS['mod_strings']['LBL_DECEMBER'] ); return $months[$no]; } function headerTableDashlet($days = "") { if (!$days) $days = $this->day_name_short; $html = $this->showNav(); $html.=''; $html.=''; // foreach ($days as $dn) { $html.=''; } $html.=''; return $html; } function headerTableMiniCalendar($days = "") { if (!$days) $days = $this->day_name_short; $html = $this->showNavMiniCalendar(); $html.='
' . $GLOBALS['mod_strings']['LBL_WEEK'] . '' . $dn . '
'; $html.=''; foreach ($days as $dn) { $html.=''; } $html.=''; return $html; } function headerTableMonth($days = "") { if (!$days) $days = $this->day_name_short; $html = '
' . $GLOBALS['mod_strings']['LBL_WEEK'] . '' . $dn . '
'; $html.=''; foreach ($days as $dn) { $html.=''; } $html.=''; return $html; } function headerTableWeek($days = "") { if (!$days) $days = $this->day_name; $html = '
' . $GLOBALS['mod_strings']['LBL_WEEK'] . '' . $dn . '
'; $html.=''; foreach ($days as $dn) { $html.=''; } $html.=''; return $html; } function headerTableDay() { if (!$days) $days = $this->day_name; $html = '
' . $GLOBALS['mod_strings']['LBL_WEEK'] . '' . $dn . '
'; $html.=''; foreach ($days as $dn) { $html.=''; } $html.=''; return $html; } function showTableMiniCalendar($month, $year) { global $timedate; $html = $this->headerTableMiniCalendar(); if ($this->noDayInWeek($month, $year) > 0) $html.=''; for ($i = 0; $i < $this->noDayInWeek($month, $year); $i++) $html.=''; for ($i = 1; $i < $this->daysInMonth($month, $year) + 1; $i++) { if (($this->noDayInWeek($month, $year) + $i - 1) % 7 == 0) $html.=''; if ($i < 10) $ni = '0' . $i; else $ni = $i; if (($this->noDayInWeek($month, $year) + $i) % 7 == 0) $class = "sundayDashlet"; elseif (date("d") == $i && date("m") == $month && date("Y") == $year) $class = "headerDashlet"; else $class = "dayDashlet"; if ($this->act_type == "All") { $num_act = count($this->getActivities($month, $year, $ni, "calls", "Calls", "date_start")) + count($this->getActivities($month, $year, $ni, "meetings", "Meetings", "date_start")) + count($this->getActivities($month, $year, $ni, "tasks", "Tasks", "date_start")); $actt = array(); if ($this->showActivities($month, $year, $ni, "calls", "Calls", "date_start")) $actt[] = $this->showActivities($month, $year, $ni, "calls", "Calls", "date_start"); if ($this->showActivities($month, $year, $ni, "meetings", "Meetings", "date_start")) $actt[] = $this->showActivities($month, $year, $ni, "meetings", "Meetings", "date_start"); if ($this->showActivities($month, $year, $ni, "tasks", "Tasks", "date_start")) $actt[] = $this->showActivities($month, $year, $ni, "tasks", "Tasks", "date_start"); $act = htmlspecialchars('
') . implode("
", $actt) . htmlspecialchars('
'); } else { $num_act = count($this->getActivities($month, $year, $ni, strtolower($this->act_type), $this->act_type, "date_start")); $actt = array(); if ($this->showActivities($month, $year, $ni, strtolower($this->act_type), $this->act_type, "date_start")) $ac = $this->showActivities($month, $year, $ni, strtolower($this->act_type), $this->act_type, "date_start"); $act = htmlspecialchars('
') . $ac . htmlspecialchars('
'); } if ($num_act > 0) { if (date("d") == $i && date("m") == $month && date("Y") == $year) $class = "headerDashlet"; elseif (($this->noDayInWeek($month, $year) + $i) % 7 == 0) $class = "actsundayDashlet"; else $class = "actDashlet"; $mouse = ' onclick=" if(!document.getElementById(\'desc\')) { showdescriptionCalendar(\'' . $GLOBALS['mod_strings']['LBL_ACTIVITIES'] . ' ' . $timedate->to_display($year . '-' . $month . '-' . $ni, "Y-m-d", $timedate->get_date_format()) . '\',\'' . $act . '\',this,1); } else { hidedescriptionCalendar(); };"'; $img = '
'; } else { $mouse = ' onmouseout="this.style.fontWeight=\'\';" onmouseover="this.style.fontWeight=\'bold\';hidedescriptionCalendar();"'; $img = ''; } $html.=''; } $html.='
' . $GLOBALS['mod_strings']['LBL_WEEK'] . '' . $dn . '
' . $this->getNoOfWeek($month, $year, 1) . ' 
' . $this->getNoOfWeek($month, $year, $i) . '' . $ni . ' ' . $img . '
'; $html.=$this->showFooterMiniCalendar(); return $html; } function showTableDashlet($month, $year) { global $timedate; $tmplanguage = $GLOBALS['mod_strings']; $GLOBALS['mod_strings'] = return_module_language($current_language, 'EcmCalendars'); $html = $this->headerTableDashlet(); if ($this->noDayInWeek($month, $year) > 0) { $html.='' . $this->getNoOfWeek($month, $year, 1) . ''; } for ($i = 0; $i < $this->noDayInWeek($month, $year); $i++) { $html.=' '; } for ($i = 1; $i < $this->daysInMonth($month, $year) + 1; $i++) { if (($this->noDayInWeek($month, $year) + $i - 1) % 7 == 0) { $html.='' . $this->getNoOfWeek($month, $year, $i) . ''; } if ($i < 10) { $ni = '0' . $i; } else { $ni = $i; } if (($this->noDayInWeek($month, $year) + $i) % 7 == 0) { $class = "sundayDashlet"; } elseif (date("d") == $i && date("m") == $month && date("Y") == $year) { $class = "headerDashlet"; } else { $class = "dayDashlet"; } if ($this->act_type == "All") { $num_act = count($this->getActivities($month, $year, $ni, "calls", "Calls", "date_start")) + count($this->getActivities($month, $year, $ni, "meetings", "Meetings", "date_start")) + count($this->getActivities($month, $year, $ni, "tasks", "Tasks", "date_start")); $actt = array(); if ($this->showActivities($month, $year, $ni, "calls", "Calls", "date_start")) { $actt[] = $this->showActivities($month, $year, $ni, "calls", "Calls", "date_start"); } if ($this->showActivities($month, $year, $ni, "meetings", "Meetings", "date_start")) { $actt[] = $this->showActivities($month, $year, $ni, "meetings", "Meetings", "date_start"); } if ($this->showActivities($month, $year, $ni, "tasks", "Tasks", "date_start")) { $actt[] = $this->showActivities($month, $year, $ni, "tasks", "Tasks", "date_start"); } $act = htmlspecialchars('
') . implode("
", $actt) . htmlspecialchars('
'); } else { $num_act = count($this->getActivities($month, $year, $ni, strtolower($this->act_type), $this->act_type, "date_start")); $actt = array(); if ($this->showActivities($month, $year, $ni, strtolower($this->act_type), $this->act_type, "date_start")) { $ac = $this->showActivities($month, $year, $ni, strtolower($this->act_type), $this->act_type, "date_start"); } $act = htmlspecialchars('
') . $ac . htmlspecialchars('
'); } if ($num_act > 0) { if (date("d") == $i && date("m") == $month && date("Y") == $year) { $class = "headerDashlet"; } elseif (($this->noDayInWeek($month, $year) + $i) % 7 == 0) { $class = "actsundayDashlet"; } else { $class = "actDashlet"; } $mouse = ' onclick=" if(!document.getElementById(\'desc\')) { showdescriptionCalendar(\'' . $GLOBALS['mod_strings']['LBL_ACTIVITIES'] . ' ' . $timedate->to_display($year . '-' . $month . '-' . $ni, "Y-m-d", $timedate->get_date_format()) . '\',\'' . $act . '\',this,1); } else { hidedescriptionCalendar(); };"'; $img = '
'; } else { $mouse = ' onmouseout="this.style.fontWeight=\'\';" onmouseover="this.style.fontWeight=\'bold\';hidedescriptionCalendar();"'; $img = ''; } $html.='' . $ni . ' ' . $img . ''; } $html.=''; $html.=$this->showFooter(); $GLOBALS['mod_strings'] = $tmplanguage; return $html; } function showTableMonth($month, $year) { $html = $this->headerTableMonth(); $html.='' . $this->getNoOfWeek($month, $year, 1) . ''; for ($i = 0; $i < $this->noDayInWeek($month, $year); $i++) $html.=' '; for ($i = 1; $i < $this->daysInMonth($month, $year) + 1; $i++) { if (($this->noDayInWeek($month, $year) + $i - 1) % 7 == 0) $html.='' . $this->getNoOfWeek($month, $year, $i) . ''; if ($i < 10) $ni = '0' . $i; else $ni = $i; $html.='' . $ni . '
'; $html.=$this->showActivities($month, $year, $ni, "calls", "Calls", "date_start") . '<br>'; $html.=$this->showActivities($month, $year, $ni, "meetings", "Meetings", "date_start"); $html.=''; } $html.=''; return $html; } function showTableWeek($month, $year, $day) { $html = $this->headerTableWeek($this->day_name); $days = $this->getDaysWeek($month, $year, $day); $html.='' . $this->getNoOfWeek($month, $year, $day) . ''; foreach ($days as $d) { $exp = explode("-", $d); $html.='' . $d . '
'; $html.=$this->showActivities($month, $year, $exp[2], "calls", "Calls", "date_start") . '
'; $html.=$this->showActivities($month, $year, $exp[2], "meetings", "Meetings", "date_start"); $html.=""; } $html.=''; return $html; } function showTableDay($month, $year, $day) { $html = ''; for ($i = 6; $i <= 24; $i++) { if ($i < 10) $h = '0' . $i; else $h = $i; $html.=''; } $html.='
' . $h . ':00 
'; $html.=$this->showActivitiesDay($month, $year, $day, array("meetings", "calls", "tasks"), array("Meetings", "Calls", "Tasks"), array("date_start", "date_start", "date_start")); return $html; } function matchTime($time1, $duration1, $time2, $duration2) { $exp1 = explode(":", $time1); $date1 = date("H:i:s", @mktime($exp1[0], $exp1[1], $exp1[2], 0, 0, 0) + $duration1); $exp2 = explode(":", $time2); $date2 = date("H:i:s", @mktime($exp2[0], $exp2[1], $exp2[2], 0, 0, 0)); if ($date1 > $date2) return true; } function getActivityHours($time, $duration) { $exp = explode(":", $time); $hours = ceil($duration / 3600); for ($i = 0; $i <= $hours; $i++) { $n = $i * 3600; $arr[date("H", mktime($exp[0], $exp[1], $exp[2], 0, 0, 0) + $n)] = date("H", mktime($exp[0], $exp[1], $exp[2], 0, 0, 0) + $n); } //print_r($arr); return $arr; } function getAllActivityHours($arr) { foreach ($arr as $r) { $time = explode(" ", $r['date']); $exp = explode(":", $time[1]); for ($i = 0; $i < (int) $r['duration']; $i++) { $arrr[date("H", @mktime($exp[0], $exp[1], $exp[2], 0, 0, 0) + $i)] = date("H", @mktime($exp[0], $exp[1], $exp[2], 0, 0, 0) + $i); } } return $arrr; } function resizeHours($arr) { $html = ''; foreach ($arr as $a) $html.='resizeHours("' . (int) $a . '","' . $this->hour_height . '");'; return $html; } function getHourPosition($hour, $resized_hours) { $v = 0; for ($i = 0; $i <= (int) $hour; $i++) $arr[$i] = $this->hour_label_height; foreach ($resized_hours as $a) $arr[(int) $a] = $this->hour_height; for ($i = 0; $i <= (int) $hour; $i++) $v+=$arr[$i]; return $v; } function multisort($data, $keys) { if (count($data) > 0) { foreach ($data as $key => $row) { foreach ($keys as $k) { $cols[$k['key']][$key] = $row[$k['key']]; } } $idkeys = @array_keys($data); $i = 0; foreach ($keys as $k) { if ($i > 0) $sort.=','; $sort.='$cols[' . $k['key'] . ']'; if ($k['sort']) $sort.=',SORT_' . strtoupper($k['sort']); if ($k['type']) $sort.=',SORT_' . strtoupper($k['type']); $i++; } $sort.=',$idkeys'; $sort = '@array_multisort(' . $sort . ');'; eval($sort); foreach ($idkeys as $idkey) { $result[$idkey] = $data[$idkey]; } return $result; } } function ca($position, $boxes_defs, $time, $duration) { foreach ($boxes_defs as $bd) { if ($this->matchTime($bd['box_time'], $bd['box_duration'], $time, $duration) && $position == $bd['box_position']) return false; } return true; } function setBoxesPositions($b, $positions) { $b = $this->multisort($b, array(array('key' => 'box_time', 'sort' => 'asc'))); for ($i = count($b) - 1; $i >= 0; $i--) { for ($j = 0; $j < count($b); $j++) { foreach ($positions as $position) { if ($i != $j && $position == $b[$j]['box_position'] && !$this->matchTime($b[$j]['box_time'], $b[$j]['box_duration'], $b[$i]['box_time'], $b[$i]['box_duration'])) { if ($this->ca($position, $b, $b[$i]['box_time'], $b[$i]['box_duration'])) $b[$i]['box_position'] = $b[$j]['box_position']; } } } } //print_r($b); return $b; } function showActivitiesDay($month, $year, $day, $table, $module, $date_field) { $calls = $this->getActivities($month, $year, $day, "calls", "Calls", "date_start"); $meetings = $this->getActivities($month, $year, $day, "meetings", "Meetings", "date_start"); $tasks = $this->getActivities($month, $year, $day, "tasks", "Tasks", "date_start"); if (count($calls) > 0) foreach ($calls as $call) $arr[] = $call; if (count($meetings) > 0) foreach ($meetings as $meeting) $arr[] = $meeting; if (count($tasks) > 0) foreach ($tasks as $task) $arr[] = $task; $arr = $this->multisort($arr, array(array('key' => 'date', 'sort' => 'asc'))); //print_r($arr); if (count($arr) > 0) { $cc = 0; $mn = $this->hour_height / 60; foreach ($arr as $r) { $o++; $exp = explode(" ", $r['date']); $hour = explode(":", $exp[1]); $y = $hour[1] * $mn; //by id $height = $this->hour_height; if ($time_temp && $duration_temp && $this->matchTime($time_temp, $duration_temp, $exp[1], $r['duration'])) $cc+=$this->box_width; else $cc = 0; $maxcc+=$this->box_width; $boxes_defs[] = array( 'box_position' => $cc, 'box_height' => $height, 'box_time' => $exp[1], 'box_id' => $r['id'], 'box_duration' => $r['duration'], ); if ($r['status'] == "Held" || $r['status'] == "Not Held") $activityClass = "activityBoxHeld"; elseif (date("Y-m-d H:i:s") > $r['date']) $activityClass = "activityBoxExpired"; else $activityClass = "activityBox"; if ($r['status'] == "Held" || $r['status'] == "Not Held") { $linkClass = "boxLink"; $linkClassName = "boxLinkNameHeld"; $hourClass = ""; } elseif (date("Y-m-d H:i:s") > $r['date']) { $linkClass = "boxLink"; $linkClassName = "boxLinkExpired"; $hourClass = ""; } else { $linkClass = "boxLink"; $linkClassName = "boxLink"; $hourClass = ""; } $u = new User(); $u->retrieve($r['user_id']); $user = $u->first_name . PHP_EOL . $u->last_name; unset($u); $html.='
'; $html.='
'; $html.='
 ' . substr($exp[1], 0, 5) . '
'; $html.=''; $html.='
'; if (strlen($r['name']) > 24) $name = mb_substr($r['name'], 0, 23, "UTF-8") . " ..."; else $name = $r['name']; //$html.='
'; $html.='
' . $r['name'] . '
'; //$html.='
'; if ($r['account_name'] && $r['account_id']) { if (strlen($r['account_name']) > 24) $account_name = mb_substr($r['account_name'], 0, 23, "UTF-8") . " ..."; else $account_name = $r['account_name']; //$html.='
'; $html.='
' . $account_name . '
'; //$html.='
'; } for ($i = 0; $i < count($r['contact_id']); $i++) { if ($r['contact_id'][$i] && $r['contact_name'][$i]) { if (strlen($r['contact_name']) > 24) $contact_name = mb_substr($r['contact_name'][$i], 0, 23, "UTF-8") . " ..."; else $contact_name = $r['contact_name'][$i]; //$html.='
'; $html.='
' . $contact_name . '

'; //$html.='
'; } } $html.='
'; $html.=''; //$html.=''; $time_temp = $exp[1]; $duration_temp = $r['duration']; } $pos = 0; $i = 0; $row = 0; $maxhour = $this->hour_height; foreach ($arr as $r) { $exp = explode(" ", $r['date']); $hour = explode(":", $exp[1]); if ($temp_hour == (int) $hour[0] && $i < 3) { $pos+=$this->box_width; $i++; } elseif ($temp_hour == (int) $hour[0] && $i >= 3) { $pos = 0; $i = 0; $row++; $bd_hours[(int) $hour[0]] = ($row + 1) * $this->hour_height; } else { $pos = 0; $i = 0; $row = 0; $maxhour = $this->hour_height; } $b[(int) $hour[0]][] = array("id" => $r['id'], "time" => $exp[1], "pos" => $pos, "i" => $i, "row" => $row); $temp_hour = (int) $hour[0]; $temp_pos = $pos; $temp_id = $r['id']; $temp_row = $row; } //print_r($b); if (count($bd_hours) > 0) { foreach ($bd_hours as $key => $value) { $html.=''; } } if (count($b) > 0) { foreach ($b as $bdd) { foreach ($bdd as $bd) { $hour = explode(":", $bd['time']); $y = $this->hour_height * $bd['row']; $html.=''; } } } } return $html; } function showActivities($month, $year, $day, $table, $module, $date_field) { $arr = $this->getActivities($month, $year, $day, $table, $module, $date_field); if (count($arr) > 0) { $html = ''; foreach ($arr as $r) { if ($r['status'] == "Held" || $r['status'] == "Not Held") { $linkClass = "dashletLink"; $linkClassName = "dashletLinkNameHeld"; $hourClass = ""; } elseif (date("Y-m-d H:i:s") > $r['date']) { $linkClass = "dashletLink"; $linkClassName = "dashletLinkExpired"; $hourClass = ""; } else { $linkClass = "dashletLink"; $linkClassName = "dashletLink"; $hourClass = ""; } $exp = explode(" ", $r['date']); $u = new User(); $u->retrieve($r['user_id']); $user = $u->first_name . PHP_EOL . $u->last_name; unset($u); $html.='
'; $html.='
 ' . substr($exp[1], 0, 5) . '
'; $html.=''; $html.=''; $html.='
'; if ($r['account_name'] && $r['account_id']) { $html.='
'; $html.='
'; $html.=''; $html.='
'; } for ($i = 0; $i <= 0; $i++) { if ($r['contact_id'][$i] && $r['contact_name'][$i]) { $html.='
'; $html.='
'; $html.='
'; $html.='
'; } } } } $html = str_replace("<", "<", $html); $html = str_replace(">", ">", $html); $html = str_replace("'", "´", $html); $html = str_replace('"', """, $html); $html = str_replace("\n", "", $html); return $html; } function getDaysWeek($month, $year, $day) { $no = $this->noDayInWeek($month, $year, $day); for ($i = 0; $i < $no; $i++) { $days[$i] = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year) - ($no - $i) * 24 * 3600); } $days[$no] = $year . "-" . $month . "-" . $day; for ($i = 0; $i < 7 - $no; $i++) { $days[$i + $no] = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year) + $i * 24 * 3600); } return $days; } function getActivities($month, $year, $day, $table, $module, $date_field, $status = "") { if ($month < 10 && strlen($month) < 2) $month = "0" . $month; global $timedate, $current_user; if ($this->act_status == "All" || !$this->act_status) $status = ""; else $status = " and " . $table . ".status='" . $this->act_status . "'"; if ($this->act_user == "All" || !$this->act_user) $assigned_user = ""; else $assigned_user = " and " . $table . ".assigned_user_id='" . $this->act_user . "'"; $q = "select " . $table . ".*,users.user_name as user,users.id as user_id from " . $table . " inner join users on users.id=" . $table . ".assigned_user_id where " . $table . ".deleted='0' and " . $table . "." . $date_field . " like '" . $year . "-" . $month . "-" . $day . "%'" . $status . $assigned_user . " order by " . $table . "." . $date_field . " asc"; //print $q; $query = $GLOBALS['db']->query($q); while ($row = $GLOBALS['db']->fetchByAssoc($query)) { $exp = explode(" ", $row[$date_field]); $expp = explode(":", $exp[1]); $expd = explode("-", $exp[0]); if ((int) $expp[0] > 3) { $r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from accounts where id='" . $row['parent_id'] . "'")); $account_name = $r['name']; if ($table != "tasks") { $w = $GLOBALS['db']->query("select contacts.first_name as first_name,contacts.last_name as last_name,contacts.id as id from " . $table . "_contacts inner join contacts on contacts.id=" . $table . "_contacts.contact_id where " . $table . "_contacts.deleted='0' and " . substr($table, 0, strlen($table) - 1) . "_id='" . $row['id'] . "' and contacts.deleted='0'"); $contact_name = array(); $contact_id = array(); while ($r = $GLOBALS['db']->fetchByAssoc($w)) { $contact_name[] = $r['first_name'] . " " . $r['last_name']; $contact_id[] = $r['id']; } } $duration = ($row['duration_hours'] * 60 + $row['duration_minutes']) * 60; $ddate = date("Y-m-d H:i:s", mktime($expp[0], $expp[1], $expp[2], $expd[1], $expd[2], $expd[0])); $arr[] = array( "id" => $row['id'], "name" => $row['name'], "date" => $timedate->handle_offset($ddate, "Y-m-d H:i:s", true, $current_user), "module" => $module, "user" => $row['user'], "user_id" => $row['user_id'], "duration" => $duration, "account_id" => $row['parent_id'], "account_name" => $account_name, "contact_id" => $contact_id, "contact_name" => $contact_name, "status" => $row['status'], ); } } return $arr; } } ?>