4 // ----------------------------------------------------------------
6 // Creator: Janusz Dobrwolski
8 // Title: Print Delivery Notes
10 // ----------------------------------------------------------------
13 include_once($path_to_root . "includes/session.inc");
14 include_once($path_to_root . "includes/date_functions.inc");
15 include_once($path_to_root . "includes/data_checks.inc");
16 include_once($path_to_root . "sales/includes/sales_db.inc");
18 //----------------------------------------------------------------------------------------------------
20 // trial_inquiry_controls();
23 //----------------------------------------------------------------------------------------------------
25 function print_deliveries()
29 include_once($path_to_root . "reporting/includes/pdf_report.inc");
31 $from = $_POST['PARAM_0'];
32 $to = $_POST['PARAM_1'];
33 $email = $_POST['PARAM_2'];
34 $comments = $_POST['PARAM_3'];
40 $dec = user_price_dec();
42 $fno = explode("-", $from);
43 $tno = explode("-", $to);
45 $cols = array(4, 60, 225, 300, 325, 385, 450, 515);
47 // $headers in doctext.inc
48 $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right');
50 $params = array('comments' => $comments);
52 $cur = get_company_Pref('curr_default');
56 $rep = new FrontReport(_('DELIVERY'), "DeliveryNoteBulk.pdf", user_pagesize());
57 $rep->currency = $cur;
59 $rep->Info($params, $cols, null, $aligns);
62 for ($i = $fno[0]; $i <= $tno[0]; $i++)
64 if (!exists_customer_trans(13, $i))
66 $myrow = get_customer_trans($i, 13);
67 $branch = get_branch($myrow["branch_code"]);
68 $sales_order = get_sales_order_header($myrow["order_"]); // ?
71 $rep = new FrontReport("", "", user_pagesize());
72 $rep->currency = $cur;
74 $rep->title = _('DELIVERY NOTE');
75 $rep->filename = "Delivery" . $myrow['reference'] . ".pdf";
76 $rep->Info($params, $cols, null, $aligns);
79 $rep->title = _('DELIVERY NOTE');
80 $rep->Header2($myrow, $branch, $sales_order, '', 13);
82 $result = get_customer_trans_details(13, $i);
84 while ($myrow2=db_fetch($result))
86 $Net = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
89 $DisplayPrice = number_format2($myrow2["unit_price"],$dec);
90 $DisplayQty = number_format2($myrow2["quantity"],get_qty_dec($myrow2['stock_id']));
91 $DisplayNet = number_format2($Net,$dec);
92 if ($myrow2["discount_percent"]==0)
95 $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
96 $rep->TextCol(0, 1, $myrow2['stock_id'], -2);
97 $rep->TextCol(1, 2, $myrow2['StockDescription'], -2);
98 $rep->TextCol(2, 3, $DisplayQty, -2);
99 $rep->TextCol(3, 4, $myrow2['units'], -2);
100 $rep->TextCol(4, 5, $DisplayPrice, -2);
101 $rep->TextCol(5, 6, $DisplayDiscount, -2);
102 $rep->TextCol(6, 7, $DisplayNet, -2);
104 if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
105 $rep->Header2($myrow, $branch, $sales_order,'',13);
108 $comments = get_comments(13, $i);
109 if ($comments && db_num_rows($comments))
112 while ($comment=db_fetch($comments))
113 $rep->TextColLines(0, 6, $comment['memo_'], -2);
116 $DisplaySubTot = number_format2($SubTotal,$dec);
117 $DisplayFreight = number_format2($myrow["ov_freight"],$dec);
119 $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
122 if ($rep->currency != $myrow['curr_code'])
124 include($path_to_root . "reporting/includes/doctext2.inc");
128 include($path_to_root . "reporting/includes/doctext.inc");
131 $rep->TextCol(3, 6, $doc_Sub_total, -2);
132 $rep->TextCol(6, 7, $DisplaySubTot, -2);
134 $rep->TextCol(3, 6, $doc_Shipping, -2);
135 $rep->TextCol(6, 7, $DisplayFreight, -2);
137 $tax_items = get_customer_trans_tax_details(13, $i);
138 while ($tax_item = db_fetch($tax_items))
140 $DisplayTax = number_format2($tax_item['amount'], $dec);
141 if ($tax_item['included_in_price'])
143 $rep->TextCol(3, 7, $doc_Included . " " . $tax_item['tax_type_name'] .
144 " (" . $tax_item['rate'] . "%) " . $doc_Amount . ":" . $DisplayTax, -2);
148 $rep->TextCol(3, 6, $tax_item['tax_type_name'] . " (" .
149 $tax_item['rate'] . "%)", -2);
150 $rep->TextCol(6, 7, $DisplayTax, -2);
155 $DisplayTotal = number_format2($myrow["ov_freight"] +$myrow["ov_freight_tax"] + $myrow["ov_gst"] +
156 $myrow["ov_amount"],$dec);
158 $rep->TextCol(3, 6, $doc_TOTAL_DELIVERY, - 2);
159 $rep->TextCol(6, 7, $DisplayTotal, -2);
163 $myrow['dimension_id'] = $paylink; // helper for pmt link
164 if ($myrow['email'] == '')
166 $myrow['email'] = $branch['email'];
167 $myrow['DebtorName'] = $branch['br_name'];
169 $rep->End($email, $doc_Delivery_no . " " . $myrow['reference'], $myrow, 13);