public function get_all() { global $LANG; $sql = "SELECT * FROM " . TB_PREFIX . "customers WHERE domain_id = :domain_id"; $sth = dbQuery($sql, ':domain_id', $this->domain_id); $customers = null; $customer = null; for ($i = 0; $customer = $sth->fetch(); $i++) { if ($customer['enabled'] == 1) { $customer['enabled'] = $LANG['enabled']; } else { $customer['enabled'] = $LANG['disabled']; } #invoice total calc - start $customer['total'] = calc_customer_total($customer['id']); #invoice total calc - end #amount paid calc - start $customer['paid'] = calc_customer_paid($customer['id']); #amount paid calc - end #amount owing calc - start $customer['owing'] = $customer['total'] - $customer['paid']; #amount owing calc - end $customers[$i] = $customer; } return $customers; }
* GPL v2 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $customer_id = $_GET['id']; $customer = getCustomer($customer_id); $customer['wording_for_enabled'] = $customer['enabled'] == 1 ? $LANG['enabled'] : $LANG['disabled']; //TODO: Perhaps possible a bit nicer? $stuff = null; $stuff['total'] = calc_customer_total($customer['id'], domain_id::get(), true); #amount paid calc - start $stuff['paid'] = calc_customer_paid($customer['id'], domain_id::get(), true); #amount paid calc - end #amount owing calc - start $stuff['owing'] = $stuff['total'] - $stuff['paid']; #get custom field labels $customFieldLabel = getCustomFieldLabels(); $invoices = getCustomerInvoices($customer_id); //$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ; $dir = "DESC"; $sort = "id"; $rp = isset($_POST['rp']) ? $_POST['rp'] : "25"; $having = 'money_owed'; $page = isset($_POST['page']) ? $_POST['page'] : "1"; //$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit"; $invoice_owing = new invoice(); $invoice_owing->sort = $sort;
$invoice_age_days = number_format((strtotime(date('Y-m-d')) - strtotime($invoice['calc_date'])) / (60 * 60 * 24), 0); $invoice_age = "{$invoice_age_days} {$LANG['days']}"; } else { $invoice_age = ""; } $url_for_pdf = "./pdfmaker.php?id=" . $invoice['id']; $invoice['url_for_pdf'] = $url_for_pdf; $customFieldLabels = getCustomFieldLabels(); for ($i = 1; $i <= 4; $i++) { $customField[$i] = show_custom_field("invoice_cf{$i}", $invoice["custom_field{$i}"], "read", 'details_screen summary', 'details_screen', 'details_screen', 5, ':'); } $pageActive = "invoices"; //Customer accounts sections $customerAccount = null; $customerAccount['total'] = calc_customer_total($customer['id']); $customerAccount['paid'] = calc_customer_paid($customer['id']); $customerAccount['owing'] = $customerAccount['total'] - $customerAccount['paid']; $smarty->assign('pageActive', $pageActive); $smarty->assign("customField", $customField); $smarty->assign("customFieldLabels", $customFieldLabels); $smarty->assign("invoice_age", $invoice_age); $smarty->assign("invoiceItems", $invoiceItems); $smarty->assign("defaults", $defaults); $smarty->assign("preference", $preference); $smarty->assign("biller", $biller); $smarty->assign("customer", $customer); $smarty->assign("invoice_type", $invoice_type); $smarty->assign("invoice", $invoice); $smarty->assign("word_processor", $word_processor); $smarty->assign("spreadsheet", $spreadsheet); $smarty->assign("customerAccount", $customerAccount);
$invoice_age = ""; } $url_for_pdf = "./index.php?module=export&view=pdf&id=" . $invoice['id']; $invoice['url_for_pdf'] = $url_for_pdf; $customFieldLabels = getCustomFieldLabels(); for ($i = 1; $i <= 4; $i++) { $customField[$i] = show_custom_field("invoice_cf{$i}", $invoice["custom_field{$i}"], "read", 'summary', '', '', 5, ':'); } $sql = "SELECT * FROM " . TB_PREFIX . "products_attributes"; $sth = dbQuery($sql); $attributes = $sth->fetchAll(); $smarty->assign("attributes", $attributes); //Customer accounts sections $customerAccount = null; $customerAccount['total'] = calc_customer_total($customer['id'], '', true); $customerAccount['paid'] = calc_customer_paid($customer['id'], '', true); $customerAccount['owing'] = $customerAccount['total'] - $customerAccount['paid']; $smarty->assign('pageActive', 'invoice'); $smarty->assign('subPageActive', 'invoice_view'); $smarty->assign('active_tab', '#money'); $smarty->assign("customField", $customField); $smarty->assign("customFieldLabels", $customFieldLabels); $smarty->assign("invoice_age", $invoice_age); $smarty->assign("invoice_number_of_taxes", $invoice_number_of_taxes); $smarty->assign("invoiceItems", $invoiceItems); $smarty->assign("defaults", $defaults); $smarty->assign("preference", $preference); $smarty->assign("biller", $biller); $smarty->assign("customer", $customer); $smarty->assign("invoice_type", $invoice_type); $smarty->assign("invoice", $invoice);
* GPL v2 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $customer_id = $_GET['id']; $customer = getCustomer($customer_id); $customer['wording_for_enabled'] = $customer['enabled'] == 1 ? $LANG['enabled'] : $LANG['disabled']; //TODO: Perhaps possible a bit nicer? $stuff = null; $stuff['total'] = calc_customer_total($customer['id']); #amount paid calc - start $stuff['paid'] = calc_customer_paid($customer['id']); #amount paid calc - end #amount owing calc - start $stuff['owing'] = $stuff['total'] - $stuff['paid']; #get custom field labels $customFieldLabel = getCustomFieldLabels(); $invoices = getCustomerInvoices($customer_id); //$customFieldLabel = getCustomFieldLabels("biller"); $smarty->assign("stuff", $stuff); $smarty->assign('customer', $customer); $smarty->assign('invoices', $invoices); $smarty->assign('customFieldLabel', $customFieldLabel); $smarty->assign('pageActive', 'customer'); $subPageActive = $_GET['action'] == "view" ? "customer_view" : "customer_edit"; $smarty->assign('subPageActive', $subPageActive); $smarty->assign('pageActive', 'customer');
function getCustomers() { global $dbh; global $LANG; global $auth_session; $customer = null; $sql = "SELECT * FROM " . TB_PREFIX . "customers WHERE domain_id = :domain_id"; $sth = dbQuery($sql, ':domain_id', $auth_session->domain_id) or die(htmlsafe(end($dbh->errorInfo()))); $customers = null; for ($i = 0; $customer = $sth->fetch(); $i++) { if ($customer['enabled'] == 1) { $customer['enabled'] = $LANG['enabled']; } else { $customer['enabled'] = $LANG['disabled']; } #invoice total calc - start $customer['total'] = calc_customer_total($customer['id']); #invoice total calc - end #amount paid calc - start $customer['paid'] = calc_customer_paid($customer['id']); #amount paid calc - end #amount owing calc - start $customer['owing'] = $customer['total'] - $customer['paid']; #amount owing calc - end $customers[$i] = $customer; } return $customers; }
function getCustomers() { global $LANG; $SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers(); $result = $SI_CUSTOMERS->fetchAll(); $customers = array(); foreach($result as $customer) { if ($customer['enabled'] == 1) { $customer['enabled'] = $LANG['enabled']; } else { $customer['enabled'] = $LANG['disabled']; } #invoice total calc - start $customer['total'] = calc_customer_total($customer['id']); #invoice total calc - end #amount paid calc - start $customer['paid'] = calc_customer_paid($customer['id']); #amount paid calc - end #amount owing calc - start $customer['owing'] = $customer['total'] - $customer['paid']; #amount owing calc - end $customers[] = $customer; } return $customers; }