<th><?php 
echo gettext("active");
?>
</th>
    			<th><?php 
echo gettext("ready");
?>
</th>
    		</tr>
		</thead>
		<tbody>
<?php 
$voucherlck = lock("vouche{$cpzone}r");
$i = 0;
foreach ($a_roll as $rollent) {
    $used = voucher_used_count($rollent['number']);
    $active = count(voucher_read_active_db($rollent['number']), $rollent['minutes']);
    $ready = $rollent['count'] - $used;
    /* used also count active vouchers, remove them */
    $used = $used - $active;
    ?>
    		<tr>
    			<td>
    				<?php 
    echo htmlspecialchars($rollent['number']);
    ?>
    			</td>
    			<td>
    				<?php 
    echo htmlspecialchars($rollent['minutes']);
    ?>
Esempio n. 2
0
/**
 * parses a roll to json
 * @param Array $roll The roll info as it arrives from the pfSense persistence
 */
function to_json($roll)
{
    $format = '{"number": "%s", "minutes": "%s", "comment": "%s", "count": "%s"';
    $data = sprintf($format, $roll["number"], $roll["minutes"], $roll["comment"], $roll["count"]);
    #print_r($roll);
    if (isset($roll["active"]) && sizeof($roll["active"]) && is_array($roll["active"])) {
        $acts = $roll["active"];
        $data .= ', "active": {';
        foreach ($acts as $key => $vo) {
            $data .= sprintf('"%s": ', $key);
            $data .= sprintf('{"voucher": "%s", "timestamp": "%s"},', $vo["voucher"], $vo["timestamp"]);
        }
        $data = str_replace("},", "}}", $data);
    }
    $data .= sprintf(', "used": "%s"', voucher_used_count($roll["number"]));
    $vouchers = retrieve_vouchers($roll["number"], $roll["count"]);
    $tdata = "";
    foreach ($vouchers as $voucher) {
        $tdata .= sprintf('"%s", ', $voucher);
    }
    //print_r($vouchers);
    if (sizeof($vouchers) > 0) {
        $tdata = preg_replace("/,\\s\$/", "", $tdata);
        $data .= ', "vouchers": [' . $tdata . "]";
    }
    $data .= "}";
    retrieve_vouchers($roll["number"], $roll["count"]);
    return $data;
}