Exemplo n.º 1
0
function print_salesman_list()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $summary = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($summary == 0) {
        $sum = _("No");
    } else {
        $sum = _("Yes");
    }
    $dec = user_price_dec();
    $cols = array(0, 60, 150, 220, 325, 385, 450, 515);
    $headers = array(_('Invoice'), _('Customer'), _('Branch'), _('Customer Ref'), _('Inv Date'), _('Total'), _('Provision'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    $headers2 = array(_('Salesman'), " ", _('Phone'), _('Email'), _('Provision'), _('Break Pt.'), _('Provision') . " 2");
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Summary Only'), 'from' => $sum, 'to' => ''));
    $aligns2 = $aligns;
    $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $cols2 = $cols;
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->NewPage();
    $salesman = 0;
    $subtotal = $total = $subprov = $provtotal = 0;
    $result = GetSalesmanTrans($from, $to);
    while ($myrow = db_fetch($result)) {
        $rep->NewLine(0, 2, false, $salesman);
        if ($salesman != $myrow['salesman_code']) {
            if ($salesman != 0) {
                $rep->Line($rep->row - 8);
                $rep->NewLine(2);
                $rep->TextCol(0, 3, _('Total'));
                $rep->AmountCol(5, 6, $subtotal, $dec);
                $rep->AmountCol(6, 7, $subprov, $dec);
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
            }
            $rep->TextCol(0, 2, $myrow['salesman_code'] . " " . $myrow['salesman_name']);
            $rep->TextCol(2, 3, $myrow['salesman_phone']);
            $rep->TextCol(3, 4, $myrow['salesman_email']);
            $rep->TextCol(4, 5, number_format2($myrow['provision'], user_percent_dec()) . " %");
            $rep->AmountCol(5, 6, $myrow['break_pt'], $dec);
            $rep->TextCol(6, 7, number_format2($myrow['provision2'], user_percent_dec()) . " %");
            $rep->NewLine(2);
            $salesman = $myrow['salesman_code'];
            $total += $subtotal;
            $provtotal += $subprov;
            $subtotal = 0;
            $subprov = 0;
        }
        $rate = $myrow['rate'];
        $amt = $myrow['InvoiceTotal'] * $rate;
        if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) {
            $prov = $myrow['provision2'] * $amt / 100;
        } else {
            $prov = $myrow['provision'] * $amt / 100;
        }
        if (!$summary) {
            $rep->TextCol(0, 1, $myrow['trans_no']);
            $rep->TextCol(1, 2, $myrow['DebtorName']);
            $rep->TextCol(2, 3, $myrow['br_name']);
            $rep->TextCol(3, 4, $myrow['contact_name']);
            $rep->DateCol(4, 5, $myrow['tran_date'], true);
            $rep->AmountCol(5, 6, $amt, $dec);
            $rep->AmountCol(6, 7, $prov, $dec);
            $rep->NewLine();
        }
        $subtotal += $amt;
        $subprov += $prov;
    }
    if ($salesman != 0) {
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, _('Total'));
        $rep->AmountCol(5, 6, $subtotal, $dec);
        $rep->AmountCol(6, 7, $subprov, $dec);
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $total += $subtotal;
        $provtotal += $subprov;
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    $rep->AmountCol(5, 6, $total, $dec);
    $rep->AmountCol(6, 7, $provtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 2
0
function print_salesman_list()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $summary = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    if ($summary == 0) {
        $sum = tr("No");
    } else {
        $sum = tr("Yes");
    }
    $dec = user_qty_dec();
    $cols = array(0, 60, 150, 220, 325, 385, 450, 515);
    $headers = array(tr('Invoice'), tr('Customer'), tr('Branch'), tr('Customer Ref'), tr('Inv Date'), tr('Total'), tr('Provision'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    $headers2 = array(tr('Salesman'), " ", tr('Phone'), tr('Email'), tr('Provision'), tr('Break Pt.'), tr('Provision') . " 2");
    $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Summary Only'), 'from' => $sum, 'to' => ''));
    $cols2 = $cols;
    $aligns2 = $aligns;
    $rep = new FrontReport(tr('Salesman Listing'), "SalesmanListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->Header();
    $salesman = 0;
    $subtotal = $total = $subprov = $provtotal = 0;
    $result = GetSalesmanTrans($from, $to);
    while ($myrow = db_fetch($result)) {
        if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
            $salesman = 0;
            $rep->Header();
        }
        $rep->NewLine(0, 2, false, $salesman);
        if ($salesman != $myrow['salesman_code']) {
            if ($salesman != 0) {
                $rep->Line($rep->row - 8);
                $rep->NewLine(2);
                $rep->TextCol(0, 3, tr('Total'));
                $rep->TextCol(5, 6, number_format2($subtotal, $dec));
                $rep->TextCol(6, 7, number_format2($subprov, $dec));
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
                //$rep->Line($rep->row);
            }
            $rep->TextCol(0, 2, $myrow['salesman_code'] . " " . $myrow['salesman_name']);
            $rep->TextCol(2, 3, $myrow['salesman_phone']);
            $rep->TextCol(3, 4, $myrow['salesman_email']);
            $rep->TextCol(4, 5, number_format2($myrow['provision'], user_percent_dec()) . " %");
            $rep->TextCol(5, 6, number_format2($myrow['break_pt'], $dec));
            $rep->TextCol(6, 7, number_format2($myrow['provision2'], user_percent_dec()) . " %");
            $rep->NewLine(2);
            $salesman = $myrow['salesman_code'];
            $total += $subtotal;
            $provtotal += $subprov;
            $subtotal = 0;
            $subprov = 0;
        }
        $date = sql2date($myrow['tran_date']);
        $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
        $amt = $myrow['InvoiceTotal'] * $rate;
        if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) {
            $prov = $myrow['provision2'] * $amt / 100;
        } else {
            $prov = $myrow['provision'] * $amt / 100;
        }
        if (!$summary) {
            $rep->TextCol(0, 1, $myrow['trans_no']);
            $rep->TextCol(1, 2, $myrow['DebtorName']);
            $rep->TextCol(2, 3, $myrow['br_name']);
            $rep->TextCol(3, 4, $myrow['contact_name']);
            $rep->TextCol(4, 5, $date);
            $rep->TextCol(5, 6, number_format2($amt, $dec));
            $rep->TextCol(6, 7, number_format2($prov, $dec));
            $rep->NewLine();
            if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
                $salesman = 0;
                $rep->Header();
            }
        }
        $subtotal += $amt;
        $subprov += $prov;
    }
    if ($salesman != 0) {
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, tr('Total'));
        $rep->TextCol(5, 6, number_format2($subtotal, $dec));
        $rep->TextCol(6, 7, number_format2($subprov, $dec));
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        //$rep->Line($rep->row);
        $total += $subtotal;
        $provtotal += $subprov;
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    $rep->TextCol(5, 6, number_format2($total, $dec));
    $rep->TextCol(6, 7, number_format2($provtotal, $dec));
    $rep->Line($rep->row - 4);
    $rep->End();
}