Exemplo n.º 1
0
	$default = "delete";
	$description = $LANG['delete'];
	$value = dropDown($array, $defaults['delete']);
}
else if ($_GET['submit'] == "logging") {

	$array = array(0 => $LANG['disabled'], 1=>$LANG['enabled']);
	$default = "logging";
	$description = $LANG['logging'];
	$value = dropDown($array, $defaults[$default]);
}

else if($_GET['submit'] == "language") {
    $default = "language";
    $languages = getLanguageList($include_dir . 'sys/lang/');
    $system_defaults = new SimpleInvoices_Db_Table_SystemDefaults();
    $lang = $system_defaults->findByName('language');

    usort($languages,"compareNameIndex");

    $description = $LANG['language'];
    //print_r($languages);
    $value = "<select name='value'>";
    foreach($languages as $language) {
        $selected = "";
        if($language->shortname == $lang) {
            $selected = " selected ";
        }
        $value .= "<option $selected value='".htmlsafe($language->shortname)."'>".htmlsafe("$language->name ($language->englishname) ($language->shortname)")."</option>";
    }
    $value .= "</select>";
Exemplo n.º 2
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;

	}
Exemplo n.º 3
0
*	 Justin Kelly, Nicolas Ruflin
*
* Last edited:
* 	 2007-07-19
*
* License:
*	 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();

$SI_PRODUCTS = new SimpleInvoices_Db_Table_Products();
$SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults();
$SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers();
$SI_TAX = new SimpleInvoices_Db_Table_Tax();
$SI_BILLER = new SimpleInvoices_Db_Table_Biller();
$SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences();

$billers = $SI_BILLER->fetchAllActive();
$customers = $SI_CUSTOMERS->fetchAllActive();
$taxes = $SI_TAX->fetchAllActive();
$products = $SI_PRODUCTS->findActive();
$preferences = $SI_PREFERENCES->fetchAllActive();
$defaults = $SI_SYSTEM_DEFAULTS->fetchAll();


$defaultBiller = $SI_BILLER->getDefault();
$defaultCustomerID = (isset($_GET['customer_id'])) ? $_GET['customer_id'] : $SI_CUSTOMERS->getDefault();
Exemplo n.º 4
0
<?php

//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();

//gets the long language name out of the short name
$SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults();
$SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes();
$SI_CUSTOMERS = new SimpleInvoices_Db_Table_Customers();
$SI_BILLER = new SimpleInvoices_Db_Table_Biller();
$SI_TAX = new SimpleInvoices_Db_Table_Tax();
$SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences();

$lang = $SI_SYSTEM_DEFAULTS->findByName('language');
$languages = getLanguageList($include_dir . 'sys/lang/');
foreach($languages as $language) {
	if($language->shortname == $lang) {
		$lang = $language->name;
		break;
	}
}

// Default delete
$defaults['delete'] = $system_defaults->findByName('delete');
$defaults['delete'] = $defaults['delete']==1?$LANG['enabled']:$LANG['disabled'];

// Default Logging
$defaults['logging'] = $system_defaults->findByName('logging');
$defaults['logging'] = $defaults['logging']==1?$LANG['enabled']:$LANG['disabled'];

// Default inventory
Exemplo n.º 5
0
$dbAdapter = Zend_Db::factory($config->resources->db->adapter, array(
    'host'     => $config->resources->db->params->host,
    'username' => $config->resources->db->params->username,
    'password' => $config->resources->db->params->password,
    'dbname'   => $config->resources->db->params->dbname)
);
*/
$errorMessage = '';
if (!empty($_POST['value'])) {
    $cust_language = $_POST['value'];
    $language = $cust_language;
    $smarty -> assign("LANG",getLanguageArray());
}

// System defaults are needed in several places
$system_defaults = new SimpleInvoices_Db_Table_SystemDefaults();

if (!empty($_POST['user']) && !empty($_POST['pass']))
{ 
    $errorMessage = $system_defaults->update('language', $language);
////	require_once 'Zend/Auth/Adapter/DbTable.php';

	// Configure the instance with constructor parameters...
	//$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter, 'users', 'username', 'password');

	// ...or configure the instance with setter methods
	$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());

	//sql patch 161 changes user table name - need to accomodate
	$user_table = (SimpleInvoices_Db_Table_SQLPatchManager::getNumberOfDoneSQLPatches() < "161") ? "users" : "user";
	$user_email = (SimpleInvoices_Db_Table_SQLPatchManager::getNumberOfDoneSQLPatches() < "184") ? "user_email" : "email";
Exemplo n.º 6
0
else $extension_name = NULL;

$action = $_GET['action'];

if (isset($_GET['description'])) $extension_desc = $_GET['description'];
else $extension_desc = NULL;



if ($extension_id == null) {	// extension not yet registered
    $count = 0;
} else {
    $SI_EXTENSIONS = new SimpleInvoices_Db_Table_Extensions();
    $info = $SI_EXTENSIONS->getExtensionById($extension_id);
    $extension_name = $info['name'];
    $extension_desc = $info['description'];

    $system_defaults = new SimpleInvoices_Db_Table_SystemDefaults();
    $extension_defaults = $system_defaults->fetchAllForExtension($extension_id);
    $count = count($extension_defaults);
}

$smarty-> assign('id',$extension_id);
$smarty-> assign('action',$action);
$smarty-> assign('name',$extension_name);
$smarty-> assign('count',$count);
$smarty-> assign('description',$extension_desc);
$smarty-> assign('pageActive','extensions');
$smarty-> assign('active_tab','#settings');
?>
Exemplo n.º 7
0
<?php

//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();

$SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults();
$SI_TAX = new SimpleInvoices_Db_Table_Tax();
$SI_CUSTOM_FIELDS = new SimpleInvoices_Db_Table_CustomFields();

#get custom field labels
$customFieldLabel = $SI_CUSTOM_FIELDS->getLabels();
$taxes = $SI_TAX->fetchAllActive();
//if valid then do save
if (array_key_exists('description', $_POST)) {
    if ($_POST['description'] != "" ) {
        include("sys/modules/products/save.php");
    }    
}

$smarty -> assign("defaults",$SI_SYSTEM_DEFAULTS->fetchAll());
$smarty -> assign('customFieldLabel',$customFieldLabel);
if (isset($save)) {
    $smarty -> assign('save',$save);
} else {
    $smarty -> assign('save','');
}
$smarty -> assign('taxes',$taxes);

$smarty -> assign('pageActive', 'product_add');
$smarty -> assign('active_tab', '#product');
Exemplo n.º 8
0
<?php

checkLogin();

# Deal with op and add some basic sanity checking

error_log($_POST['name']."  ".$_POST['value']);

$saved = false;

if (isset($_POST['op']) && $_POST['op'] == 'update_system_defaults' ) {
    $system_defaults = new SimpleInvoices_Db_Table_SystemDefaults();
    $saved = $system_defaults->update($_POST['name'], $_POST['value']);
}
$smarty -> assign("saved",$saved);

$smarty -> assign('pageActive', 'system_default');
$smarty -> assign('active_tab', '#setting');