Example #1
0
	$inventory = new inventory();
	$inventory->id=$_GET['id'];
	$inventory->domain_id=domain_id::get();
	$inventory->product_id=$_POST['product_id'];
	$inventory->quantity=$_POST['quantity'];
	$inventory->cost=$_POST['cost'];
	$inventory->date=$_POST['date'];
	$inventory->note=$_POST['note'];
	$result = $inventory->update();

	$saved = !empty($result) ? "true" : "false";
}      

$invoices = new invoice();
$invoices->sort='id';
$invoice_all = $invoices->select_all('count');

$get_inventory = new inventory();
$get_inventory->id = $_GET['id'];
$inventory = $get_inventory->select();

$product_all = product::get_all();
$smarty -> assign('product_all',$product_all);
$smarty -> assign('saved',$saved);
$smarty -> assign('inventory',$inventory);

$smarty -> assign('pageActive', 'inventory');
$smarty -> assign('subPageActive', 'inventory_edit');
$smarty -> assign('active_tab', '#product');
Example #2
0
$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_owing->having_and = "real";
$invoice_owing->query = $_REQUEST['query'];
$invoice_owing->qtype = $_REQUEST['qtype'];
$large_dataset = getDefaultLargeDataset();
if ($large_dataset == $LANG['enabled']) {
    $sth = $invoice_owing->select_all('large_count', $dir, $rp, $page, $having);
} else {
    $sth = $invoice_owing->select_all('', $dir, $rp, $page, $having);
}
$invoices_owing = $sth->fetchAll(PDO::FETCH_ASSOC);
//$customFieldLabel = getCustomFieldLabels("biller");
$smarty->assign("stuff", $stuff);
$smarty->assign('customer', $customer);
$smarty->assign('invoices', $invoices);
$smarty->assign('invoices_owing', $invoices_owing);
$smarty->assign('customFieldLabel', $customFieldLabel);
$smarty->assign('pageActive', 'customer');
$subPageActive = $_GET['action'] == "view" ? "customer_view" : "customer_edit";
$smarty->assign('subPageActive', $subPageActive);
$smarty->assign('pageActive', 'customer');
$smarty->assign('active_tab', '#people');
define("BROWSE","browse");
//if this page has error with auth remove the above line and figure out how to do it right

$SI_INVOICE_TYPE = new SimpleInvoices_Db_Table_InvoiceType();

$domain_id = domain_id::get();

#$sql = "SELECT * FROM ".TB_PREFIX."invoices where domain_id = ".$domain_id;

#global $dbh;
#$sth = dbQuery($sql) or die(htmlsafe(end($dbh->errorInfo())));

//$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit";
$invoice = new invoice();
$sth = $invoice->select_all();

$q = strtolower($_GET["q"]);
if (!$q) return;

