Example #1
0
 public function run()
 {
     global $db;
     $today = date('Y-m-d');
     $cron = new cron();
     $data = $cron->select_crons_to_run();
     $return['cron_message'] = "Cron started";
     $number_of_crons_run = "0";
     $cron_log = new cronlog();
     $cron_log->run_date = $today;
     foreach ($data as $key => $value) {
         $cron->domain_id = $value['domain_id'];
         $cron_log->cron_id = $value['id'];
         $cron_log->domain_id = $domain_id = $value['domain_id'];
         $check_cron_log = $cron_log->check();
         $i = "0";
         if ($check_cron_log == 0) {
             //only proceed if cron has not been run for today
             $run_cron = false;
             $start_date = date('Y-m-d', strtotime($value['start_date']));
             $end_date = $value['end_date'];
             // Seconds in a day = 60 * 60 * 24 = 86400
             $diff = number_format((strtotime($today) - strtotime($start_date)) / 86400, 0);
             //only check if diff is positive
             if ($diff >= 0 and ($end_date == "" or $end_date >= $today)) {
                 if ($value['recurrence_type'] == 'day') {
                     $modulus = $diff % $value['recurrence'];
                     if ($modulus == 0) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron does not runs TODAY-days";
                     }
                 }
                 if ($value['recurrence_type'] == 'week') {
                     $period = 7 * $value['recurrence'];
                     $modulus = $diff % $period;
                     if ($modulus == 0) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-week";
                     }
                 }
                 if ($value['recurrence_type'] == 'month') {
                     $start_day = date('d', strtotime($value['start_date']));
                     $start_month = date('m', strtotime($value['start_date']));
                     $start_year = date('Y', strtotime($value['start_date']));
                     $today_day = date('d');
                     $today_month = date('m');
                     $today_year = date('Y');
                     $months = $today_month - $start_month + 12 * ($today_year - $start_year);
                     $modulus = $months % $value['recurrence'];
                     if ($modulus == 0 and $start_day == $today_day) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-month";
                     }
                 }
                 if ($value['recurrence_type'] == 'year') {
                     $start_day = date('d', strtotime($value['start_date']));
                     $start_month = date('m', strtotime($value['start_date']));
                     $start_year = date('Y', strtotime($value['start_date']));
                     $today_day = date('d');
                     $today_month = date('m');
                     $today_year = date('Y');
                     $years = $today_year - $start_year;
                     $modulus = $years % $value['recurrence'];
                     if ($modulus == 0 and $start_day == $today_day and $start_month == $today_month) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-year";
                     }
                 }
                 //run the recurrence for this invoice
                 if ($run_cron) {
                     $number_of_crons_run++;
                     $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " was run today :: Info diff=" . $diff;
                     $i++;
                     $ni = new invoice();
                     $ni->id = $value['invoice_id'];
                     $ni->domain_id = $domain_id;
                     // $domain_id gets propagated from invoice to be copied from
                     $new_invoice_id = $ni->recur();
                     //insert into cron_log date of run
                     //$cron_log = new cronlog();
                     //$cron_log->run_date = $today;
                     //$cron_log->domain_id = $domain_id;
                     //$cron_log->cron_id = $value['cron_id'];
                     $cron_log->insert();
                     ## email the people
                     $invoiceobj = new invoice();
                     $invoice = $invoiceobj->select($new_invoice_id, $domain_id);
                     $preference = getPreference($invoice['preference_id'], $domain_id);
                     $biller = getBiller($invoice['biller_id'], $domain_id);
                     $customer = getCustomer($invoice['customer_id'], $domain_id);
                     #print_r($customer);
                     #create PDF nameVj
                     $spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
                     $pdf_file_name_invoice = $spc2us_pref . ".pdf";
                     // email invoice
                     if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
                         $export = new export();
                         $export->domain_id = $domain_id;
                         $export->format = "pdf";
                         $export->file_location = 'file';
                         $export->module = 'invoice';
                         $export->id = $invoice['id'];
                         $export->execute();
                         #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
                         $email = new email();
                         $email->domain_id = $domain_id;
                         $email->format = 'cron_invoice';
                         $email_body = new email_body();
                         $email_body->email_type = 'cron_invoice';
                         $email_body->customer_name = $customer['name'];
                         $email_body->invoice_name = $invoice['index_name'];
                         $email_body->biller_name = $biller['name'];
                         $email->notes = $email_body->create();
                         $email->from = $biller['email'];
                         $email->from_friendly = $biller['name'];
                         $email->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']);
                         $email->invoice_name = $invoice['index_name'];
                         $email->subject = $email->set_subject();
                         $email->attachment = $pdf_file_name_invoice;
                         $return['email_message'] = $email->send();
                     }
                     //Check that all details are OK before doing the eway payment
                     $eway_check = new eway();
                     $eway_check->domain_id = $domain_id;
                     $eway_check->invoice = $invoice;
                     $eway_check->customer = $customer;
                     $eway_check->biller = $biller;
                     $eway_check->preference = $preference;
                     $eway_pre_check = $eway_check->pre_check();
                     //do eway payment
                     if ($eway_pre_check == 'true') {
                         // input customerID,  method (REAL_TIME, REAL_TIME_CVN, GEO_IP_ANTI_FRAUD) and liveGateway or not
                         $eway = new eway();
                         $eway->domain_id = $domain_id;
                         $eway->invoice = $invoice;
                         $eway->biller = $biller;
                         $eway->customer = $customer;
                         $payment_done = $eway->payment();
                         $payment_id = $db->lastInsertID();
                         $pdf_file_name_receipt = 'payment' . $payment_id . '.pdf';
                         if ($payment_done == 'true') {
                             //do email of receipt to biller and customer
                             if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
                                 /*
                                  * If you want a new copy of the invoice being emailed to the customer 
                                  * use this code
                                  */
                                 $export_rec = new export();
                                 $export_rec->domain_id = $domain_id;
                                 $export_rec->format = "pdf";
                                 $export_rec->file_location = 'file';
                                 $export_rec->module = 'invoice';
                                 $export_rec->id = $invoice['id'];
                                 $export_rec->execute();
                                 #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
                                 $email_rec = new email();
                                 $email_rec->domain_id = $domain_id;
                                 $email_rec->format = 'cron_invoice';
                                 $email_body_rec = new email_body();
                                 $email_body_rec->email_type = 'cron_invoice_receipt';
                                 $email_body_rec->customer_name = $customer['name'];
                                 $email_body_rec->invoice_name = $invoice['index_name'];
                                 $email_body_rec->biller_name = $biller['name'];
                                 $email_rec->notes = $email_body_rec->create();
                                 $email_rec->from = $biller['email'];
                                 $email_rec->from_friendly = $biller['name'];
                                 $email_rec->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']);
                                 $email_rec->invoice_name = $invoice['index_name'];
                                 $email_rec->attachment = $pdf_file_name_invoice;
                                 $email_rec->subject = $email_rec->set_subject('invoice_eway_receipt');
                                 $return['email_message'] = $email_rec->send();
                                 /*
                                  * If you want a receipt as PDF being emailed to the customer
                                  * uncomment the code below
                                  */
                                 /*
                                 $export = new export();
                                 $export -> format = "pdf";
                                 $export -> file_location = 'file';
                                 $export -> module = 'payment';
                                 $export -> id = $payment_id;
                                 $export -> execute();
                                 
                                 $email = new email();
                                 $email -> format = 'cron_payment';
                                 
                                     $email_body = new email_body();
                                     $email_body->email_type = 'cron_payment';
                                     $email_body->customer_name = $customer['name'];
                                     $email_body->invoice_name = 'payment'.$payment_id;
                                     $email_body->biller_name = $biller['name'];
                                 
                                 $email -> notes = $email_body->create();
                                 $email -> from = $biller['email'];
                                 $email -> from_friendly = $biller['name'];
                                 if($value['email_customer'] == "1")
                                 {
                                     $email -> to = $customer['email'];
                                 }
                                 if($value['email_biller'] == "1" AND $value['email_customer'] == "1")
                                 {
                                     $email -> to = $customer['email'].";".$biller['email'];
                                 }
                                 if($value['email_biller'] == "1" AND $value['email_customer'] == "0")
                                 {
                                     $email -> to = $customer['email'];
                                 }
                                 $email -> subject = $pdf_file_name_receipt." from ".$biller['name'];
                                 $email -> attachment = $pdf_file_name_receipt;
                                 $return['email_message'] = $email->send();
                                 */
                             }
                         } else {
                             //do email to biller/admin - say error
                             $email = new email();
                             $email->domain_id = $domain_id;
                             $email->format = 'cron_payment';
                             $email->from = $biller['email'];
                             $email->from_friendly = $biller['name'];
                             $email->to = $biller['email'];
                             $email->subject = "Payment failed for " . $invoice['index_name'];
                             $error_message = "Invoice:  " . $invoice['index_name'] . "<br /> Amount: " . $invoice['total'] . " <br />";
                             foreach ($eway->get_message() as $key => $value) {
                                 $error_message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
                             }
                             $email->notes = $error_message;
                             $return['email_message'] = $email->send();
                         }
                     }
                 } else {
                     //cron not run for this cron_id
                     $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff;
                 }
             } else {
                 //days diff is negative - whats going on
                 $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: - Not cheduled for today - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff;
             }
         } else {
             // cron has already been run for that cron_id today
             $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron has already been run for domain: " . $domain_id . " for the date: " . $today . " for invoice " . $value['invoice_id'];
             $return['email_message'] = "";
         }
     }
     // no crons scheduled for today
     if ($number_of_crons_run == '0') {
         $return['id'] = $i;
         $return['cron_message'] = "No invoices recurred for this cron run for domain: " . $domain_id . " for the date: " . $today;
         $return['email_message'] = "";
     }
     //insert into cron_log date of run
     /*
     		    $cron_log = new cronlog();
         $cron_log->run_date = $today;
         $cron_log->domain_id = $domain_id;
         $cron_log->insert();
     */
     /*
      * If you want to get an email once cron has been run edit the below details
      *
      */
     /*
         $email = new email();
         $email -> format = 'cron';
         #$email -> notes = $return;
         $email -> from = "simpleinvoices@localhost";
         $email -> from_friendly = "Simple Invoices - Cron";
         $email -> to = "simpleinvoices@localhost";
         #$email -> bcc = $_POST['email_bcc'];
         $email -> subject = "Cron for Simple Invoices has been run for today:";
         $email -> send ();
     */
     return $return;
 }
