Exemplo n.º 1
0
 public function testSaveAndMark_deleted()
 {
     error_reporting(E_ERROR | E_PARSE);
     $aosInvoices = new AOS_Invoices();
     $aosInvoices->name = 'test';
     $aosInvoices->save();
     //test for record ID to verify that record is saved
     $this->assertTrue(isset($aosInvoices->id));
     $this->assertEquals(36, strlen($aosInvoices->id));
     $this->assertGreaterThan(0, $aosInvoices->number);
     //mark the record as deleted and verify that this record cannot be retrieved anymore.
     $aosInvoices->mark_deleted($aosInvoices->id);
     $result = $aosInvoices->retrieve($aosInvoices->id);
     $this->assertEquals(null, $result);
 }
Exemplo n.º 2
0
<?php

if (!isset($_REQUEST['record']) || empty($_REQUEST['record']) || !isset($_REQUEST['templateID']) || empty($_REQUEST['templateID'])) {
    die('Error retrieving record. This record may be deleted or you may not be authorized to view it.');
}
error_reporting(0);
require_once 'modules/AOS_Invoices/AOS_Invoices.php';
require_once 'modules/AOS_Quotes/PDF_Lib/html2pdf.class.php';
require_once 'modules/AOS_Quotes/TemplateParser.php';
require_once 'modules/AOS_PDF_Templates/AOS_PDF_Templates.php';
$invoice = new AOS_Invoices();
$invoice->retrieve($_REQUEST['record']);
$lineItems = array();
$sql = "SELECT id, product_id FROM aos_products_quotes WHERE parent_type = 'AOS_Invoices' AND parent_id = '" . $this->bean->id . "' AND deleted = 0";
$res = $invoice->db->query($sql);
while ($row = $invoice->db->fetchByAssoc($res)) {
    $lineItems[$row['id']] = $row['product_id'];
}
$tempalte = new AOS_PDF_Templates();
$tempalte->retrieve($_REQUEST['templateID']);
$object_arr = array();
$object_arr['AOS_Invoices'] = $invoice->id;
$search = array('@<script[^>]*?>.*?</script>@si', '@<[\\/\\!]*?[^<>]*?>@si', '@([\\r\\n])[\\s]+@', '@&(quot|#34);@i', '@&(amp|#38);@i', '@&(lt|#60);@i', '@&(gt|#62);@i', '@&(nbsp|#160);@i', '@&(iexcl|#161);@i', '@&(cent|#162);@i', '@&(pound|#163);@i', '@&(copy|#169);@i', '@&#(\\d+);@e', '@<address[^>]*?>@si');
$replace = array('', '', '\\1', '"', '&', '<', '>', ' ', chr(161), chr(162), chr(163), chr(169), 'chr(\\1)', '<br>');
$text = preg_replace($search, $replace, $tempalte->description);
$text = str_replace('aos_quotes', 'aos_invoices', $text);
$text = str_replace("\$subtotal_amount", "\$aos_invoices_subtotal_amount", $text);
$text = str_replace("\$tax_amount", "\$aos_invoices_tax_amount", $text);
$text = str_replace("\$shipping_amount", "\$aos_invoices_shipping_amount", $text);
$text = str_replace("\$total_amount", "\$aos_invoices_total_amount", $text);
//Converting Text