Ejemplo n.º 1
0
        die;
    }
    if (!empty($_GET['cash'])) {
        $ids = $DB->GetCol('SELECT DISTINCT docid FROM cash, documents
            WHERE docid = documents.id AND documents.type = 2
                AND cash.id IN (' . implode(',', $ids) . ')');
    }
    sort($ids);
    $i = 0;
    $count = sizeof($ids);
    foreach ($ids as $idx => $receiptid) {
        if ($receipt = GetReceipt($receiptid)) {
            $type = $_GET['which'];
            $i++;
            if ($i == $count) {
                $receipt['last'] = TRUE;
            }
            $receipt['first'] = $i > 1 ? FALSE : TRUE;
            receipt_body();
        }
    }
} elseif ($receipt = GetReceipt($_GET['id'])) {
    $type = isset($_GET['which']) ? $_GET['which'] : '';
    $receipt['last'] = TRUE;
    $receipt['first'] = TRUE;
    receipt_body();
} else {
    $SESSION->redirect('?m=receiptlist');
}
close_pdf($pdf);
Ejemplo n.º 2
0
function module_tariff()
{
    global $LMS, $voip;
    $cnet = 'Cena za minutę połączenia (netto)';
    $voip->toiso($cnet);
    $cbrut = 'Cena za minutę połączenia (brutto)';
    $voip->toiso($cbrut);
    $taxes = $LMS->GetTaxes();
    $tax = 23;
    if (is_array($taxes)) {
        foreach ($taxes as $val) {
            if ($val['id'] == $voip->config['taxid']) {
                $tax = $val['value'];
            }
        }
    }
    setlocale(LC_TIME, "C");
    $sip = $voip->GetNode($_GET['id']);
    $exp = $voip->wsdl->CennExport($sip['id_tariffs']);
    $data = array();
    $i = 1;
    $suma = 0;
    $poz = 0;
    if (is_array($exp)) {
        foreach ($exp as $val) {
            $el = array();
            $el['L.p.'] = $i++;
            $el['Kierunek'] = $val['desc'];
            if ($val['days'] == 510 && $val['from'] == '00:00' && $val['to'] == '23:59') {
                $el['Kiedy'] = 'zawsze';
            } else {
                $x = decbin($val['days']);
                $x = sprintf('%09s', $x);
                $x = $voip->str_split($x);
                $el['Kiedy'] = $val['from'] . '-' . $val['to'] . "\n" . $voip->wsdl->days($x);
            }
            $koszt = $val['price'] * 60;
            $el[$cnet] = sprintf("%.3f", round($koszt, 3));
            $koszt = $koszt * ($tax / 100) + $koszt;
            $el[$cbrut] = sprintf("%.3f", round($koszt, 3));
            $data[] = $voip->toiso($el);
        }
    }
    if ($_GET['csv']) {
        $fname = tempnam("/tmp", "CSV");
        $f = fopen($fname, 'w');
        foreach ((array) $data as $key => $val) {
            $line = '';
            $line1 = '';
            if ($key == 0) {
                foreach ((array) $val as $key1 => $val1) {
                    $line1 .= $key1 . ';';
                    $line .= $val1 . ';';
                }
                $line = substr($line1, 0, -1) . "\n" . $line;
            } else {
                foreach ((array) $val as $key1 => $val1) {
                    $line .= $val1 . ';';
                }
            }
            $line = substr($line, 0, -1) . "\n";
            fwrite($f, $line);
        }
        fclose($f);
        header('Content-type: text/csv');
        header('Content-Disposition: attachment; filename="cenn.csv"');
        readfile($fname);
        unlink($fname);
        exit;
    }
    require_once LIB_DIR . '/ezpdf.php';
    $pdf = init_pdf('A4', 'portrait', trans('Invoices'));
    $pdf->ezTable($data, '', '', array('fontSize' => 5));
    $pdf->ezStream();
    close_pdf($pdf);
    exit;
}