X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Fincludes%2Fdoctext.inc;h=f39254afee2f4a8fd830c47fd5188f43231b6296;hb=7e830126b96477e969fe3b48d9fc0e78f6c1fe00;hp=4d92c66444e3c941d5bb5b76b1ea3eca71bf1a92;hpb=26229b5446802a5fbc9582ede69c5a2ca5348a81;p=fa-stable.git diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index 4d92c664..f39254af 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -32,34 +32,48 @@ // for links use 'text' => 'url' $Footer[0] = _("All amounts stated in") . " - " . @$this->formData['curr_code']; + if (!in_array($this->formData['doctype'], array(ST_STATEMENT, ST_WORKORDER))) + { + $id = $this->formData['payment_terms']; + $sql = "SELECT terms, days_before_due FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id); + $result = db_query($sql,"could not get paymentterms"); + $row = db_fetch($result); + $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"]; + if ($this->formData['doctype'] == ST_SALESINVOICE && $this->formData['prepaid']) + $this->formData['prepaid'] = ($row['days_before_due'] >= 0) ? 'final' : 'partial'; + } + + switch ($this->formData['doctype']) { case ST_SALESQUOTE: $this->title = _("SALES QUOTATION"); $this->formData['document_name'] =_("Quotation No."); $this->formData['document_date'] = $this->formData['ord_date']; - $this->formData['document_number'] = $this->formData['order_no']; + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : $this->formData['order_no']; $aux_info = array( _("Customers Reference") => $this->formData["customer_ref"], _("Sales Person") => get_salesman_name($this->formData['salesman']), - _("Your VAT no.") => '', - _("Our Order No") => '', + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Quotation No") => $this->formData['order_no'], _("Valid until") => sql2date($this->formData['delivery_date']), ); break; case ST_SALESORDER: - $this->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER")); + $this->title = ($print_as_quote==1 ? _("QUOTE") : ($this->formData['prepaid'] ? _("PREPAYMENT ORDER") : _("SALES ORDER"))); $this->formData['document_name'] =_("Order No."); $this->formData['document_date'] = $this->formData['ord_date']; - $this->formData['document_number'] = $this->formData['order_no']; + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : $this->formData['order_no']; $this->formData['document_amount'] = $this->formData['order_no']; $aux_info = array( _("Customers Reference") => $this->formData["customer_ref"], _("Sales Person") => get_salesman_name($this->formData['salesman']), - _("Your VAT no.") => '', - _("Our Order No") => '', + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => $this->formData['order_no'], _("Delivery Date") => sql2date($this->formData['delivery_date']), ); break; @@ -100,7 +114,8 @@ break; case ST_SALESINVOICE: - $this->title = _("INVOICE"); + $this->title = $this->formData['prepaid']=='partial' ? _("PREPAYMENT INVOICE") + : ($this->formData['prepaid']=='final' ? _("FINAL INVOICE") : _("INVOICE")); $this->formData['document_name'] =_("Invoice No."); $this->formData['domicile'] = $this->company['domicile']; $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code']; @@ -116,9 +131,18 @@ _("Customers Reference") => $this->formData["customer_ref"], _("Sales Person") => get_salesman_name($this->formData['salesman']), _("Your VAT no.") => $this->formData['tax_id'], - _("Delivery Note No.") => implode(',', $deliveries), - _("Due Date") => sql2date($this->formData['due_date']), ); + if ($this->formData['prepaid']=='partial') + { + $aux_info[_("Date of Payment")] = sql2date(get_oldest_payment_date($this->formData['trans_no'])); + $aux_info[_("Our Order No")] = $this->formData['order_']; + } else { + if ($this->formData['prepaid'] =='final') + $aux_info[_("Invoice Date")] = sql2date($this->formData['tran_date']); + else + $aux_info[_("Date of Sale")] = sql2date(get_oldest_delivery_date($this->formData['trans_no'])); + $aux_info[_("Due Date")] = sql2date($this->formData['due_date']); + } break; case ST_SUPPAYMENT: @@ -151,9 +175,10 @@ $Addr1['address'] = $this->formData['address']; $Addr2['title'] = _("Deliver To"); $Addr2['name'] = $this->company['coy_name']; - $Addr2['address'] = $this->company['postal_address']; + //$Addr2['address'] = $this->company['postal_address']; No, don't destroy delivery address! $this->formData['document_date'] = $this->formData['ord_date']; - $this->formData['document_number'] = $this->formData['order_no']; + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : $this->formData['order_no']; $aux_info = array( _("Customers Reference") => $this->formData['supp_account_no'], @@ -230,15 +255,6 @@ $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) ? $this->formData['reference'] : @$this->formData['trans_no']; - if (!isset($Payment_Terms)) - { - $id = $this->formData['payment_terms']; - $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id); - $result = db_query($sql,"could not get paymentterms"); - $row = db_fetch($result); - $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"]; - } - // footer generic content if (@$this->formData['bank_name']) $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number']; @@ -267,5 +283,3 @@ foreach(explode("\n", $this->company['legal_text']) as $line) $Footer[] = $line; } - -?>