Example #1
0
    foreach ($accounts as $account) {
        echo "<br /><b>Total for {$account}</b>";
        $totalR = $dbc->exec_statement($totalQ, array($account, $span[0], $span[1]));
        $data = array();
        while ($totalW = $dbc->fetch_row($totalR)) {
            if (empty($data["{$totalW['0']}"])) {
                $data["{$totalW['0']}"] = array($totalW[1], $account, $totalW[2]);
            } else {
                $data["{$totalW['0']}"][0] += $totalW[1];
                $data["{$totalW['0']}"][2] += $totalW[2];
            }
        }
        echo tablify($data, array(0, 1, 2, 3), array("pCode", "Retail", "Account", "Wholesale"), array($ALIGN_LEFT, $ALIGN_RIGHT | $TYPE_MONEY, $ALIGN_CENTER, $ALIGN_RIGHT | $TYPE_MONEY), 2, array(1, 3));
    }
    $output = ob_get_contents();
    \COREPOS\Fannie\API\data\DataCache::putFile('monthly', $output);
    ob_end_clean();
}
echo $output;
function tablify($data, $col_order, $col_headers, $formatting, $sums = -1, $sum_cols = array())
{
    $sum = 0;
    $ret = "";
    $ret .= "<table cellspacing=0 cellpadding=4 border=1><tr>";
    $i = 0;
    foreach ($col_headers as $c) {
        while ($formatting[$i] == 0) {
            $i++;
        }
        $ret .= cellify("<u>" . $c . "</u>", $formatting[$i++] & 7);
    }
Example #2
0
 function get_startDate_endDate_view()
 {
     global $FANNIE_URL, $FANNIE_ROOT;
     $records = \COREPOS\Fannie\API\data\DataCache::getFile('daily');
     if ($records !== False) {
         $records = unserialize($records);
     }
     if (!is_array($records) || FormLib::get('no-cache') == '1') {
         $records = $this->get_data();
         \COREPOS\Fannie\API\data\DataCache::putFile('daily', serialize($records));
     }
     $ret = '';
     $debit = $credit = 0.0;
     if (FormLib::get_form_value('excel', '') === '') {
         $ret .= sprintf('<a href="OverShortMAS.php?startDate=%s&endDate=%s&excel=yes">Download</a>', $this->startDate, $this->endDate);
         $ret .= '<table class="table table-bordered small">';
         foreach ($records as $r) {
             if (preg_match('/\\(\\d+-\\d+-\\d+ \\d+-\\d+-\\d+\\)/', $r[5])) {
                 $tmp = explode(' ', $r[5]);
                 $date = trim($tmp[count($tmp) - 2], '()');
                 $trans = trim($tmp[count($tmp) - 1], '()');
                 $r[5] = sprintf('<a href="%sadmin/LookupReceipt/RenderReceiptPage.php?receipt=%s&date=%s">%s</a>', $FANNIE_URL, $trans, $date, $r[5]);
             }
             $ret .= sprintf('<tr><td>%d</td><td>%s</td><td>%s</td>
                     <td>%.2f</td><td>%.2f</td><td>%s</td></tr>', $r[0], $r[1], $r[2], $r[3], $r[4], $r[5]);
             $debit += $r[3];
             $credit += $r[4];
         }
         $ret .= sprintf('<tr><td colspan="3">Sum</td><td>%.2f</td><td>%.2f</td><td>&nbsp;</td></tr>', $debit, $credit);
         $ret .= '</table>';
     } else {
         foreach ($records as $row) {
             $line = '';
             foreach ($row as $val) {
                 $line .= strstr($val, ',') ? '"' . $val . '"' : $val;
                 $line .= ',';
             }
             $line = substr($line, 0, strlen($line) - 1) . "\r\n";
             $ret .= $line;
         }
     }
     return $ret;
 }