Example #2
0
 public function payment()
 {
     global $config;
     global $logger;
     //set customer,biller and preference if not defined
     if (empty($this->customer)) {
         $this->customer = getCustomer($this->invoice['customer_id'], $this->domain_id);
     }
     if (empty($this->biller)) {
         $this->biller = getBiller($this->invoice['biller_id'], $this->domain_id);
     }
     if (empty($this->preference)) {
         $this->preference = getPreference($this->invoice['preference_id'], $this->domain_id);
     }
     $eway = new ewaylib($this->biller['eway_customer_id'], 'REAL_TIME', false);
     //Eway only accepts amount in cents - so times 100
     $value = $this->invoice['total'] * 100;
     $eway_invoice_total = htmlsafe(trim($value));
     $logger->log("eway total: " . $eway_invoice_total, Zend_Log::INFO);
     $enc = new encryption();
     $key = $config->encryption->default->key;
     $credit_card_number = $enc->decrypt($key, $this->customer['credit_card_number']);
     $eway->setTransactionData("TotalAmount", $eway_invoice_total);
     //mandatory field
     $eway->setTransactionData("CustomerFirstName", $this->customer['name']);
     $eway->setTransactionData("CustomerLastName", "");
     $eway->setTransactionData("CustomerAddress", "");
     $eway->setTransactionData("CustomerPostcode", "");
     $eway->setTransactionData("CustomerInvoiceDescription", "");
     $eway->setTransactionData("CustomerEmail", $this->customer['email']);
     $eway->setTransactionData("CustomerInvoiceRef", $this->invoice['index_name']);
     $eway->setTransactionData("CardHoldersName", $this->customer['credit_card_holder_name']);
     //mandatory field
     $eway->setTransactionData("CardNumber", $credit_card_number);
     //mandatory field
     $eway->setTransactionData("CardExpiryMonth", $this->customer['credit_card_expiry_month']);
     //mandatory field
     $eway->setTransactionData("CardExpiryYear", $this->customer['credit_card_expiry_year']);
     //mandatory field
     $eway->setTransactionData("Option1", "");
     $eway->setTransactionData("Option2", "");
     $eway->setTransactionData("Option3", "");
     $eway->setTransactionData("TrxnNumber", $this->invoice['id']);
     //special preferences for php Curl
     //pass a long set to zero value stops curl from verifying peer's certificate
     $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0);
     $ewayResponseFields = $eway->doPayment();
     $this->message = $ewayResponseFields;
     $message = "";
     if ($ewayResponseFields["EWAYTRXNSTATUS"] == "False") {
         $logger->log("Transaction Error: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO);
         foreach ($ewayResponseFields as $key => $value) {
             $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
         }
         $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO);
         //header("Location: trasnactionerrorpage.php");
         //exit();
         $return = 'false';
     } else {
         if ($ewayResponseFields["EWAYTRXNSTATUS"] == "True") {
             $logger->log("Transaction Success: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO);
             foreach ($ewayResponseFields as $key => $value) {
                 $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
             }
             $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO);
             //header("Location: trasnactionsuccess.php");
             //exit();
             $payment = new payment();
             $payment->ac_inv_id = $this->invoice['id'];
             #$payment->ac_inv_id = $_POST['invoice'];
             $payment->ac_amount = $this->invoice['total'];
             #$payment->ac_amount = $ewayResponseFields['EWAYRETURNAMOUNT']/100;
             #$payment->ac_amount = $_POST['mc_gross'];
             $payment->ac_notes = $message;
             $payment->ac_date = date('Y-m-d');
             $payment->online_payment_id = $ewayResponseFields['EWAYTRXNNUMBER'];
             $payment->domain_id = $this->domain_id;
             $payment_type = new payment_type();
             $payment_type->type = "Eway";
             $payment_type->domain_id = $this->domain_id;
             $payment->ac_payment_type = $payment_type->select_or_insert_where();
             $logger->log('Paypal - payment_type=' . $payment->ac_payment_type, Zend_Log::INFO);
             $payment->insert();
             #echo $db->lastInsertID();
             $return = 'true';
         }
     }
     return $return;
 }
