function can_process() { if (!check_num('po_over_receive', 0, 100)) { display_error(_("The delivery over-receive allowance must be between 0 and 100.")); set_focus('po_over_receive'); return false; } if (!check_num('po_over_charge', 0, 100)) { display_error(_("The invoice over-charge allowance must be between 0 and 100.")); set_focus('po_over_charge'); return false; } if (!check_num('past_due_days', 0, 100)) { display_error(_("The past due days interval allowance must be between 0 and 100.")); set_focus('past_due_days'); return false; } $grn_act = get_company_pref('grn_clearing_act'); if (get_post('grn_clearing_act') != $grn_act && db_num_rows(get_grn_items(0, '', true))) { display_error(_("Before GRN Clearing Account can be changed all GRNs have to be invoiced")); $_POST['grn_clearing_act'] = $grn_act; set_focus('grn_clearing_account'); return false; } if (!is_account_balancesheet(get_post('retained_earnings_act')) || is_account_balancesheet(get_post('profit_loss_year_act'))) { display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)")); return false; } return true; }
function display_customer_summary($customer_record) { global $table_style; $past1 = get_company_pref('past_due_days'); $past2 = 2 * $past1; if ($customer_record["dissallow_invoices"] != 0) { echo "<center><font color=red size=4><b>" . tr("CUSTOMER ACCOUNT IS ON HOLD") . "</font></b></center>"; } $nowdue = "1-" . $past1 . " " . tr('Days'); $pastdue1 = $past1 + 1 . "-" . $past2 . " " . tr('Days'); $pastdue2 = tr('Over') . " " . $past2 . " " . tr('Days'); start_table("width=80% {$table_style}"); $th = array(tr("Currency"), tr("Terms"), tr("Current"), $nowdue, $pastdue1, $pastdue2, tr("Total Balance")); table_header($th); start_row(); label_cell($customer_record["curr_code"]); label_cell($customer_record["terms"]); amount_cell($customer_record["Balance"] - $customer_record["Due"]); amount_cell($customer_record["Due"] - $customer_record["Overdue1"]); amount_cell($customer_record["Overdue1"] - $customer_record["Overdue2"]); amount_cell($customer_record["Overdue2"]); amount_cell($customer_record["Balance"]); end_row(); end_table(); }
function gl_inquiry_controls() { $dim = get_company_pref('use_dimension'); start_form(); start_table(TABLESTYLE_NOBORDER); $date = today(); if (!isset($_POST['TransFromDate'])) { $_POST['TransFromDate'] = begin_month($date); } if (!isset($_POST['TransToDate'])) { $_POST['TransToDate'] = end_month($date); } date_cells(_("From:"), 'TransFromDate'); date_cells(_("To:"), 'TransToDate'); if ($dim >= 1) { dimensions_list_cells(_("Dimension") . " 1:", 'Dimension', null, true, " ", false, 1); } if ($dim > 1) { dimensions_list_cells(_("Dimension") . " 2:", 'Dimension2', null, true, " ", false, 2); } check_cells(_("No zero values"), 'NoZero', null); check_cells(_("Only balances"), 'Balance', null); submit_cells('Show', _("Show"), '', '', 'default'); end_table(); end_form(); }
function check_can_delete($curr) { if ($curr == "") { return false; } // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master if (key_in_foreign_table($curr, 'debtors_master', 'curr_code')) { display_error(_("Cannot delete this currency, because customer accounts have been created referring to this currency.")); return false; } if (key_in_foreign_table($curr, 'suppliers', 'curr_code')) { display_error(_("Cannot delete this currency, because supplier accounts have been created referring to this currency.")); return false; } if ($curr == get_company_pref('curr_default')) { display_error(_("Cannot delete this currency, because the company preferences uses this currency.")); return false; } // see if there are any bank accounts that use this currency if (key_in_foreign_table($curr, 'bank_accounts', 'bank_curr_code')) { display_error(_("Cannot delete this currency, because thre are bank accounts that use this currency.")); return false; } return true; }
function write_customer($email, $name, $company, $address, $phone, $fax, $currency) { global $paypal_sales_type_id, $paypal_tax_group_id, $paypal_salesman, $paypal_area, $paypal_location, $paypal_credit_status, $paypal_shipper; global $SysPrefs; log_message("Memory, write_customer start:" . memory_get_usage()); $customer_id = find_customer_by_email($email); if (empty($customer_id)) { $customer_id = find_customer_by_name($company); } if (empty($customer_id)) { //it is a new customer begin_transaction(); add_customer($company, substr($company, 0, 30), $address, '', $currency, 0, 0, $paypal_credit_status, -1, 0, 0, $SysPrefs->default_credit_limit(), $paypal_sales_type_id, 'PayPal'); $customer_id = db_insert_id(); add_branch($customer_id, $company, substr($company, 0, 30), $address, $paypal_salesman, $paypal_area, $paypal_tax_group_id, '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $paypal_location, $address, 0, 0, $paypal_shipper, 'PayPal'); $selected_branch = db_insert_id(); $nameparts = explode(" ", $name); $firstname = ""; for ($i = 0; $i < count($nameparts) - 1; $i++) { if (!empty($firstname)) { $firstname .= " "; } $firstname .= $nameparts[$i]; } $lastname = $nameparts[count($nameparts) - 1]; add_crm_person('paypal', $firstname, $lastname, $address, $phone, '', $fax, $email, '', ''); add_crm_contact('customer', 'general', $selected_branch, db_insert_id()); commit_transaction(); } else { $selected_branch = 0; } log_message("Memory, write_customer end:" . memory_get_usage()); return array($customer_id, $selected_branch); }
function inquiry_controls() { $dim = get_company_pref('use_dimension'); start_table(TABLESTYLE_NOBORDER); date_cells(_("As at:"), 'TransToDate'); if ($dim >= 1) { dimensions_list_cells(_("Dimension") . " 1:", 'Dimension', null, true, " ", false, 1); } if ($dim > 1) { dimensions_list_cells(_("Dimension") . " 2:", 'Dimension2', null, true, " ", false, 2); } submit_cells('Show', _("Show"), '', '', 'default'); end_table(); hidden('TransFromDate'); hidden('AccGrp'); }
function dimensions_app() { $dim = get_company_pref('use_dimension'); $this->application("proj", _($this->help_context = "&Dimensions"), $dim); if ($dim > 0) { $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Dimension &Entry"), "dimensions/dimension_entry.php?", 'SA_DIMENSION', MENU_ENTRY); $this->add_lapp_function(0, _("&Outstanding Dimensions"), "dimensions/inquiry/search_dimensions.php?outstanding_only=1", 'SA_DIMTRANSVIEW', MENU_TRANSACTION); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Dimension &Inquiry"), "dimensions/inquiry/search_dimensions.php?", 'SA_DIMTRANSVIEW', MENU_INQUIRY); $this->add_rapp_function(1, _("Dimension &Reports"), "reporting/reports_main.php?Class=4", 'SA_DIMENSIONREP', MENU_REPORT); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Dimension &Tags"), "admin/tags.php?type=dimension", 'SA_DIMTAGS', MENU_MAINTENANCE); $this->add_extensions(); } }
function display_supplier_summary($supplier_record) { $past1 = get_company_pref('past_due_days'); $past2 = 2 * $past1; $nowdue = "1-" . $past1 . " " . _('Days'); $pastdue1 = $past1 + 1 . "-" . $past2 . " " . _('Days'); $pastdue2 = _('Over') . " " . $past2 . " " . _('Days'); start_table(TABLESTYLE, "width='80%'"); $th = array(_("Currency"), _("Terms"), _("Current"), $nowdue, $pastdue1, $pastdue2, _("Total Balance")); table_header($th); start_row(); label_cell($supplier_record["curr_code"]); label_cell($supplier_record["terms"]); amount_cell($supplier_record["Balance"] - $supplier_record["Due"]); amount_cell($supplier_record["Due"] - $supplier_record["Overdue1"]); amount_cell($supplier_record["Overdue1"] - $supplier_record["Overdue2"]); amount_cell($supplier_record["Overdue2"]); amount_cell($supplier_record["Balance"]); end_row(); end_table(1); }
function inquiry_controls() { global $Ajax; $dim = get_company_pref('use_dimension'); start_table(TABLESTYLE_NOBORDER); $date = today(); if (!isset($_POST['TransFromDate'])) { $_POST['TransFromDate'] = begin_month($date); } if (!isset($_POST['TransToDate'])) { $_POST['TransToDate'] = end_month($date); } date_cells(_("From:"), 'TransFromDate'); date_cells(_("To:"), 'TransToDate'); type_list_cells(_("Category: "), 'typeId', null, true); $r = set(); account_list_cells(_(""), 'accountId', $r); submit_cells('submit_submit', _("Generate Report"), true, '', 'default'); //submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), 'default'); end_table(); }
function check_inputs() { global $Refs; if (!get_post('supplier_id')) { display_error(_("There is no supplier selected.")); set_focus('supplier_id'); return false; } if (@$_POST['amount'] == "") { $_POST['amount'] = price_format(0); } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('amount'); return false; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('charge'); return false; } if (isset($_POST['charge']) && input_num('charge') > 0) { $charge_acct = get_company_pref('bank_charge_act'); if (get_gl_account($charge_acct) == false) { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } } if (@$_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount', 0)) { display_error(_("The entered discount is invalid or less than zero.")); set_focus('amount'); return false; } //if (input_num('amount') - input_num('discount') <= 0) if (input_num('amount') <= 0) { display_error(_("The total of the amount and the discount is zero or negative. Please enter positive values.")); set_focus('amount'); return false; } if (isset($_POST['bank_amount']) && input_num('bank_amount') <= 0) { display_error(_("The entered bank amount is zero or negative.")); set_focus('bank_amount'); return false; } if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); set_focus('DatePaid'); return false; } elseif (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is out of fiscal year or is closed for further data entry.")); set_focus('DatePaid'); return false; } $limit = get_bank_account_limit($_POST['bank_account'], $_POST['DatePaid']); if ($limit !== null && floatcmp($limit, input_num('amount')) < 0) { display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); set_focus('amount'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], ST_SUPPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!db_has_currency_rates(get_supplier_currency($_POST['supplier_id']), $_POST['DatePaid'], true)) { return false; } $_SESSION['alloc']->amount = -input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
} else { display_notification_centered(_("Purchase Order has been updated") . " #{$order_no}"); } display_note(get_trans_view_str($trans_type, $order_no, _("&View this order")), 0, 1); display_note(print_document_link($order_no, _("&Print This Order"), true, $trans_type), 0, 1); display_note(print_document_link($order_no, _("&Email This Order"), true, $trans_type, false, "printlink", "", 1)); hyperlink_params($path_to_root . "/purchasing/po_receive_items.php", _("&Receive Items on this Purchase Order"), "PONumber={$order_no}"); hyperlink_params($_SERVER['PHP_SELF'], _("Enter &Another Purchase Order"), "NewOrder=yes"); hyperlink_no_params($path_to_root . "/purchasing/inquiry/po_search.php", _("Select An &Outstanding Purchase Order")); display_footer_exit(); } elseif (isset($_GET['AddedGRN'])) { $trans_no = $_GET['AddedGRN']; $trans_type = ST_SUPPRECEIVE; display_notification_centered(_("Direct GRN has been entered")); display_note(get_trans_view_str($trans_type, $trans_no, _("&View this GRN")), 0); $clearing_act = get_company_pref('grn_clearing_act'); if ($clearing_act) { display_note(get_gl_view_str($trans_type, $trans_no, _("View the GL Journal Entries for this Delivery")), 1); } // not yet // display_note(print_document_link($trans_no, _("&Print This GRN"), true, $trans_type), 0, 1); hyperlink_params("{$path_to_root}/purchasing/supplier_invoice.php", _("Entry purchase &invoice for this receival"), "New=1"); hyperlink_params("{$path_to_root}/admin/attachments.php", _("Add an Attachment"), "filterType={$trans_type}&trans_no={$trans_no}"); hyperlink_params($_SERVER['PHP_SELF'], _("Enter &Another GRN"), "NewGRN=Yes"); display_footer_exit(); } elseif (isset($_GET['AddedPI'])) { $trans_no = $_GET['AddedPI']; $trans_type = ST_SUPPINVOICE; display_notification_centered(_("Direct Purchase Invoice has been entered")); display_note(get_trans_view_str($trans_type, $trans_no, _("&View this Invoice")), 0); // not yet
function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report2.inc"; $from = date2sql($_POST['PARAM_0']); $to = date2sql($_POST['PARAM_1']); $customer = $_POST['PARAM_2']; $currency = $_POST['PARAM_3']; $email = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $orientation = $orientation ? 'L' : 'P'; $dec = 2; $cols = array(4, 64, 180, 250, 300, 350, 400, 480); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('CUSTOMER ACCOUNT STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT b.debtor_no, b.name AS DebtorName, b.address, b.tax_id, b.curr_code, cust.salesman, \n\tcurdate() AS tran_date, CONCAT (d.name, d.name2) AS contactPerson, d.phone, d.phone2 \n\tFROM " . TB_PREF . "debtors_master b INNER JOIN\n" . TB_PREF . "crm_contacts c on b.debtor_no=c.entity_id INNER JOIN " . TB_PREF . "crm_persons d on c.person_id=d.id\nINNER JOIN " . TB_PREF . "cust_branch cust on b.debtor_no=cust.debtor_no"; if ($customer != ALL_TEXT) { $sql .= " WHERE c.type='customer' and cust.salesman = " . db_escape($customer); } else { $sql .= " where c.type='customer' and cust.salesman = " . db_escape($customer) . " ORDER by b.name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($debtor_row = db_fetch($result)) { $date = date('Y-m-d'); if ($from != $to) { // find the latest point where the balance was null $start = findLatestNullDate($debtor_row['debtor_no'], $from); // but not earlier than the $to date. if (date1_greater_date2(sql2date($start), sql2date($to))) { $start = $to; } if (date1_greater_date2(sql2date($from), sql2date($start))) { $start = $from; } } else { $start = $from; } $debtor_row['order_'] = ""; $TransResult = getTransactions($debtor_row['debtor_no'], $start, $date); $baccount = get_default_bank_account($debtor_row['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("CUSTOMER ACCOUNT STATEMENT", "", user_pagesize(), 9, $orientation); $rep->title = _('STATEMENT OF ACCOUNT'); $rep->filename = "Statement" . $debtor_row['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $rep->filename = "ST-" . strtr($debtor_row['DebtorName'], " '", "__") . "--" . strtr(Today(), "/", "-") . ".pdf"; $contacts = get_customer_contacts($debtor_row['debtor_no'], 'invoice'); $rep->SetHeaderType('customheader'); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); $rep->SetCommonData($debtor_row, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $doctype = ST_STATEMENT; //$rep->TextCol(0,4,"yeah"); $current = false; $balance = getInitialBalance($debtor_row['debtor_no'], $start); if (true || Abs($balance) > 1.0E-6) { if (Abs($balance) < 1.0E-6) { $rep->SetTextColor(190, 190, 190); } else { if ($balance > 0) { $rep->SetTextColor(190, 0, 0); } } $rep->SetTextColor(0, 0, 0); } $overdue = 0; $prev = ''; $gross_amount = 0; $gross_amount2 = 0; $payment_tot = 0; $tots = 0; $discount_amount = 0; $percent = 0; while ($transaction_row = db_fetch($TransResult)) { if ($myrow['IsVoid'] == '') { $company_data = get_company_prefs(); $branch = get_branch($transaction_row["branch_code"]); $branch_data = get_branch_accounts($transaction_row['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $transaction_row['type'], $transaction_row['trans_no']); $DisplayTotal = number_format2(Abs($transaction_row["TotalAmount"] + $dt), $dec); $DisplayAlloc = number_format2($transaction_row["Allocated"], $dec); $DisplayNet = number_format2($transaction_row["TotalAmount"] - $transaction_row["Allocated"], $dec); /*if ($dt != 0 && $transaction_row['type'] == ST_SALESINVOICE || $transaction_row['type'] == ST_CUSTCREDIT) { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; }*/ $amount = $transaction_row["TotalAmount"] + $dt; $balance += $transaction_row["TotalAmount"]; $invoice_no = get_custom_no($transaction_row['trans_no'], $transaction_row['type']); $enter1 = 0; if ($systypes_array[$transaction_row['type']] == "Customer Payment") { $open_pay = get_payment_invoice_details($transaction_row["trans_no"], ST_CUSTPAYMENT); if ($open_pay) { $stat2 = false; } else { $stat2 = true; $payment_tot += $amount; $text = "pr#"; } } if ($systypes_array[$transaction_row['type']] == "Sales Invoice") { if ($transaction_row['ov_amount'] > $transaction_row['alloc'] || $transaction_row['alloc'] == 0) { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; $gross_amount += $amount; $text = ''; $stat3 = true; } else { $stat3 = false; } } if ($systypes_array[$transaction_row['type']] == "Customer Credit Note") { $open = get_sales_invoice_details($transaction_row['order_'], ST_SALESINVOICE); if ($open) { $stat = false; } else { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; $gross_amount2 += $amount; $stat = true; } $text = "cm#"; } $current = $text; $tot = $gross_amount + $gross_amount2 - $discount_amount; if ($current != '') { if ($prev == $current) { } else { if ($prev == "" && $text == "cm#" && $stat) { $rep->NewLine(); $rep->TextCol(1, 2, "Less Returns"); $rep->NewLine(); } if ($text == 'pr#' && $prev == "cm#" && $stat2) { $rep->AmountCol(6, 7, $tot, 2); $rep->NewLine(2); $rep->TextCol(1, 2, "Less Payments:"); $rep->NewLine(); } if ($prev == '' && $text == 'pr#' && $stat2) { $rep->TextCol(1, 2, "Less Payments:"); $rep->NewLine(); } } $prev = $current; } if ($transaction_row['type'] == ST_SALESINVOICE && $stat3) { $rep->TextCol(1, 2, $text . $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(3, 4, $DisplayTotal, -2); $rep->NewLine(); } if ($transaction_row['type'] == ST_CUSTCREDIT && $stat) { $rep->TextCol(1, 2, $text . $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(3, 4, $DisplayTotal, -2); $rep->NewLine(); } if ($transaction_row['type'] == ST_CUSTPAYMENT && $stat2) { if ($invoice_no == "") { $rep->TextCol(1, 2, $text . $transaction_row['reference'], -2); } else { $rep->TextCol(1, 2, $text . $invoice_no, -2); } $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(5, 6, $DisplayTotal, -2); $rep->NewLine(); } $rep->SetTextColor(0, 0, 0); //$rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->NewPage(); } } } if (!$current) { $overdue = $balance; $balance = 0; } $rep->NewLine(); $net = $gross_amount - abs($gross_amount2); $percent = $ctr / $net * 100; $per = number_format2($percent, 2); if ($per != 0) { $rep->TextCol(1, 2, "Less " . $ctr . "% discount"); $rep->AmountCol(5, 6, $discount_amount, 2); } $rep->SetTextColor(0, 0, 0); $rep->fontSize += 2; $rep->NewLine(5); $rep->TextCol(1, 2, 'Amount Due'); //$rep->TextCol(6,7, " ____________", -2); if ($payment_tot != 0) { $rep->TextCol(6, 7, number_format2($tot - abs($payment_tot), $dec)); } else { $rep->AmountCol(6, 7, $tot, 2); } $rep->NewLine(5); $rep->TextCol(2, 4, "Verified & Checked by:"); $rep->TextCol(4, 6, "___________________"); $rep->NewLine(); $rep->TextCol(4, 6, "Credit & Collection"); $rep->fontSize -= 2; } //$rep->NewPage(); if ($email == 0) { $rep->End(); } }
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 print_trial_balance() { global $path_to_root; global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $zero = $_POST['PARAM_2']; $balances = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } 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(); $cols2 = array(0, 50, 190, 310, 430, 530); //-------------0--1---2----3----4----5-- $headers2 = array('', '', _('Brought Forward'), _('This Period'), _('Balance')); $aligns2 = array('left', 'left', 'left', 'left', 'left'); $cols = array(0, 50, 150, 210, 270, 330, 390, 450, 510, 570); //------------0--1---2----3----4----5----6----7----8-- $headers = array(_('Account'), _('Account Name'), _('Debit'), _('Credit'), _('Debit'), _('Credit'), _('Debit'), _('Credit')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(_('Trial Balance'), "TrialBalance", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); recalculate_cols($cols2); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); $classresult = get_account_classes(false); while ($class = db_fetch($classresult)) { $rep->Font('bold'); $rep->TextCol(0, 1, $class['cid']); $rep->TextCol(1, 4, $class['class_name']); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2); } $rep->NewLine(); } $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); if ($balances == 0) { $rep->TextCol(0, 2, _("Total")); $rep->AmountCol(2, 3, $pdeb, $dec); $rep->AmountCol(3, 4, $pcre, $dec); $rep->AmountCol(4, 5, $cdeb, $dec); $rep->AmountCol(5, 6, $ccre, $dec); $rep->AmountCol(6, 7, $tdeb, $dec); $rep->AmountCol(7, 8, $tcre, $dec); $rep->NewLine(); } $rep->TextCol(0, 2, _("Ending Balance")); if ($pbal >= 0.0) { $rep->AmountCol(2, 3, $pbal, $dec); } else { $rep->AmountCol(3, 4, abs($pbal), $dec); } if ($cbal >= 0.0) { $rep->AmountCol(4, 5, $cbal, $dec); } else { $rep->AmountCol(5, 6, abs($cbal), $dec); } if ($tbal >= 0.0) { $rep->AmountCol(6, 7, $tbal, $dec); } else { $rep->AmountCol(7, 8, abs($tbal), $dec); } $rep->NewLine(); $rep->Line($rep->row + 10); if (($pbal = round2($pbal, $dec)) != 0.0 && $dimension == 0 && $dimension2 == 0) { $rep->NewLine(2); $rep->Font(); $rep->TextCol(0, 8, _("The Opening Balance is not in balance, probably due to a non closed Previous Fiscalyear.")); } $rep->End(); }
function print_GL_transactions() { global $path_to_root, $systypes_array; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $fromacc = $_POST['PARAM_2']; $toacc = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } 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'; $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize(), 9, $orientation); $dec = 2; //$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', 'left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension') . " 1", _('Dimension') . " 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } elseif ($dim == 1) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } else { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc)); } } if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $accounts = get_gl_accounts($fromacc, $toacc); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) { $begin = $from; } $begin = add_days($begin, -1); } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2); $rows = db_num_rows($trans); if ($prev_balance == 0.0 && $rows == 0) { continue; } $rep->Font('bold'); $rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2); $rep->TextCol(4, 6, _('Opening Balance')); if ($prev_balance > 0.0) { $rep->AmountCol(7, 8, abs($prev_balance), $dec); } else { $rep->AmountCol(8, 9, abs($prev_balance), $dec); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); if ($rows > 0) { while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $type_name = $systypes_array[$myrow["type"]]; if ($type_name == "Customer Payment") { $rep->TextCol(0, 1, "CRB", -2); } if ($type_name == "Cash Disbursement/Check Voucher") { $rep->TextCol(0, 1, "CDB", -2); } if ($type_name == "Journal Entry") { $rep->TextCol(0, 1, "JB", -2); } if ($type_name == "Customer Credit Note") { $type_name = "Credit Memo"; } if ($type_name == "Sales Invoice") { $type_name = "Invoice"; } else { if ($type_name != "Customer Payment" && $type_name != "Cash Disbursement/Check Voucher" && $type_name != "Journal Entry") { $rep->TextCol(0, 1, $type_name, -2); } } $reference = get_reference($myrow["type"], $myrow["type_no"]); $rep->TextCol(1, 2, $reference); $rep->TextCol(2, 3, $myrow['type_no'], -2); $rep->DateCol(3, 4, $myrow["tran_date"], true); if ($dim >= 1) { $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id'])); } if ($dim > 1) { $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id'])); } $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false); $memo = $myrow['memo_']; if ($txt != "") { if ($memo != "") { $txt = $txt . "/" . $memo; } } else { $txt = $memo; } $rep->TextCol(6, 7, $txt, -2); if ($myrow['amount'] > 0.0) { $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); } else { $rep->AmountCol(8, 9, abs($myrow['amount']), $dec); } $rep->TextCol(9, 10, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(7, 8, abs($total), $dec); } else { $rep->AmountCol(8, 9, abs($total), $dec); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
function can_process() { global $Refs; if (!get_post('customer_id')) { display_error(_("There is no customer selected.")); set_focus('customer_id'); return false; } if (!get_post('BranchID')) { display_error(_("This customer has no branch defined.")); set_focus('BranchID'); return false; } if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) { display_error(_("The entered date is invalid. Please enter a valid date for the payment.")); set_focus('DateBanked'); return false; } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('DateBanked'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } //Chaitanya : 13-OCT-2011 - To support Edit feature if (isset($_POST['trans_no']) && $_POST['trans_no'] == 0 && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } elseif ($_POST['ref'] != $_POST['old_ref'] && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); set_focus('amount'); return false; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); set_focus('charge'); return false; } if (isset($_POST['charge']) && input_num('charge') > 0) { $charge_acct = get_company_pref('bank_charge_act'); if (get_gl_account($charge_acct) == false) { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } } if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 1.0E-6)) { display_error(_("The exchange rate must be numeric and greater than zero.")); set_focus('_ex_rate'); return false; } if ($_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount')) { display_error(_("The entered discount is not a valid number.")); set_focus('discount'); return false; } //if ((input_num('amount') - input_num('discount') <= 0)) { if (input_num('amount') <= 0) { display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts.")); set_focus('discount'); return false; } if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) { return false; } $_SESSION['alloc']->amount = input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
function inquiry_controls() { $dim = get_company_pref('use_dimension'); start_table(TABLESTYLE_NOBORDER); $date = today(); if (!isset($_POST['TransFromDate'])) { $_POST['TransFromDate'] = begin_month($date); } if (!isset($_POST['TransToDate'])) { $_POST['TransToDate'] = end_month($date); } date_cells(_("From:"), 'TransFromDate'); date_cells(_("To:"), 'TransToDate'); //Compare Combo global $sel; $sel = array(_("Accumulated"), _("Period Y-1"), _("Budget")); echo "<td>" . _("Compare to") . ":</td>\n"; echo "<td>"; echo array_selector('Compare', null, $sel); echo "</td>\n"; if ($dim >= 1) { dimensions_list_cells(_("Dimension") . " 1:", 'Dimension', null, true, " ", false, 1); } if ($dim > 1) { dimensions_list_cells(_("Dimension") . " 2:", 'Dimension2', null, true, " ", false, 2); } submit_cells('Show', _("Show"), '', '', 'default'); end_table(); hidden('AccGrp'); }
function supplier_settings(&$supplier_id) { start_outer_table(TABLESTYLE2); table_section(1); if ($supplier_id) { //SupplierID exists - either passed when calling the form or from the form itself $myrow = get_supplier($_POST['supplier_id']); $_POST['supp_name'] = $myrow["supp_name"]; $_POST['supp_ref'] = $myrow["supp_ref"]; $_POST['address'] = $myrow["address"]; $_POST['supp_address'] = $myrow["supp_address"]; $_POST['gst_no'] = $myrow["gst_no"]; $_POST['website'] = $myrow["website"]; $_POST['supp_account_no'] = $myrow["supp_account_no"]; $_POST['bank_account'] = $myrow["bank_account"]; $_POST['dimension_id'] = $myrow["dimension_id"]; $_POST['dimension2_id'] = $myrow["dimension2_id"]; $_POST['curr_code'] = $myrow["curr_code"]; $_POST['payment_terms'] = $myrow["payment_terms"]; $_POST['credit_limit'] = price_format($myrow["credit_limit"]); $_POST['tax_group_id'] = $myrow["tax_group_id"]; $_POST['tax_included'] = $myrow["tax_included"]; $_POST['payable_account'] = $myrow["payable_account"]; $_POST['purchase_account'] = $myrow["purchase_account"]; $_POST['payment_discount_account'] = $myrow["payment_discount_account"]; $_POST['notes'] = $myrow["notes"]; $_POST['inactive'] = $myrow["inactive"]; } else { $_POST['supp_name'] = $_POST['supp_ref'] = $_POST['address'] = $_POST['supp_address'] = $_POST['tax_group_id'] = $_POST['website'] = $_POST['supp_account_no'] = $_POST['notes'] = ''; $_POST['dimension_id'] = 0; $_POST['dimension2_id'] = 0; $_POST['tax_included'] = 0; $_POST['sales_type'] = -1; $_POST['gst_no'] = $_POST['bank_account'] = ''; $_POST['payment_terms'] = ''; $_POST['credit_limit'] = price_format(0); $company_record = get_company_prefs(); $_POST['curr_code'] = $company_record["curr_default"]; $_POST['payable_account'] = $company_record["creditors_act"]; $_POST['purchase_account'] = ''; // default/item's cogs account $_POST['payment_discount_account'] = $company_record['pyt_discount_act']; } table_section_title(_("Basic Data")); text_row(_("Supplier Name:"), 'supp_name', null, 42, 40); text_row(_("Supplier Short Name:"), 'supp_ref', null, 30, 30); text_row(_("GSTNo:"), 'gst_no', null, 42, 40); link_row(_("Website:"), 'website', null, 35, 55); if ($supplier_id && !is_new_supplier($supplier_id) && (key_in_foreign_table($_POST['supplier_id'], 'supp_trans', 'supplier_id') || key_in_foreign_table($_POST['supplier_id'], 'purch_orders', 'supplier_id'))) { label_row(_("Supplier's Currency:"), $_POST['curr_code']); hidden('curr_code', $_POST['curr_code']); } else { currencies_list_row(_("Supplier's Currency:"), 'curr_code', null); } tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null); text_row(_("Our Customer No:"), 'supp_account_no', null, 42, 40); table_section_title(_("Purchasing")); text_row(_("Bank Name/Account:"), 'bank_account', null, 42, 40); amount_row(_("Credit Limit:"), 'credit_limit', null); payment_terms_list_row(_("Payment Terms:"), 'payment_terms', null); // // tax_included option from supplier record is used directly in update_average_cost() function, // therefore we can't edit the option after any transaction waas done for the supplier. // if (is_new_supplier($supplier_id)) { check_row(_("Prices contain tax included:"), 'tax_included'); } else { hidden('tax_included'); label_row(_("Prices contain tax included:"), $_POST['tax_included'] ? _('Yes') : _('No')); } table_section_title(_("Accounts")); gl_all_accounts_list_row(_("Accounts Payable Account:"), 'payable_account', $_POST['payable_account']); gl_all_accounts_list_row(_("Purchase Account:"), 'purchase_account', $_POST['purchase_account'], false, false, _("Use Item Inventory/COGS Account")); gl_all_accounts_list_row(_("Purchase Discount Account:"), 'payment_discount_account', $_POST['payment_discount_account']); if (!$supplier_id) { table_section_title(_("Contact Data")); text_row(_("Phone Number:"), 'phone', null, 32, 30); text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30); } table_section(2); $dim = get_company_pref('use_dimension'); if ($dim >= 1) { table_section_title(_("Dimension")); dimensions_list_row(_("Dimension") . " 1:", 'dimension_id', null, true, " ", false, 1); if ($dim > 1) { dimensions_list_row(_("Dimension") . " 2:", 'dimension2_id', null, true, " ", false, 2); } } if ($dim < 1) { hidden('dimension_id', 0); } if ($dim < 2) { hidden('dimension2_id', 0); } table_section_title(_("Addresses")); textarea_row(_("Mailing Address:"), 'address', null, 35, 5); textarea_row(_("Physical Address:"), 'supp_address', null, 35, 5); table_section_title(_("General")); textarea_row(_("General Notes:"), 'notes', null, 35, 5); if ($supplier_id) { record_status_list_row(_("Supplier status:"), 'inactive'); } else { table_section_title(_("Contact Data")); text_row(_("Contact Person:"), 'contact', null, 42, 40); text_row(_("Fax Number:"), 'fax', null, 32, 30); email_row(_("E-mail:"), 'email', null, 35, 55); languages_list_row(_("Document Language:"), 'rep_lang', null, _('System default')); } end_outer_table(1); div_start('controls'); if ($supplier_id) { submit_center_first('submit', _("Update Supplier"), _('Update supplier data'), @$_REQUEST['popup'] ? true : 'default'); submit_return('select', get_post('supplier_id'), _("Select this supplier and return to document entry.")); submit_center_last('delete', _("Delete Supplier"), _('Delete supplier data if have been never used'), true); } else { submit_center('submit', _("Add New Supplier Details"), true, '', 'default'); } div_end(); }
function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $customer = $_POST['PARAM_0']; $currency = $_POST['PARAM_1']; $show_also_allocated = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(4, 100, 130, 190, 250, 320, 385, 450, 515); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, curr_code, curdate() AS tran_date FROM " . TB_PREF . "debtors_master"; if ($customer != ALL_TEXT) { $sql .= " WHERE debtor_no = " . db_escape($customer); } else { $sql .= " ORDER by name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { $date = date('Y-m-d'); $myrow['order_'] = ""; $TransResult = getTransactions($myrow['debtor_no'], $date, $show_also_allocated); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('STATEMENT'); $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $contacts = get_customer_contacts($myrow['debtor_no'], 'invoice'); $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); //= get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no']); $rep->SetCommonData($myrow, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $rep->NewLine(); $doctype = ST_STATEMENT; $rep->fontSize += 2; $rep->TextCol(0, 8, _("Outstanding Transactions")); $rep->fontSize -= 2; $rep->NewLine(2); while ($myrow2 = db_fetch($TransResult)) { $DisplayTotal = number_format2(Abs($myrow2["TotalAmount"]), $dec); $DisplayAlloc = number_format2($myrow2["Allocated"], $dec); $DisplayNet = number_format2($myrow2["TotalAmount"] - $myrow2["Allocated"], $dec); $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); $rep->TextCol(1, 2, $myrow2['reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); if ($myrow2['type'] == ST_SALESINVOICE) { $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); } if ($myrow2['type'] == ST_SALESINVOICE || $myrow2['type'] == ST_BANKPAYMENT) { $rep->TextCol(4, 5, $DisplayTotal, -2); } else { $rep->TextCol(5, 6, $DisplayTotal, -2); } $rep->TextCol(6, 7, $DisplayAlloc, -2); $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->NewPage(); } } $nowdue = "1-" . $PastDueDays1 . " " . _("Days"); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _("Days"); $pastdue2 = _("Over") . " " . $PastDueDays2 . " " . _("Days"); $CustomerRecord = get_customer_details($myrow['debtor_no'], null, $show_also_allocated); $str = array(_("Current"), $nowdue, $pastdue1, $pastdue2, _("Total Balance")); $str2 = array(number_format2($CustomerRecord["Balance"] - $CustomerRecord["Due"], $dec), number_format2($CustomerRecord["Due"] - $CustomerRecord["Overdue1"], $dec), number_format2($CustomerRecord["Overdue1"] - $CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Balance"], $dec)); $col = array($rep->cols[0], $rep->cols[0] + 110, $rep->cols[0] + 210, $rep->cols[0] + 310, $rep->cols[0] + 410, $rep->cols[0] + 510); $rep->row = $rep->bottomMargin + (10 * $rep->lineHeight - 6); for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str[$i], 'right'); } $rep->NewLine(); for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); } if ($email == 1) { $rep->End($email, _("Statement") . " " . _("as of") . " " . sql2date($date)); } } if ($email == 0) { $rep->End(); } }
function print_profit_and_loss_statement() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $compare = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $graphics = $_REQUEST['PARAM_5']; $comments = $_REQUEST['PARAM_6']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Period'), tr('Accumulated'), tr('Achieved %')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = tr('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = tr('Period Y-1'); } $rep = new FrontReport(tr('Profit and Loss Statement'), "ProfitAndLoss.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalper = 0.0; $totalacc = 0.0; $classper = 0.0; $classacc = 0.0; $salesper = 0.0; $salesacc = 0.0; $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($compare == 2) { $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } else { $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } if (!$per_balance && !$acc_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $totalper = $totalacc = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->Font(); $salesper += $classper; $salesacc += $classacc; $classper = $classacc = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $per_balance *= -1; $acc_balance *= -1; $totalper += $per_balance; $totalacc += $acc_balance; $classper += $per_balance; $classacc += $acc_balance; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($per_balance, $dec)); $rep->TextCol(3, 4, number_format2($acc_balance, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($per_balance, $acc_balance), $pdec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateper = $salesper + $classper; $calculateacc = $salesacc + $classacc; $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateper, $dec)); $rep->TextCol(3, 4, number_format2($calculateacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($calculateper, $calculateacc), $pdec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateper); $pg->z[] = abs($calculateacc); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function display_fiscalyear_edit($selected_id) { global $Mode; start_form(); start_table(TABLESTYLE2); $company_year = get_company_pref('f_year'); $result = get_all_fiscalyears(); $row_cnt = db_num_rows($result); if ($selected_id != -1) { if ($Mode == 'Edit') { $myrow = get_fiscalyear($selected_id); $_POST['from_date'] = sql2date($myrow["begin"]); $_POST['to_date'] = sql2date($myrow["end"]); $_POST['closed'] = $myrow["closed"]; } if ($row_cnt == 1) { date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001); } else { hidden('from_date'); label_row(_("Fiscal Year Begin:"), $_POST['from_date']); } hidden('to_date'); label_row(_("Fiscal Year End:"), $_POST['to_date']); if ($myrow["id"] != $company_year) { yesno_list_row(_("Is Closed:"), 'closed', null, "", "", false); } else { hidden('closed'); label_row(_("Is Closed:"), yesno_value($_POST['closed'])); } } else { $begin = next_begin_date(); if ($begin && $Mode != 'ADD_ITEM') { $_POST['from_date'] = $begin; $_POST['to_date'] = end_month(add_months($begin, 11)); $_POST['closed'] = 0; } hidden('from_date'); hidden('to_date'); hidden('closed'); } hidden('selected_id', $selected_id); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); }
} /*Don't re-calculate freight if some of the order has already been delivered - depending on the business logic required this condition may not be required. It seems unfair to charge the customer twice for freight if the order was not fully delivered the first time ?? */ if (!isset($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] == "") { if ($_SESSION['Items']->any_already_delivered() == 1) { $_POST['ChargeFreightCost'] = price_format(0); } else { $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); } if (!check_num('ChargeFreightCost')) { $_POST['ChargeFreightCost'] = price_format(0); } } $accumulate_shipping = get_company_pref('accumulate_shipping'); if ($is_batch_invoice && $accumulate_shipping) { set_delivery_shipping_sum(array_keys($_SESSION['Items']->src_docs)); } $colspan = 9; start_row(); label_cell(_("Shipping Cost"), "colspan={$colspan} align=right"); small_amount_cells(null, 'ChargeFreightCost', null); if ($is_batch_invoice) { label_cell('', 'colspan=2'); } end_row(); $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); $display_sub_total = price_format($inv_items_total + input_num('ChargeFreightCost')); label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right", $is_batch_invoice ? 2 : 0); $taxes = $_SESSION['Items']->get_taxes(input_num('ChargeFreightCost'));
function print_trial_balance() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $zero = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } else { $comments = $_REQUEST['PARAM_3']; } } $dec = user_price_dec(); $cols2 = array(0, 50, 230, 330, 430, 530); //-------------0--1---2----3----4----5-- $headers2 = array('', '', tr('Brought Forward'), tr('This Period'), tr('Balance')); $aligns2 = array('left', 'left', 'left', 'left', 'left'); $cols = array(0, 50, 200, 250, 300, 350, 400, 450, 500, 550); //------------0--1---2----3----4----5----6----7----8----9-- $headers = array(tr('Account'), tr('Account Name'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(tr('Trial Balance'), "TrialBalance.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->Header(); $accounts = get_gl_accounts(); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { if ($from < $begin) { $begin = add_days($from, -1); } else { $begin = add_days(begin_fiscalyear(), -1); } } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($zero == 0 && !$prev_balance && !$curr_balance) { continue; } $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); if ($prev_balance > 0.0) { $rep->TextCol(2, 3, number_format2(abs($prev_balance), $dec)); } else { $rep->TextCol(3, 4, number_format2(abs($prev_balance), $dec)); } if ($curr_balance > 0.0) { $rep->TextCol(4, 5, number_format2(abs($curr_balance), $dec)); } else { $rep->TextCol(5, 6, number_format2(abs($curr_balance), $dec)); } if ($curr_balance + $prev_balance > 0.0) { $rep->TextCol(6, 7, number_format2(abs($curr_balance + $prev_balance), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($curr_balance + $prev_balance), $dec)); } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } $rep->Line($rep->row); $rep->End(); }
function check_valid_entries() { global $Refs; if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); set_focus('DatePaid'); return false; } if (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('DatePaid'); return false; } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('amount'); return false; } if (input_num('amount') == 0) { display_error(_("The total bank amount cannot be 0.")); set_focus('amount'); return false; } $limit = get_bank_account_limit($_POST['FromBankAccount'], $_POST['DatePaid']); $amnt_tr = input_num('charge') + input_num('amount'); if ($limit !== null && floatcmp($limit, $amnt_tr) < 0) { display_error(sprintf(_("The total bank amount exceeds allowed limit (%s) for source account."), price_format($limit))); set_focus('amount'); return false; } if ($trans = check_bank_account_history(-$amnt_tr, $_POST['FromBankAccount'], $_POST['DatePaid'])) { display_error(sprintf(_("The bank transaction would result in exceed of authorized overdraft limit for transaction: %s #%s on %s."), $systypes_array[$trans['type']], $trans['trans_no'], sql2date($trans['trans_date']))); set_focus('amount'); $input_error = 1; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('charge'); return false; } if (isset($_POST['charge']) && input_num('charge') > 0 && get_company_pref('bank_charge_act') == '') { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], ST_BANKTRANSFER)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if ($_POST['FromBankAccount'] == $_POST['ToBankAccount']) { display_error(_("The source and destination bank accouts cannot be the same.")); set_focus('ToBankAccount'); return false; } if (isset($_POST['target_amount']) && !check_num('target_amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('target_amount'); return false; } if (isset($_POST['target_amount']) && input_num('target_amount') == 0) { display_error(_("The incomming bank amount cannot be 0.")); set_focus('target_amount'); return false; } if (!db_has_currency_rates(get_bank_account_currency($_POST['FromBankAccount']), $_POST['DatePaid'])) { return false; } if (!db_has_currency_rates(get_bank_account_currency($_POST['ToBankAccount']), $_POST['DatePaid'])) { return false; } return true; }
function customer_settings($selected_id) { global $SysPrefs, $path_to_root, $auto_create_branch; if (!$selected_id) { if (list_updated('customer_id') || !isset($_POST['CustName'])) { $_POST['CustName'] = $_POST['cust_ref'] = $_POST['address'] = $_POST['tax_id'] = ''; $_POST['dimension_id'] = 0; $_POST['dimension2_id'] = 0; $_POST['sales_type'] = -1; $_POST['curr_code'] = get_company_currency(); $_POST['credit_status'] = -1; $_POST['payment_terms'] = $_POST['notes'] = ''; $_POST['discount'] = $_POST['pymt_discount'] = percent_format(0); $_POST['credit_limit'] = price_format($SysPrefs->default_credit_limit()); } } else { $myrow = get_customer($selected_id); $_POST['CustName'] = $myrow["name"]; $_POST['cust_ref'] = $myrow["debtor_ref"]; $_POST['address'] = $myrow["address"]; $_POST['tax_id'] = $myrow["tax_id"]; $_POST['dimension_id'] = $myrow["dimension_id"]; $_POST['dimension2_id'] = $myrow["dimension2_id"]; $_POST['sales_type'] = $myrow["sales_type"]; $_POST['curr_code'] = $myrow["curr_code"]; $_POST['credit_status'] = $myrow["credit_status"]; $_POST['payment_terms'] = $myrow["payment_terms"]; $_POST['discount'] = percent_format($myrow["discount"] * 100); $_POST['pymt_discount'] = percent_format($myrow["pymt_discount"] * 100); $_POST['credit_limit'] = price_format($myrow["credit_limit"]); $_POST['notes'] = $myrow["notes"]; $_POST['inactive'] = $myrow["inactive"]; } start_outer_table(TABLESTYLE2); table_section(1); table_section_title(_("Name and Address")); text_row(_("Customer Name:"), 'CustName', $_POST['CustName'], 40, 80); text_row(_("Customer Short Name:"), 'cust_ref', null, 30, 30); textarea_row(_("Address:"), 'address', $_POST['address'], 35, 5); text_row(_("GSTNo:"), 'tax_id', null, 40, 40); if (!$selected_id || is_new_customer($selected_id)) { currencies_list_row(_("Customer's Currency:"), 'curr_code', $_POST['curr_code']); } else { label_row(_("Customer's Currency:"), $_POST['curr_code']); hidden('curr_code', $_POST['curr_code']); } sales_types_list_row(_("Sales Type/Price List:"), 'sales_type', $_POST['sales_type']); if ($selected_id) { record_status_list_row(_("Customer status:"), 'inactive'); } elseif (isset($auto_create_branch) && $auto_create_branch == 1) { table_section_title(_("Branch")); text_row(_("Phone:"), 'phone', null, 32, 30); text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30); text_row(_("Fax Number:"), 'fax', null, 32, 30); email_row(_("E-mail:"), 'email', null, 35, 55); sales_persons_list_row(_("Sales Person:"), 'salesman', null); } table_section(2); table_section_title(_("Sales")); percent_row(_("Discount Percent:"), 'discount', $_POST['discount']); percent_row(_("Prompt Payment Discount Percent:"), 'pymt_discount', $_POST['pymt_discount']); amount_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit']); payment_terms_list_row(_("Payment Terms:"), 'payment_terms', $_POST['payment_terms']); credit_status_list_row(_("Credit Status:"), 'credit_status', $_POST['credit_status']); $dim = get_company_pref('use_dimension'); if ($dim >= 1) { dimensions_list_row(_("Dimension") . " 1:", 'dimension_id', $_POST['dimension_id'], true, " ", false, 1); } if ($dim > 1) { dimensions_list_row(_("Dimension") . " 2:", 'dimension2_id', $_POST['dimension2_id'], true, " ", false, 2); } if ($dim < 1) { hidden('dimension_id', 0); } if ($dim < 2) { hidden('dimension2_id', 0); } if ($selected_id) { start_row(); echo '<td class="label">' . _('Customer branches') . ':</td>'; hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php", '<b>' . (@$_REQUEST['popup'] ? _("Select or &Add") : _("&Add or Edit ")) . '</b>', "debtor_no=" . $selected_id . (@$_REQUEST['popup'] ? '&popup=1' : '')); end_row(); } textarea_row(_("General Notes:"), 'notes', null, 35, 5); if (!$selected_id && isset($auto_create_branch) && $auto_create_branch == 1) { table_section_title(_("Branch")); locations_list_row(_("Default Inventory Location:"), 'location'); shippers_list_row(_("Default Shipping Company:"), 'ship_via'); sales_areas_list_row(_("Sales Area:"), 'area', null); tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null); } end_outer_table(1); div_start('controls'); if (!$selected_id) { submit_center('submit', _("Add New Customer"), true, '', 'default'); } else { submit_center_first('submit', _("Update Customer"), _('Update customer data'), @$_REQUEST['popup'] ? true : 'default'); submit_return('select', $selected_id, _("Select this customer and return to document entry.")); submit_center_last('delete', _("Delete Customer"), _('Delete customer data if have been never used'), true); } div_end(); }
function show_results() { global $path_to_root, $systypes_array; if (!isset($_POST["account"])) { $_POST["account"] = null; } $act_name = $_POST["account"] ? get_gl_account_name($_POST["account"]) : ""; $dim = get_company_pref('use_dimension'); /*Now get the transactions */ if (!isset($_POST['Dimension'])) { $_POST['Dimension'] = 0; } if (!isset($_POST['Dimension2'])) { $_POST['Dimension2'] = 0; } $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], null, input_num('amount_min'), input_num('amount_max')); $colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4"); if ($_POST["account"] != null) { display_heading($_POST["account"] . " " . $act_name); } // Only show balances if an account is specified AND we're not filtering by amounts $show_balances = $_POST["account"] != null && input_num("amount_min") == 0 && input_num("amount_max") == 0; start_table(TABLESTYLE); $first_cols = array(_("Type"), _("#"), _("Date")); if ($_POST["account"] == null) { $account_col = array(_("Account")); } else { $account_col = array(); } if ($dim == 2) { $dim_cols = array(_("Dimension") . " 1", _("Dimension") . " 2"); } else { if ($dim == 1) { $dim_cols = array(_("Dimension")); } else { $dim_cols = array(); } } if ($show_balances) { $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo")); } else { $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo")); } $th = array_merge($first_cols, $account_col, $dim_cols, $remaining_cols); table_header($th); if ($_POST["account"] != null && is_account_balancesheet($_POST["account"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $bfw = 0; if ($show_balances) { $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']); start_row("class='inquirybg'"); label_cell("<b>" . _("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($bfw, true); label_cell(""); label_cell(""); end_row(); } $running_total = $bfw; $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $running_total += $myrow["amount"]; $trandate = sql2date($myrow["tran_date"]); label_cell($systypes_array[$myrow["type"]]); label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true)); label_cell($trandate); if ($_POST["account"] == null) { label_cell($myrow["account"] . ' ' . get_gl_account_name($myrow["account"])); } if ($dim >= 1) { label_cell(get_dimension_string($myrow['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($myrow['dimension2_id'], true)); } label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"])); display_debit_or_credit_cells($myrow["amount"]); if ($show_balances) { amount_cell($running_total); } if ($myrow['memo_'] == "") { $myrow['memo_'] = get_comments_string($myrow['type'], $myrow['type_no']); } label_cell($myrow['memo_']); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } //end of while loop if ($show_balances) { start_row("class='inquirybg'"); label_cell("<b>" . _("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($running_total, true); label_cell(""); label_cell(""); end_row(); } end_table(2); if (db_num_rows($result) == 0) { display_note(_("No general ledger transactions have been created for the specified criteria."), 0, 1); } }
function print_annual_balance_breakdown_detail() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $title = _("Annual Balance Breakdown - Detailed"); $output_filename = "AnnualBalanceBreakDownDetail"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 12; // 12 amount columns for ($i = 2; $i < 15; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } /* $header_row[] = "Fiscal Year Begin"; $header_row[] = "Fiscal YTD"; for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i+2] - $cols[$i+1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } */ if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->NewLine(); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $oldFontSize = $rep->fontSize; $rep->fontSize = 12; $rep->Font('b'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->fontSize = $oldFontSize; $rep->SetCellPadding($oldcMargin); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 5; $rep->Line($rep->row - 3); $rep->NewLine(); $rep->Font('b'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $fill = 0; $rep->TextCol(0, 1, _('Total') . " " . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $ctotal[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Net Assets (Liabilities)'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $sales[$i] * -1, $dec, 0, 4, 0, $fill, NULL, 1, true); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $convert = get_class_type_convert($class["ctype"]); //Print Class Name $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->Font('b'); $rep->TextCol(0, 1, _("Total ") . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); $typeresult = get_account_types(false, $class['cid']); while ($accounttype = db_fetch($typeresult)) { $result = get_gl_accounts(null, null, $accounttype['id']); while ($account = db_fetch($result)) { $bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2); $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); for ($i = 1; $i <= 12; $i++) { $total[$i] += $balance[$i]; } } } for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $total[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $calc[$i] += $total[$i]; $total[$i] = 0; } $rep->NewLine(2); } $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Total Profit/Loss'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, -$calc[$i], $dec, 0, 4, 0, $fill, NULL, 1, true); // no convert } $rep->Font(); $rep->End(); }
function line_start_focus() { set_focus(get_company_pref('no_supplier_list') ? 'stock_id_edit' : 'StockID2'); }
start_row(); label_cells(_("Reference"), $to_trans['ref'], "class='tableheader2'", "colspan={$colspan2}"); end_row(); comments_display_row(ST_BANKDEPOSIT, $trans_no); end_table(1); is_voided_display(ST_BANKDEPOSIT, $trans_no, _("This deposit has been voided.")); $items = get_gl_trans(ST_BANKDEPOSIT, $trans_no); if (db_num_rows($items) == 0) { display_note(_("There are no items for this deposit.")); } else { display_heading2(_("Items for this Deposit")); if ($show_currencies) { display_heading2(_("Item Amounts are Shown in:") . " " . $company_currency); } start_table(TABLESTYLE, "width=80%"); $dim = get_company_pref('use_dimension'); if ($dim == 2) { $th = array(_("Account Code"), _("Account Description"), _("Dimension") . " 1", _("Dimension") . " 2", _("Amount"), _("Memo")); } else { if ($dim == 1) { $th = array(_("Account Code"), _("Account Description"), _("Dimension"), _("Amount"), _("Memo")); } else { $th = array(_("Account Code"), _("Account Description"), _("Amount"), _("Memo")); } } table_header($th); $k = 0; //row colour counter $total_amount = 0; while ($item = db_fetch($items)) { if ($item["account"] != $to_trans["account_code"]) {
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(); }