Example #1
0
 public function execute()
 {
     $this->td_served = gfPostVar('td_served', array());
     $_SESSION['td_served'] = $this->td_served;
     if (!$this->td_served && !isset($_POST['pause'])) {
         $this->message = "Errore: selezionare almeno un'area tematica.";
         return true;
     }
     // Handle served ticket
     $served = Ticket::fromDatabaseByDesk($this->getDesk()->getNumber());
     if ($served) {
         $stats = TicketStats::newFromTicket($served);
         $served->delete();
         if (!$stats->save()) {
             throw new Exception("Unable to save ticket stats.");
         }
     }
     // Handle pause button
     if (isset($_POST['pause'])) {
         $this->pauseButtonEnabled = false;
         $this->ticket_served = null;
         return true;
     }
     // Call next ticket
     $ticket = Ticket::serveNextTicket($this->td_served, $this->getOperator()->getCode(), $this->getDesk()->getNumber());
     if (!$ticket) {
         $this->message = "Nessun ticket da chiamare";
         $this->pauseButtonEnabled = false;
         $this->ticket_served = null;
         return true;
     }
     $ticket->save();
     $this->ticket_served = $ticket;
     $this->disableNextButton = true;
     $this->pauseButtonEnabled = true;
     return true;
 }
Example #2
0
    public function getSourceStatsTable()
    {
        $counters = array();
        $totalCount = 0;
        foreach (array('app', 'totem', 'web') as $source) {
            $tickets = TicketStats::fromDatabaseListBySource($source, $this->dateFrom, $this->dateTo);
            $counters[$source] = array("count" => count($tickets));
            $totalCount += $counters[$source]['count'];
        }
        $rows = '';
        foreach ($counters as $source => $value) {
            if ($totalCount != 0) {
                $percentage = (int) ($value['count'] / $totalCount * 100);
            } else {
                $percentage = 0;
            }
            $counters[$source]['percentage'] = $percentage;
        }
        $table = <<<EOS
<table id="listTable">
<caption>Statistiche per sorgente</caption>
    <tr>
        <th />
        <th>App</th>
        <th>Totem</th>
        <th>Web</th>
    </tr>
    <tr>
        <th>Conteggio</th>
        <td>{$counters['app']['count']}</td>
        <td>{$counters['totem']['count']}</td>
        <td>{$counters['web']['count']}</td>
    </tr>
    <tr>
        <th>Percentuale</th>
        <td>{$counters['app']['percentage']} %</td>
        <td>{$counters['totem']['percentage']} %</td>
        <td>{$counters['web']['percentage']} %</td>
    </tr>
</table>
<canvas id="sourceChart" width="150" height="150"></canvas>
<script>
    var data = [
        {
            value: {$counters['app']['count']},
            label: "App",
            color:"#F7464A",
            highlight: "#FF5A5E"
        },
        {
            value: {$counters['totem']['count']},
            label: "Totem",
            color: "#46BFBD",
            highlight: "#5AD3D1"
        },
        {
            value: {$counters['web']['count']},
            label: "Web",
            color: "#FDB45C",
            highlight: "#FFC870",
        },
    ];
    var ctx = document.getElementById("sourceChart").getContext("2d");
    var myPieChart = new Chart(ctx).Pie(data);
</script>
EOS;
        return $table;
    }
Example #3
0
 public static function clearTableForLogout($op_code, $desk = null, $ticket = null)
 {
     if (!$desk) {
         // Load desk
         $desk = Desk::fromDatabaseByOperator($op_code);
     }
     if (!$ticket) {
         // Load ticket
         $ticket = Ticket::fromDatabaseByOperator($op_code);
     }
     if ($desk) {
         $desk->setLastActivityTime(null);
         $desk->setOpCode(null);
         $desk->save();
     }
     if ($ticket) {
         $stats = TicketStats::newFromTicket($ticket);
         $ticket->delete();
         $stats->save();
     }
 }
Example #4
0
 public function getTicketStats()
 {
     return TicketStats::newFromTicket($this);
 }