Example #3
0
* 	Email invoice page
*
* License:
*	 GPL v3 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
$invoice_id = $_GET['id'];
$invoiceobj = new invoice();
$invoice = $invoiceobj->select($invoice_id);
$preference = getPreference($invoice['preference_id']);
$biller = getBiller($invoice['biller_id']);
$customer = getCustomer($invoice['customer_id']);
$invoiceType = getInvoiceType($invoice['type_id']);
#create PDF name
$spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
$pdf_file_name = $spc2us_pref . '.pdf';
if ($_GET['stage'] == 2) {
    #echo $block_stage2;
    // Create invoice
    $export = new export();
    $export->format = "pdf";
    $export->file_location = 'file';
    $export->module = 'invoice';
    $export->id = $invoice_id;
    $export->execute();
    #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
Example #4
0
<?php

//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
$menu = false;
$payment = getPayment($_GET['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');
Example #5
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();
#get the invoice id
$biller_id = $_GET['id'];
$biller = getBiller($biller_id);
/*drop down list code for invoice logo */
$files = getLogoList();
/*end logo stuff */
#get custom field labels
$customFieldLabel = getCustomFieldLabels();
$smarty->assign('biller', $biller);
/*
$smarty -> assign('enabled', array(
                               0 => $LANG[disabled],
				1 => $LANG[enabled]
			)
		);
*/
$smarty->assign('files', $files);
$smarty->assign('customFieldLabel', $customFieldLabel);
        $invoice->having_and = "date_between";
        $filter_by_date = "yes";
        $having_and_count = 1;
    }
    $invoice->sort = "date";
    $invoice_all = $invoice->select_all();
    $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'];
    }
}
$sql = "select DISTINCT(custom_field3) from  " . TB_PREFIX . "invoices where custom_field3 != ''";
$cf3 = $db->query($sql);
$biller_details = getBiller($biller_id);
$customer_details = getCustomer($customer_id);
$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('cf3', $cf3->fetchAll());
$smarty->assign('custom_field3', $custom_field3);
$smarty->assign('filter_by_date', $filter_by_date);
$smarty->assign('invoices', $invoices);
$smarty->assign('statement', $statement);
$smarty->assign('start_date', $start_date);
$smarty->assign('end_date', $end_date);
$smarty->assign('pageActive', 'report');
$smarty->assign('active_tab', '#home');
$smarty->assign('menu', $menu);
Example #7
0
* Website:
* 	http://www.simpleinvoices.org
*/
//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
$biller_id = $_GET['biller_id'];
$customer_id = $_GET['customer_id'];
$filter_by_date = $_GET['filter_by_date'];
if ($filter_by_date == "yes") {
    $start_date = $_GET['start_date'];
    $end_date = $_GET['end_date'];
}
$show_only_unpaid = $_GET['show_only_unpaid'];
$get_format = $_GET['format'];
$get_file_type = $_GET['filetype'];
$biller = getBiller($_GET['biller_id']);
$customer = getCustomer($_GET['customer_id']);
#create PDF name
if ($_GET['stage'] == 2) {
    #echo $block_stage2;
    #get the invoice id
    $export = new export();
    $export->format = 'pdf';
    $export->file_type = $get_file_type;
    $export->file_location = 'file';
    $export->module = 'statement';
    $export->biller_id = $biller_id;
    $export->customer_id = $customer_id;
    $export->start_date = $start_date;
    $export->end_date = $end_date;
    $export->show_only_unpaid = $show_only_unpaid;
Example #8
-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;
 }