Exemple #1
0
function print_royalty_sales()
{
    $item_id = $_POST['PARAM_0'];
    global $path_to_root, $systypes_array;
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $result = fetchRoyalty($item_id);
    $name = "";
    while ($book = db_fetch($result)) {
        $name = $book[1];
    }
    $params = array(0 => $comments, 1 => array('text' => _('Item'), 'from' => $name));
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 150, 250, 350, 450);
    $headers = array(_('Name'), _('ID #'), _('Date'), _('Quantity'), _('Status'));
    $aligns = array('left', 'left', 'left', 'left', 'left');
    $usr = get_user($user);
    $user_id = $usr['user_id'];
    $rep = new FrontReport(_('Royalty Sales'), "RoyaltySales", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('Header');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $rep->TextCol(0, 1, $item_id);
    $rep->TextCol(2, 4, fetchTitle($item_id));
    $rep->NewLine();
    $rep->NewLine();
    $result = fetchRoyalty($item_id);
    while ($myrow = db_fetch($result)) {
        $rep->TextCol(0, 1, $myrow[0]);
        $rep->TextCol(1, 2, '  ' . $myrow[1]);
        $rep->TextCol(2, 3, $myrow[2]);
        $rep->TextCol(3, 4, $myrow[3]);
        $rep->TextCol(4, 5, 'Closed');
        $rep->NewLine();
    }
    $result1 = fetchCreditMemo($item_id);
    while ($myrow1 = db_fetch($result1)) {
        if ($myrow1[3] > 0) {
            $rep->TextCol(0, 1, $myrow1[0]);
            $rep->TextCol(1, 2, '  ' . $myrow1[1]);
            $rep->TextCol(2, 3, $myrow1[2]);
            $rep->TextCol(3, 4, '- ' . $myrow1[3]);
            $rep->TextCol(4, 5, 'Closed');
            $rep->NewLine();
        }
    }
    $rep->Line($rep->row + 4);
    $rep->End();
}
function print_royalty_sales()
{
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $item = $_POST['PARAM_2'];
    $status = $_POST['PARAM_3'];
    $destination = $_POST['PARAM_4'];
    $orientation = $_POST['PARAM_5'];
    global $path_to_root, $systypes_array;
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $result = fetchRoyalty($item);
    $name = "";
    while ($book = db_fetch($result)) {
        $name = $book[1];
    }
    $params = array(0 => $comments, 1 => array('text' => _('Item'), 'from' => $name));
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 200, 210, 300, 310, 360, 380, 430, 440, 490, 500, 550);
    $headers = array(_('Client'), '', _('IMC'), '', _('Invoice/CM #'), '', _('Date'), '', _('Quantity'), '', _('Status'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
    $usr = get_user($user);
    $user_id = $usr['user_id'];
    $rep = new FrontReport(_('Royalty Sales'), "RoyaltySales", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('Header');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    if ($item == '') {
        $no_title_print = false;
        $enter = true;
    } else {
        $no_title_print = true;
        $enter = false;
    }
    if ($no_title_print) {
        $rep->Font('bold');
        $rep->TextCol(0, 1, $item);
        $rep->TextCol(2, 10, fetchTitle($item));
        $rep->Font();
    }
    $total = 0;
    $total_invoice_qty = 0;
    $total_credit_qty = 0;
    $rep->NewLine();
    if ($item == "") {
        $code = array();
        $ItemCode = fetchItemCode();
        while ($r = db_fetch($ItemCode)) {
            array_push($code, $r[0]);
        }
        $total = 0;
        $total_invoice_qty = 0;
        $total_credit_qty = 0;
        foreach ($code as $codes) {
            $result = fetchRoyalty($codes, $status, $from, $to);
            $bookname = fetchTitle($codes);
            $rep->Font('bold');
            $rep->TextCol(0, 5, $codes . "-" . $bookname);
            $rep->Font();
            $rep->NewLine();
            while ($myrow = db_fetch($result)) {
                if ($myrow['alloc'] == $myrow['ov_amount']) {
                    $stat = 'Closed';
                }
                if ($myrow['alloc'] < $myrow['ov_amount']) {
                    $stat = 'Open';
                }
                $scode = get_code($myrow['salesman']);
                $salesman = get_salesman_name($myrow['salesman']);
                $total_invoice_qty += $myrow[3];
                $clientName = get_customer_name($myrow[0]);
                $rep->TextCol(0, 1, $clientName);
                $rep->TextCol(2, 3, $scode);
                $rep->TextCol(4, 5, '  ' . $myrow['customized_no']);
                $rep->TextCol(6, 7, $myrow['tranDate']);
                $rep->TextCol(8, 9, $myrow['quantity']);
                $rep->TextCol(10, 11, $stat);
                $rep->NewLine();
            }
            $result1 = fetchCreditMemo($codes, $status, $from, $to);
            while ($myrow1 = db_fetch($result1)) {
                if ($myrow1[3] > 0) {
                    if ($myrow1['alloc'] == $myrow1['ov_amount']) {
                        $stat = 'Closed';
                    }
                    if ($myrow1['alloc'] < $myrow1['ov_amount']) {
                        $stat = 'Open';
                    }
                }
                $qty = -$myrow1['quantity'];
                $total_credit_qty += $qty;
                $scode = get_code($myrow1['salesman']);
                $clientName2 = get_customer_name($myrow1[0]);
                $rep->TextCol(0, 1, $clientName2);
                $rep->TextCol(2, 3, $scode);
                $rep->TextCol(4, 5, '  ' . $myrow1['customized_no']);
                $rep->TextCol(6, 7, $myrow1['tranDate']);
                $rep->TextCol(8, 9, $qty);
                $rep->TextCol(10, 11, $stat);
                $rep->NewLine();
            }
            $rep->NewLine(1);
            $total = $total_invoice_qty + $total_credit_qty;
            $rep->Font('bold');
            $rep->TextCol(6, 7, _("Total"));
            $rep->TextCol(8, 9, $total);
            $rep->Line($rep->row + 10);
            $rep->Font();
            $rep->NewLine();
            $total = 0;
            $total_invoice_qty = 0;
            $total_credit_qty = 0;
        }
    } else {
        $result = fetchRoyalty($item, $status, $from, $to);
        while ($myrow = db_fetch($result)) {
            if ($myrow['alloc'] == $myrow['ov_amount']) {
                $stat = 'Closed';
            }
            if ($myrow['alloc'] < $myrow['ov_amount']) {
                $stat = 'Open';
            }
            $scode = get_code($myrow['salesman']);
            $salesman = get_salesman_name($myrow['salesman']);
            $total_invoice_qty += $myrow[3];
            $clientName = get_customer_name($myrow[0]);
            $rep->TextCol(0, 1, $clientName);
            $rep->TextCol(2, 3, $scode);
            $rep->TextCol(4, 5, '  ' . $myrow['customized_no']);
            $rep->TextCol(6, 7, $myrow['tranDate']);
            $rep->TextCol(8, 9, $myrow['quantity']);
            $rep->TextCol(10, 11, $stat);
            $rep->NewLine();
        }
        $result1 = fetchCreditMemo($item, $status, $from, $to);
        while ($myrow1 = db_fetch($result1)) {
            if ($myrow1[3] > 0) {
                if ($myrow1['alloc'] == $myrow1['ov_amount']) {
                    $stat = 'Closed';
                }
                if ($myrow1['alloc'] < $myrow1['ov_amount']) {
                    $stat = 'Open';
                }
                $qty = -$myrow1['quantity'];
                $total_credit_qty += $qty;
                $scode = get_code($myrow1['salesman']);
                $clientName2 = get_customer_name($myrow1[0]);
                $rep->TextCol(0, 1, $clientName2);
                $rep->TextCol(2, 3, $scode);
                $rep->TextCol(4, 5, '  ' . $myrow1['customized_no']);
                $rep->TextCol(6, 7, $myrow1['tranDate']);
                $rep->TextCol(8, 9, $qty);
                $rep->TextCol(10, 11, $stat);
                $rep->NewLine();
            }
        }
        $rep->NewLine(1);
        $total = $total_invoice_qty + $total_credit_qty;
        $rep->Font('bold');
        $rep->TextCol(6, 7, _("Total"));
        $rep->TextCol(8, 9, $total);
        $rep->Line($rep->row + 10);
        $rep->NewLine();
        $total = 0;
        $total_invoice_qty = 0;
        $total_credit_qty = 0;
    }
    $rep->End();
}