function print_summary()
{
    global $path_to_root;
    $imc = $_POST['PARAM_0'];
    $comments = $_POST['PARAM_1'];
    $orientation = $_POST['PARAM_2'];
    $destination = $_POST['PARAM_3'];
    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';
    $dec = user_price_dec();
    $cols = array(0, 10, 100, 150, 200, 250, 300, 350, 400, 450, 520);
    //$headers = array(_('IMC'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left');
    //$params =   array( 	0 => $comments,	1 => array(  'text' => _('Period'), 'from' => $from));
    $aligns2 = $aligns;
    $summary = 1;
    $rep = new FrontReport(_('Client List'), "ClientList", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $cols2 = $cols;
    $rep->Font();
    $rep->Info(null, $cols, null, $aligns);
    $rep->NewPage();
    $salesman = 0;
    $result = getList($imc);
    while ($myrow = db_fetch($result)) {
        $previous == '';
        $salesman = get_salesman_name($myrow['salesman']);
        $current = $salesman;
        if ($salesman != "") {
            if ($previous == $current) {
                $salesman = '';
                $rep->TextCol(1, 10, $myrow['br_name']);
                $rep->NewLine();
            } else {
                $rep->Font('bold');
                $rep->NewLine(2);
                $rep->Line($rep->row + 10);
                $rep->TextCol(0, 2, $salesman);
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
                $rep->Font();
                $rep->TextCol(1, 10, $myrow['br_name']);
                $rep->NewLine();
            }
            $previous = $current;
        }
    }
    $rep->NewLine();
    $rep->End();
}
Example #2
0
function print_subsidiary_ledger()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $cat = $_POST['PARAM_2'];
    $account = $_POST['PARAM_3'];
    $account2 = $_POST['PARAM_4'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, L);
    $dec = user_price_dec();
    //$headers = array(_('Type'),   _('Ref'), _('#'),   _('Date'), _('Dimension')." 1", _('Dimension')." 2",
    //      _('Person/Item'), _('Debit'),   _('Credit'), _('Balance'));
    //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
    $cols = array(0, 50, 140, 200, 210, 400, 450, 550, 600, 650);
    //------------0--1---2-----3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    //$headers = array(_('ID'), '', '', '', '', '', '', _('Debit'), _('Credit'), _('Balance'));
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc));
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('header3');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    if ($cat == 3) {
        $person = get_salesman_name($account);
    }
    if ($cat == 1) {
        $person = get_supplier_name($account);
    }
    /*$rep->TextCol(0,2, $cat);
      $rep->NewLine();*/
    $rep->Font('bold');
    $rep->TextCol(0, 2, "Name:" . $person);
    $rep->NewLine();
    $rep->TextCol(0, 1, "ID:");
    $rep->TextCol(1, 2, "Src:");
    $rep->TextCol(2, 3, "Date:");
    $rep->TextCol(4, 5, "Memo:");
    $rep->TextCol(5, 6, "Account:");
    $rep->TextCol(6, 7, "Debit:");
    $rep->TextCol(8, 9, "Credit:");
    $rep->Font();
    $rep->NewLine(2);
    $result = getTransaction($from, $to, $cat, $account, $account2);
    $type = '';
    while ($myrow = db_fetch($result)) {
        if ($myrow['Voided'] == '' && $myrow['amount'] > 0) {
            $comments = get_comments_string($myrow['type'], $myrow['type_no']);
            $custom = get_custom_no($myrow['type_no'], $myrow['type']);
            if ($myrow['type'] == ST_DISBURSEMENT) {
                $type = "CD";
            }
            if ($myrow['type'] == ST_PURCHASEORDER) {
                $type = "P.O.";
            }
            if ($myrow['type'] == ST_SUPPAYMENT) {
                $type = "CD";
            }
            //else
            //    $type = $systypes_array[$myrow["type"]];
            $rep->TextCol(0, 1, "#" . $custom);
            $rep->TextCol(1, 2, $type);
            $rep->TextCol(2, 3, $myrow['tranDate']);
            $rep->TextCol(4, 5, $comments);
            $rep->TextCol(5, 6, $myrow['account']);
            $dr += $myrow['amount'];
            $rep->AmountCol(6, 7, $myrow['amount'], 2);
            $rep->NewLine();
        } else {
            if ($myrow['Voided'] == '' && $myrow['amount'] < 0) {
                $cr += $myrow['amount'];
                //$rep->AmountCol(8,9, $myrow['amount'], 2);
            }
        }
    }
    $rep->NewLine(2);
    $rep->Font('bold');
    $rep->AmountCol(6, 7, $dr, 2);
    $rep->NewLine(2);
    $rep->TextCol(1, 2, "Net Activity: ");
    $rep->AmountCol(2, 4, $cr, 2);
    $rep->End();
}
function imc_name($row, $type)
{
    return get_salesman_name($row['imc']);
}
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();
}
function print_royalty_sales()
{
    $imc = $_POST['PARAM_0'];
    $destination = $_POST['PARAM_2'];
    $orientation = $_POST['PARAM_1'];
    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";
    }
    $params = array(0 => $comments, 1 => array('text' => _('Item'), 'from' => $name));
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 100, 150, 250, 300, 350, 400, 450, 520);
    $headers = array(_('IMC/Client'), _('Address'), '', _('Contact Person'), '', _('Contact No.'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left');
    $usr = get_user($user);
    $user_id = $usr['user_id'];
    $rep = new FrontReport(_('Client Listing'), "Client Listing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('Header');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $salesman = 0;
    $result = getList($imc);
    while ($myrow = db_fetch($result)) {
        $previous == '';
        $salesman = get_salesman_name($myrow['salesman']);
        $current = $salesman;
        if ($salesman != "") {
            if ($previous == $current) {
                $salesman = '';
                $name = $myrow['name'] . " " . $myrow['name2'];
                $rep->TextCol(0, 2, $myrow['br_name']);
                $rep->NewLine();
                $rep->TextCol(1, 7, "Address: " . $myrow['br_address']);
                $rep->TextCol(7, 15, "Contact Person: " . $name);
                $rep->NewLine();
                if ($myrow['phone'] != NULL && $myrow['phone2'] != NULL) {
                    $rep->TextCol(1, 5, "Contact Nos. " . $myrow['phone'] . "/" . $myrow['phone2']);
                }
                if ($myrow['phone2'] == NULL) {
                    $rep->TextCol(1, 5, "Contact Nos. " . $myrow['phone']);
                }
                if ($myrow['fax'] != NULL) {
                    $rep->TextCol(6, 8, "Fax" . $myrow['fax']);
                }
                if ($myrow['email'] != NULL) {
                    $rep->TextCol(9, 15, "Email" . $myrow['email']);
                }
                $rep->NewLine();
            } else {
                $name = $myrow['name'] . " " . $myrow['name2'];
                $rep->Font('bold');
                $rep->NewLine(2);
                $rep->Line($rep->row + 10);
                $rep->TextCol(0, 10, $salesman);
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
                $rep->Font();
                $rep->TextCol(0, 2, $myrow['br_name']);
                $rep->NewLine();
                $rep->TextCol(1, 7, "Address: " . $myrow['br_address']);
                $rep->TextCol(7, 15, "Contact Person: " . $name);
                $rep->NewLine();
                if ($myrow['phone'] != NULL && $myrow['phone2'] != NULL) {
                    $rep->TextCol(1, 5, "Contact Nos. " . $myrow['phone'] . "/" . $myrow['phone2']);
                }
                if ($myrow['phone2'] == NULL) {
                    $rep->TextCol(1, 5, "Contact Nos. " . $myrow['phone']);
                }
                if ($myrow['fax'] != NULL) {
                    $rep->TextCol(6, 8, "Fax" . $myrow['fax']);
                }
                if ($myrow['email'] != NULL) {
                    $rep->TextCol(9, 15, "Email" . $myrow['email']);
                }
                $rep->NewLine();
            }
            $previous = $current;
        }
    }
    $rep->NewLine();
    $rep->End();
}
Example #6
0
function print_customer_details_listing()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $area = $_POST['PARAM_1'];
    $folk = $_POST['PARAM_2'];
    $more = $_POST['PARAM_3'];
    $less = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $destination = $_POST['PARAM_7'];
    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';
    $dec = 0;
    if ($area == ALL_NUMERIC) {
        $area = 0;
    }
    if ($folk == ALL_NUMERIC) {
        $folk = 0;
    }
    if ($area == 0) {
        $sarea = _('All Areas');
    } else {
        $sarea = get_area_name($area);
    }
    if ($folk == 0) {
        $salesfolk = _('All Sales Folk');
    } else {
        $salesfolk = get_salesman_name($folk);
    }
    if ($more != '') {
        $morestr = _('Greater than ') . number_format2($more, $dec);
    } else {
        $morestr = '';
    }
    if ($less != '') {
        $lessstr = _('Less than ') . number_format2($less, $dec);
    } else {
        $lessstr = '';
    }
    $more = (double) $more;
    $less = (double) $less;
    $cols = array(0, 150, 300, 425, 550);
    $headers = array(_('Customer Postal Address'), _('Price/Turnover'), _('Branch Contact Information'), _('Branch Delivery Address'));
    $aligns = array('left', 'left', 'left', 'left');
    $params = array(0 => $comments, 1 => array('text' => _('Activity Since'), 'from' => $from, 'to' => ''), 2 => array('text' => _('Sales Areas'), 'from' => $sarea, 'to' => ''), 3 => array('text' => _('Sales Folk'), 'from' => $salesfolk, 'to' => ''), 4 => array('text' => _('Activity'), 'from' => $morestr, 'to' => $lessstr . " " . get_company_pref("curr_default")));
    $rep = new FrontReport(_('Customer Details Listing'), "CustomerDetailsListing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $result = get_customer_details_for_report($area, $folk);
    $carea = '';
    $sman = '';
    while ($myrow = db_fetch($result)) {
        $printcustomer = true;
        if ($more != '' || $less != '') {
            $turnover = getTransactions($myrow['debtor_no'], $myrow['branch_code'], $from);
            if ($more != 0.0 && $turnover <= (double) $more) {
                $printcustomer = false;
            }
            if ($less != 0.0 && $turnover >= (double) $less) {
                $printcustomer = false;
            }
        }
        if ($printcustomer) {
            if ($carea != $myrow['description']) {
                $rep->fontSize += 2;
                $rep->NewLine(2, 7);
                $rep->Font('bold');
                $rep->TextCol(0, 3, _('Customers in') . " " . $myrow['description']);
                $carea = $myrow['description'];
                $rep->fontSize -= 2;
                $rep->Font();
                $rep->NewLine();
            }
            if ($sman != $myrow['salesman_name']) {
                $rep->fontSize += 2;
                $rep->NewLine(1, 7);
                $rep->Font('bold');
                $rep->TextCol(0, 3, $myrow['salesman_name']);
                $sman = $myrow['salesman_name'];
                $rep->fontSize -= 2;
                $rep->Font();
                $rep->NewLine();
            }
            $rep->NewLine();
            // Here starts the new report lines 2010-11-02 Joe Hunt
            $contacts = get_contacts_for_branch($myrow['branch_code']);
            $rep->TextCol(0, 1, $myrow['name']);
            $rep->TextCol(1, 2, _('Price List') . ": " . $myrow['sales_type']);
            $rep->TextCol(2, 3, $myrow['br_name']);
            $rep->NewLine();
            $adr = Explode("\n", $myrow['address']);
            if ($myrow['br_post_address'] == '') {
                $adr2 = Explode("\n", $myrow['br_address']);
            } else {
                $adr2 = Explode("\n", $myrow['br_post_address']);
            }
            $count1 = count($adr);
            $count2 = count($adr2);
            $count1 = max($count1, $count2);
            $count1 = max($count1, 4);
            if (isset($adr[0])) {
                $rep->TextCol(0, 1, $adr[0]);
            }
            $rep->TextCol(1, 2, _('Currency') . ": " . $myrow['curr_code']);
            if (isset($contacts[0])) {
                $rep->TextCol(2, 3, $contacts[0]['name'] . " " . $contacts[0]['name2']);
            }
            if (isset($adr2[0])) {
                $rep->TextCol(3, 4, $adr2[0]);
            }
            $rep->NewLine();
            if (isset($adr[1])) {
                $rep->TextCol(0, 1, $adr[1]);
            }
            if ($myrow['dimension_id'] != 0) {
                $dim = get_dimension($myrow['dimension_id']);
                $rep->TextCol(1, 2, _('Dimension') . ": " . $dim['name']);
            }
            if (isset($contacts[0])) {
                $rep->TextCol(2, 3, _('Ph') . ": " . $contacts[0]['phone']);
            }
            if (isset($adr2[1])) {
                $rep->TextCol(3, 4, $adr2[1]);
            }
            $rep->NewLine();
            if (isset($adr[2])) {
                $rep->TextCol(0, 1, $adr[2]);
            }
            if ($myrow['dimension2_id'] != 0) {
                $dim = get_dimension($myrow['dimension2_id']);
                $rep->TextCol(1, 2, _('Dimension') . " 2: " . $dim['name']);
            }
            if (isset($contacts[0])) {
                $rep->TextCol(2, 3, _('Fax') . ": " . $contacts[0]['fax']);
            }
            if (isset($adr2[2])) {
                $rep->TextCol(3, 4, $adr2[2]);
            }
            if ($more != 0.0 || $less != 0.0) {
                $rep->TextCol(1, 2, _('Turnover') . ": " . number_format2($turnover, $dec));
            }
            for ($i = 3; $i < $count1; $i++) {
                $rep->NewLine();
                if (isset($adr[$i])) {
                    $rep->TextCol(0, 1, $adr[$i]);
                }
                if ($i == 3 && isset($contacts[0]) && isset($contacts[0]['email'])) {
                    $rep->TextCol(2, 3, _('Email') . ": " . $contacts[0]['email']);
                }
                if (isset($adr2[$i])) {
                    $rep->TextCol(3, 4, $adr2[$i]);
                }
            }
            $rep->NewLine();
            /*
            $rep->TextCol(0, 1,	$myrow['name']);
            $adr = Explode("\n", $myrow['address']);
            $count1 = count($adr);
            for ($i = 0; $i < $count1; $i++)
            	$rep->TextCol(0, 1, $adr[$i], 0, ($i + 1) * $rep->lineHeight);
            $count1++;
            $rep->TextCol(1, 2,	_('Price List') . ": " . $myrow['sales_type']);
            if ($more != 0.0 || $less != 0.0)
            	$rep->TextCol(1, 2,	_('Turnover') . ": " . number_format2($turnover, $dec), 0, $rep->lineHeight);
            $rep->TextCol(2, 3,	$myrow['br_name']);
            
            $contacts = get_branch_contacts($myrow['branch_code']);
            if (isset($contacts[0]))
            {
            	$rep->TextCol(2, 3, $contacts[0]['name'], 0, $rep->lineHeight);
            	$rep->TextCol(2, 3, _('Ph') . ": " . $contacts[0]['phone'], 0, 2 * $rep->lineHeight);
            	$rep->TextCol(2, 3, _('Fax') . ": " . $contacts[0]['fax'], 0, 3 * $rep->lineHeight);
            }
            $adr = Explode("\n", $myrow['br_address']);
            $count2 = count($adr);
            for ($i = 0; $i < $count2; $i++)
            	$rep->TextCol(3, 4, $adr[$i], 0, ($i + 1) * $rep->lineHeight);
            //$rep->TextCol(3, 4, $myrow['email'], 0, ($count2 + 1) * $rep->lineHeight);
            $count2++;
            $count1 = Max($count1, $count2);
            $count1 = Max($count1, 4);
            $rep->NewLine($count3);
            */
            $rep->Line($rep->row + 8);
            $rep->NewLine(0, 3);
        }
    }
    $rep->End();
}
Example #7
0
function print_subsidiary_ledger()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $cat = $_POST['PARAM_2'];
    $account = $_POST['PARAM_3'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, $orientation);
    $dec = user_price_dec();
    //$headers = array(_('Type'),   _('Ref'), _('#'),   _('Date'), _('Dimension')." 1", _('Dimension')." 2",
    //      _('Person/Item'), _('Debit'),   _('Credit'), _('Balance'));
    //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
    $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    $headers = array(_('ID'), '', '', '', '', '', '', _('Debit'), _('Credit'), _('Balance'));
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc));
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('0');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $rep->NewLine(5);
    $rep->TextCol(4, 8, "ST. MATTHEWS PUBLISHING CORPORATION");
    $rep->NewLine();
    $rep->TextCol(1, 10, "First RVC Building #92 Anonas corner K-6 Streets, East Kamias, Quezon City 1102");
    $rep->NewLine(3);
    $rep->TextCol(4, 8, "SUBSIDIARY LEDGER");
    $rep->NewLine(2);
    //date range here
    if ($cat == 3) {
        $person = get_salesman_name($account);
    }
    $rep->TextCol(0, 2, "Name:" . $person);
    $rep->NewLine();
    $rep->TextCol(0, 1, "ID:");
    $rep->TextCol(1, 2, "Src:");
    $rep->TextCol(2, 3, "Date:");
    $rep->TextCol(3, 4, "Memo:");
    $rep->TextCol(4, 5, "Account:");
    $rep->TextCol(5, 6, "Debit:");
    $rep->TextCol(6, 7, "Credit:");
    $rep->NewLine(2);
    /*  $rep->TextCol(0,1, $from);
        $rep->TextCol(1,2, $to);
        $rep->TextCol(2,3, $cat);
        $rep->TextCol(3,4, $account);*/
    $rep->TextCol(0, 1, $person);
    $rep->NewLine();
    $result = getTransaction($from, $to, $cat, $account);
    while ($myrow = db_fetch($result)) {
        if ($myrow['type'] == ST_DISBURSEMENT && $myrow['customized_no'] != 0) {
            $type = "CV";
        } else {
            $type = "";
        }
        $rep->TextCol(0, 5, $type . "#" . $myrow['customized_no']);
        $rep->TextCol(2, 3, "");
        $rep->TextCol(3, 4, $myrow['tran_date']);
        $rep->TextCol(4, 5, $myrow['account']);
        $rep->AmountCol(5, 6, $myrow['amount'], 2);
        if ($myrow['amount'] < 0) {
            $cr += $myrow['amount'];
        }
        if ($myrow['amount'] > 0) {
            $dr += $myrow['amount'];
        }
        $rep->NewLine();
    }
    $rep->AmountCol(5, 6, $dr, 2);
    $rep->NewLine();
    $rep->AmountCol(1, 2, abs($cr), 2);
    $rep->End();
}
Example #8
0
function print_invoices()
{
    global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount;
    include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $currency = $_POST['PARAM_2'];
    $email = $_POST['PARAM_3'];
    $pay_service = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $customer = $_POST['PARAM_6'];
    $orientation = $_POST['PARAM_7'];
    if (!$from || !$to) {
        return;
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $fno = explode("-", $from);
    $tno = explode("-", $to);
    $from = min($fno[0], $tno[0]);
    $to = max($fno[0], $tno[0]);
    $cols = array(-15, 10, 30, 50, 80, 240, 300, 340, 360, 400);
    // $headers in doctext.inc
    $aligns = array('right', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array('comments' => $comments);
    $cur = get_company_Pref('curr_default');
    if ($email == 0) {
        $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation);
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    for ($i = $from; $i <= $to; $i++) {
        if (!exists_customer_trans(ST_SALESINVOICE, $i)) {
            continue;
        }
        $sign = 1;
        $myrow = get_customer_trans($i, ST_SALESINVOICE);
        if ($customer && $myrow['debtor_no'] != $customer) {
            continue;
        }
        $baccount = get_default_bank_account($myrow['curr_code']);
        $params['bankaccount'] = $baccount['id'];
        $branch = get_branch($myrow["branch_code"]);
        $salesm = get_salesman_name($branch['salesman']);
        $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER);
        if ($email == 1) {
            $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
            $rep->title = _('INVOICE');
            $rep->filename = "Invoice" . $myrow['reference'] . ".pdf";
        }
        $rep->SetHeaderType(0);
        $rep->currency = $cur;
        $rep->Font();
        $rep->Info(null, $cols, null, $aligns);
        $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true);
        $baccount['payment_service'] = $pay_service;
        $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
        $rep->NewPage();
        $result = get_customer_trans_details(ST_SALESINVOICE, $i);
        $SubTotal = 0;
        $invoice_no = get_custom_no($myrow['trans_no'], ST_SALESINVOICE);
        $rep->NewLine(5);
        $rep->TextCol(2, 5, $branch['br_name']);
        $rep->TextCol(7, 9, $myrow['TranDate']);
        $rep->NewLine();
        $rep->TextCol(2, 10, $branch['br_address']);
        $rep->TextCol(7, 9, "SI - " . $invoice_no);
        $rep->NewLine();
        $rep->TextCol(0, 2, "Contact: ");
        $rep->TextCol(2, 5, $contacts["name"] . $contacts["name2"]);
        $rep->TextCol(6, 9, "IMC: " . $salesm);
        $rep->NewLine();
        $rep->TextCol(2, 5, "");
        $rep->NewLine();
        $rep->TextCol(2, 5, "");
        $rep->NewLine(3);
        //$rep->NewLine(2);
        $ent = 0;
        while ($myrow2 = db_fetch($result)) {
            if ($myrow2["quantity"] == 0) {
                continue;
            }
            $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec());
            $SubTotal += $Net;
            $DisplayPrice = number_format2($myrow2["unit_price"], 2);
            $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id']));
            $DisplayNet = number_format2($Net, 2);
            if ($myrow2["discount_percent"] == 0) {
                $DisplayDiscount = "";
            } else {
                $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, 2) . "%";
            }
            //$rep->TextCol(3, 4,	$myrow2['stock_id'], -2);
            $oldrow = $rep->row;
            $rep->TextColLines(4, 6, $myrow2['StockDescription'], -2);
            $newrow = $rep->row;
            $rep->row = $oldrow;
            $ent++;
            if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) {
                $rep->TextCol(2, 3, $DisplayQty, -2);
                $rep->TextCol(3, 4, $myrow2['units'], -2);
                $rep->TextCol(6, 7, $DisplayPrice, -2);
                $rep->TextCol(7, 9, $DisplayNet, -2);
            }
            $rep->row = $newrow;
            //$rep->NewLine(1);
            if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) {
                $rep->NewPage();
            }
        }
        $memo = get_comments_string(ST_SALESINVOICE, $i);
        if ($memo != "") {
            $rep->NewLine();
            $rep->TextColLines(1, 5, $memo, -2);
        }
        $DisplaySubTot = $SubTotal;
        $rep->NewLine(8 - $ent);
        $doctype = ST_SALESINVOICE;
        $tot = $sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]);
        if ($tot != $SubTotal) {
            $discount = $SubTotal * ($myrow['bulk_discount'] / 100);
        }
        $rep->AmountCol(7, 9, $DisplaySubTot, 2);
        $rep->NewLine();
        if ($myrow['bulk_discount'] != 0) {
            $rep->TextCol(5, 7, "Less Discount: " . $myrow['bulk_discount'] . "%");
        }
        $rep->AmountCol(7, 9, $discount, 2);
        $rep->NewLine();
        $DisplayTotal = $sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]);
        $rep->Font('bold');
        $rep->AmountCol(7, 9, $DisplayTotal, 2);
    }
    if ($email == 0) {
        $rep->End();
    }
}
Example #9
0
function print_voucher()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $voucher_no = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $destination = $_POST['PARAM_2'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('COMMISSION VOUCHER'), "CommissionVoucherReport", user_pagesize(), 9, $orientation);
    $dec = user_price_dec();
    $cols = array(-15, 20, 40, 60, 90, 150, 200, 225, 220, 465, 525);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right');
    $headers = array('', _('Commission Voucher'), '', '', '', '', '');
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType(0);
    $rep->Font();
    $rep->Info(null, $cols, null, $aligns);
    $rep->NewPage();
    $res = get_transaction($voucher_no);
    $myrow = db_fetch($res);
    $salesman = get_salesman_name($myrow['imc']);
    $client = get_customer_name($myrow['client']);
    $rep->Font('bold');
    // $rep->TextCol(4,8, _("ST. MATTHEW'S PUBLISHING CORPORATION"));
    $rep->Font();
    $rep->NewLine();
    // $rep->TextCol(4,8, _("Tel. Nos. 426-5611 * 433-5385 Telefax: 426-1274"));
    $rep->NewLine(5);
    $rep->Font('bold');
    $rep->SetFontSize(14);
    //$rep->TextCol(0,3, _("COMMISSION VOUCHER"));
    $rep->Font();
    $rep->SetFontSize(10);
    $rep->NewLine(4);
    $netgross = $myrow['gross'] * ($myrow['commission'] / 100);
    //$rep->TextCol(8,9, _("Date:"));
    $rep->TextCol(5, 6, $myrow['Dated']);
    $year = substr($myrow['dateYear'], 2);
    $rep->TextCol(6, 7, $year);
    $rep->NewLine(1);
    $rep->TextCol(1, 4, $salesman);
    $rep->NewLine(3);
    //$rep->Line($rep->row  - -10);
    //$rep->TextCol(2,5, _("EXPLANATION"));
    //$rep->TextCol(8,9, _("AMOUNT"));
    // $rep->Line($rep->row  - 4);
    $rep->NewLine(2);
    $rep->SetFontSize('8');
    $oldrow = $rep->row;
    $rep->TextColLines(2, 5, $client);
    $newrow = $rep->row;
    $rep->row = $oldrow;
    $rep->NewLine(3);
    $rep->SetFontSize('10');
    //$rep->TextCol(8,9, _("Gross: "));
    $rep->AmountCol(5, 7, $netgross, 2);
    $rep->NewLine(1);
    $rep->TextCol(2, 4, $myrow['commission']);
    $rep->AmountCol(5, 7, $myrow['with_tax'], 2);
    $rep->NewLine(2);
    $rep->TextCol(2, 4, $myrow['invoice_no']);
    $rep->NewLine(4);
    $rep->Font('bold');
    $rep->AmountCol(5, 7, $myrow['net_commission'], 2);
    $rep->NewLine();
    // $rep->Line($rep->row  - 4);
    // $rep->Line($rep->row  - 8);
    $rep->NewLine(3);
    $rep->Font();
    $rep->SetFontSize('9');
    //$rep->TextCol(1,4, _("Approved by:"));
    // $rep->TextCol(5,8, _("Received payment by:"));
    $rep->NewLine(2);
    $rep->TextCol(2, 4, _("Checked by:"));
    $rep->End();
}
Example #10
0
function print_customer_details_listing()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $area = $_REQUEST['PARAM_1'];
    $folk = $_REQUEST['PARAM_2'];
    $more = $_REQUEST['PARAM_3'];
    $less = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    $dec = 0;
    if ($area == reserved_words::get_all_numeric()) {
        $area = 0;
    }
    if ($folk == reserved_words::get_all_numeric()) {
        $folk = 0;
    }
    if ($area == 0) {
        $sarea = tr('All Areas');
    } else {
        $sarea = get_area_name($area);
    }
    if ($folk == 0) {
        $salesfolk = tr('All Sales Folk');
    } else {
        $salesfolk = get_salesman_name($folk);
    }
    if ($more != '') {
        $morestr = tr('Greater than ') . number_format2($more, $dec);
    } else {
        $morestr = '';
    }
    if ($less != '') {
        $lessstr = tr('Less than ') . number_format2($less, $dec);
    } else {
        $lessstr = '';
    }
    $more = (double) $more;
    $less = (double) $less;
    $cols = array(0, 150, 300, 400, 550);
    $headers = array(tr('Customer Postal Address'), tr('Price/Turnover'), tr('Branch Contact Information'), tr('Branch Delivery Address'));
    $aligns = array('left', 'left', 'left', 'left');
    $params = array(0 => $comments, 1 => array('text' => tr('Activity Since'), 'from' => $from, 'to' => ''), 2 => array('text' => tr('Sales Areas'), 'from' => $sarea, 'to' => ''), 3 => array('text' => tr('Sales Folk'), 'from' => $salesfolk, 'to' => ''), 4 => array('text' => tr('Activity'), 'from' => $morestr, 'to' => $lessstr));
    $rep = new FrontReport(tr('Customer Details Listing'), "CustomerDetailsListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $result = get_customer_details_for_report($area, $folk);
    $carea = '';
    $sman = '';
    while ($myrow = db_fetch($result)) {
        $printcustomer = true;
        if ($more != '' || $less != '') {
            $turnover = getTransactions($myrow['debtor_no'], $myrow['branch_code'], $from);
            if ($more != 0.0 && $turnover <= (double) $more) {
                $printcustomer = false;
            }
            if ($less != 0.0 && $turnover >= (double) $less) {
                $printcustomer = false;
            }
        }
        if ($printcustomer) {
            if ($carea != $myrow['description']) {
                $rep->fontSize += 2;
                $rep->NewLine(2, 7);
                $rep->Font('bold');
                $rep->TextCol(0, 3, tr('Customers in') . " " . $myrow['description']);
                $carea = $myrow['description'];
                $rep->fontSize -= 2;
                $rep->Font();
                $rep->NewLine();
            }
            if ($sman != $myrow['salesman_name']) {
                $rep->fontSize += 2;
                $rep->NewLine(1, 7);
                $rep->Font('bold');
                $rep->TextCol(0, 3, $myrow['salesman_name']);
                $sman = $myrow['salesman_name'];
                $rep->fontSize -= 2;
                $rep->Font();
                $rep->NewLine();
            }
            $rep->NewLine();
            $rep->TextCol(0, 1, $myrow['name']);
            $adr = Explode("\n", $myrow['address']);
            $count1 = count($adr);
            for ($i = 0; $i < $count1; $i++) {
                $rep->TextCol(0, 1, $adr[$i], 0, ($i + 1) * $rep->lineHeight);
            }
            $count1++;
            $rep->TextCol(1, 2, tr('Price List') . ": " . $myrow['sales_type']);
            if ($more != 0.0 || $less != 0.0) {
                $rep->TextCol(1, 2, tr('Turnover') . ": " . number_format2($turnover, $dec), 0, $rep->lineHeight);
            }
            $rep->TextCol(2, 3, $myrow['br_name']);
            $rep->TextCol(2, 3, $myrow['contact_name'], 0, $rep->lineHeight);
            $rep->TextCol(2, 3, tr('Ph') . ": " . $myrow['phone'], 0, 2 * $rep->lineHeight);
            $rep->TextCol(2, 3, tr('Fax') . ": " . $myrow['fax'], 0, 3 * $rep->lineHeight);
            $adr = Explode("\n", $myrow['br_address']);
            $count2 = count($adr);
            for ($i = 0; $i < $count2; $i++) {
                $rep->TextCol(3, 4, $adr[$i], 0, ($i + 1) * $rep->lineHeight);
            }
            $rep->TextCol(3, 4, $myrow['email'], 0, ($count2 + 1) * $rep->lineHeight);
            $count2++;
            $count1 = Max($count1, $count2);
            $count1 = Max($count1, 4);
            $rep->NewLine($count1);
            $rep->Line($rep->row + 8);
            $rep->NewLine(0, 3);
        }
    }
    $rep->End();
}
Example #11
0
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $fromcust = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $destination = $_POST['PARAM_7'];
    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';
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == '') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($fromcust == '') {
        $fromc = _('All');
    } else {
        $fromc = get_customer_name($fromcust);
    }
    $cols = array(0, 50, 190, 320, 360, 400, 430, 460, 490, 550);
    $headers = array(_('Category'), _('Description'), _('Customer'), _('Invoice/CM #'), _(''), _('Qty'), _('Sales'), _('Cost'), _('Contribution'));
    if ($fromcust != '') {
        $headers[2] = '';
    }
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Customer'), 'from' => $fromc, 'to' => ''));
    $rep = new FrontReport(_('Inventory Sales Report'), "InventorySalesReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $location, $fromcust, $from, $to);
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 4, _('Total'));
                $rep->AmountCol(6, 7, $total, $dec);
                $rep->AmountCol(7, 8, $total1, $dec);
                $rep->AmountCol(8, 9, $total2, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $rep->NewLine();
                $total = $total1 = $total2 = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 6, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $curr = get_customer_currency($trans['debtor_no']);
        $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date']));
        $trans['amt'] *= $rate;
        $cb = $trans['amt'] - $trans['cost'];
        $rep->NewLine();
        $rep->fontSize -= 2;
        $rep->TextCol(0, 1, $trans['stock_id']);
        if ($fromcust == ALL_TEXT) {
            $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
            $rep->TextCol(2, 4, $trans['debtor_name']);
        } else {
            $rep->TextCol(1, 3, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
        }
        $salesman = get_salesman_name($trans['salesman']);
        $rep->TextCol(4, 5, $salesman);
        if ($trans['type'] == ST_CUSTCREDIT) {
            $rep->TextCol(3, 4, "CM#" . $trans['customized_no']);
        } else {
            $rep->TextCol(3, 4, $trans['customized_no']);
        }
        $rep->AmountCol(5, 6, $trans['qty'], get_qty_dec($trans['stock_id']));
        $rep->AmountCol(6, 7, $trans['amt'], $dec);
        $rep->AmountCol(7, 8, $trans['cost'], $dec);
        $rep->AmountCol(8, 9, $cb, $dec);
        $rep->fontSize += 2;
        $total += $trans['amt'];
        $total1 += $trans['cost'];
        $total2 += $cb;
        $grandtotal += $trans['amt'];
        $grandtotal1 += $trans['cost'];
        $grandtotal2 += $cb;
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 4, _('Total'));
    $rep->AmountCol(6, 7, $total, $dec);
    $rep->AmountCol(7, 8, $total1, $dec);
    $rep->AmountCol(8, 9, $total2, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(6, 7, $grandtotal, $dec);
    $rep->AmountCol(7, 8, $grandtotal1, $dec);
    $rep->AmountCol(8, 9, $grandtotal2, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}