- $sign = -1;
- $myrow = get_customer_trans($i, ST_CUSTCREDIT);
- $baccount = get_default_bank_account($myrow['curr_code']);
- $params['bankaccount'] = $baccount['id'];
-
- $branch = get_branch($myrow["branch_code"]);
- $branch['disable_branch'] = $paylink; // helper
- $sales_order = null;
- if ($email == 1)
- {
- $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
- $rep->title = _('CREDIT NOTE');
- $rep->filename = "CreditNote" . $myrow['reference'] . ".pdf";
- }
- $rep->SetHeaderType('Header2');
- $rep->currency = $cur;
- $rep->Font();
- $rep->Info($params, $cols, null, $aligns);
-
- $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], false);
- $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_CUSTCREDIT, $contacts);
- $rep->NewPage();
-
- $result = get_customer_trans_details(ST_CUSTCREDIT, $i);
- $SubTotal = 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"],$dec);
- $DisplayQty = number_format2($sign*$myrow2["quantity"],get_qty_dec($myrow2['stock_id']));
- $DisplayNet = number_format2($Net,$dec);
- if ($myrow2["discount_percent"]==0)
- $DisplayDiscount ="";
- else
- $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
- $rep->TextCol(0, 1, $myrow2['stock_id'], -2);
- $oldrow = $rep->row;
- $rep->TextColLines(1, 2, $myrow2['StockDescription'], -2);
- $newrow = $rep->row;
- $rep->row = $oldrow;
- $rep->TextCol(2, 3, $DisplayQty, -2);
- $rep->TextCol(3, 4, $myrow2['units'], -2);
- $rep->TextCol(4, 5, $DisplayPrice, -2);
- $rep->TextCol(5, 6, $DisplayDiscount, -2);
- $rep->TextCol(6, 7, $DisplayNet, -2);
- $rep->row = $newrow;
- //$rep->NewLine(1);
- if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
- $rep->NewPage();
- }