Exemplo n.º 1
0
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>&nbsp;</p>
    <?php 
}
Exemplo n.º 2
0
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 
}