function ts_EmployeeMonthGraphs() { $curmonth = curmonth(); $employees = ts_GetAllEmployee(); $month_jobs_q = "SELECT `workerid`,`jobid` from `jobs` WHERE `date` LIKE '" . $curmonth . "%'"; $alljobs = simple_queryall($month_jobs_q); $jobtypes = ts_GetAllJobtypes(); $jobdata = array(); $result = ''; if (!empty($employees)) { if (!empty($alljobs)) { foreach ($alljobs as $io => $eachjob) { if (isset($jobdata[$eachjob['workerid']][$eachjob['jobid']])) { $jobdata[$eachjob['workerid']][$eachjob['jobid']]++; } else { $jobdata[$eachjob['workerid']][$eachjob['jobid']] = 1; } } } //build graphs for each employee if (!empty($jobdata)) { foreach ($jobdata as $employee => $each) { $employeeName = isset($employees[$employee]) ? $employees[$employee] : __('Deleted'); $result .= wf_tag('h3', false) . $employeeName . wf_tag('h3', true); $rows = ''; if (!empty($each)) { foreach ($each as $jobid => $count) { $cells = wf_TableCell(@$jobtypes[$jobid], '40%'); $cells .= wf_TableCell($count, '20%'); $cells .= wf_TableCell(web_bar($count, sizeof($alljobs)), '40%'); $rows .= wf_TableRow($cells, 'row3'); } } $result .= wf_TableBody($rows, '100%', 0); $result .= wf_delimiter(); } } } return $result; }
/** * Returns list of expired undone tasks * * @return string */ function ts_ShowLate() { $allemployee = ts_GetAllEmployee(); $alljobtypes = ts_GetAllJobtypes(); $curyear = curyear(); $curmonth = date("m"); $curdate = curdate(); if ($curmonth != 1 and $curmonth != 12) { $query = "SELECT * from `taskman` WHERE `status`='0' AND `startdate` LIKE '" . $curyear . "-%' AND `startdate`< '" . $curdate . "' ORDER BY `startdate` ASC"; } else { $query = "SELECT * from `taskman` WHERE `status`='0' AND `startdate`< '" . $curdate . "' ORDER BY `startdate` ASC"; } $cells = wf_TableCell(__('Target date')); $cells .= wf_TableCell(__('Task address')); $cells .= wf_TableCell(__('Phone')); $cells .= wf_TableCell(__('Job type')); $cells .= wf_TableCell(__('Who should do')); $cells .= wf_TableCell(__('Actions')); $rows = wf_TableRow($cells, 'row1'); $all = simple_queryall($query); if (!empty($all)) { foreach ($all as $io => $each) { $cells = wf_TableCell($each['startdate']); $cells .= wf_TableCell($each['address']); $cells .= wf_TableCell($each['phone']); $cells .= wf_TableCell(@$alljobtypes[$each['jobtype']]); $cells .= wf_TableCell(@$allemployee[$each['employee']]); $actions = wf_Link('?module=taskman&edittask=' . $each['id'], web_edit_icon(), false, ''); $cells .= wf_TableCell($actions); $rows .= wf_TableRow($cells, 'row3'); } } $result = wf_TableBody($rows, '100%', '0', 'sortable'); return $result; }
/** * Loads all existing employees from database * * @return void */ protected function loadAllEmployee() { $this->allEmployee = ts_GetAllEmployee(); }
/** * Performs switch replacement in database * * @param int $fromId * @param int $toId * @param int $employeeid * * @return void */ function zb_SwitchReplace($fromId, $toId, $employeeId) { $fromId = vf($fromId, 3); $toId = vf($toId, 3); $employeeId = vf($employeeId, 3); $allEmployees = ts_GetAllEmployee(); $fromData = zb_SwitchGetData($fromId); $toData = zb_SwitchGetData($toId); if (!empty($fromData)) { //copy geo coordinates to new switch simple_update_field('switches', 'geo', $fromData['geo'], "WHERE `id`='" . $toId . "'"); //setting new description and remove NP flag $newDescriptionTo = str_replace('NP', 'm:' . @$allEmployees[$employeeId], $toData['desc']); simple_update_field('switches', 'desc', $newDescriptionTo, "WHERE `id`='" . $toId . "'"); //copy location simple_update_field('switches', 'location', $fromData['location'], "WHERE `id`='" . $toId . "'"); //copy switch parent ID if (!empty($fromData['parentid'])) { simple_update_field('switches', 'parentid', $fromData['parentid'], "WHERE `id`='" . $toId . "'"); } else { $parentId_q = "UPDATE `switches` SET `parentid`=NULL WHERE `id`='" . $toId . "';"; nr_query($parentId_q); } //moving childs if it present simple_update_field('switches', 'parentid', $toId, "WHERE `parentid`='" . $fromId . "'"); // doing old switch cleanup and disabling it simple_update_field('switches', 'geo', '', "WHERE `id`='" . $fromId . "'"); $newFromLocation = __('removed from') . ': ' . $fromData['location']; simple_update_field('switches', 'location', $newFromLocation, "WHERE `id`='" . $fromId . "'"); $newFromDesc = 'NP u:' . @$allEmployees[$employeeId]; simple_update_field('switches', 'desc', $newFromDesc, "WHERE `id`='" . $fromId . "'"); $parentIdFrom_q = "UPDATE `switches` SET `parentid`=NULL WHERE `id`='" . $fromId . "';"; nr_query($parentIdFrom_q); log_register("SWITCH REPLACE FROM [" . $fromId . "] TO [" . $toId . "] EMPLOYEE [" . $employeeId . "]"); } else { show_error(__('Strange exeption') . ': FROM_SWITCH_EMPTY_DATA'); } }
/** * Loads all of employees from database * * @return void */ protected function loadEmployeeRaw() { $this->allEmployeeRaw = ts_GetAllEmployee(); }