while ($invoice = getInvoices($sth)) {

	$invoiceType = $SI_INVOICE_TYPE->getInvoiceType($invoice['type_id']);

	if (strpos(strtolower($invoice['index_id']), $q) !== false) {
		$invoice['id'] = htmlsafe($invoice['id']);
		$invoice['total'] = htmlsafe(number_format($invoice['total'],2));
		$invoice['paid'] = htmlsafe(number_format($invoice['paid'],2));
		$invoice['owing'] = htmlsafe(number_format($invoice['owing'],2));
		echo "$invoice[id]|<table><tr><td class='details_screen'>$invoice[preference]:</td><td>$invoice[index_id]</td><td  class='details_screen'>Total: </td><td>$invoice[total] </td></tr><tr><td class='details_screen'>Biller: </td><td>$invoice[biller] </td><td class='details_screen'>Paid: </td><td>$invoice[paid] </td></tr><tr><td class='details_screen'>Customer: </td><td>$invoice[customer] </td><td class='details_screen'>Owing: </td><td><u>$invoice[owing]</u></td></tr></table>\n";
	}
Example #4
0
$rp = isset($_POST['rp']) ? $_POST['rp'] : "25";
$having = isset($_GET['having']) ? $_GET['having'] : "";
$page = isset($_POST['page']) ? $_POST['page'] : "1";
//$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit";
$invoice = new invoice();
$invoice->sort = $sort;
if ($auth_session->role_name == 'customer') {
    $invoice->customer = $auth_session->user_id;
} elseif ($auth_session->role_name == 'biller') {
    $invoice->biller = $auth_session->user_id;
}
$invoice->query = isset($_REQUEST['query']) ? $_REQUEST['query'] : null;
$invoice->qtype = isset($_REQUEST['qtype']) ? $_REQUEST['qtype'] : null;
$large_dataset = getDefaultLargeDataset();
if ($large_dataset == $LANG['enabled']) {
    $sth = $invoice->select_all('large', $dir, $rp, $page, $having);
    $sth_count_rows = $invoice->count();
    $invoice_count = $sth_count_rows->fetch(PDO::FETCH_ASSOC);
    $invoice_count = $invoice_count['count'];
} else {
    $sth = $invoice->select_all('', $dir, $rp, $page, $having);
    $sth_count_rows = $invoice->select_all('count', $dir, $rp, $page, $having);
    $invoice_count = $sth_count_rows->rowCount();
}
$invoices = $sth->fetchAll(PDO::FETCH_ASSOC);
$xml = "";
$xml .= "<rows>";
$xml .= "<page>{$page}</page>";
$xml .= "<total>" . $invoice_count . "</total>";
foreach ($invoices as $row) {
    $xml .= "<row id='" . $row['id'] . "'>";
Example #5
0
	function getData()
	{
		//echo "export - get data";
		global $smarty;
		global $siUrl;
		global $include_dir;
        
        $SI_BILLER = new SimpleInvoices_Db_Table_Biller();
        $SI_CUSTOM_FIELDS = new SimpleInvoices_Db_Table_CustomFields();
        $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences();
        
		switch ($this->module)
		{
			case "database":
			{
                $data = SimpleInvoices_Db::performBackup();
				break;
			}
			case "statement":
			{
				$invoice = new invoice();
				$invoice->biller = $this->biller_id;
				$invoice->customer = $this->customer_id;

				if ( $this->filter_by_date =="yes" )
				{
					if ( isset($this->start_date) )
					{
						$invoice->start_date = $this->start_date;
					}
					if ( isset($this->end_date) )
					{
						$invoice->end_date = $this->end_date;
					}

					if ( isset($this->start_date) AND isset($this->end_date) )
					{
						$invoice->having = "date_between";
					}
					$having_count = '1';
				}

				if ( $this->show_only_unpaid == "yes")
				{
					if ($having_count == '1')
					{

						$invoice->having_and = "money_owed";
					    $having_count = '2';

					} else {

						$invoice->having = "money_owed";
					    $having_count = '1';

					}
				}

				if ( $this->show_only_real == "yes")
				{
					if ($having_count == '2')
					{

						$invoice->having_and2 = "real";

					} elseif ($having_count == '1') {

						$invoice->having_and = "real";

					} else {

						$invoice->having = "real";

					}
				}

				$invoice_all = $invoice->select_all('count');

				$invoices = $invoice_all->fetchAll();

				foreach ($invoices as $i => $row) {
					$statement['total'] = $statement['total'] + $row['invoice_total'];
					$statement['owing'] = $statement['owing'] + $row['owing'] ;
					$statement['paid'] = $statement['paid'] + $row['INV_PAID'];

				}

                // ToDo: THIS FILE IS MISSING!!
				$templatePath = $include_dir . "sys/templates/default/statement/index.tpl";

				$biller_details = $SI_BILLER->getBiller($this->biller_id);
				$customer_details = customer::get($this->customer_id);

				$this->file_name = "statement_".$this->biller_id."_".$this->customer_id."_".$invoice->start_date."_".$invoice->end_date;

				$smarty -> assign('biller_id', $biller_id);
				$smarty -> assign('biller_details', $biller_details);
				$smarty -> assign('customer_id', $customer_id);
				$smarty -> assign('customer_details', $customer_details);

				$smarty -> assign('show_only_unpaid', $show_only_unpaid);
				$smarty -> assign('show_only_real', $show_only_real);
				$smarty -> assign('filter_by_date', $this->filter_by_date);

				$smarty -> assign('invoices', $invoices);
				$smarty -> assign('start_date', $this->start_date);
				$smarty -> assign('end_date', $this->end_date);

				$smarty -> assign('invoices',$invoices);
				$smarty -> assign('statement',$statement);
				$data = $smarty -> fetch(".".$templatePath);

				break;
			}
            case "payment":
            {
                $customFieldLabels = $SI_CUSTOM_FIELDS->getLabels();
                
                $payment = new SimpleInvoices_Payment($this->id);
                $invoice = $payment->getInvoice();
                $biller = $invoice->getBiller();
                $logo = $biller->getLogo();
                $logo = str_replace(" ", "%20", $logo);
                $customer = $invoice->getCustomer();
                
                $smarty -> assign("payment",$payment->toArray());
                $smarty -> assign("invoice",$invoice->toArray());
                $smarty -> assign("biller",$biller->toArray());
                $smarty -> assign("logo",$logo);
                $smarty -> assign("customer",$customer->toArray());
                $smarty -> assign("invoiceType",$invoice->getType());
                $smarty -> assign("paymentType",$payment->getType());
                $smarty -> assign("preference",$invoice->getPreference());
                $smarty -> assign("customFieldLabels",$customFieldLabels);

                $smarty -> assign('pageActive', 'payment');
                $smarty -> assign('active_tab', '#money');

				$css = $siUrl."/sys/templates/invoices/default/style.css";
				$smarty -> assign('css',$css);

                $templatePath = $include_dir . "sys/templates/default/modules/payments/print.tpl";
				$data = $smarty -> fetch($templatePath);
				
                break;
            }
			case "invoice":
			{
                $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults();
                
				$invoice = invoice::select($this->id);
 			    $invoice_number_of_taxes = numberOfTaxesForInvoice($this->id);
				$customer = customer::get($invoice['customer_id']);
				$biller = biller::select($invoice['biller_id']);
				$preference = $SI_PREFERENCES->getPreferenceById($invoice['preference_id']);
				$defaults = $SI_SYSTEM_DEFAULTS->fetchAll();
				$logo = getLogo($biller);
				$logo = str_replace(" ", "%20", $logo);
				$invoiceItems = invoice::getInvoiceItems($this->id);

				$spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
				$this->file_name = $spc2us_pref;

				$customFieldLabels = $SI_CUSTOM_FIELDS->getLabels();
				$customFieldDisplay = $SI_CUSTOM_FIELDS->getDisplay();

				/*Set the template to the default*/
				$template = $defaults['template'];

                // Instead of appending the CSS we are going to inject it allowing
                // a cleaner hierarchy tree while allowing public directories
				$css_file = $include_dir ."/sys/templates/invoices/${template}/style.css";
                
                if (file_exists($css_file)) {
                    $css = file_get_contents($css_file);
                    if ($css) {
                        // Create the tags
                        $css = '<style type="text/css" media="all">' . $css . '</style>';
                    }
                } else {
                    $css = '';
                }

                $smarty->addTemplateDir($include_dir . "sys/templates/invoices/${template}/", 'Invoice_' . $template);
				$smarty->addPluginsDir($include_dir ."sys/templates/invoices/${template}/plugins/");

				$pageActive = "invoices";
				$smarty->assign('pageActive', $pageActive);

                if ($smarty->templateExists('file:[Invoice_' . $template . ']template.tpl')) {
					$smarty -> assign('biller',$biller);
					$smarty -> assign('customer',$customer);
					$smarty -> assign('invoice',$invoice);
					$smarty -> assign('invoice_number_of_taxes',$invoice_number_of_taxes);
					$smarty -> assign('preference',$preference);
					$smarty -> assign('logo',$logo);
					$smarty -> assign('template',$template);
					$smarty -> assign('invoiceItems',$invoiceItems);
					$smarty -> assign('css',$css);
					$smarty -> assign('customFieldLabels',$customFieldLabels);
					$smarty -> assign('customFieldDisplay',$customFieldDisplay);

					$data = $smarty->fetch('file:[Invoice_' . $template . ']template.tpl');
				}

				break;
			}

		}

		return $data;

	}
{
    return date("Y-m-d", strtotime('01-' . date('m') . '-' . date('Y') . ' 00:00:00'));
}
function lastOfMonth()
{
    return date("Y-m-d", strtotime('-1 second', strtotime('+1 month', strtotime('01-' . date('m') . '-' . date('Y') . ' 00:00:00'))));
}
isset($_POST['start_date']) ? $start_date = $_POST['start_date'] : ($start_date = firstOfMonth());
isset($_POST['end_date']) ? $end_date = $_POST['end_date'] : ($end_date = lastOfMonth());
$sql = "select \n        e.amount as expense, \n        e.status as status, \n        ea.name as account,\n        (select sum(tax_amount) from si_expense_item_tax where expense_id = e.id) as tax,\n        (select tax + e.amount) as total,\n        (CASE WHEN status = 1 THEN '" . $LANG['paid'] . "'\n              WHEN status = 0 THEN '" . $LANG['not_paid'] . "'\n         END) AS status_wording\n    from \n        si_expense e, \n        si_expense_account ea \n    where \n        e.expense_account_id = ea.id \n        and \n        e.date between '{$start_date}' and '{$end_date}'";
$sth = $db->query($sql);
$accounts = $sth->fetchAll();
$payment = new payment();
$payment->start_date = $start_date;
$payment->end_date = $end_date;
$payment->filter = "date";
$payments = $payment->select_all();
$invoice = new invoice();
$invoice->start_date = $start_date;
$invoice->end_date = $end_date;
$invoice->having = "date_between";
$invoice->sort = "preference";
$invoice_all = $invoice->select_all();
$invoices = $invoice_all->fetchAll();
$smarty->assign('accounts', $accounts);
$smarty->assign('payments', $payments);
$smarty->assign('invoices', $invoices);
$smarty->assign('start_date', $start_date);
$smarty->assign('end_date', $end_date);
$smarty->assign('pageActive', 'report');
$smarty->assign('active_tab', '#home');
Example #7
-1
 function getData()
 {
     //echo "export - get data";
     global $smarty;
     global $siUrl;
     switch ($this->module) {
         case "statement":
             $invoice = new invoice();
             $invoice->biller = $this->biller_id;
             $invoice->customer = $this->customer_id;
             if ($this->filter_by_date == "yes") {
                 if (isset($this->start_date)) {
                     $invoice->start_date = $this->start_date;
                 }
                 if (isset($this->end_date)) {
                     $invoice->end_date = $this->end_date;
                 }
                 if (isset($this->start_date) and isset($this->end_date)) {
                     $invoice->having = "date_between";
                 }
                 $having_count = 1;
             }
             if ($this->show_only_unpaid == "yes") {
                 if ($having_count == 1) {
                     $invoice->having_and = "money_owed";
                 } else {
                     $invoice->having = "money_owed";
                 }
             }
             $invoice_all = $invoice->select_all('count');
             $invoices = $invoice_all->fetchAll();
             foreach ($invoices as $i => $row) {
                 $statement['total'] = $statement['total'] + $row['invoice_total'];
                 $statement['owing'] = $statement['owing'] + $row['owing'];
                 $statement['paid'] = $statement['paid'] + $row['INV_PAID'];
             }
             $templatePath = "./templates/default/statement/index.tpl";
             $biller_details = getBiller($this->biller_id);
             $customer_details = getCustomer($this->customer_id);
             $this->file_name = "statement_" . $this->biller_id . "_" . $this->customer_id . "_" . $invoice->start_date . "_" . $invoice->end_date;
             $smarty->assign('biller_id', $biller_id);
             $smarty->assign('biller_details', $biller_details);
             $smarty->assign('customer_id', $customer_id);
             $smarty->assign('customer_details', $customer_details);
             $smarty->assign('show_only_unpaid', $show_only_unpaid);
             $smarty->assign('filter_by_date', $this->filter_by_date);
             $smarty->assign('invoices', $invoices);
             $smarty->assign('start_date', $this->start_date);
             $smarty->assign('end_date', $this->end_date);
             $smarty->assign('invoices', $invoices);
             $smarty->assign('statement', $statement);
             $data = $smarty->fetch("." . $templatePath);
             break;
         case "payment":
             $payment = getPayment($this->id);
             /*Code to get the Invoice preference - so can link from this screen back to the invoice - START */
             $invoice = getInvoice($payment['ac_inv_id']);
             $biller = getBiller($payment['biller_id']);
             $logo = getLogo($biller);
             $logo = str_replace(" ", "%20", $logo);
             $customer = getCustomer($payment['customer_id']);
             $invoiceType = getInvoiceType($invoice['type_id']);
             $customFieldLabels = getCustomFieldLabels();
             $paymentType = getPaymentType($payment['ac_payment_type']);
             $preference = getPreference($invoice['preference_id']);
             $smarty->assign("payment", $payment);
             $smarty->assign("invoice", $invoice);
             $smarty->assign("biller", $biller);
             $smarty->assign("logo", $logo);
             $smarty->assign("customer", $customer);
             $smarty->assign("invoiceType", $invoiceType);
             $smarty->assign("paymentType", $paymentType);
             $smarty->assign("preference", $preference);
             $smarty->assign("customFieldLabels", $customFieldLabels);
             $smarty->assign('pageActive', 'payment');
             $smarty->assign('active_tab', '#money');
             $css = $siUrl . "/templates/invoices/default/style.css";
             $smarty->assign('css', $css);
             $templatePath = "./templates/default/payments/print.tpl";
             $data = $smarty->fetch("." . $templatePath);
             break;
         case "invoice":
             $invoice = invoice::select($this->id);
             $invoice_number_of_taxes = numberOfTaxesForInvoice($this->id);
             $customer = getCustomer($invoice['customer_id']);
             $biller = biller::select($invoice['biller_id']);
             $preference = getPreference($invoice['preference_id']);
             $defaults = getSystemDefaults();
             $logo = getLogo($biller);
             $logo = str_replace(" ", "%20", $logo);
             $invoiceItems = invoice::getInvoiceItems($this->id);
             $spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
             $this->file_name = $spc2us_pref;
             $customFieldLabels = getCustomFieldLabels();
             /*Set the template to the default*/
             $template = $defaults['template'];
             $templatePath = "./templates/invoices/{$template}/template.tpl";
             $template_path = "../templates/invoices/{$template}";
             $css = $siUrl . "/templates/invoices/{$template}/style.css";
             $pluginsdir = "./templates/invoices/{$template}/plugins/";
             //$smarty = new Smarty();
             $smarty->plugins_dir = $pluginsdir;
             $pageActive = "invoices";
             $smarty->assign('pageActive', $pageActive);
             if (file_exists($templatePath)) {
                 //echo "test";
                 $smarty->assign('biller', $biller);
                 $smarty->assign('customer', $customer);
                 $smarty->assign('invoice', $invoice);
                 $smarty->assign('invoice_number_of_taxes', $invoice_number_of_taxes);
                 $smarty->assign('preference', $preference);
                 $smarty->assign('logo', $logo);
                 $smarty->assign('template', $template);
                 $smarty->assign('invoiceItems', $invoiceItems);
                 $smarty->assign('template_path', $template_path);
                 $smarty->assign('css', $css);
                 $smarty->assign('customFieldLabels', $customFieldLabels);
                 $data = $smarty->fetch("." . $templatePath);
             }
             break;
     }
     return $data;
 }