public function check_reorder_level() { global $db; global $auth_session; $domain_id = domain_id::get($this->domain_id); //sellect qty and reorder level $inventory = new product(); $sth = $inventory->select_all('count'); $inventory_all = $sth->fetchAll(PDO::FETCH_ASSOC); $email = ""; foreach ($inventory_all as $row) { if ($row['quantity'] <= $row['reorder_level']) { $message = "The quantity of Product: " . $row['description'] . " is " . siLocal::number($row['quantity']) . ", which is equal to or below its reorder level of " . $row['reorder_level']; $return['row_' . $row['id']]['message'] = $message; $email_message .= $message . "<br />\n"; } } //print_r($return); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email = new email(); $email->notes = $email_message; $email->from = $email->get_admin_email(); $email->to = $email->get_admin_email(); #$email -> bcc = "justin@localhost"; $email->subject = "Simple Invoices reorder level email"; $email->send(); return $return; }
function smarty_function_total($params, &$smarty) { $subtotal = 0; foreach ($params['cost'] as $key => $value) { if ($value['product']['custom_field1'] == $params['group']) { $subtotal = $value['total'] + $subtotal; } } $subtotal = siLocal::number($subtotal); return $subtotal; }
public static function number_trim($number) { global $config; $formatted_number = siLocal::number($number); //get the precision and add 1 - for the decimal place and reverse the sign $position = ($config->local->precision + 1) * -1; if (substr($formatted_number, $position, '1') == ".") { $formatted_number = rtrim(trim($formatted_number, '0'), '.'); } if (substr($formatted_number, $position, '1') == ",") { $formatted_number = rtrim(trim($formatted_number, '0'), ','); /* Added to deal with "," */ } return $formatted_number; }
$sth = sql('', $dir, $start, $sort, $rp, $page); $sth_count_rows = sql('count',$dir, $start, $sort, $rp, $page); $tax = $sth->fetchAll(PDO::FETCH_ASSOC); $count = $sth_count_rows->rowCount(); $xml .= "<rows>"; $xml .= "<page>$page</page>"; $xml .= "<total>$count</total>"; foreach ($tax as $row) { $xml .= "<row id='".$row['tax_id']."'>"; $xml .= "<cell><![CDATA[ <a class='index_table' title='$LANG[view] $LANG[tax_rate] ".$row['tax_description']."' href='index.php?module=tax_rates&view=details&id=$row[tax_id]&action=view'><img src='" . $baseUrl . "images/common/view.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a> <a class='index_table' title='$LANG[edit] $LANG[tax_rate] ".$row['tax_description']."' href='index.php?module=tax_rates&view=details&id=$row[tax_id]&action=edit'><img src='" . $baseUrl . "images/common/edit.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a> ]]></cell>"; $xml .= "<cell><![CDATA[".$row['tax_description']."]]></cell>"; $xml .= "<cell><![CDATA[".siLocal::number($row['tax_percentage'])." ".$row['type']."]]></cell>"; if ($row['enabled']==$LANG['enabled']) { $xml .= "<cell><![CDATA[<img src='" . $baseUrl . "images/common/tick.png' alt='".utf8_encode($row['enabled'])."' title='".utf8_encode($row['enabled'])."' />]]></cell>"; } else { $xml .= "<cell><![CDATA[<img src='" . $baseUrl . "images/common/cross.png' alt='".utf8_encode($row['enabled'])."' title='".utf8_encode($row['enabled'])."' />]]></cell>"; } $xml .= "</row>"; } $xml .= "</rows>"; echo $xml;
if ($row['status'] && $row['owing'] > 0) { // Real Invoice Has Owing - Process payment $xml .= "<!--6 Payment --><a title='" . $LANG['process_payment_for'] . " " . $row['preference'] . " " . $row['index_id'] . "' class='index_table' href='index.php?module=payments&view=process&id=" . $row['id'] . "&op=pay_selected_invoice'><img src='images/common/money_dollar.png' class='action' /></a>"; } elseif ($row['status']) { // Real Invoice Payment Details if not Owing (get different color payment icon) $xml .= "<!--6 Payment --><a title='" . $LANG['process_payment_for'] . " " . $row['preference'] . " " . $row['index_id'] . "' class='index_table' href='index.php?module=payments&view=details&id=" . $row['id'] . "&action=view'><img src='images/common/money_dollar.png' class='action' /></a>"; } else { // Draft Invoice Just Image to occupy space till blank or greyed out icon becomes available $xml .= "<!--6 Payment --><img src='images/common/money_dollar.png' class='action' />"; } $xml .= "<!--7 Email --><a title='" . $LANG['email'] . " " . $row['preference'] . " " . $row['index_id'] . "' class='index_table' href='index.php?module=invoices&view=email&stage=1&id=" . $row['id'] . "'><img src='images/common/mail-message-new.png' class='action' /></a>\n\t\t\t]]>\n\t\t\t\t</cell>"; $xml .= "<cell><![CDATA[" . $row['index_name'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['biller'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['customer'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::date($row['date']) . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::number($row['invoice_total']) . "]]></cell>"; if ($row['status']) { $xml .= "<cell><![CDATA[" . siLocal::number($row['owing']) . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['aging'] . "]]></cell>"; } else { $xml .= "<cell><![CDATA[ ]]></cell>"; $xml .= "<cell><![CDATA[ ]]></cell>"; } $xml .= "<cell><![CDATA[" . $row['preference'] . "]]></cell>"; $xml .= "</row>"; } $xml .= "</rows>"; echo $xml; ?>
$sql = "SELECT \n\t\t\t\t\tc.id as CID, \n\t\t\t\t\tc.name as name, \n\t\t\t\t\t(SELECT (CASE WHEN c.enabled = 0 THEN 'Disabled' ELSE 'Enabled' END )) AS enabled,\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\n\t\t\t\t coalesce(sum(ii.total), 0) AS total \n\t\t\t\t FROM\n\t\t\t\t " . TB_PREFIX . "invoice_items ii INNER JOIN\n\t\t\t\t " . TB_PREFIX . "invoices iv ON (iv.id = ii.invoice_id)\n\t\t\t\t WHERE \n\t\t\t\t iv.customer_id = CID ) as customer_total,\n\t\t( SELECT MAX(id)\n\t\t\tFROM\n\t\t\t\t" . TB_PREFIX . "invoices \n\t\t\tWHERE\tcustomer_id = CID) AS last_invoice, (\n \n\t SELECT \n\t coalesce(sum(ap.ac_amount), 0) AS amount \n\t FROM\n\t " . TB_PREFIX . "payment ap INNER JOIN\n\t " . TB_PREFIX . "invoices iv ON (iv.id = ap.ac_inv_id)\n\t WHERE \n\t iv.customer_id = CID) AS paid,\n\t ( select customer_total - paid ) AS owing\n\t\n\t\t\t\tFROM \n\t\t\t\t\t" . TB_PREFIX . "customers c \n\t\t\t\tWHERE c.domain_id = :domain_id\n\t\t\t\t\t{$where}\n\t\t\t\tORDER BY \n\t\t\t\t\t{$sort} {$dir} \n\t\t\t\t{$limit}"; if (empty($query)) { $result = dbQuery($sql, ':domain_id', $auth_session->domain_id); } else { $result = dbQuery($sql, ':domain_id', $auth_session->domain_id, ':query', "%{$query}%"); } return $result; } $sth = sql('', $dir, $sort, $rp, $page); $sth_count_rows = sql('count', $dir, $sort, $rp, $page); $customers = $sth->fetchAll(PDO::FETCH_ASSOC); $count = $sth_count_rows->rowCount(); $xml .= "<rows>"; $xml .= "<page>{$page}</page>"; $xml .= "<total>{$count}</total>"; foreach ($customers as $row) { $xml .= "<row id='" . $row['CID'] . "'>"; $xml .= "<cell><![CDATA[\n\t\t\t<a class='index_table' title='{$LANG['view']} {$LANG['customer']} " . utf8_encode($row['name']) . "' href='index.php?module=customers&view=details&id={$row['CID']}&action=view'><img src='images/common/view.png' class='action' /></a>\n\t\t\t<a class='index_table' title='{$LANG['edit']} {$LANG['customer']} " . utf8_encode($row['name']) . "' href='index.php?module=customers&view=details&id={$row['CID']}&action=edit'><img src='images/common/edit.png' class='action' /></a>\n\t\t\t<a class='index_table' title='{$LANG['new_invoice']} {$LANG['for']} {$LANG['customer']} " . utf8_encode($row['name']) . "' href='index.php?module=invoices&view=usedefault&customer_id={$row['CID']}&action=edit'><img src='images/famfam/page_add.png' class='action' /></a>\n\t\t]]></cell>"; $xml .= "<cell><![CDATA[" . $row['CID'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . utf8_encode($row['name']) . "]]></cell>"; $xml .= "<cell><![CDATA[<a class='index_table' title='quick view' href='index.php?module=invoices&view=quick_view&id=" . utf8_encode($row['last_invoice']) . "'>" . utf8_encode($row['last_invoice']) . "</a>]]></cell>"; $xml .= "<cell><![CDATA[" . utf8_encode(siLocal::number($row['customer_total'])) . "]]></cell>"; $xml .= "<cell><![CDATA[" . utf8_encode(siLocal::number($row['owing'])) . "]]></cell>"; $xml .= "<cell><![CDATA[" . utf8_encode($row['enabled']) . "]]></cell>"; $xml .= "</row>"; } $xml .= "</rows>"; echo $xml; ?>
header("Content-type: text/xml"); //$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ; $dir = isset($_POST['sortorder']) ? $_POST['sortorder'] : "DESC"; $sort = isset($_POST['sortname']) ? $_POST['sortname'] : "id"; $rp = isset($_POST['rp']) ? $_POST['rp'] : "25"; $page = isset($_POST['page']) ? $_POST['page'] : "1"; //$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit"; $inventory = new inventory(); $inventory->sort = $sort; $inventory_all = $inventory->select_all('', $dir, $rp, $page); $sth_count_rows = $inventory->select_all('count', $dir, $rp, $page); $xml = ""; $count = $sth_count_rows; $xml .= "<rows>"; $xml .= "<page>{$page}</page>"; $xml .= "<total>{$count}</total>"; foreach ($inventory_all as $row) { $xml .= "<row id='" . $row['id'] . "'>"; $xml .= "<cell><![CDATA[\n\t\t<a class='index_table' title='{$LANG['view']} " . $row['name'] . "' href='index.php?module=inventory&view=view&id={$row['id']}'><img src='images/common/view.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a>\n\t\t<a class='index_table' title='{$LANG['edit']} " . $row['name'] . "' href='index.php?module=inventory&view=edit&id={$row['id']}'><img src='images/common/edit.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a>\n\t\t]]></cell>"; $xml .= "<cell><![CDATA[" . $row['date'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['description'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::number($row['quantity']) . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::number($row['cost']) . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::number($row['total_cost']) . "]]></cell>"; $xml .= "</row>"; } $xml .= "</rows>"; echo $xml; ?>
} $sth = sql('', $dir, $sort, $rp, $page); $sth_count_rows = sql('count', $dir, $sort, $rp, $page); $payments = $sth->fetchAll(PDO::FETCH_ASSOC); $count = $sth_count_rows->rowCount(); /* $sqlTotal = "SELECT count(id) AS count FROM ".TB_PREFIX."payment"; $tth = dbQuery($sqlTotal) or die(end($dbh->errorInfo())); $resultCount = $tth->fetch(); $count = $resultCount[0]; //echo sql2xml($customers, $count); */ $xml = "<rows>"; $xml .= "<page>{$page}</page>"; $xml .= "<total>{$count}</total>"; foreach ($payments as $row) { $notes = si_truncate($row['ac_notes'], '13', '...'); $xml .= "<row id='" . $row['id'] . "'>"; $xml .= "<cell><![CDATA[\n\t<a class='index_table' title='{$LANG['view']} " . $row['name'] . "' href='index.php?module=payments&view=details&id={$row['id']}&action=view'><img src='images/common/view.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a>\n\t<a class='index_table' title='{$LANG['print_preview_tooltip']} " . $row['id'] . "' href='index.php?module=payments&view=print&id={$row['id']}'><img src='images/common/printer.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a>\n\t]]></cell>"; $xml .= "<cell><![CDATA[" . $row['id'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['index_name'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['cname'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['bname'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::number($row['ac_amount']) . "]]></cell>"; $xml .= "<cell><![CDATA[" . $notes . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['description'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::date($row['date']) . "]]></cell>"; $xml .= "</row>"; } $xml .= "</rows>"; echo $xml;
global $dbh; $sqlTotal = "SELECT count(id) AS count FROM ".TB_PREFIX."invoices"; $tth = dbQuery($sqlTotal) or die(end($dbh->errorInfo())); $resultCount = $tth->fetch(); $count = $resultCount[0]; //echo sql2xml($invoices, $count); $xml .= "<rows>"; $xml .= "<page>$page</page>"; $xml .= "<total>$count</total>"; foreach ($invoices as $row) { $xml .= "<row id='".$row['id']."'>"; $xml .= "<action><![CDATA[<a href='index.php?module=invoices&view=quick_view&invoice=".$row['id']."'>".utf8_encode($row['id'])."</a>]]></action>"; $xml .= "<customer><![CDATA[".utf8_encode($row['customer'])."]]></customer>"; $xml .= "<date><![CDATA[".utf8_encode($row['date'])."]]></date>"; $xml .= "<invoice_total><![CDATA[".utf8_encode(siLocal::number($row['invoice_total']))."]]></invoice_total>"; $xml .= "</row>"; } $xml .= "</rows>"; echo $xml; ?>
$smarty->assign("defaults", $defaults); $products = new product(); $sth = $products->select_all('', $dir, $sort, $rp, $page); $sth_count_rows = $products->select_all('count', $dir, $sort, $rp, $page); $products_all = $sth->fetchAll(PDO::FETCH_ASSOC); $count = $sth_count_rows->rowCount(); //echo sql2xml($customers, $count); $xml .= "<rows>"; $xml .= "<page>{$page}</page>"; $xml .= "<total>{$count}</total>"; foreach ($products_all as $row) { $xml .= "<row id='" . $row['iso'] . "'>"; $xml .= "<cell><![CDATA[\n\t\t\t<a class='index_table' title='{$LANG['view']} " . $row['description'] . "' href='index.php?module=products&view=details&id=" . $row['id'] . "&action=view'><img src='images/common/view.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a>\n\t\t\t<a class='index_table' title='{$LANG['edit']} " . $row['description'] . "' href='index.php?module=products&view=details&id=" . $row['id'] . "&action=edit'><img src='images/common/edit.png' height='16' border='-5px' padding='-4px' valign='bottom' /></a>\n\t\t]]></cell>"; $xml .= "<cell><![CDATA[" . $row['id'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . $row['description'] . "]]></cell>"; $xml .= "<cell><![CDATA[" . siLocal::number($row['unit_price']) . "]]></cell>"; if ($defaults['inventory'] == '1') { $xml .= "<cell><![CDATA[" . siLocal::number_trim($row['quantity']) . "]]></cell>"; } if ($row['enabled'] == $LANG['enabled']) { $xml .= "<cell><![CDATA[<img src='images/common/tick.png' alt='" . $row['enabled'] . "' title='" . $row['enabled'] . "' />]]></cell>"; } else { $xml .= "<cell><![CDATA[<img src='images/common/cross.png' alt='" . $row['enabled'] . "' title='" . $row['enabled'] . "' />]]></cell>"; } $xml .= "</row>"; } $xml .= "</rows>"; echo $xml; ?>