/** * Returns data for jq fullcalendar widget with all tasks * * @global object $ubillingConfig * @return string */ function ts_JGetAllTasks() { global $ubillingConfig; $altCfg = $ubillingConfig->getAlter(); //ADcomments init if ($altCfg['ADCOMMENTS_ENABLED']) { $adcomments = new ADcomments('TASKMAN'); $adcFlag = true; } else { $adcFlag = false; } $allemployee = ts_GetAllEmployee(); $alljobdata = ts_GetAllJobtypesData(); $curyear = curyear(); $curmonth = date("m"); //per employee filtering $displaytype = isset($_POST['displaytype']) ? $_POST['displaytype'] : 'all'; if ($displaytype == 'onlyme') { $whoami = whoami(); $curempid = ts_GetEmployeeByLogin($whoami); $appendQuery = " AND `employee`='" . $curempid . "'"; } else { $appendQuery = ''; } if ($curmonth != 1 and $curmonth != 12) { $query = "SELECT * from `taskman` WHERE `startdate` LIKE '" . $curyear . "-%' " . $appendQuery . " ORDER BY `date` ASC"; } else { if ($appendQuery) { $appendQuery = str_replace('AND', 'WHERE', $appendQuery); } $query = "SELECT * from `taskman` " . $appendQuery . " ORDER BY `date` ASC"; } $allundone = simple_queryall($query); $result = ''; $i = 1; $taskcount = sizeof($allundone); if (!empty($allundone)) { foreach ($allundone as $io => $eachtask) { if ($i != $taskcount) { $thelast = ','; } else { $thelast = ''; } $startdate = strtotime($eachtask['startdate']); $startdate = date("Y, n-1, j", $startdate); //time ordering if (!empty($eachtask['starttime'])) { $startTime = $eachtask['starttime']; $startTime = substr($startTime, 0, 5) . ' '; $startTimeTimestamp = ', ' . str_replace(':', ', ', $startTime); } else { $startTime = ''; $startTimeTimestamp = ''; } if ($eachtask['enddate'] != '') { $enddate = strtotime($eachtask['enddate']); $enddate = date("Y, n-1, j", $enddate); } else { $enddate = $startdate; } if ($eachtask['status'] == 0) { $coloring = "className : 'undone',"; if (isset($alljobdata[$eachtask['jobtype']])) { if (!empty($alljobdata[$eachtask['jobtype']]['jobcolor'])) { $coloring = "className : 'jobcolorcustom_" . $eachtask['jobtype'] . "',"; } else { $coloring = "className : 'undone',"; } } else { $jobColorClass = "className : 'undone',"; } } else { $coloring = ''; } //adcomments detect if ($adcFlag) { $adcommentsCount = $adcomments->getCommentsCount($eachtask['id']); } else { $adcommentsCount = 0; } if ($adcommentsCount > 0) { $adcText = ' (' . $adcommentsCount . ')'; } else { $adcText = ''; } $result .= "\n {\n title: '" . $startTime . $eachtask['address'] . " - " . @$alljobdata[$eachtask['jobtype']]['jobname'] . $adcText . "',\n start: new Date(" . $startdate . $startTimeTimestamp . "),\n end: new Date(" . $enddate . "),\n " . $coloring . "\n url: '?module=taskman&edittask=" . $eachtask['id'] . "'\n\t\t }\n " . $thelast; } } return $result; }