} } else { hesk_error($hesklang['ede']); } // Make sure the file can be saved and written to @file_put_contents($save_to, ''); if (!file_exists($save_to)) { hesk_error($hesklang['eef']); } // Start generating the report message and generating the export $flush_me = '<br /><br />'; $flush_me .= hesk_date() . " | {$hesklang['inite']} "; if ($date_from == $date_to) { $flush_me .= "(" . hesk_dateToString($date_from, 0) . ")<br />\n"; } else { $flush_me .= "(" . hesk_dateToString($date_from, 0) . " - " . hesk_dateToString($date_to, 0) . ")<br />\n"; } // Start generating file contents $tmp = '<?xml version="1.0" encoding="UTF-8"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <AllowPNG/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>8250</WindowHeight> <WindowWidth>16275</WindowWidth>
function mail_list_messages() { global $hesk_settings, $hesklang, $admins; $href = 'mail.php'; $query = ''; if ($hesk_settings['mailtmp']['folder'] == 'outbox') { $query .= 'folder=outbox&'; } $query .= 'page='; $maxresults = 30; $tmp = intval(hesk_POST('page', 1)); $page = $tmp > 1 ? $tmp : 1; /* List of private messages */ $res = hesk_dbQuery("SELECT COUNT(*) FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mail` WHERE `" . hesk_dbEscape($hesk_settings['mailtmp']['this']) . "`='" . intval($_SESSION['id']) . "' AND `deletedby`!='" . intval($_SESSION['id']) . "'"); $total = hesk_dbResult($res, 0, 0); if ($total > 0) { $pages = ceil($total / $maxresults) or $pages = 1; if ($page > $pages) { $page = $pages; } $limit_down = $page * $maxresults - $maxresults; $prev_page = $page - 1 <= 0 ? 0 : $page - 1; $next_page = $page + 1 > $pages ? 0 : $page + 1; if ($pages > 1) { echo $hesklang['pg'] . ': '; /* List pages */ if ($pages >= 7) { if ($page > 2) { echo '<a href="' . $href . '?' . $query . '1"><b>«</b></a> '; } if ($prev_page) { echo '<a href="' . $href . '?' . $query . $prev_page . '"><b>‹</b></a> '; } } for ($i = 1; $i <= $pages; $i++) { if ($i <= $page + 5 && $i >= $page - 5) { if ($i == $page) { echo ' <b>' . $i . '</b> '; } else { echo ' <a href="' . $href . '?' . $query . $i . '">' . $i . '</a> '; } } } if ($pages >= 7) { if ($next_page) { echo ' <a href="' . $href . '?' . $query . $next_page . '"><b>›</b></a> '; } if ($page < $pages - 1) { echo ' <a href="' . $href . '?' . $query . $pages . '"><b>»</b></a>'; } } echo '<br /> '; } // end PAGES > 1 // Get messages from the database $res = hesk_dbQuery("SELECT `id`, `from`, `to`, `subject`, `dt`, `read` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "mail` WHERE `" . hesk_dbEscape($hesk_settings['mailtmp']['this']) . "`='" . intval($_SESSION['id']) . "' AND `deletedby`!='" . intval($_SESSION['id']) . "' ORDER BY `id` DESC LIMIT " . intval($limit_down) . " , " . intval($maxresults) . " "); ?> <form action="mail.php<?php if ($hesk_settings['mailtmp']['folder'] == 'outbox') { echo '?folder=outbox'; } ?> " name="form1" method="post"> <div class="container table-responsive"> <table class="table table-bordered table-hover" style="background: #E0EEEE;"> <tr> <th class="admin_white" style="width:1px"><input type="checkbox" name="checkall" value="2" onclick="hesk_changeAll(this)" /></th> <th class="admin_white" style="text-align:left; white-space:nowrap;"><?php echo $hesklang['m_sub']; ?> </th> <th class="admin_white" style="text-align:left; white-space:nowrap;"><?php echo $hesk_settings['mailtmp']['m_from']; ?> </th> <th class="admin_white" style="text-align:left; white-space:nowrap;"><?php echo $hesklang['date']; ?> </th> </tr> <?php $i = 0; while ($pm = hesk_dbFetchAssoc($res)) { if ($i) { $color = "admin_gray"; $i = 0; } else { $color = "admin_white"; $i = 1; } $pm['subject'] = '<a href="mail.php?a=read&id=' . $pm['id'] . '">' . $pm['subject'] . '</a>'; if ($hesk_settings['mailtmp']['this'] == 'to' && !$pm['read']) { $pm['subject'] = '<b>' . $pm['subject'] . '</b>'; } $pm['name'] = isset($admins[$pm[$hesk_settings['mailtmp']['other']]]) ? '<a href="mail.php?a=new&id=' . $pm[$hesk_settings['mailtmp']['other']] . '">' . $admins[$pm[$hesk_settings['mailtmp']['other']]] . '</a>' : ($pm['from'] == 9999 ? '<a href="http://www.hesk.com" target="_blank">HESK.com</a>' : $hesklang['e_udel']); $pm['dt'] = hesk_dateToString($pm['dt'], 0, 0, 0, true); echo <<<EOC \t\t\t\t\t<tr> \t\t\t\t\t<td class="{$color}" style="text-align:left; white-space:nowrap;"><input type="checkbox" name="id[]" value="{$pm['id']}" /> </td> \t\t\t\t\t<td class="{$color}">{$pm['subject']}</td> \t\t\t\t\t<td class="{$color}">{$pm['name']}</td> \t\t\t\t\t<td class="{$color}">{$pm['dt']}</td> \t\t\t\t\t</tr> EOC; } // End while ?> </table><!-- end table table-bordered table-hover table-responsive --> </div> <div class="container" align="right"><select name="a"> <?php if ($hesk_settings['mailtmp']['this'] == 'to') { ?> <option value="mark_read" selected="selected"><?php echo $hesklang['mo1']; ?> </option> <option value="mark_unread"><?php echo $hesklang['mo2']; ?> </option> <?php } ?> <option value="delete"><?php echo $hesklang['mo3']; ?> </option> </select> <input type="hidden" name="token" value="<?php hesk_token_echo(); ?> " /> <input type="submit" value="<?php echo $hesklang['execute']; ?> " onclick="Javascript:if (document.form1.a.value=='delete') return hesk_confirmExecute('<?php echo hesk_makeJsString($hesklang['mo3']); ?> ?');" class="btn btn-default" /> </form> <br/><br/> </div> <?php } else { echo '<div class="container"><i>' . $hesklang['npm'] . '</i></div><br/>'; } }
} else { $ticket['repliername'] = $ticket['name']; } echo '<td class="' . $color . '">' . $ticket['repliername'] . '</td>'; } // Print time worked if (hesk_show_column('time_worked')) { echo '<td class="' . $color . '">' . $ticket['time_worked'] . '</td>'; } // Print custom fields foreach ($hesk_settings['custom_fields'] as $key => $value) { if ($value['use'] && hesk_show_column($key)) { echo '<td class="' . $color . '">'; if ($value['type'] == 'date' && !empty($ticket[$key])) { $dt = date('Y-m-d h:i:s', $ticket[$key]); echo hesk_dateToString($dt, 0); } else { echo $ticket[$key]; } echo '</td>'; } } // End ticket row echo ' <td class="' . $color . '" style="text-align:center; white-space:nowrap;">' . $ticket['priority'] . ' </td> </tr>'; } // End while ?> </table> </div>
function hesk_ticketsByDay() { global $hesk_settings, $hesklang, $date_from, $date_to, $can_run_reports_full; $tickets = array(); $totals = array('all' => 0, 'resolved' => 0, 'worked' => 0); $dt = DateArray($date_from, $date_to); // Pre-populate date values foreach ($dt as $day) { $tickets[$day] = array('all' => 0, 'resolved' => 0, 'worked' => ''); } // SQL query for all $res = hesk_dbQuery("SELECT DATE(`dt`) AS `mydt`, COUNT(*) AS `cnt`" . ($hesk_settings['time_worked'] ? ", SUM( TIME_TO_SEC(`time_worked`) ) AS `seconds_worked`" : '') . " FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE " . ($can_run_reports_full ? '1' : "`owner` = '" . intval($_SESSION['id']) . "'") . " AND {$hesk_settings['dt_sql']} GROUP BY `mydt`"); // Update ticket values while ($row = hesk_dbFetchAssoc($res)) { if (!$hesk_settings['time_worked']) { $row['seconds_worked'] = 0; } $tickets[$row['mydt']]['all'] += $row['cnt']; $tickets[$row['mydt']]['worked'] = $hesk_settings['time_worked'] ? hesk_SecondsToHHMMSS($row['seconds_worked']) : 0; $totals['all'] += $row['cnt']; $totals['worked'] += $row['seconds_worked']; } // SQL query for resolved $res = hesk_dbQuery("SELECT DATE(`dt`) AS `mydt`, COUNT(*) AS `cnt` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE " . ($can_run_reports_full ? '1' : "`owner` = '" . intval($_SESSION['id']) . "'") . " AND `status`='3' AND {$hesk_settings['dt_sql']} GROUP BY `mydt`"); // Update ticket values while ($row = hesk_dbFetchAssoc($res)) { $tickets[$row['mydt']]['resolved'] += $row['cnt']; $totals['resolved'] += $row['cnt']; } // Convert total seconds worked to HH:MM:SS $totals['worked'] = $hesk_settings['time_worked'] ? hesk_SecondsToHHMMSS($totals['worked']) : 0; ?> <table width="100%" cellpadding="5" style="text-align:justify;border-collapse:collapse;padding:10px;"> <tr style="border-bottom:1px solid #000000;"> <td><?php echo $hesklang['date']; ?> </td> <td><?php echo $hesklang['atik']; ?> </td> <td><?php echo $hesklang['topen']; ?> </td> <td><?php echo $hesklang['closed']; ?> </td> <?php if ($hesk_settings['time_worked']) { echo '<td>' . $hesklang['ts'] . '</td>'; } ?> </tr> <?php $num_tickets = count($tickets); if ($num_tickets > 10) { ?> <tr style="border-bottom:1px solid #000000;"> <td><b><?php echo $hesklang['totals']; ?> </b></td> <td><b><?php echo $totals['all']; ?> </b></td> <td><b><?php echo $totals['all'] - $totals['resolved']; ?> </b></td> <td><b><?php echo $totals['resolved']; ?> </b></td> <?php if ($hesk_settings['time_worked']) { echo '<td><b>' . $totals['worked'] . '</b></td>'; } ?> </tr> <?php } $cls = ''; foreach ($tickets as $k => $d) { $cls = $cls ? '' : 'style="background:#EEEEE8;"'; ?> <tr <?php echo $cls; ?> > <td><?php echo hesk_dateToString($k); ?> </td> <td><?php echo $d['all']; ?> </td> <td><?php echo $d['all'] - $d['resolved']; ?> </td> <td><?php echo $d['resolved']; ?> </td> <?php if ($hesk_settings['time_worked']) { echo '<td>' . $d['worked'] . '</td>'; } ?> </tr> <?php } ?> <tr style="border-top:1px solid #000000;"> <td><b><?php echo $hesklang['totals']; ?> </b></td> <td><b><?php echo $totals['all']; ?> </b></td> <td><b><?php echo $totals['all'] - $totals['resolved']; ?> </b></td> <td><b><?php echo $totals['resolved']; ?> </b></td> <?php if ($hesk_settings['time_worked']) { echo '<td><b>' . $totals['worked'] . '</b></td>'; } ?> </tr> </table> <p> </p> <?php }
function hesk_ticketsByDay() { global $hesk_settings, $hesklang, $date_from, $date_to, $can_run_reports_full; $tickets = array(); $totals = array('all' => 0, 'resolved' => 0, 'worked' => 0); $dt = DateArray($date_from, $date_to); // Pre-populate date values foreach ($dt as $day) { $tickets[$day] = array('all' => 0, 'resolved' => 0, 'worked' => ''); } // SQL query for all $res = hesk_dbQuery("SELECT DATE(`dt`) AS `mydt`, COUNT(*) AS `cnt`" . ($hesk_settings['time_worked'] ? ", SUM( TIME_TO_SEC(`time_worked`) ) AS `seconds_worked`" : '') . " FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE " . ($can_run_reports_full ? '1' : "`owner` = '" . intval($_SESSION['id']) . "'") . " AND {$hesk_settings['dt_sql']} GROUP BY `mydt`"); // Update ticket values while ($row = hesk_dbFetchAssoc($res)) { if (!$hesk_settings['time_worked']) { $row['seconds_worked'] = 0; } $tickets[$row['mydt']]['all'] += $row['cnt']; $tickets[$row['mydt']]['worked'] = $hesk_settings['time_worked'] ? hesk_SecondsToHHMMSS($row['seconds_worked']) : 0; $totals['all'] += $row['cnt']; $totals['worked'] += $row['seconds_worked']; } // SQL query for resolved $res = hesk_dbQuery("SELECT DATE(`dt`) AS `mydt`, COUNT(*) AS `cnt` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE " . ($can_run_reports_full ? '1' : "`owner` = '" . intval($_SESSION['id']) . "'") . " AND `status` IN (SELECT `ID` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` WHERE `IsClosed` = 1) AND {$hesk_settings['dt_sql']} GROUP BY `mydt`"); // Update ticket values while ($row = hesk_dbFetchAssoc($res)) { $tickets[$row['mydt']]['resolved'] += $row['cnt']; $totals['resolved'] += $row['cnt']; } // Convert total seconds worked to HH:MM:SS $totals['worked'] = $hesk_settings['time_worked'] ? hesk_SecondsToHHMMSS($totals['worked']) : 0; ?> <table class="table table-striped table-condensed"> <tr> <th><?php echo $hesklang['date']; ?> </th> <th><?php echo $hesklang['atik']; ?> </th> <th><?php echo $hesklang['topen']; ?> </th> <th><?php echo $hesklang['closed_title']; ?> </th> <?php if ($hesk_settings['time_worked']) { echo '<th>' . $hesklang['ts'] . '</th>'; } ?> </tr> <?php $num_tickets = count($tickets); if ($num_tickets > 10) { ?> <tr> <td><b><?php echo $hesklang['totals']; ?> </b></td> <td><b><?php echo $totals['all']; ?> </b></td> <td><b><?php echo $totals['all'] - $totals['resolved']; ?> </b></td> <td><b><?php echo $totals['resolved']; ?> </b></td> <?php if ($hesk_settings['time_worked']) { echo '<td><b>' . $totals['worked'] . '</b></td>'; } ?> </tr> <?php } foreach ($tickets as $k => $d) { ?> <tr> <td><?php echo hesk_dateToString($k); ?> </td> <td><?php echo $d['all']; ?> </td> <td><?php echo $d['all'] - $d['resolved']; ?> </td> <td><?php echo $d['resolved']; ?> </td> <?php if ($hesk_settings['time_worked']) { echo '<td>' . $d['worked'] . '</td>'; } ?> </tr> <?php } ?> <tr> <td><b><?php echo $hesklang['totals']; ?> </b></td> <td><b><?php echo $totals['all']; ?> </b></td> <td><b><?php echo $totals['all'] - $totals['resolved']; ?> </b></td> <td><b><?php echo $totals['resolved']; ?> </b></td> <?php if ($hesk_settings['time_worked']) { echo '<td><b>' . $totals['worked'] . '</b></td>'; } ?> </tr> </table> <?php }