Inheritance: extends SugarBean
 public function requireDefaultRecords()
 {
     // If no tax rates, setup some defaults
     if (!TaxRate::get()->exists()) {
         $vat = TaxRate::create();
         $vat->Title = "VAT";
         $vat->Amount = 20;
         $vat->Code = "T1";
         $vat->write();
         DB::alteration_message('VAT tax rate created.', 'created');
         $reduced = TaxRate::create();
         $reduced->Title = "Reduced rate";
         $reduced->Amount = 5;
         $reduced->Code = "T2";
         $reduced->write();
         DB::alteration_message('Reduced tax rate created.', 'created');
         $zero = TaxRate::create();
         $zero->Title = "Zero rate";
         $zero->Amount = 0;
         $zero->Code = "T4";
         $zero->write();
         DB::alteration_message('Zero tax rate created.', 'created');
     }
     parent::requireDefaultRecords();
 }
 public function updateCMSFields(FieldList $fields)
 {
     // Add config sets
     $fields->addFieldToTab('Root.Catalogue', UploadField::create('DefaultProductImage', _t("Catalogue.DefaultProductImage", 'Default product image')));
     // Add config sets
     $fields->addFieldToTab('Root.Catalogue', GridField::create('TaxRates', _t("Catalogue.TaxRates", "Tax Rates"), TaxRate::get(), GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm())));
 }
 public static function importTaxPercent(&$obj, $val, $record)
 {
     $tax_rate = TaxRate::get()->filter("Amount", $val)->first();
     if ($tax_rate) {
         $obj->TaxRateID = $tax_rate->ID;
     }
 }
 private function saveRate(DeliveryZone $zone, Tax $tax, TaxClass $class = null)
 {
     $value = $this->request->get($this->getFieldName($tax, $class));
     if (!is_null($value) && $value !== '') {
         $taxRate = TaxRate::getNewInstance($zone, $tax, $value);
         $taxRate->taxClass->set($class);
         $taxRate->save();
         return $taxRate;
     }
 }
 public function run()
 {
     $this->trancate();
     $tax_rate_23 = TaxRate::whereName("FPA 23%")->first();
     $tax_rate_8 = TaxRate::whereName("FPA 8%")->first();
     $tax_class_id = DB::table('tax_classes')->insertGetId(array('name' => "Taxable products", 'description' => "Taxable products"));
     DB::table('tax_rules')->insert(array('tax_class_id' => $tax_class_id, 'tax_rate_id' => $tax_rate_23->id));
     DB::table('tax_rules')->insert(array('tax_class_id' => $tax_class_id, 'tax_rate_id' => $tax_rate_8->id));
     $tax_class_id = DB::table('tax_classes')->insertGetId(array('name' => "Non Taxable products", 'description' => "Non Taxable products"));
 }
Exemple #6
0
 public function calc_percentage($rate_id, $status_id, $amount)
 {
     $rate = new TaxRate();
     $rate->load($rate_id);
     // If no rate supplied then return zero
     if (!$rate->isLoaded()) {
         return 0;
     }
     $rate_percentage = $rate->percentage;
     $status = new TaxStatus();
     $status->load($status_id);
     // If no status supplied then by default apply tax
     if (!$status->isLoaded()) {
         $status->apply_tax = 't';
     }
     if ($status->apply_tax === 't') {
         $percentage = $rate_percentage;
     } else {
         $percentage = 0;
     }
     return bcdiv($percentage, 100, 4);
 }
Exemple #7
0
 /**
  * Get a list of existing taxes
  *
  * @param boolean $includeDisabled Include disabled taxes in this list
  * @param TaxRate $doNotBelongToRate Don not belong to specified rate
  * @param boolean $loadReferencedRecords Load referenced records
  *
  * @return ARSet
  */
 public static function getTaxes(DeliveryZone $notUsedInThisZone = null, $loadReferencedRecords = false)
 {
     $filter = new ARSelectFilter();
     $rates = TaxRate::getRecordSetByDeliveryZone($notUsedInThisZone);
     if ($rates->getTotalRecordCount() > 0) {
         $zoneRatesIDs = array();
         foreach ($rates as $rate) {
             $taxIDs[] = $rate->tax->get()->getID();
         }
         $notInCond = new NotINCond(new ARFieldHandle(__CLASS__, "ID"), $taxIDs);
         $filter->setCondition($notInCond);
     }
     return self::getRecordSet($filter, $loadReferencedRecords);
 }
 public function actionCreate()
 {
     $model = new TaxRate();
     $description = new TaxRateDescription();
     $this->performAjaxValidation(array($model, $description), 'tax-rate-form');
     if (isset($_POST[$this->modelName])) {
         $model->setAttributes($_POST[$this->modelName]);
         $description->setAttributes($_POST[$this->modelName . 'Description']);
         $suc = Yii::t('info', 'TaxRate was successfully created');
         $err = Yii::t('info', 'Could not update TaxRate');
         $description->tax_rate_id = 0;
         $description->locale_code = Yii::app()->getLanguage();
         if ($model->validate() && $description->validate()) {
             if ($model->save()) {
                 $description->tax_rate_id = $model->id;
                 $description->save();
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc);
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_view', array('model' => $model, 'description' => $description), false, true);
                     Yii::app()->end();
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err);
             }
         } else {
             $description->validate();
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form', array('model' => $model, 'description' => $description), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'description' => $description));
 }
 public function showSection($section = ACCOUNT_DETAILS, $subSection = false)
 {
     if ($section == ACCOUNT_DETAILS) {
         $data = ['account' => Account::with('users')->findOrFail(Auth::user()->account_id), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(), 'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(), 'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'languages' => Language::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'taxRates' => TaxRate::orderBy('name')->get()];
         return View::make('accounts.details', $data);
     } else {
         if ($section == ACCOUNT_NOTIFICATIONS) {
             $data = ['account' => Account::with('users')->findOrFail(Auth::user()->account_id)];
             return View::make('accounts.notifications', $data);
         } else {
             if ($section == ACCOUNT_IMPORT_EXPORT) {
                 return View::make('accounts.import_export');
             } else {
                 if ($section == ACCOUNT_ADVANCED_SETTINGS) {
                     $data = ['account' => Auth::user()->account, 'feature' => $subSection];
                     return View::make("accounts.{$subSection}", $data);
                 } else {
                     if ($section == ACCOUNT_PRODUCTS) {
                         $data = ['account' => Auth::user()->account];
                         return View::make('accounts.products', $data);
                     } else {
                         if ($section == ACCOUNT_BRANCHES) {
                             $data = ['account' => Auth::user()->account];
                             return View::make('accounts.branches', $data);
                         } else {
                             if ($section == ACCOUNT_GROUPS) {
                                 $data = ['account' => Auth::user()->account];
                                 return View::make('accounts.groups', $data);
                             } else {
                                 if ($section == ACCOUNT_USERS) {
                                     $data = ['account' => Auth::user()->account];
                                     return View::make('accounts.user_management', $data);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Delete existing currency
  *
  * @param void
  * @return null
  */
 function delete()
 {
     if ($this->active_tax_rate->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_tax_rate->canDelete($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->request->isSubmitted()) {
         $delete = $this->active_tax_rate->delete();
         if ($delete && !is_error($delete)) {
             flash_success('Tax rate ":name" has been deleted', array('name' => $this->active_tax_rate->getName()));
         } else {
             flash_error('Failed to delete ":name" tax rate', array('name' => $this->active_tax_rate->getName()));
         }
         // if
         $this->redirectTo('admin_tax_rates');
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
 public function editarpost()
 {
     // return Response::json(Input::all());
     //revisar esto hacer que funcione los campos adicionales
     if (Auth::user()->is_admin) {
         $base64 = null;
         $cuenta = Account::find(Auth::user()->account_id);
         if ($cuenta->custom_client_label1 && Input::get('l1') == "") {
             $cuenta->custom_client_label1 = "Dato Adicional";
         } else {
             $cuenta->custom_client_label1 = Input::get('l1');
         }
         if ($cuenta->custom_client_label2 && Input::get('l2') == "") {
             $cuenta->custom_client_label2 = "Dato Adicional";
         } else {
             $cuenta->custom_client_label2 = Input::get('l2');
         }
         if ($cuenta->custom_client_label3 && Input::get('l3') == "") {
             $cuenta->custom_client_label3 = "Dato Adicional";
         } else {
             $cuenta->custom_client_label3 = Input::get('l3');
         }
         if ($cuenta->custom_client_label4 && Input::get('l4') == "") {
             $cuenta->custom_client_label4 = "Dato Adicional";
         } else {
             $cuenta->custom_client_label4 = Input::get('l4');
         }
         if ($cuenta->custom_client_label5 && Input::get('l5') == "") {
             $cuenta->custom_client_label5 = "Dato Adicional";
         } else {
             $cuenta->custom_client_label5 = Input::get('l5');
         }
         if ($cuenta->custom_client_label6 && Input::get('l6') == "") {
             $cuenta->custom_client_label6 = "Dato Adicional";
         } else {
             $cuenta->custom_client_label6 = Input::get('l6');
         }
         $tax_rates = TaxRate::find(Auth::user()->account_id);
         $ice = Input::get('rate');
         if (is_numeric($ice)) {
             $tax_rates->rate = $ice;
         }
         $tax_rates->save();
         $cuenta->save();
         if (Input::hasFile('imgInp')) {
             $file = Input::file('imgInp')->getRealPath();
             $data = file_get_contents($file);
             $base64 = base64_encode($data);
             if (!function_exists('mime_content_type ')) {
                 $finfo = finfo_open(FILEINFO_MIME);
                 $mime = finfo_file($finfo, $file);
                 finfo_close($finfo);
             } else {
                 $mime = mime_content_type($file);
             }
             // $src = 'data:image/jpg;base64,'.$base64;
             $src = $base64;
             $td = TypeDocument::getDocumento();
             $td->logo = $src;
             //this part is to update a logo for a document
             //
             //                        $masters=  MasterDocument::get();
             //                        foreach ($masters as $master)
             //                        {
             //                            $typeDocument = TypeDocument::where("account_id",Auth::user()->account_id)->where("master_id",$master->id)->orderBy("id")->first();
             //                            if(isset($typeDocument))
             //                            {
             //                                $newType =  TypeDocument::createNew();
             //                                $newType->account_id = $typeDocument->id;
             //                                $newType->master_id = $typeDocument->master_id;
             //                                $newType->logo=$src;
             //                                $newType->javascript_web = $typeDocument->javascript_web;
             //                                $newType->javascript_pos = $typeDocument->javascript_pos;
             //                                $newType->save();
             //                            }
             //                        }
             //
             //return 0;
             $td->setMasterIds(Input::get('documentos'));
             if ($td->Actualizar()) {
                 //    redireccionar con el mensaje a la siguiente vista
                 Session::flash('message', $td->getErrorMessage());
                 return Redirect::to('editarcuenta');
             }
         }
         //Session::flash('error',"Seleccione una imagen antes de guardar.  ");
     }
     return Redirect::to('editarcuenta');
 }
 public function getCMSFields()
 {
     // Get a list of available product classes
     $classnames = ClassInfo::getValidSubClasses("CatalogueProduct");
     $product_array = array();
     foreach ($classnames as $classname) {
         if ($classname != "CatalogueProduct") {
             $description = Config::inst()->get($classname, 'description');
             if ($classname == 'Product' && !$description) {
                 $description = self::config()->description;
             }
             $description = $description ? $classname . ' - ' . $description : $classname;
             $product_array[$classname] = $description;
         }
     }
     // If we are creating a product, let us choose the product type
     if (!$this->ID) {
         $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', HiddenField::create("Title")->setValue(_t("Catalogue.NewProduct", "New Product")), ProductTypeField::create("ClassName", _t("Catalogue.SelectProductType", "Select a type of Product"), $product_array))));
     } else {
         // If CMS Installed, use URLSegmentField, otherwise use text
         // field for URL
         if (class_exists('SiteTreeURLSegmentField')) {
             $baseLink = Controller::join_links(Director::absoluteBaseURL());
             $url_field = SiteTreeURLSegmentField::create("URLSegment");
             $url_field->setURLPrefix($baseLink);
         } else {
             $url_field = TextField::create("URLSegment");
         }
         $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', TextField::create("Title", $this->fieldLabel('Title')), $url_field, HTMLEditorField::create('Content', $this->fieldLabel('Content'))->setRows(20)->addExtraClass('stacked'), ToggleCompositeField::create('Metadata', _t('CatalogueAdmin.MetadataToggle', 'Metadata'), array($metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4)), $tabSettings = new Tab('Settings', NumericField::create("BasePrice", _t("Catalogue.Price", "Price")), TextField::create("StockID", $this->fieldLabel('StockID'))->setRightTitle(_t("Catalogue.StockIDHelp", "For example, a product SKU")), DropdownField::create("TaxRateID", $this->fieldLabel('TaxRate'), TaxRate::get()->map())->setEmptyString(_t("Catalogue.None", "None")), TreeMultiSelectField::create("Categories", null, "CatalogueCategory"), CheckboxField::create("Disabled", _t("Catalogue.DisableProduct", "Disable this product (will not appear on shopfront)")), DropdownField::create("ClassName", _t("CatalogueAdmin.ProductType", "Type of product"), $product_array)), $tabImages = new Tab('Images', SortableUploadField::create('Images', $this->fieldLabel('Images'), $this->Images()))));
         // Help text for MetaData on page content editor
         $metaFieldDesc->setRightTitle(_t('CatalogueAdmin.MetaDescHelp', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help');
         $metaFieldExtra->setRightTitle(_t('CatalogueAdmin.MetaExtraHelp', "HTML tags for additional meta information. For example <meta name=\"customName\" content=\"your custom content here\" />"))->addExtraClass('help');
         $fields->addFieldToTab('Root.Related', GridField::create('RelatedProducts', "", $this->RelatedProducts(), GridFieldConfig_RelationEditor::create()));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 private static function getViewModel()
 {
     return ['entityType' => ENTITY_QUOTE, 'account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels()];
 }
Exemple #14
0
    public function run()
    {
        $master = new MasterDocument();
        $master->name = 'Factura Normal';
        $master->javascript_web = 'class MYPDF extends TCPDF {
	public function Footer() {
        $this->SetY(-15);
        $this->SetFont(\'helvetica\', \'\', 8, false);
		$imgdata = base64_decode(\'/9j/4QmpRXhpZgAATU0AKgAAAAgADAEAAAMAAAABAk8AAAEBAAMAAAABAKUAAAECAAMAAAADAAAA
ngEGAAMAAAABAAIAAAESAAMAAAABAAEAAAEVAAMAAAABAAMAAAEaAAUAAAABAAAApAEbAAUAAAAB
AAAArAEoAAMAAAABAAIAAAExAAIAAAAeAAAAtAEyAAIAAAAUAAAA0odpAAQAAAABAAAA6AAAASAA
CAAIAAgALcbAAAAnEAAtxsAAACcQQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykAMjAxNjow
MTowNSAxMjoyNDozNQAAAAAEkAAABwAAAAQwMjIxoAEAAwAAAAH//wAAoAIABAAAAAEAAAAqoAMA
BAAAAAEAAACWAAAAAAAAAAYBAwADAAAAAQAGAAABGgAFAAAAAQAAAW4BGwAFAAAAAQAAAXYBKAAD
AAAAAQACAAACAQAEAAAAAQAAAX4CAgAEAAAAAQAACCMAAAAAAAAASAAAAAEAAABIAAAAAf/Y/+0A
DEFkb2JlX0NNAAL/7gAOQWRvYmUAZIAAAAAB/9sAhAAMCAgICQgMCQkMEQsKCxEVDwwMDxUYExMV
ExMYEQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAQ0LCw0ODRAODhAUDg4OFBQO
Dg4OFBEMDAwMDBERDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCACWACoD
ASIAAhEBAxEB/90ABAAD/8QBPwAAAQUBAQEBAQEAAAAAAAAAAwABAgQFBgcICQoLAQABBQEBAQEB
AQAAAAAAAAABAAIDBAUGBwgJCgsQAAEEAQMCBAIFBwYIBQMMMwEAAhEDBCESMQVBUWETInGBMgYU
kaGxQiMkFVLBYjM0coLRQwclklPw4fFjczUWorKDJkSTVGRFwqN0NhfSVe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vdWJAb+AAAAAAAAAAAABC
cmRUVW50RiNSbHQAAAAAAAAAAAAAAABCbGQgVW50RiNSbHQAAAAAAAAAAAAAAABSc2x0VW50RiNQ
eGxAcsAAAAAAAAAAAAp2ZWN0b3JEYXRhYm9vbAEAAAAAUGdQc2VudW0AAAAAUGdQcwAAAABQZ1BD
AAAAAExlZnRVbnRGI1JsdAAAAAAAAAAAAAAAAFRvcCBVbnRGI1JsdAAAAAAAAAAAAAAAAFNjbCBV
bnRGI1ByY0BZAAAAAAAAAAAAEGNyb3BXaGVuUHJpbnRpbmdib29sAAAAAA5jcm9wUmVjdEJvdHRv
bWxvbmcAAAAAAAAADGNyb3BSZWN0TGVmdGxvbmcAAAAAAAAADWNyb3BSZWN0UmlnaHRsb25nAAAA
AAAAAAtjcm9wUmVjdFRvcGxvbmcAAAAAADhCSU0D7QAAAAAAEAEsAAAAAQACASwAAAABAAI4QklN
BCYAAAAAAA4AAAAAAAAAAAAAP4AAADhCSU0EDQAAAAAABAAAAHg4QklNBBkAAAAAAAQAAAAeOEJJ
TQPzAAAAAAAJAAAAAAAAAAABADhCSU0nEAAAAAAACgABAAAAAAAAAAI4QklNA/UAAAAAAEgAL2Zm
AAEAbGZmAAYAAAAAAAEAL2ZmAAEAoZmaAAYAAAAAAAEAMgAAAAEAWgAAAAYAAAAAAAEANQAAAAEA
LQAAAAYAAAAAAAE4QklNA/gAAAAAAHAAAP////////////////////////////8D6AAAAAD/////
////////////////////////A+gAAAAA/////////////////////////////wPoAAAAAP//////
//////////////////////8D6AAAOEJJTQQIAAAAAAAQAAAAAQAAAkAAAAJAAAAAADhCSU0EHgAA
AAAABAAAAAA4QklNBBoAAAAAA2UAAAAGAAAAAAAAAAAAAACWAAAAKgAAABgAbABvAGcAaQBuAC0A
ZgBhAGMAdAB1AHIAYQAtAHYAaQByAHQAdQBhAGwALQBCAE4AAAABAAAAAAAAAAAAAAAAAAAAAAAA
AAEAAAAAAAAAAAAAACoAAACWAAAAAAAAAAAAAAAA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wIENTNiAoV2luZG93cykiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPC9yZGY6
U2VxPiA8L3htcE1NOkhpc3Rvcnk+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4
bXBtZXRhPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgIC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23uaSbFU+59rbj21XRPFntpZKtr6LFZPIYOSaTK7Xykk2NmjnoqoHRLExgmqacx1EnuvdHD/
AJHH/bwzrn/wye0v/eKyfv3Xut5D37r3X//Xst/4Uaf8zd+NX/iON6/+9NjffuvdUafGPfDdZ/I7
oXsFZvAuzO4et9yVEh5X7LE7vxFZXRyDi8U1HFIrD8qx9+691uS72+QOA+BvyX+S+H3hCZuvu++u
o/lH0zt6KvxGG/vD3jtumx3XPbHVG2qjK1MLVu6+xJaLAZ2GFQypLUVsqq7vo9+691qY/MSp7L7D
3o/yE7hrqGj7I7gymRr9zbNm3Tg8tlcC9AkEGIlw2EoM1l81gNhR4MU9Dj6bJeKppHo5IQZI0SRv
de6Nf/I4/wC3hnXP/hk9pf8AvFZP37r3W8h7917r/9Czv/hRrja9Oy/jHl2o6hcXU7F7AxtPXmJh
SS19Dn8DVVdGsxGg1FPT5CF2S9wsim1j7917rW2VihDKSpUgggkEEG4II+hHv3Xurlf5pn8wofJb
LdHbG63yePm271Z1tgMpn95Y2CjmyeU7Q33tPb9VvOhw+denbI47G7XSFMdJ9pLEKivSpLmRI6dl
917qm6aaaokknqJJZ55pHllnldpZpZJGLSSSyOxeSR2NySSTe5Pv3Xurfv5GGPrqz+YLsmopKaeo
gxPX3Z+Qyc0UZeOhopdtS4qOqqSP81A+SydNCGNh5JlX6ke/de63hPfuvdf/0dxz56r8J36U0fOq
TaEPVz5ymXCy58bhO4Yt0NFKIJNijZKS79OcSiMpm/hKtIaMSecGn8g9+691Rr/BP+E34A/3+G4j
x9ftvmTc/wCvba4F/fuvde/gn/Cb7/nr9xf+c3zK/wDsX9+6917+Cf8ACb7/AJ6/cX/nN8yv/sX9
+691bH/Lfg/loU+P31D8BKza9flEai/v/V1C9gJ2LNQlgccaxe2aWi3kNqLOQI/tIlxX3QP1n1E+
691aH7917r//2Q==\');

		  $html = \'<hr><table border="0">
			<tr>
			<td align="center">Servicio de Facturación <b>www.emizor.com</b></td>
			</tr>
			<tr>
			<td width="578" align="center">Pág \'.$this->getAliasNumPage().\'/\'.$this->getAliasNbPages().\'</td>
			</tr>
			</table>\';
        $this->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
		$this->Image(\'@\'.$imgdata, \'7\', \'158\', 4, 12, \'\', \'www.emizor.com\', \'T\', false, 300, \'\', false, false, 0, false, false, false);

	}
}
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, \'UTF-8\', false);

$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(\'ipxserver\');
$pdf->SetTitle(\'Factura\');
$pdf->SetSubject(\'Primera Factura\');
$pdf->SetKeywords(\'TCPDF, PDF, example, test, guide\');

// set margins
$pdf->SetMargins(15, 20, 15);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// borra la linea de arriba en el area del header
$pdf->setPrintHeader(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set some language-dependent strings (optional)
if (@file_exists(\'/includes/tcpdf/examples/lang/spa.php\')) {
	require_once(\'/includes/tcpdf/examples/lang/spa.php\');
	$pdf->setLanguageArray($l);
}
$pdf->SetFont(\'helvetica\', \'B\' , 12);
$nit = $invoice->account_nit;
$nfac = $invoice->invoice_number;
$nauto = $invoice->number_autho;
$sfc = $invoice->sfc;

// add a page
$pdf->AddPage(\'P\', \'LETTER\');
//contenido del recuadro
$html = \'
	<table border="0" width="180">
	<tr>
		<td width="75" style="font-size:8px">NIT:</td>
		<td align="left" style="font-size:10px">:&nbsp;\'.$nit.\'</td>
	</tr>
	<tr>
		<td style="font-size:8px">AUTORIZACI&Oacute;N N&ordm;</td>
		<td align="left" style="font-size:10px">:&nbsp;\'.$nauto.\'</td>
	</tr>
	<tr>
		<td style="font-size:8px">FACTURA N&ordm;</td>
		<td align="left" style="font-size:10px">:&nbsp;\'.$nfac.\'</td>
	</tr>
	<tr><td></td></tr>

	</table>
\';
//imprime el contenido de la variable html
$pdf->writeHTMLCell($w=0, $h=0, $x=\'140\', $y=\'13\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//dibuja un rectangulo
$pdf->SetLineStyle(array(\'width\' => 0.5, \'cap\' => \'butt\', \'join\' => \'miter\', \'dash\' => 0, \'color\' => array(0, 0, 0)));
$pdf->RoundedRect(138, 11, 63, 18, 2, \'1111\', null);
$imgdata = base64_decode($invoice->logo);
$pdf->Image(\'@\'.$imgdata, \'14\', \'10\', \'35\', \'35\', \'\', \'\', \'T\', false, 500, \'\', false, false, 0, false, false, false);

//marca de agua
$imgdata = base64_decode($invoice->logo);
$pdf->SetAlpha(0.3);
$pdf->Image(\'@\'.$imgdata, \'65\', \'90\', \'90\', \'90\', \'\', \'\', \'T\', false, 500, \'\', false, false, 0, false, false, false);
$pdf->SetAlpha(1);
///title
$anchoDivFac = 480;
if($invoice->type_third==0)
{
    $factura = "FACTURA";
    $tercero ="";
}
else{
    $factura = "FACTURA POR TERCEROS";
    $tercero = $matriz->name;
	$anchoDivFac = 520;
}
if($invoice->invoice_status_id == 6)
{
	$factura = "FACTURA ANULADA";
}

$titleFactura=\'<table border="0">
<tr>
<td width="480" align="center"><font color="#333333">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\'.$factura.\'</font></td>
</tr>
</table>\';
$pdf->SetFont(\'helvetica\', \'B\' , 22);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'42\', $titleFactura, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'helvetica\', \'B\' , 9);

// $sinCreditoFiscal = "SIN DERECHO A CR&Eacute;DITO FISCAL";
// $sinCreditoFiscalHtml=\'<table border="0">
// <tr>
// <td width="500" align="center"><font color="#333333">&nbsp;&nbsp;&nbsp;&nbsp;\'.$sinCreditoFiscal.\'</font></td>
// </tr>
// </table>\';
$pdf->SetFont(\'helvetica\', \'B\' , 13);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'38\', $sinCreditoFiscalHtml, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'helvetica\', \'B\' , 11);








//nombre de la empresa
$business = $invoice->account_name;
$unipersonal = $invoice->account_uniper;
$pdf->SetFont(\'helvetica\', \'B\', 10, false);
// $NombreEmpresa = \'
//     <p style="line-height: 150%">
//         <font color="#333333">
//             \'.$business.\'
//         </font>
//     </p>\';
//$NombreEmpresa = \' <table border="0">
//  <tr>
 //   <td width="250" align="center"><font color="#333333">\'.$business.\'</font></td>
//  </tr>
//</table>
//\';
//$pdf->writeHTMLCell($w=0, $h=0, $x=\'45\', $y=\'10\', $NombreEmpresa, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$pdf->SetFont(\'helvetica\', \'B\', 8, false);
if($unipersonal!="")
    $pdf->writeHTMLCell($w=0, $h=0, $x=\'15\', $y=\'36\', \'De: \'.$unipersonal, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'15\', $y=\'1\', $tercero, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
if($copia==1)
    $original = "COPIA";
else
$original = "ORIGINAL";


$pdf->SetFont(\'helvetica\', \'B\', 12);
    $original = \'
        <p style="line-height: 150% ">
            \'.$original.\'
        </p>\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'155\', $y=\'29\', $original, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//datos de la empresa
// $casa = $matriz->name;
$casa = "CASA MATRIZ";
$dir_casa = $matriz->address2."  ".$matriz->address1;
$tel_casa = $matriz->work_phone;
$city_casa = $matriz->city." - Bolivia";
if($matriz->city == $invoice->city && $invoice->branch_id != $matriz->id)
    $city_casa ="";
else
$city_casa = \'<tr>
        <td width="150" align="left">\'.$city_casa.\'</td>
        </tr>\';
$pdf->SetFont(\'helvetica\', \'\', 8);

if($invoice->branch_id == $matriz->id || $branch->number_branch == 0)
{
	$datoEmpresa = \'
    <table border = "0">
        <tr style="line-height:1">
        <td width="150" align="left"><b>\'.$casa.\'</b></td>
        </tr>
        <tr style="line-height:1">
        <td width="150" align="left">\'.$dir_casa.\' </td>
        </tr>
        <tr style="line-height:1">
        <td width="150" align="left">Telfs: \'.$tel_casa.\'</td>
        </tr>
        \'.$city_casa.\'
    </table>
    \';
}
else{
	$sucursal = $invoice->branch_name;
	$direccion = $invoice->address1." - ".$invoice->address2;
	$ciudad = $invoice->city." - Bolivia";
	$telefonos =$invoice->phone;
	$datoEmpresa = \'
    <table border = "0">
        <tr style="line-height:0.9">
        <td width="270" align="left"><b><font size="7">\'.$casa.\'</font></b></td>
        </tr>
        <tr style="line-height:0.9">
        <td width="270" align="left"><font size="7">\'.$dir_casa.\'</font></td>
        </tr>
        <tr style="line-height:0.9">
        <td width="270" align="left"><font size="7">Telfs: \'.$tel_casa.\'</font></td>
        </tr>
        <font size="7">\'.$city_casa.\'</font>
        <tr style="line-height:0.9">
        <td width="270" align="left"><b><font size="7">\'.$sucursal.\'</font></b></td>
        </tr>
        <tr style="line-height:0.9">
        <td width="270" align="left"><font size="7">\'.$direccion.\'</font></td>
        </tr>
        <tr style="line-height:0.9">
        <td width="270" align="left"><font size="7">Telfs: \'.$telefonos.\'</font></td>
        </tr>
        <tr style="line-height:0.9">
        <td width="270" align="left"><font size="7">\'.$ciudad.\'</font></td>
        </tr>
    </table>
    \';
}

$pdf->writeHTMLCell($w=0, $h=0, $x=\'46\', $y=\'15\', $datoEmpresa, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//actividad económica
$actividad=$invoice->economic_activity;
$pdf->SetFont(\'helvetica\', \'\', 10);
$actividadEmpresa = \'
    <table>
        <tr>
            <td align="center">\'.$actividad.\'</td>
        </tr>
    </table>\';

$pdf->writeHTMLCell($w=0, $h=0, $x=\'135\', $y=\'36\', $actividadEmpresa, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//TABLA datos del cliente

$pdf->SetFont(\'helvetica\', \'\', 11);

$meses = array("","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");

$lenguage = \'es_ES.UTF-8\';
putenv("LANG=$lenguage");
setlocale(LC_ALL, $lenguage);

//$date =date("d/m/Y", strtotime($invoice->invoice_date));
//$date = DateTime::createFromFormat("d/m/Y", $date);
//$fecha=strftime("%d de %B de %Y",$date->getTimestamp());

$date = DateTime::createFromFormat("d/m/Y", $invoice->invoice_date);
if($date== null){
    $date = DateTime::createFromFormat("Y-m-d", $invoice->invoice_date);
    $fecha = strftime("%d de %B de %Y",$date->getTimestamp());
}
else
    $fecha = strftime("%d de %B de %Y",$date->getTimestamp());



$fecha= $invoice->state.", ".$fecha;
$senor = $invoice->client_name;
$nit = $invoice->client_nit;

$datosCliente = \'
<table cellpadding="2" border="0">
    <tr>
        <td width="300"><b>&nbsp;Lugar y fecha :</b>\'.$fecha.\'</td>
        <td width="220" align="right"><b>NIT/CI :</b>\'.$nit.\'</td>
    </tr>
    <tr>
        <td colspan="2"><b>&nbsp;Se&ntilde;or(es):</b> \'.$senor .\'</td>
    </tr>

</table>
\';
//$datosCliente="asdf";

$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'58\', $datosCliente, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//dibuja rectangulo datos del cliente
$pdf->SetLineStyle(array(\'width\' => 0.3, \'cap\' => \'butt\', \'join\' => \'miter\', \'dash\' => 0, \'color\' => array(0, 0, 0)));
$pdf->RoundedRect(16, 58, 184, 14, 1, \'1111\', null);
$textTitulos = "";
$textTitulos .= \'<p></p>
<table border="0.2" cellpadding="3" cellspacing="0">
    <thead>
        <tr>
          <td width="70" align="center" bgcolor="#E6DFDF"><font size="10"><b>CANTIDAD</b></font></td>
         <td width="240" align="center" bgcolor="#E6DFDF"><font size="10"><b>CONCEPTO</b></font></td>
         <td width="115" align="center" bgcolor="#E6DFDF"><font size="10"><b>PRECIO UNITARIO</b></font></td>
         <td width="97" align="center" bgcolor="#E6DFDF"><font size="10"><b>TOTAL</b></font></td>
        </tr>
    </thead>
</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'66\', $textTitulos, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//
$ini = 0;
$final = "";
$resto = $ini;
//number_format((float)($product->cost*6), 2, \'.\', \',\')
foreach ($products as $key => $product){
		$textContenido =\'
        <table border="0.2" cellpadding="3" cellspacing="0">
		<tr>
		<td width="70" align="center"><font size="10">\'.intval($product->packs).\'</font></td>
		<td width="240"><font size="10">\'.$product->notes.\'</font></td>
		<td width="115" align="right"><font size="10">\'.number_format((float)$product->cost, 2, \'.\', \',\').\'</font></td>
		<td width="97" align="right"><font size="10"> \'.number_format((float)$product->units2->units*$product->packs*$product->cost, 2, \'.\', \'\').\'</font></td>
		</tr>
         </table>
		\';
        $ini = $pdf->GetY(); //punto inicial antes de dibujar la siguiente fila

        if(($ini+$resto)>= 250.46944444444){

			$pdf->AddPage(\'P\', \'LETTER\');
            $pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $textContenido, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
        }
        else{
        $pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $textContenido, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
        $final = $pdf->GetY();  //punto hasta donde se dibujo la fila
        }
        $resto = $final-$ini; //diferencia entre $ini y $final para sacar el tamaño siguiente a dibujar
//}
}
$texPie = "";
$subtotal = number_format((float)$invoice->importe_total, 2, \'.\', \',\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \',\');
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \',\');
$fiscal=number_format((float)$invoice->debito_fiscal, 2, \'.\', \'\');
$ice=number_format((float)$invoice->importe_ice, 2, \'.\', \'\');


require_once(app_path().\'/includes/numberToString.php\');
$nts = new numberToString();
$importe = number_format((float)$invoice->importe_neto, 2, \'.\', \'\');
$num = explode(".", $importe);
if(!isset($num[1]))
    $num[1]="00";

$literal= $nts->to_word($num[0]).substr($num[1],0,2);





$pdf->SetFont(\'helvetica\', \'\', 11);
		$texPie .=\'
		<table border="0.2" cellpadding="3" cellspacing="0">
            <tr>
                <td width="425" align="right"><b>SUBTOTAL &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td  width="97" align="right"><b>\'.$subtotal.\'</b></td>
            </tr>
            <tr>
                <td width="425"  align="right"><b>Descuentos &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td width="97" align="right"><b>\'.$descuento.\'</b></td>
            </tr>
            <tr>
                <td width="425"  align="right"><b>TOTAL A PAGAR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td width="97" align="right"><b>\'.$total.\'</b></td>
            </tr>
            <tr>
                <td width="425"  align="right"><b>ICE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td width="97" align="right"><b>\'.$invoice->importe_ice.\'</b></td>
            </tr>
            <tr>
                <td width="425"  align="right"><b>Importe Cr&eacute;dito Fiscal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td width="97" align="right"><b>\'.$invoice->debito_fiscal.\'</b></td>
            </tr>

            <tr>
                <td colspan="2" style="font-size:9px"><b>Son: </b>\'.$literal.\'/100 BOLIVIANOS.</td>
            </tr>
		</table>
		\';
        if ($pdf->GetY() >= \'210.6375\' ){

            $pdf->AddPage(\'P\', \'LETTER\');
        }

$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $texPie, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//nota al cliente
$restoQr = 11;
$line=60;
if (!empty($invoice->public_notes)){
$nota = $invoice->public_notes;
$notaCliente = \'

		<table style="padding:0px 0px 0px 5px" border="0">
		<tr>
			<td style="line-height: \'.$line.\'%"> </td>
		</tr>
		<tr>
			<td width="88" align="right" style="font-size:9px;"><b>Nota al Cliente:</b></td>
			<td width="352" align="left" bgcolor="#F2F2F2" style="font-size:9px; border-left: 1px solid #000;">\'.$nota.\'</td>
		</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $notaCliente, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$restoQr=$restoQr+10;
$line=100;
}
if (!empty($invoice->terms)){
$nota = $invoice->public_notes;
$terminos = $invoice->terms;
$termCliente = \'
		<table style="padding:0px 0px 0px 5px">
		<tr><td style="line-height: \'.$line.\'%"> </td></tr>
		<tr>
			<td width="88" align="right" style="font-size:9px"><b>Términos de Facturación: </b></td>
			<td width="352" align="left" bgcolor="#F2F2F2" style="font-size:9px; border-left: 1px solid #000; ">\'.$terminos.\'</td>
		</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $termCliente, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$restoQr=$restoQr+11;
$line=50;
}

$control_code = $invoice->control_code;
$fecha_limite = date("d/m/Y", strtotime($invoice->deadline));
$fecha_limite = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->deadline);
if($fecha_limite== null)
    $fecha_limite = $invoice->deadline;
else
    $fecha_limite = $fecha_limite->format(\'d/m/Y\');

$law_gen="ESTA FACTURA CONTRIBUYE AL DESARROLLO DEL PAÍS, EL USO ILÍCITO DE ÉSTA SERÁ SANCIONADO DE ACUERDO A LEY";

$law=$invoice->law;
$datosFactura = \'
<table border="0" style="line-height: 160%">
	<tr><td style="line-height: \'.$line.\'%"> </td></tr>
    <tr>
        <td width="230" align="left"><b>C&Oacute;DIGO DE CONTROL :&nbsp;&nbsp;\'.$control_code.\'</b></td>
        <td width="210" align="left"><b>Fecha L&iacute;mite de Emisi&oacute;n : &nbsp;\'.$fecha_limite.\' </b></td>
    </tr>
    <tr>
        <td width="450" align="center" style="font-size:7px"><b>"\'.$law_gen.\'"</b></td>
    </tr>
    <tr>
        <td width="450" align="center" style="font-size:7px">"\'.$law.\'"</td>
    </tr>
</table>
\';
if ($pdf->GetY() >= \'226.6375\' ){
		$pdf->AddPage(\'P\', \'LETTER\');
		if(!empty($nota) && !empty($terminos)){
			$restoQr = $restoQr - 18;
		}
    }

$subtotal = number_format((float)$invoice->importe_total, 2, \'.\', \'\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \'\');
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \'\');
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $datosFactura, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$date_qr = date("d/m/Y", strtotime($invoice->invoice_date));
$date_qr = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->invoice_date);
if($date_qr== null)
    $date_qr = $invoice->invoice_date;
else
    $date_qr = $date_qr->format(\'d/m/Y\');

if($descuento == \'0.00\')
    $descuento = 0;
$datosqr = $invoice->account_nit.\'|\'.$invoice->invoice_number.\'|\'.$invoice->number_autho.\'|\'.$date_qr.\'|\'.$total.\'|\'.$fiscal.\'|\'.$invoice->control_code.\'|\'.$invoice->client_nit.\'|\'.$ice.\'|0|0|\'.$descuento;
$pdf->write2DBarcode($datosqr, \'QRCODE,M\', \'175\',
$pdf->GetY()-$restoQr, 25, 25, \'\', \'N\');

//Close and output PDF document
$pdf->Output(\'factura.pdf\', \'I\');

die;';
        //factura fiscal
        $master->javascript_pos = ' $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, \'UTF-8\', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(\'ipxserver\');
$pdf->SetTitle(\'Factura\');
$pdf->SetSubject(\'Primera Factura\');
$pdf->SetKeywords(\'TCPDF, PDF, example, test, guide\');
$pdf->SetMargins(0.5, 0.5, 0.5);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetFont(\'helvetica\', \'\' , 7);
$page_format = array(
    \'MediaBox\' => array (\'llx\' => 0, \'lly\' => 0, \'urx\' => 72, \'ury\' => 1000),
    \'Dur\' => 3,
);
$business = $invoice->account_name;
if($invoice->account_uniper !=\'\')
    $unipersonal = \'<tr><td align="center">De: \'.$invoice->account_uniper.\'</td></tr>\';
else
    $unipersonal="";
// Check the example n. 29 for viewer preferences
$pdf->AddPage(\'P\', $page_format, false, false);
$sucursal = $invoice->branch_name;
$direccion = $invoice->address1." - ".$invoice->address2;
$ciudad = $invoice->city." - Bolivia";
$telefonos =$invoice->phone;

$html = \'
<table>
	<tr>
		<td align="center" style="font-size:10px; "><b>\'.$business.\'</b></td>
	</tr>
        \'.$unipersonal.\'
        <tr>
		<td align="center">\'.$sucursal.\'</td>
	</tr><tr>
		<td align="center">\'.$direccion.\'</td>
	</tr><tr>
		<td align="center">Telefono: \'.$telefonos.\'</td>
	</tr><tr>
		<td align="center">\'.$ciudad.\'</td>
	</tr>
</table>
\';
//imprime el contenido de la variable html
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
if($copia==1)
    $original = "COPIA";
else
$original = "ORIGINAL";
$pdf->SetFont(\'times\', \'B\' , 10);
$fact = \'<br><br><table>
<tr>
	<td align="center">
		FACTURA
	</td>
</tr>
<tr>
	<td align="center">
		\'.$original.\'
	</td>
</tr>
</table>
\'
;
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $fact, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$lin = " ";

$pdf->SetFont(\'helvetica\', \' \' , 8);
for ($i=0;$i<72;$i++)$lin .= \'-\';

$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//DATOS FACTURA
$pdf->SetFont(\'helvetica\', \' \' , 8);
$nitEmpresa = $invoice->account_nit;
$nfac = $invoice->invoice_number;
$nauto = $invoice->number_autho;

$datosfac = \'
	<table border="0">
		<tr>
			<td align="left">NIT : </td>
			<td align="left">\'.$nitEmpresa.\'</td>
		</tr>
		<tr>
			<td align="left">FACTURA No : </td>
			<td align="left">\'.$nfac.\'</td>
		</tr>
		<tr>
			<td align="left">AUTORIZACION No :   </td>
			<td align="left">\'.$nauto.\'</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'10\', $y=\'\', $datosfac, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//linea
$pdf->SetFont(\'helvetica\', \' \' , 8);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//actividad economica
$pdf->SetFont(\'times\', \'B\' , 9);
$actividad=$invoice->economic_activity;
$acti = \'
	<table align="center">
		<tr>
			<td>ACTIVIDAD ECON&Oacute;MICA</td>
		</tr>
		<tr>
			<td>\'.$actividad.\'</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $acti, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'helvetica\', \'\' , 8);
$date = DateTime::createFromFormat("Y-m-d", $invoice->invoice_date);
if($date==null)
    $date = DateTime::createFromFormat("d/m/Y", $invoice->invoice_date);
$fecha = $date->format(\'d/m/Y\');
$senor = $invoice->client_name;
$nit = $invoice->client_nit;
$hora = $date->format(\'H:i:s\');

$datosCli = \'<br>
	<table border="1">
		<tr>
			<td align="left" width="40">Fecha : </td>
			<td align="left">\'.$fecha.\'</td>
			<td align="right" width="30">Hora : </td>
			<td align="left">\'.$hora.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">NIT/CI : </td>
			<td align="left">\'.$nit.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">Nombre :   </td>
			<td align="left">\'.$senor.\'</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'9\', $y=\'\', $datosCli, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//tabla
$htmlTabla = \'
	<table border="1">
		<tr>
			<td align="center">Cantidad</td>
			<td align="center">Precio</td>
			<td align="center">Importe</td>
		</tr>
	</table>
<p style="line-height: 30%">
    </p>\';

$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);


foreach ($products as $key => $product){
	$htmlTabla2 = \'
		<table border="0">
			<tr>
				<td colspan="3">\'.$product->notes.\'</td>
			</tr>
			<tr>
				<td align="center">\'.intval($product->qty).\'</td>
				<td align="center">\'.number_format((float)$product->cost, 2, \'.\', \',\').\'</td>
				<td align="center">\'.number_format((float)($product->cost*$product->qty), 2, \'.\', \',\').\'</td>
			</tr>
		</table>
	\';
	$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla2, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
}
//total
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \',\');
$htmlTotal = \'<hr>
	<table>
		<tr>
			<td align="right" width="173"><b>TOTAL: Bs \'.$total.\'</b></td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTotal, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//TOTALES
$ice = number_format((float)($invoice->importe_ice), 2, \'.\', \',\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \',\');
$importeCreditoFiscal = number_format((float)($invoice->debito_fiscal), 2, \'.\', \',\');
$fiscal =$importeCreditoFiscal;
$montoPagar = number_format((float)$invoice->importe_neto, 2, \'.\', \',\');
require_once(app_path().\'/includes/numberToString.php\');
$nts = new numberToString();
$num = explode(".", $invoice->importe_neto);
if(!isset($num[1]))
    $num[1]="00";
$literal= $nts->to_word($num[0]).substr($num[1],0,2);



$htmlDatosExtra = \'
	<table>
		<tr>
			<td>ICE: \'.$ice.\'</td>
		</tr>
		<tr>
			<td>DESCUENTOS/BONIFICACION: \'.$descuento.\'</td>
		</tr>
		<tr>
			<td>IMPORTE BASE CREDITO FISCAL: \'.$importeCreditoFiscal.\'</td>
		</tr>
		<tr>
			<td>MONTO A PAGAR: Bs \'.$montoPagar.\'</td>
		</tr>
		<tr>
			<td>SON: \'.$literal.\'/100 BOLIVIANOS</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlDatosExtra, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//linea
$pdf->SetFont(\'helvetica\', \' \' , 8);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//CODIGO DE CONTROL

$control_code = $invoice->control_code;
$fecha_limite = date("d/m/Y", strtotime($invoice->deadline));
$fecha_limite = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->deadline);
if($fecha_limite== null)
    $fecha_limite = $invoice->deadline;
else
    $fecha_limite = $fecha_limite->format(\'d/m/Y\');
$law_gen=\'"\'."ESTA FACTURA CONTRIBUYE AL DESARROLLO DEL PAÍS, EL USO ILÍCITO DE ÉSTA SERÁ SANCIONADO DE ACUERDO A LEY".\'"\';
$law=$invoice->law;

 $htmlControl = \'
 	<table>
 		<tr>
 			<td>CODIGO DE CONTROL : \'.$control_code.\'</td>
 		</tr>
 		<tr>
 			<td>FECHA LÍMITE EMISIÓN : \'.$fecha_limite.\'</td>
 		</tr>

 	</table>
 	<br>

 \';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlControl, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//qr
$subtotal = number_format((float)$invoice->importe_total, 2, \'.\', \'\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \'\');
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \'\');
$date_qr = date("d/m/Y", strtotime($invoice->invoice_date));
$date_qr = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->invoice_date);
if($date_qr== null)
    $date_qr = $invoice->invoice_date;
else
    $date_qr = $date_qr->format(\'d/m/Y\');
if($descuento=="0.00")
    $descuento=0;
if($fiscal==0) $fiscal="0";
if($ice==0) $ice ="0";
if($descuento==0)$descuento="0";
$datosqr = $invoice->account_nit.\'|\'.$invoice->invoice_number.\'|\'.$invoice->number_autho.\'|\'.$date_qr.\'|\'.$total.\'|\'.$fiscal.\'|\'.$invoice->control_code.\'|\'.$invoice->client_nit.\'|\'.$ice.\'|0|0|\'.$descuento;
$pdf->write2DBarcode($datosqr, \'QRCODE,M\', \'24\', \'\' , 25, 25, \'\', \'N\');

$htmlLeyenda = \'<br><br>
		<table>
			<tr>
				<td align="center"><b>\'.$law_gen.\'</b></td>
			</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlLeyenda, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'times\', \' \' , 9);
$emizor = \'<br><br>
		<table>
			<tr>
				<td align="center">www.emizor.com</td>
			</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $emizor, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$y = $pdf->GetY();
$y2 = intval($y) + 8;
//////pdf adaptado a nuevo tamaño//////////////////////////////////////////////////////////////////
$page_format2 = array(
    \'MediaBox\' => array (\'llx\' => 0, \'lly\' => 0, \'urx\' => 72, \'ury\' => $y2),
    \'Dur\' => 3,
);
// add first page ---
$pdf2 = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, \'UTF-8\', false);
//Close and output PDF document
$pdf2->SetCreator(PDF_CREATOR);
$pdf2->SetAuthor(\'ipxserver\');
$pdf2->SetTitle(\'Factura\');
$pdf2->SetSubject(\'Primera Factura\');
$pdf2->SetKeywords(\'TCPDF, PDF, example, test, guide\');
// set margins
$pdf2->SetMargins(0.5, 0.5, 0.5);
// set auto page breaks
$pdf2->SetAutoPageBreak(TRUE, 0.5);
// borra la linea de arriba en el area del header
$pdf2->setPrintHeader(false);
$pdf2->setPrintFooter(false);
// set some language-dependent strings (optional)
if (@file_exists(\'/includes/tcpdf/examples/lang/spa.php\')) {
	require_once(\'/includes/tcpdf/examples/lang/spa.php\');
	$pdf->setLanguageArray($l);
}
$pdf2->SetFont(\'helvetica\', \'\' , 7);
// add second page ---
$pdf2->AddPage(\'P\', $page_format2, false, false);

$html = \'
<table>
	<tr>
		<td align="center" style="font-size:10px; "><b>\'.$business.\'</b></td>
	</tr>
        \'.$unipersonal.\'
        <tr>
		<td align="center">\'.$sucursal.\'</td>
	</tr><tr>
		<td align="center">\'.$direccion.\'</td>
	</tr><tr>
		<td align="center">Telefono: \'.$telefonos.\'</td>
	</tr><tr>
		<td align="center">\'.$ciudad.\'</td>
	</tr>
</table>
\';
//imprime el contenido de la variable html
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$pdf2->SetFont(\'times\', \'B\' , 10);
$fact = \'<br><br><table>
<tr>
	<td align="center">
		FACTURA
	</td>
</tr>
<tr>
	<td align="center">
		\'.$original.\'
	</td>
</tr>
</table>
\'
;
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $fact, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$lin = " ";

$pdf2->SetFont(\'helvetica\', \' \' , 8);
for ($i=0;$i<72;$i++)
{
	$lin .= \'-\';

}
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//DATOS FACTURA
$pdf2->SetFont(\'helvetica\', \' \' , 8);


$datosfac = \'
	<table border="0">
		<tr>
			<td align="left">NIT : </td>
			<td align="left">\'.$nitEmpresa.\'</td>
		</tr>
		<tr>
			<td align="left">FACTURA No : </td>
			<td align="left">\'.$nfac.\'</td>
		</tr>
		<tr>
			<td align="left">AUTORIZACION No :   </td>
			<td align="left">\'.$nauto.\'</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'10\', $y=\'\', $datosfac, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//linea
$pdf2->SetFont(\'helvetica\', \' \' , 8);
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//actividad economica
$pdf2->SetFont(\'times\', \'B\' , 9);

$acti = \'
	<table align="center">
		<tr>
			<td>ACTIVIDAD ECON&Oacute;MICA</td>
		</tr>
		<tr>
			<td>\'.$actividad.\'</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $acti, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//datos cliente
$pdf2->SetFont(\'helvetica\', \'\' , 8);


$datosCli = \'<br>
	<table border="0">
		<tr>
			<td align="left" width="40">Fecha : </td>
			<td align="left">\'.$fecha.\'</td>
			<td align="right" width="30">Hora : </td>
			<td align="left">\'.$hora.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">NIT/CI : </td>
			<td colspan="3" align="left">\'.$nit.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">Nombre :   </td>
			<td colspan="3" align="left">\'.$senor.\'</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'9\', $y=\'\', $datosCli, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//tabla
$htmlTabla = \'
	<table border="0">
		<tr>
			<td align="center">Cantidad</td>
			<td align="center">Precio</td>
			<td align="center">Subtotal</td>
		</tr>
	</table>
<p style="line-height: 30%">
    </p>\';

$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

foreach ($products as $key => $product){
	$htmlTabla2 = \'
		<table border="0">
			<tr>
				<td colspan="3">\'.$product->notes.\'</td>
			</tr>
			<tr>
				<td align="center">\'.intval($product->qty).\'</td>
				<td align="center">\'.number_format((float)$product->cost, 2, \'.\', \',\').\'</td>
				<td align="center">\'.number_format((float)($product->cost*$product->qty), 2, \'.\', \',\').\'</td>
			</tr>
		</table>
	\';
	$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla2, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
}

//total
$htmlTotal = \'<hr>
	<table>
		<tr>
			<td align="right" width="173"><b>TOTAL: Bs \'.$total.\'</b></td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTotal, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);




$htmlDatosExtra = \'
	<table>
		<tr>
			<td>ICE: \'.$ice.\'</td>
		</tr>
		<tr>
			<td>DESCUENTOS/BONIFICACIÓN: \'.$descuento.\'</td>
		</tr>
		<tr>
			<td>IMPORTE BASE CREDITO FISCAL: \'.$importeCreditoFiscal.\'</td>
		</tr>
		<tr>
			<td>MONTO A PAGAR: Bs \'.$montoPagar.\'</td>
		</tr>
		<tr>
			<td>SON: \'.$literal.\'/100 BOLIVIANOS</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlDatosExtra, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//linea
$pdf2->SetFont(\'helvetica\', \' \' , 8);
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);


//CODIGO DE CONTROL

 $htmlControl = \'
 	<table>
 		<tr>
 			<td><b>CÓDIGO DE CONTROL : \'.$control_code.\'</b></td>
 		</tr>
 		<tr>
 			<td><b>FECHA LÍMITE EMISIÓN : \'.$fecha_limite.\'</b></td>
 		</tr>
 	</table>
 	<br>

 \';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlControl, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//qr
$pdf2->write2DBarcode($datosqr, \'QRCODE,M\', \'24\', \'\' , 25, 25, \'\', \'N\');

$htmlLeyenda = \'<br><br>
		<table>
			<tr>
				<td align="center"><b>\'.$law_gen.\'</b></td>
			</tr>
		</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlLeyenda, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf2->SetFont(\'times\', \' \' , 9);
$emizor = \'<br><br>
		<table>
			<tr>
				<td align="center">www.emizor.com</td>
			</tr>
		</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $emizor, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$pdf2->Output(\'factura.pdf\', \'I\');
die();';
        $master->save();
        $master = new MasterDocument();
        $master->name = 'Nota de Entrega';
        $master->javascript_web = 'class MYPDF extends TCPDF {
	public function Footer() {
        $this->SetY(-15);
        $this->SetFont(\'helvetica\', \'I\', 8, false);
		$logoEmizor = base64_decode(\'/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCABkABsDAREAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAABgcAAQUIBP/EABsBAAICAwEAAAAAAAAAAAAAAAUGAQIABAcD/9oADAMBAAIQAxAAAAHqiIwdsdu6pGZkrCMbEJjBGYuGmatVFNXPzUaeYAVjq1Uw0opaNOHYVhr0omGhHKBxdgB2KshFtiAxwjQXaBmojmp45c3FxzOhLDMojW3njHAtpXoFqnFIyJh2GYd/VIqFiTcj30RkoJ6QRumphpSTsMwKVmS38mdEWx1bwfcdib+h0Uk9M9nh7y0zJmU//8QAIxAAAgEEAgICAwAAAAAAAAAABAUDAAECBhAREhMUNSAxQf/aAAgBAQABBQLulbmJtj3XfDuwIrLXIvAHgMuLXyNNFkHXVf8ASbac/dqx87CPgSJXABqAuAwtfzzzYka7BNANx6h/k6nYWwXE70g1ogaYNB67php02ZKVTgnErcWZI5xYrOEKNydHkJLecXd/t9X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tAAAAAFBnUHMAAAAAUGdQQwAAAABMZWZ0VW50RiNSbHQAAAAAAAAAAAAAAABUb3AgVW50RiNSbHQAAAAAAAAAAAAAAABTY2wgVW50RiNQcmNAWQAAAAAAAAAAABBjcm9wV2hlblByaW50aW5nYm9vbAAAAAAOY3JvcFJlY3RCb3R0b21sb25nAAAAAAAAAAxjcm9wUmVjdExlZnRsb25nAAAAAAAAAA1jcm9wUmVjdFJpZ2h0bG9uZwAAAAAAAAALY3JvcFJlY3RUb3Bsb25nAAAAAAA4QklNA+0AAAAAABAASAAAAAEAAgBIAAAAAQACOEJJTQQmAAAAAAAOAAAAAAAAAAAAAD+AAAA4QklNBA0AAAAAAAQAAAAeOEJJTQQZAAAAAAAEAAAAHjhCSU0D8wAAAAAACQAAAAAAAAAAAQA4QklNJxAAAAAAAAoAAQAAAAAAAAACOEJJTQP1AAAAAABIAC9mZgABAGxmZgAGAAAAAAABAC9mZgABAKGZmgAGAAAAAAABADIAAAABAFoAAAAGAAAAAAABADUAAAABAC0AAAAGAAAAAAABOEJJTQP4AAAAAABwAAD/////////////////////////////A+gAAAAA/////////////////////////////wPoAAAAAP////////////////////////////8D6AAAAAD/////////////////////////////A+gAADhCSU0ECAAAAAAAEAAAAAEAAAJAAAACQAAAAAA4QklNBB4AAAAAAAQAAAAAOEJJTQQaAAAAAANpAAAABgAAAAAAAAAAAAAALwAAAC8AAAAaAGwAbwBnAG8ALQBlAG0AaQB6AG8AcgAtAGEAaQByAHAAYQBwAGUAcgBfADAAOABfADAAOAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAALwAAAC8AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAG51bGwAAAACAAAABmJvdW5kc09iamMAAAABAAAAAAAAUmN0MQAAAAQAAAAAVG9wIGxvbmcAAAAAAAAAAExlZnRsb25nAAAAAAAAAABCdG9tbG9uZwAAAC8AAAAAUmdodGxvbmcAA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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPD94cGFja2V0IGVuZD0idyI/Pv/uAA5BZG9iZQBkQAAAAAH/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQECAgICAgICAgICAgMDAwMDAwMDAwMBAQEBAQEBAQEBAQICAQICAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD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SVbeSJ9ErmFJYPH1WktzEscjhPEkSXDxoyq748/Gzqv4x7FpNi9X4FKGLRBLn9xVniqNz7vykUZR8tuLKLFG9TO7MxjhQR0tKrlIIo09Psr579wOZvcXe5N65kvS7VPhRLUQwIT8ESVNABQFjV3wXZjnoTe0Xs1yJ7J8rQcr8j7SsSFVNxcPRrm7lUU8W4lABdiSxVAFiiDFYY0Tt6e9u9CdS7S7BynaG2tk4fC7xy9A9BV1tBCYKVBUSmWtraPFowx2PyWR4WpqII45JlBDE65C6O/wCduaN02G35b3Dd5ZtpjkDhWNWwKKrOe5kTiiMSFNKDtUKc7V7Z8j7HzRe85bRy7Bb7/cRFGdBpXuJLssY/TSSThI6KrOK6j3MWGH2Feh31737r3X//1N/j37r3Xvfuvde9+691737r3Xvfuvde9+691//Z\');
		  $html = \'<hr><table border="0">
			<tr>
			<td align="center">Sistema de facturaci&oacute;n brindado por <a href="www.emizor.com">www.emizor.com</a></td>
			</tr>
			<tr>
			<td width="578" align="center">Pág \'.$this->getAliasNumPage().\'/\'.$this->getAliasNbPages().\'</td>
			</tr>
			</table>\';
        $this->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
		$this->Image(\'@\'.$logoEmizor, \'7\', \'128\', 4, 12, \'\', \'www.emizor.com\', \'T\', false, 300, \'\', false, false, 0, false, false, false);
		$this->Image(\'@\'.$emizorAvion, \'145\', \'265\', 5, 8, \'\', \'www.emizor.com\', \'T\', false, 300, \'\', false, false, 0, false, false, false);
	}
}
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, \'UTF-8\', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(\'ipxserver\');
$pdf->SetTitle(\'Nota de Entrega\');
$pdf->SetSubject(\'Primera Nota\');
$pdf->SetKeywords(\'TCPDF, PDF, example, test, guide\');
// set margins
$pdf->SetMargins(15, 20, 15);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// borra la linea de arriba en el area del header
$pdf->setPrintHeader(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set some language-dependent strings (optional)
if (@file_exists(\'/includes/tcpdf/examples/lang/spa.php\')) {
	require_once(\'/includes/tcpdf/examples/lang/spa.php\');
	$pdf->setLanguageArray($l);
}
$pdf->SetFont(\'helvetica\', \'B\' , 11);
$nit = $invoice->account_nit;
$nfac = $invoice->invoice_number;
$nauto = $invoice->number_autho;
$sfc = $invoice->sfc;

// add a page
$pdf->AddPage(\'P\', \'LETTER\');

$logoEmpresa = base64_decode($invoice->logo);
$pdf->Image(\'@\'.$logoEmpresa, \'14\', \'10\', 50, 20, \'\', \'\', \'T\', false, 300, \'\', false, false, 0, false, false, false);
///title

$titleFactura=\'<table>
<tr>
<td align="rigth"><font color="#333333">NOTA DE ENTREGA</font></td>
</tr>
</table>\';
$pdf->SetFont(\'helvetica\', \'B\' , 27);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'10\', $titleFactura, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'helvetica\', \'B\' , 11);
//nombre de la empresa
$business = $invoice->account_name;
$unipersonal = $invoice->account_uniper;
$pdf->SetFont(\'helvetica\', \'B\', 12, false);
$NombreEmpresa = \'
    <p style="line-height: 150%">
        <font color="#333333">
            \'.$business.\'
        </font>
    </p>\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'10\', $y=\'31\', $NombreEmpresa, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);




$pdf->SetFont(\'helvetica\', \'B\', 8, false);


//datos de la empresa
$casa = $matriz->name;
$dir_casa = $matriz->address1." - ".$matriz->address2;
$tel_casa = $matriz->work_phone;
$city_casa = $matriz->city." - Bolivia";
if($matriz->city == $invoice->city && $invoice->branch_id != $matriz->id)
    $city_casa ="";
else
$city_casa = \'<tr>
        <td width="220" align="left">\'.$city_casa.\'</td>
        </tr>\';
        $pdf->SetFont(\'helvetica\', \'\', 7);

if($invoice->branch_id == $matriz->id)
{
	$datoEmpresa = \'
    <table border = "0">
        <tr>
        <td width="250" align="left"><b>\'.$casa.\'</b></td>
        </tr>
        <tr>
        <td width="250" align="left">\'.$dir_casa.\' </td>
        </tr>
        <tr>
        <td width="250" align="left">Telfs: \'.$tel_casa.\'</td>
        </tr>
        \'.$city_casa.\'
    </table>				\';
}
else{
	$sucursal = $invoice->branch_name;
	$direccion = $invoice->address1." - ".$invoice->address2;
	$ciudad = $invoice->city." - Bolivia";
	$telefonos =$invoice->phone;
	$datoEmpresa = \'
    <table border = "0">
        <tr>
        <td width="250" align="left"><b>\'.$casa.\'</b></td>
        </tr>
        <tr>
        <td width="250" align="left">\'.$dir_casa.\'</td>
        </tr>
        <tr>
        <td width="250" align="left">Telfs: \'.$tel_casa.\'</td>
        </tr>
        \'.$city_casa.\'
        <tr>
        <td width="250" align="left"><b>\'.$sucursal.\'</b></td>
        </tr>
        <tr>
        <td width="250" align="left">\'.$direccion.\'</td>
        </tr>
        <tr>
        <td width="250" align="left">Telfs: \'.$telefonos.\'</td>
        </tr>
        <tr>
        <td width="250" align="left">\'.$ciudad.\'</td>
        </tr>
    </table>				\';
}

$pdf->writeHTMLCell($w=0, $h=0, $x=\'15\', $y=\'40\', $datoEmpresa, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//TABLA datos del cliente

$pdf->SetFont(\'helvetica\', \'\', 10);

$meses = array("","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");

$lenguage = \'es_ES.UTF-8\';
putenv("LANG=$lenguage");
setlocale(LC_ALL, $lenguage);


$date = DateTime::createFromFormat("d/m/Y", $invoice->invoice_date);
if($date== null){
    $date = DateTime::createFromFormat("Y-m-d", $invoice->invoice_date);
    $fecha = strftime("%d de %B de %Y",$date->getTimestamp());
}
else
    $fecha = strftime("%d de %B de %Y",$date->getTimestamp());



//$fecha= $invoice->state.", ".$fecha;
$senor = $invoice->client_name;
$nit = $invoice->client_nit;
$numeroNota = $invoice->document_number;

$datosCliente = \'
<table cellpadding="2" border="0">
    <tr>
        <td  width="80" align="right"><b>&nbsp;Fecha :</b></td>
        <td width="135">\'.$fecha.\'</td>
    </tr>

    <tr>
        <td width="80" align="right"><b>Nº de Nota:</b></td>
        <td width="135">\'.$numeroNota.\'</td>
    </tr>
</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'121\', $y=\'32\', $datosCliente, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$nameClient = \'
	<table border = "0">
	<tr>
        <td width="60" align="right"><b>Para:</b></td>
        <td width="90">&nbsp;\'.$senor .\'</td>
    </tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'67\', $y=\'32\', $nameClient, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//preparado por

$pdf->SetFont(\'helvetica\', \'\', 9);
$nombreUsuario = $user->last_name." ".$user->first_name;
$rol = "Soporte Técnico";
$telefono = $user->phone;
$correo = $user->email;

$preparadoPor = \'
    <table border = "0">
        <tr>
        <td width="75" align="left"><b>Preparado por: </b></td>
        <td width="110" align="left">\'.$nombreUsuario.\'</td>
        </tr>
        <!--tr>
        <td width="75" align="left"> </td>
        <td width="110" align="left">\'.$rol.\'</td>
        </tr-->
        <tr>
        <td width="75" align="left"> </td>
        <td width="110" align="left">Telfs: \'.$telefono.\'</td>
        </tr>
        <tr>
        <td width="75" align="left"> </td>
        <td width="110" align="left">\'.$correo.\'</td>
        </tr>
    </table>\';

$pdf->writeHTMLCell($w=0, $h=0, $x=\'125\', $y=\'50\', $preparadoPor, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);





$textTitulos = "";
$textTitulos .= \'<p></p>
<table border="0.2" cellpadding="3" cellspacing="0">
    <thead>
        <tr>
         <td width="70" align="center" bgcolor="#E6DFDF"><font size="10"><b>CANTIDAD</b></font></td>
         <td width="240" align="center" bgcolor="#E6DFDF"><font size="10"><b>CONCEPTO</b></font></td>
         <td width="115" align="center" bgcolor="#E6DFDF"><font size="10"><b>PRECIO UNITARIO</b></font></td>
         <td width="97" align="center" bgcolor="#E6DFDF"><font size="10"><b>TOTAL</b></font></td>
        </tr>
    </thead>
</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'60\', $textTitulos, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//
$ini = 0;
$final = "";
$resto = $ini;
//for ($i=0;$i<=10;$i++)
//{
foreach ($products as $key => $product){
		$textContenido =\'
        <table border="0.2" cellpadding="3" cellspacing="0">
		<tr>
		<td width="70" align="center"><font size="10">\'.intval($product->qty).\'</font></td>
		<td width="240"><font size="10">\'.$product->notes.\'</font></td>
		<td width="115" align="right"><font size="10">\'.number_format((float)$product->cost, 2, \'.\', \',\').\'</font></td>
		<td width="97" align="right"><font size="10"> \'.number_format((float)($product->cost*$product->qty), 2, \'.\', \',\').\'</font></td>
		</tr>
         </table>
		\';
        $ini = $pdf->GetY(); //punto inicial antes de dibujar la siguiente fila

        if(($ini+$resto)>= 250.46944444444){

			$pdf->AddPage(\'P\', \'LETTER\');
            $pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $textContenido, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
        }
        else{
        $pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $textContenido, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
        $final = $pdf->GetY();  //punto hasta donde se dibujo la fila
        }
        $resto = $final-$ini; //diferencia entre $ini y $final para sacar el tamaño siguiente a dibujar
//}
}
$texPie = "";
$subtotal = number_format((float)$invoice->importe_total, 2, \'.\', \',\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \',\');
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \',\');
$fiscal="0";
$ice="0";


require_once(app_path().\'/includes/numberToString.php\');
$nts = new numberToString();
$num = explode(".", $invoice->importe_neto);
if(!isset($num[1]))
    $num[1]="00";
$literal= $nts->to_word($num[0]).substr($num[1],0,2);


$pdf->SetFont(\'helvetica\', \'\', 11);
		$texPie .=\'
		<table border="0.2" cellpadding="3" cellspacing="0">
            <tr>
                <td width="425" align="right"><b>SUBTOTAL &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td  width="97" align="right"><b>\'.$subtotal.\'</b></td>
            </tr>
            <tr>
                <td width="425"  align="right"><b>Descuentos &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td width="97" align="right"><b>\'.$descuento.\'</b></td>
            </tr>
            <tr>
                <td width="425"  align="right"><b>TOTAL &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                <td width="97" align="right"><b>\'.$total.\'</b></td>
            </tr>

            <tr>
                <td colspan="2" style="font-size:9px"><b>Son: </b>\'.$literal.\'/100 BOLIVIANOS.</td>
            </tr>
		</table>
		\';
        if ($pdf->GetY() >= \'210.6375\' ){

            $pdf->AddPage(\'P\', \'LETTER\');
        }

$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $texPie, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//nota al cliente
$restoQr = 11;
$line=60;
if (!empty($invoice->public_notes)){
$nota = $invoice->public_notes;
$notaCliente = \'

		<table style="padding:0px 0px 0px 5px" border="0">
		<tr>
			<td style="line-height: \'.$line.\'%"> </td>
		</tr>
		<tr>
			<td width="88" align="right" style="font-size:9px;"><b>Nota al Cliente:</b></td>
			<td width="352" align="left" bgcolor="#F2F2F2" style="font-size:9px; border-left: 1px solid #000;">\'.$nota.\'</td>
		</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $notaCliente, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$restoQr=$restoQr+10;
$line=100;
}

$restoQr=$restoQr+11;
$line=50;


$control_code = $invoice->control_code;
$fecha_limite = date("d/m/Y", strtotime($invoice->deadline));
$fecha_limite = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->deadline);
if($fecha_limite== null)
    $fecha_limite = $invoice->deadline;
else
    $fecha_limite = $fecha_limite->format(\'d/m/Y\');

$law_gen="ESTA FACTURA CONTRIBUYE AL DESARROLLO DEL PAIS, EL USO ILICITO DE ESTA SERA SANCIONADO DE ACUERDO A LEY";

$law=$invoice->law;
//$usuario = "usuario";
$datosFactura = \'
<table border="0" style="line-height: 160%">
	<tr><td style="line-height: \'.$line.\'%"> </td></tr>
    <tr><td> </td></tr>
    <tr><td> </td></tr>
    <tr>
        <td width="262" align="center" style="font-size:9px"><b>Recibi Conforme</b></td>
        <td width="262" align="center" style="font-size:9px"><b>Entregue Conforme</b></td>
    </tr>
    <tr>
        <td width="262" align="center" style="font-size:9px"><b> </b></td>
        <td width="262" align="center" style="font-size:9px">\'.$nombreUsuario.\'</td>
    </tr>

</table>
\';
if ($pdf->GetY() >= \'226.6375\' ){
		$pdf->AddPage(\'P\', \'LETTER\');
		if(!empty($nota) && !empty($terminos)){
			$restoQr = $restoQr - 18;
		}
    }

$subtotal = number_format((float)$invoice->importe_total, 2, \'.\', \'\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \'\');
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \'\');
$pdf->writeHTMLCell($w=0, $h=0, \'\', \'\', $datosFactura, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//Close and output PDF document
$pdf->Output(\'factura.pdf\', \'I\');

die;';
        //factura fiscal
        $master->javascript_pos = ' $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, \'UTF-8\', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(\'ipxserver\');
$pdf->SetTitle(\'Factura\');
$pdf->SetSubject(\'Primera Factura\');
$pdf->SetKeywords(\'TCPDF, PDF, example, test, guide\');
$pdf->SetMargins(0.5, 0.5, 0.5);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetFont(\'helvetica\', \'\' , 7);
$page_format = array(
    \'MediaBox\' => array (\'llx\' => 0, \'lly\' => 0, \'urx\' => 72, \'ury\' => 1000),
    \'Dur\' => 3,
);
$business = $invoice->account_name;
if($invoice->account_uniper !=\'\')
    $unipersonal = \'<tr><td align="center">De: \'.$invoice->account_uniper.\'</td></tr>\';
else
    $unipersonal="";
// Check the example n. 29 for viewer preferences
$pdf->AddPage(\'P\', $page_format, false, false);
$sucursal = $invoice->branch_name;
$direccion = $invoice->address1." - ".$invoice->address2;
$ciudad = $invoice->city." - Bolivia";
$telefonos =$invoice->phone;

$html = \'
<table>
	<tr>
		<td align="center" style="font-size:10px; "><b>\'.$business.\'</b></td>
	</tr>
        \'.$unipersonal.\'
        <tr>
		<td align="center">\'.$sucursal.\'</td>
	</tr><tr>
		<td align="center">\'.$direccion.\'</td>
	</tr><tr>
		<td align="center">Telefono: \'.$telefonos.\'</td>
	</tr><tr>
		<td align="center">\'.$ciudad.\'</td>
	</tr>
</table>
\';
//imprime el contenido de la variable html
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
if($copia==1)
    $original = "COPIA";
else
$original = "ORIGINAL";
$pdf->SetFont(\'times\', \'B\' , 10);
$fact = \'<br><br><table>
<tr>
	<td align="center">
		FACTURA
	</td>
</tr>
<tr>
	<td align="center">
		\'.$original.\'
	</td>
</tr>
</table>
\'
;
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $fact, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$lin = " ";

$pdf->SetFont(\'helvetica\', \' \' , 8);
for ($i=0;$i<72;$i++)$lin .= \'-\';

$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//DATOS FACTURA
$pdf->SetFont(\'helvetica\', \' \' , 8);
$nitEmpresa = $invoice->account_nit;
$nfac = $invoice->invoice_number;
$nauto = $invoice->number_autho;

$datosfac = \'
	<table border="0">
		<tr>
			<td align="left">NIT : </td>
			<td align="left">\'.$nitEmpresa.\'</td>
		</tr>
		<tr>
			<td align="left">FACTURA No : </td>
			<td align="left">\'.$nfac.\'</td>
		</tr>
		<tr>
			<td align="left">AUTORIZACION No :   </td>
			<td align="left">\'.$nauto.\'</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'10\', $y=\'\', $datosfac, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//linea
$pdf->SetFont(\'helvetica\', \' \' , 8);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//actividad economica
$pdf->SetFont(\'times\', \'B\' , 9);
$actividad=$invoice->economic_activity;
$acti = \'
	<table align="center">
		<tr>
			<td>ACTIVIDAD ECON&Oacute;MICA</td>
		</tr>
		<tr>
			<td>\'.$actividad.\'</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $acti, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'helvetica\', \'\' , 8);
$date = DateTime::createFromFormat("Y-m-d", $invoice->invoice_date);
if($date==null)
    $date = DateTime::createFromFormat("d/m/Y", $invoice->invoice_date);
$fecha = $date->format(\'d/m/Y\');
$senor = $invoice->client_name;
$nit = $invoice->client_nit;
$hora = $date->format(\'H:i:s\');

$datosCli = \'<br>
	<table border="1">
		<tr>
			<td align="left" width="40">Fecha : </td>
			<td align="left">\'.$fecha.\'</td>
			<td align="right" width="30">Hora : </td>
			<td align="left">\'.$hora.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">NIT/CI : </td>
			<td align="left">\'.$nit.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">Nombre :   </td>
			<td align="left">\'.$senor.\'</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'9\', $y=\'\', $datosCli, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//tabla
$htmlTabla = \'
	<table border="1">
		<tr>
			<td align="center">Cantidad</td>
			<td align="center">Precio</td>
			<td align="center">Importe</td>
		</tr>
	</table>
<p style="line-height: 30%">
    </p>\';

$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);


foreach ($products as $key => $product){
	$htmlTabla2 = \'
		<table border="0">
			<tr>
				<td colspan="3">\'.$product->notes.\'</td>
			</tr>
			<tr>
				<td align="center">\'.intval($product->qty).\'</td>
				<td align="center">\'.number_format((float)$product->cost, 2, \'.\', \',\').\'</td>
				<td align="center">\'.number_format((float)($product->cost*$product->qty), 2, \'.\', \',\').\'</td>
			</tr>
		</table>
	\';
	$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla2, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
}
//total
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \',\');
$htmlTotal = \'<hr>
	<table>
		<tr>
			<td align="right" width="173"><b>TOTAL: Bs \'.$total.\'</b></td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTotal, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//TOTALES
$ice = number_format((float)($invoice->importe_ice), 2, \'.\', \',\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \',\');
$importeCreditoFiscal = number_format((float)($invoice->debito_fiscal), 2, \'.\', \',\');
$fiscal =$importeCreditoFiscal;
$montoPagar = number_format((float)$invoice->importe_neto, 2, \'.\', \',\');
require_once(app_path().\'/includes/numberToString.php\');
$nts = new numberToString();
$num = explode(".", $invoice->importe_neto);
if(!isset($num[1]))
    $num[1]="00";
$literal= $nts->to_word($num[0]).substr($num[1],0,2);



$htmlDatosExtra = \'
	<table>
		<tr>
			<td>ICE: \'.$ice.\'</td>
		</tr>
		<tr>
			<td>DESCUENTOS/BONIFICACION: \'.$descuento.\'</td>
		</tr>
		<tr>
			<td>IMPORTE BASE CREDITO FISCAL: \'.$importeCreditoFiscal.\'</td>
		</tr>
		<tr>
			<td>MONTO A PAGAR: Bs \'.$montoPagar.\'</td>
		</tr>
		<tr>
			<td>SON: \'.$literal.\'/100 BOLIVIANOS</td>
		</tr>
	</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlDatosExtra, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//linea
$pdf->SetFont(\'helvetica\', \' \' , 8);
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//CODIGO DE CONTROL

$control_code = $invoice->control_code;
$fecha_limite = date("d/m/Y", strtotime($invoice->deadline));
$fecha_limite = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->deadline);
if($fecha_limite== null)
    $fecha_limite = $invoice->deadline;
else
    $fecha_limite = $fecha_limite->format(\'d/m/Y\');
$law_gen=\'"\'."ESTA FACTURA CONTRIBUYE AL DESARROLLO DEL PAÍS, EL USO ILÍCITO DE ÉSTA SERÁ SANCIONADO DE ACUERDO A LEY".\'"\';
$law=$invoice->law;

 $htmlControl = \'
 	<table>
 		<tr>
 			<td>CODIGO DE CONTROL : \'.$control_code.\'</td>
 		</tr>
 		<tr>
 			<td>FECHA LÍMITE EMISIÓN : \'.$fecha_limite.\'</td>
 		</tr>

 	</table>
 	<br>

 \';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlControl, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//qr
$subtotal = number_format((float)$invoice->importe_total, 2, \'.\', \'\');
$descuento= number_format((float)($invoice->importe_total-$invoice->importe_neto), 2, \'.\', \'\');
$total = number_format((float)$invoice->importe_neto, 2, \'.\', \'\');
$date_qr = date("d/m/Y", strtotime($invoice->invoice_date));
$date_qr = \\DateTime::createFromFormat(\'Y-m-d\',$invoice->invoice_date);
if($date_qr== null)
    $date_qr = $invoice->invoice_date;
else
    $date_qr = $date_qr->format(\'d/m/Y\');
if($descuento=="0.00")
    $descuento=0;
if($fiscal==0) $fiscal="0";
if($ice==0) $ice ="0";
if($descuento==0)$descuento="0";
$datosqr = $invoice->account_nit.\'|\'.$invoice->invoice_number.\'|\'.$invoice->number_autho.\'|\'.$date_qr.\'|\'.$total.\'|\'.$fiscal.\'|\'.$invoice->control_code.\'|\'.$invoice->client_nit.\'|\'.$ice.\'|0|0|\'.$descuento;
$pdf->write2DBarcode($datosqr, \'QRCODE,M\', \'24\', \'\' , 25, 25, \'\', \'N\');

$htmlLeyenda = \'<br><br>
		<table>
			<tr>
				<td align="center"><b>\'.$law_gen.\'</b></td>
			</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlLeyenda, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf->SetFont(\'times\', \' \' , 9);
$emizor = \'<br><br>
		<table>
			<tr>
				<td align="center">www.emizor.com</td>
			</tr>
		</table>
\';
$pdf->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $emizor, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$y = $pdf->GetY();
$y2 = intval($y) + 8;
//////pdf adaptado a nuevo tamaño//////////////////////////////////////////////////////////////////
$page_format2 = array(
    \'MediaBox\' => array (\'llx\' => 0, \'lly\' => 0, \'urx\' => 72, \'ury\' => $y2),
    \'Dur\' => 3,
);
// add first page ---
$pdf2 = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, \'UTF-8\', false);
//Close and output PDF document
$pdf2->SetCreator(PDF_CREATOR);
$pdf2->SetAuthor(\'ipxserver\');
$pdf2->SetTitle(\'Factura\');
$pdf2->SetSubject(\'Primera Factura\');
$pdf2->SetKeywords(\'TCPDF, PDF, example, test, guide\');
// set margins
$pdf2->SetMargins(0.5, 0.5, 0.5);
// set auto page breaks
$pdf2->SetAutoPageBreak(TRUE, 0.5);
// borra la linea de arriba en el area del header
$pdf2->setPrintHeader(false);
$pdf2->setPrintFooter(false);
// set some language-dependent strings (optional)
if (@file_exists(\'/includes/tcpdf/examples/lang/spa.php\')) {
	require_once(\'/includes/tcpdf/examples/lang/spa.php\');
	$pdf->setLanguageArray($l);
}
$pdf2->SetFont(\'helvetica\', \'\' , 7);
// add second page ---
$pdf2->AddPage(\'P\', $page_format2, false, false);

$html = \'
<table>
	<tr>
		<td align="center" style="font-size:10px; "><b>\'.$business.\'</b></td>
	</tr>
        \'.$unipersonal.\'
        <tr>
		<td align="center">\'.$sucursal.\'</td>
	</tr><tr>
		<td align="center">\'.$direccion.\'</td>
	</tr><tr>
		<td align="center">Telefono: \'.$telefonos.\'</td>
	</tr><tr>
		<td align="center">\'.$ciudad.\'</td>
	</tr>
</table>
\';
//imprime el contenido de la variable html
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$pdf2->SetFont(\'times\', \'B\' , 10);
$fact = \'<br><br><table>
<tr>
	<td align="center">
		FACTURA
	</td>
</tr>
<tr>
	<td align="center">
		\'.$original.\'
	</td>
</tr>
</table>
\'
;
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $fact, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$lin = " ";

$pdf2->SetFont(\'helvetica\', \' \' , 8);
for ($i=0;$i<72;$i++)
{
	$lin .= \'-\';

}
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//DATOS FACTURA
$pdf2->SetFont(\'helvetica\', \' \' , 8);


$datosfac = \'
	<table border="0">
		<tr>
			<td align="left">NIT : </td>
			<td align="left">\'.$nitEmpresa.\'</td>
		</tr>
		<tr>
			<td align="left">FACTURA No : </td>
			<td align="left">\'.$nfac.\'</td>
		</tr>
		<tr>
			<td align="left">AUTORIZACION No :   </td>
			<td align="left">\'.$nauto.\'</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'10\', $y=\'\', $datosfac, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//linea
$pdf2->SetFont(\'helvetica\', \' \' , 8);
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//actividad economica
$pdf2->SetFont(\'times\', \'B\' , 9);

$acti = \'
	<table align="center">
		<tr>
			<td>ACTIVIDAD ECON&Oacute;MICA</td>
		</tr>
		<tr>
			<td>\'.$actividad.\'</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $acti, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
//datos cliente
$pdf2->SetFont(\'helvetica\', \'\' , 8);


$datosCli = \'<br>
	<table border="0">
		<tr>
			<td align="left" width="40">Fecha : </td>
			<td align="left">\'.$fecha.\'</td>
			<td align="right" width="30">Hora : </td>
			<td align="left">\'.$hora.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">NIT/CI : </td>
			<td colspan="3" align="left">\'.$nit.\'</td>
		</tr>
		<tr>
			<td align="left" width="40">Nombre :   </td>
			<td colspan="3" align="left">\'.$senor.\'</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'9\', $y=\'\', $datosCli, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//tabla
$htmlTabla = \'
	<table border="0">
		<tr>
			<td align="center">Cantidad</td>
			<td align="center">Precio</td>
			<td align="center">Subtotal</td>
		</tr>
	</table>
<p style="line-height: 30%">
    </p>\';

$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

foreach ($products as $key => $product){
	$htmlTabla2 = \'
		<table border="0">
			<tr>
				<td colspan="3">\'.$product->notes.\'</td>
			</tr>
			<tr>
				<td align="center">\'.intval($product->qty).\'</td>
				<td align="center">\'.number_format((float)$product->cost, 2, \'.\', \',\').\'</td>
				<td align="center">\'.number_format((float)($product->cost*$product->qty), 2, \'.\', \',\').\'</td>
			</tr>
		</table>
	\';
	$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTabla2, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
}

//total
$htmlTotal = \'<hr>
	<table>
		<tr>
			<td align="right" width="173"><b>TOTAL: Bs \'.$total.\'</b></td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlTotal, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);




$htmlDatosExtra = \'
	<table>
		<tr>
			<td>ICE: \'.$ice.\'</td>
		</tr>
		<tr>
			<td>DESCUENTOS/BONIFICACIÓN: \'.$descuento.\'</td>
		</tr>
		<tr>
			<td>IMPORTE BASE CREDITO FISCAL: \'.$importeCreditoFiscal.\'</td>
		</tr>
		<tr>
			<td>MONTO A PAGAR: Bs \'.$montoPagar.\'</td>
		</tr>
		<tr>
			<td>SON: \'.$literal.\'/100 BOLIVIANOS</td>
		</tr>
	</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlDatosExtra, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//linea
$pdf2->SetFont(\'helvetica\', \' \' , 8);
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $lin, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);


//CODIGO DE CONTROL

 $htmlControl = \'
 	<table>
 		<tr>
 			<td><b>CÓDIGO DE CONTROL : \'.$control_code.\'</b></td>
 		</tr>
 		<tr>
 			<td><b>FECHA LÍMITE EMISIÓN : \'.$fecha_limite.\'</b></td>
 		</tr>
 	</table>
 	<br>

 \';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlControl, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

//qr
$pdf2->write2DBarcode($datosqr, \'QRCODE,M\', \'24\', \'\' , 25, 25, \'\', \'N\');

$htmlLeyenda = \'<br><br>
		<table>
			<tr>
				<td align="center"><b>\'.$law_gen.\'</b></td>
			</tr>
		</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $htmlLeyenda, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);
$pdf2->SetFont(\'times\', \' \' , 9);
$emizor = \'<br><br>
		<table>
			<tr>
				<td align="center">www.emizor.com</td>
			</tr>
		</table>
\';
$pdf2->writeHTMLCell($w=0, $h=0, $x=\'\', $y=\'\', $emizor, $border=0, $ln=1, $fill=0, $reseth=true, $align=\'left\', $autopadding=true);

$pdf2->Output(\'factura.pdf\', \'I\');
die();';
        $master->save();
        PaymentType::create(array('name' => 'Efectivo'));
        PaymentType::create(array('name' => 'Crédito'));
        PaymentType::create(array('name' => 'Transferencia Bancaria'));
        PaymentType::create(array('name' => 'Cheque'));
        //Unidad::create(array('name' => 'unidad','is_int'=>true,));
        //Unidad::create(array('nombre' => 'decimal','is_int'=>false));
        InvoiceStatus::create(array('name' => 'Emitido'));
        InvoiceStatus::create(array('name' => 'Enviado'));
        InvoiceStatus::create(array('name' => 'Visto'));
        InvoiceStatus::create(array('name' => 'Parcial'));
        InvoiceStatus::create(array('name' => 'Pagado'));
        InvoiceStatus::create(array('name' => 'Anulado'));
        Frequency::create(array('name' => 'Mensual'));
        Frequency::create(array('name' => 'Trimestral'));
        Frequency::create(array('name' => 'Semestral'));
        Frequency::create(array('name' => 'Anual'));
        Currency::create(array('name' => 'Bolivianos', 'code' => 'BS', 'symbol' => 'Bs', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
        DatetimeFormat::create(array('format' => 'd/M/Y g:i a', 'label' => '10/Mar/2013'));
        DatetimeFormat::create(array('format' => 'd-M-Yk g:i a', 'label' => '10-Mar-2013'));
        DatetimeFormat::create(array('format' => 'd/F/Y g:i a', 'label' => '10/March/2013'));
        DatetimeFormat::create(array('format' => 'd-F-Y g:i a', 'label' => '10-March-2013'));
        DatetimeFormat::create(array('format' => 'M j, Y g:i a', 'label' => 'Mar 10, 2013 6:15 pm'));
        DatetimeFormat::create(array('format' => 'F j, Y g:i a', 'label' => 'March 10, 2013 6:15 pm'));
        DatetimeFormat::create(array('format' => 'D M jS, Y g:ia', 'label' => 'Mon March 10th, 2013 6:15 pm'));
        DateFormat::create(array('format' => 'd/M/Y', 'picker_format' => 'dd/M/yyyy', 'label' => '10/Mar/2013'));
        DateFormat::create(array('format' => 'd-M-Y', 'picker_format' => 'dd-M-yyyy', 'label' => '10-Mar-2013'));
        DateFormat::create(array('format' => 'd/F/Y', 'picker_format' => 'dd/MM/yyyy', 'label' => '10/March/2013'));
        DateFormat::create(array('format' => 'd-F-Y', 'picker_format' => 'dd-MM-yyyy', 'label' => '10-March-2013'));
        DateFormat::create(array('format' => 'M j, Y', 'picker_format' => 'M d, yyyy', 'label' => 'Mar 10, 2013'));
        DateFormat::create(array('format' => 'F j, Y', 'picker_format' => 'MM d, yyyy', 'label' => 'March 10, 2013'));
        DateFormat::create(array('format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy', 'label' => 'Mon March 10, 2013'));
        TaxRate::create(array('account_id' => '1', 'name' => 'ICE', 'rate' => '0.42'));
        //
        Category::create(array('name' => 'General'));
        /*
        d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05.
        D, DD: Abbreviated and full weekday names, respectively. Eg, Mon, Monday.
        m, mm: Numeric month, no leading zero and leading zero, respectively. Eg, 7, 07.
        M, MM: Abbreviated and full month names, respectively. Eg, Jan, January
        yy, yyyy: 2- and 4-digit years, respectively. Eg, 12, 2012.)
        */
        $timezones = array('Pacific/Midway' => "(GMT-11:00) Midway Island", 'US/Samoa' => "(GMT-11:00) Samoa", 'US/Hawaii' => "(GMT-10:00) Hawaii", 'US/Alaska' => "(GMT-09:00) Alaska", 'US/Pacific' => "(GMT-08:00) Pacific Time (US &amp; Canada)", 'America/Tijuana' => "(GMT-08:00) Tijuana", 'US/Arizona' => "(GMT-07:00) Arizona", 'US/Mountain' => "(GMT-07:00) Mountain Time (US &amp; Canada)", 'America/Chihuahua' => "(GMT-07:00) Chihuahua", 'America/Mazatlan' => "(GMT-07:00) Mazatlan", 'America/Mexico_City' => "(GMT-06:00) Mexico City", 'America/Monterrey' => "(GMT-06:00) Monterrey", 'Canada/Saskatchewan' => "(GMT-06:00) Saskatchewan", 'US/Central' => "(GMT-06:00) Central Time (US &amp; Canada)", 'US/Eastern' => "(GMT-05:00) Eastern Time (US &amp; Canada)", 'US/East-Indiana' => "(GMT-05:00) Indiana (East)", 'America/Bogota' => "(GMT-05:00) Bogota", 'America/Lima' => "(GMT-05:00) Lima", 'America/Caracas' => "(GMT-04:30) Caracas", 'Canada/Atlantic' => "(GMT-04:00) Atlantic Time (Canada)", 'America/La_Paz' => "(GMT-04:00) La Paz", 'America/Santiago' => "(GMT-04:00) Santiago", 'Canada/Newfoundland' => "(GMT-03:30) Newfoundland", 'America/Buenos_Aires' => "(GMT-03:00) Buenos Aires", 'Greenland' => "(GMT-03:00) Greenland", 'Atlantic/Stanley' => "(GMT-02:00) Stanley", 'Atlantic/Azores' => "(GMT-01:00) Azores", 'Atlantic/Cape_Verde' => "(GMT-01:00) Cape Verde Is.", 'Africa/Casablanca' => "(GMT) Casablanca", 'Europe/Dublin' => "(GMT) Dublin", 'Europe/Lisbon' => "(GMT) Lisbon", 'Europe/London' => "(GMT) London", 'Africa/Monrovia' => "(GMT) Monrovia", 'Europe/Amsterdam' => "(GMT+01:00) Amsterdam", 'Europe/Belgrade' => "(GMT+01:00) Belgrade", 'Europe/Berlin' => "(GMT+01:00) Berlin", 'Europe/Bratislava' => "(GMT+01:00) Bratislava", 'Europe/Brussels' => "(GMT+01:00) Brussels", 'Europe/Budapest' => "(GMT+01:00) Budapest", 'Europe/Copenhagen' => "(GMT+01:00) Copenhagen", 'Europe/Ljubljana' => "(GMT+01:00) Ljubljana", 'Europe/Madrid' => "(GMT+01:00) Madrid", 'Europe/Paris' => "(GMT+01:00) Paris", 'Europe/Prague' => "(GMT+01:00) Prague", 'Europe/Rome' => "(GMT+01:00) Rome", 'Europe/Sarajevo' => "(GMT+01:00) Sarajevo", 'Europe/Skopje' => "(GMT+01:00) Skopje", 'Europe/Stockholm' => "(GMT+01:00) Stockholm", 'Europe/Vienna' => "(GMT+01:00) Vienna", 'Europe/Warsaw' => "(GMT+01:00) Warsaw", 'Europe/Zagreb' => "(GMT+01:00) Zagreb", 'Europe/Athens' => "(GMT+02:00) Athens", 'Europe/Bucharest' => "(GMT+02:00) Bucharest", 'Africa/Cairo' => "(GMT+02:00) Cairo", 'Africa/Harare' => "(GMT+02:00) Harare", 'Europe/Helsinki' => "(GMT+02:00) Helsinki", 'Europe/Istanbul' => "(GMT+02:00) Istanbul", 'Asia/Jerusalem' => "(GMT+02:00) Jerusalem", 'Europe/Kiev' => "(GMT+02:00) Kyiv", 'Europe/Minsk' => "(GMT+02:00) Minsk", 'Europe/Riga' => "(GMT+02:00) Riga", 'Europe/Sofia' => "(GMT+02:00) Sofia", 'Europe/Tallinn' => "(GMT+02:00) Tallinn", 'Europe/Vilnius' => "(GMT+02:00) Vilnius", 'Asia/Baghdad' => "(GMT+03:00) Baghdad", 'Asia/Kuwait' => "(GMT+03:00) Kuwait", 'Africa/Nairobi' => "(GMT+03:00) Nairobi", 'Asia/Riyadh' => "(GMT+03:00) Riyadh", 'Asia/Tehran' => "(GMT+03:30) Tehran", 'Europe/Moscow' => "(GMT+04:00) Moscow", 'Asia/Baku' => "(GMT+04:00) Baku", 'Europe/Volgograd' => "(GMT+04:00) Volgograd", 'Asia/Muscat' => "(GMT+04:00) Muscat", 'Asia/Tbilisi' => "(GMT+04:00) Tbilisi", 'Asia/Yerevan' => "(GMT+04:00) Yerevan", 'Asia/Kabul' => "(GMT+04:30) Kabul", 'Asia/Karachi' => "(GMT+05:00) Karachi", 'Asia/Tashkent' => "(GMT+05:00) Tashkent", 'Asia/Kolkata' => "(GMT+05:30) Kolkata", 'Asia/Kathmandu' => "(GMT+05:45) Kathmandu", 'Asia/Yekaterinburg' => "(GMT+06:00) Ekaterinburg", 'Asia/Almaty' => "(GMT+06:00) Almaty", 'Asia/Dhaka' => "(GMT+06:00) Dhaka", 'Asia/Novosibirsk' => "(GMT+07:00) Novosibirsk", 'Asia/Bangkok' => "(GMT+07:00) Bangkok", 'Asia/Jakarta' => "(GMT+07:00) Jakarta", 'Asia/Krasnoyarsk' => "(GMT+08:00) Krasnoyarsk", 'Asia/Chongqing' => "(GMT+08:00) Chongqing", 'Asia/Hong_Kong' => "(GMT+08:00) Hong Kong", 'Asia/Kuala_Lumpur' => "(GMT+08:00) Kuala Lumpur", 'Australia/Perth' => "(GMT+08:00) Perth", 'Asia/Singapore' => "(GMT+08:00) Singapore", 'Asia/Taipei' => "(GMT+08:00) Taipei", 'Asia/Ulaanbaatar' => "(GMT+08:00) Ulaan Bataar", 'Asia/Urumqi' => "(GMT+08:00) Urumqi", 'Asia/Irkutsk' => "(GMT+09:00) Irkutsk", 'Asia/Seoul' => "(GMT+09:00) Seoul", 'Asia/Tokyo' => "(GMT+09:00) Tokyo", 'Australia/Adelaide' => "(GMT+09:30) Adelaide", 'Australia/Darwin' => "(GMT+09:30) Darwin", 'Asia/Yakutsk' => "(GMT+10:00) Yakutsk", 'Australia/Brisbane' => "(GMT+10:00) Brisbane", 'Australia/Canberra' => "(GMT+10:00) Canberra", 'Pacific/Guam' => "(GMT+10:00) Guam", 'Australia/Hobart' => "(GMT+10:00) Hobart", 'Australia/Melbourne' => "(GMT+10:00) Melbourne", 'Pacific/Port_Moresby' => "(GMT+10:00) Port Moresby", 'Australia/Sydney' => "(GMT+10:00) Sydney", 'Asia/Vladivostok' => "(GMT+11:00) Vladivostok", 'Asia/Magadan' => "(GMT+12:00) Magadan", 'Pacific/Auckland' => "(GMT+12:00) Auckland", 'Pacific/Fiji' => "(GMT+12:00) Fiji");
        foreach ($timezones as $name => $location) {
            Timezone::create(array('name' => $name, 'location' => $location));
        }
    }
Exemple #15
0
 public function testGetTaxRates()
 {
     $zone = DeliveryZone::getNewInstance();
     $zone->name->set(':TEST_ZONE');
     $zone->save();
     $tax = Tax::getNewInstance('VAT');
     $tax->save();
     $taxRate = TaxRate::getNewInstance($zone, $tax, 15);
     $taxRate->save();
     $taxRates = $zone->getTaxRates();
     $this->assertEquals($taxRates->getTotalRecordCount(), 1);
     $this->assertTrue($taxRates->get(0) === $taxRate);
 }
 /**
  * Return number of items that user $rate tax rate
  *
  * @param TaxRate $tax_rate
  * @return integer
  */
 function countByTaxRate($tax_rate)
 {
     return InvoiceItems::count(array('tax_rate_id = ?', $tax_rate->getId()));
 }
Exemple #17
0
 public static function getCartDetails($sessionId = null, $cartItems = null)
 {
     //This function returns an array that contains the sub total, shipping cost, tax cost, and total cost
     //If $cartItems is an array we will use it as the cart items
     //Otherwise, we'll get the cart items from the database based on the session ID
     //If $cartItems is known before calling this method, it is a good idea to pass it to this method for performance purposes
     //If $sessionId is null, it means we want the current session
     $session = Session::getActiveSession($sessionId);
     $sessionId = $session->getId();
     if (!is_array($cartItems)) {
         $cartItems = CartItem::getAll($sessionId);
     }
     $userId = $session->getUser();
     $userDetails = UserDetails::getUserDetailsBasedOnUserId($userId);
     $shippingAddress = $userDetails->getAddress('shipping_address');
     $cartDetails = array("subTotal" => 0, "tax" => 0, "shipping" => 0, "total" => 0);
     foreach ($cartItems as $cartItem) {
         $product = new Product($cartItem->getProduct());
         $productPrice = $cartItem->calculatePrice() * $cartItem->getQuantity();
         $cartDetails["subTotal"] += $productPrice;
         $cartDetails["tax"] += TaxRate::calculateTax($product->getTaxClass(), $productPrice, $shippingAddress);
     }
     require_once 'plugins/shipping/ECommShipping.php';
     $ECommShipping = new ECommShipping();
     $shippingObj = $ECommShipping->getPlugin($session->getShippingClass());
     $cartDetails["shipping"] = (double) $shippingObj->getShippingCost($sessionId, $cartItems);
     $cartDetails["total"] = (double) $cartDetails["subTotal"] + (double) $cartDetails["tax"] + (double) $cartDetails["shipping"];
     foreach ($cartDetails as &$cartDetailsItem) {
         $cartDetailsItem = number_format($cartDetailsItem, 2);
     }
     return $cartDetails;
 }
Exemple #18
0
 /**
  *
  *	@return ARSet
  */
 public function getTaxRates($includeDisabled = true, $loadReferencedRecords = array('Tax'))
 {
     if (!$this->taxRates) {
         $this->taxRates = TaxRate::getRecordSetByDeliveryZone($this, $loadReferencedRecords);
     }
     return $this->taxRates;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $sucurasl = Branch::find(Session::get('branch_id'));
     if ($sucurasl->type_third != 2) {
         if (sizeof(Input::get('productos')) > 1) {
             if (Input::has('client')) {
                 $account = Account::where('id', Auth::user()->account_id)->first();
                 $branch = Branch::find(Session::get('branch_id'));
                 $tax = TaxRate::where("name", 'ICE')->first();
                 $invoice = Invoice::createNew();
                 $invoice->setBranch(Session::get('branch_id'));
                 $invoice->setTerms(trim(Input::get('terms')));
                 $invoice->setPublicNotes(trim(Input::get('public_notes')));
                 $invoice->setInvoiceDate(trim(Input::get('invoice_date')));
                 $invoice->setClient(trim(Input::get('client')));
                 $invoice->setEconomicActivity($branch->economic_activity);
                 $dateparser = explode("/", Input::get('due_date'));
                 if (Input::get('due_date')) {
                     $date = $dateparser[2] . '-' . $dateparser[1] . '-' . $dateparser[0];
                     $invoice->setDueDate($date);
                 }
                 $invoice->setDiscount(trim(Input::get('discount')));
                 $invoice->setClientName(trim(Input::get('razon')));
                 $invoice->setClientNit(trim(Input::get('nit')));
                 $invoice->setUser(Auth::user()->id);
                 $dateparser = explode("/", Input::get('invoice_date'));
                 $date = $dateparser[2] . '-' . $dateparser[1] . '-' . $dateparser[0];
                 $invoice->setInvoiceDate($date);
                 $invoice->importe_neto = trim(Input::get('total'));
                 $invoice->importe_total = trim(Input::get('subtotal'));
                 if (Input::get('nota')) {
                     $nota = array();
                     $nota[0] = ['date' => date('d-m-Y H:i:s'), 'note' => '<b>' . Auth::user()->first_name . " " . Auth::user()->last_name . "</b>: " . trim(Input::get('nota'))];
                     $invoice->note = json_encode($nota);
                 }
                 //ACCOUTN AND BRANCK
                 $invoice->balance = trim(Input::get('total'));
                 $invoice->discount = Input::get('descuento_send');
                 $invoice->setAccountName($account->name);
                 $invoice->setAccountNit($account->nit);
                 $invoice->setBranchName($branch->name);
                 $invoice->setAddress1($branch->address1);
                 $invoice->setAddress2($branch->address2);
                 $invoice->setPhone($branch->work_phone);
                 $invoice->setCity($branch->city);
                 $invoice->setState($branch->state);
                 $invoice->setNumberAutho($branch->number_autho);
                 $invoice->setKeyDosage($branch->key_dosage);
                 $invoice->setTypeThird($branch->type_third);
                 $invoice->setDeadline($branch->deadline);
                 $invoice->setLaw($branch->law);
                 $type_document = TypeDocument::where('account_id', Auth::user()->account_id)->first();
                 $numAuth = $invoice->number_autho;
                 $invoice->invoice_number = branch::getInvoiceNumber();
                 $numfactura = $invoice->invoice_number;
                 $nit = $invoice->client_nit;
                 $fechaEmision = date("Ymd", strtotime($invoice->invoice_date));
                 $total = $invoice->importe_neto;
                 $llave = $branch->key_dosage;
                 $codigoControl = Utils::getControlCode($numfactura, $nit, $fechaEmision, $total, $numAuth, $llave);
                 //calculates ICE
                 //$desc = $invoice->subtotal-$invoice->amount;
                 $invoice->importe_ice = number_format(Input::get('importe_ice'), 2, '.', '');
                 $invoice->debito_fiscal = number_format(Input::get('importe_fiscal'), 2, '.', '');
                 //$invoice->discount = number_format($desc, 2, '.', '');
                 $invoice->setControlCode($codigoControl);
                 $documents = TypeDocumentBranch::where('branch_id', $invoice->branch_id)->orderBy('id', 'ASC')->get();
                 foreach ($documents as $document) {
                     $actual_document = TypeDocument::where('id', $document->type_document_id)->first();
                     if ($actual_document->master_id == 1) {
                         $id_documento = $actual_document->id;
                     }
                 }
                 $invoice->setJavascript($id_documento);
                 if (Input::get('printer_type') == 1) {
                     $invoice->logo = 1;
                 } else {
                     $invoice->logo = 0;
                 }
                 $invoice->sfc = $branch->sfc;
                 $invoice->qr = $invoice->account_nit . '|' . $invoice->invoice_number . '|' . $invoice->number_autho . '|' . $invoice->invoice_date . '|' . $invoice->importe_neto . '|' . $invoice->importe_total . '|' . $invoice->client_nit . '|' . $invoice->importe_ice . '|0|0|' . $invoice->descuento_total;
                 if ($account->is_uniper) {
                     $invoice->account_uniper = $account->uniper;
                 }
                 $invoice->save();
                 $invoice_items = [];
                 foreach (Input::get('productos') as $producto) {
                     $prod = $producto;
                     $product = Product::where('account_id', Auth::user()->account_id)->where('product_key', $producto["'product_key'"])->first();
                     if ($product != null) {
                         $invoiceItem = InvoiceItem::createNew();
                         $invoiceItem->setInvoice($invoice->id);
                         $invoiceItem->setProduct($product->id);
                         $invoiceItem->setProductKey($producto["'product_key'"]);
                         $proo = DB::table('products')->where('product_key', '=', $producto["'product_key'"])->first();
                         $invoiceItem->setNotes($proo->notes);
                         $invoiceItem->setCost($producto["'cost'"]);
                         ///$invoiceItem->setQty($producto["'qty'"]/$proo->units+$producto["'pack'"]);
                         $invoiceItem->setQty($proo->units * $producto["'pack'"]);
                         $invoiceItem->packs = $producto["'pack'"];
                         $invoiceItem->discount = $producto["'disc'"];
                         $invoiceItem->boni = $producto["'bonus'"];
                         $invoiceItem->is_web = 1;
                         $invoiceItem->price_type_id = Auth::user()->price_type_id;
                         $invoiceItem->subtotal = round($producto["'pack'"] * $producto["'cost'"], 2);
                         //$invoiceItem->importe_neto=$producto["'pack'"]*$producto["'cost'"]-$producto["'bonus'"]*$producto["'cost'"]-$producto["'disc'"];
                         //$invoiceItem->importe_fiscal=
                         $invoiceItem->ice = $proo->cc * $invoiceItem->getQty() / 1000 * $tax->rate;
                         $invoiceItem->save();
                         $new_item = ['boni' => $producto["'bonus'"], 'desc' => $producto["'disc'"], 'qty' => $producto["'qty'"] / $proo->units + $producto["'pack'"], 'id' => $invoice->id, 'units' => 1, 'cost' => $producto["'cost'"], 'ice' => $proo->ice, 'cc' => $proo->cc * $proo->units, 'product_key' => $producto["'product_key'"], 'notes' => $proo->notes, 'packs' => $producto["'qty'"] + $proo->units * $producto["'pack'"], 'is_web' => 1];
                         array_push($invoice_items, $new_item);
                     }
                 }
                 //adicionando cargo al cliente
                 $cliente = Client::find($invoice->client_id);
                 $cliente->balance = $cliente->balance + $invoice->balance;
                 $cliente->save();
                 $new = ['fecha' => $invoice->invoice_date, 'name' => $invoice->client_name, 'cod_control' => $invoice->control_code, 'nit' => $invoice->client_nit, 'invoice_number' => $invoice->invoice_number, 'client_id' => $invoice->client_id . "1", 'user_id' => $invoice->user_id, 'ice' => $tax->rate, 'deadline' => $branch->deadline, 'account_id' => '1', 'branch_id' => $branch->id, 'law' => $branch->law, 'activity_pri' => $branch->economic_activity, 'activity_sec1' => "-", 'address1' => $branch->address1, 'address2' => $branch->address2, 'number_autho' => $branch->number_autho, 'postal_code' => $branch->sfc, 'city' => $branch->city, 'state' => $branch->state, 'country_id' => $branch->id, 'key_dosage' => $branch->key_dosage, 'branch' => $branch->name, 'invoice_items' => $invoice_items, 'terceros' => $branch->terceros, 'discount' => $invoice->discount];
                 /*
                 						return $new;*/
                 $array = [];
                 array_push($array, $new);
                 //$this->saveBackUpToMirror($array);
                 //print_r($array);
                 //return;
                 $newInvoice = Invoice::where('id', '=', $invoice->getId())->first();
                 return Redirect::to("factura/" . $newInvoice->id);
             }
             Session::flash('error', 'por favor ingrese cliente');
             return Redirect::to('factura/create');
         }
         Session::flash('error', 'por favor ingrese productos');
         return Redirect::to('factura/create');
     }
     Session::flash('error', 'La Dosificación es para un dispositivo POS razon por la cual no se puede facturar via web');
     return Redirect::to('factura');
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /tax_rates/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     TaxRate::destroy($id);
     return Redirect::route('tax_rates.index');
 }
 private static function getViewModel()
 {
     return ['account' => Auth::user()->account, 'branch' => Auth::user()->branch, 'products' => Product::scope()->with('prices')->orderBy('id')->get(), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::orderBy('name')->get(), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'frequencies' => array(1 => 'Semanal', 2 => 'Cada 2 semanas', 3 => 'Cada 4 semanas', 4 => 'Mensual', 5 => 'Trimestral', 6 => 'Semestral', 7 => 'Anual')];
 }
Exemple #22
0
 private function createOrderWithZone(DeliveryZone $zone = null)
 {
     if (is_null($zone)) {
         $zone = DeliveryZone::getNewInstance();
     }
     $zone->name->set('Latvia');
     $zone->isEnabled->set(true);
     $zone->save();
     $this->newZone = $zone;
     $country = DeliveryZoneCountry::getNewInstance($zone, 'LV');
     $country->save();
     $tax = Tax::getNewInstance('VAT');
     $tax->save();
     $taxRate = TaxRate::getNewInstance($zone, $tax, 20);
     $taxRate->save();
     $service = ShippingService::getNewInstance($zone, 'def', ShippingService::SUBTOTAL_BASED);
     $service->save();
     $this->newService = $service;
     $shippingRate = ShippingRate::getNewInstance($service, 0, 10000000);
     $shippingRate->flatCharge->set(100);
     $shippingRate->save();
     $this->newRate = $shippingRate;
     // user address
     $address = UserAddress::getNewInstance();
     $address->countryID->set('LV');
     $billingAddress = BillingAddress::getNewInstance($this->user, $address);
     $billingAddress->save();
     // set up order
     $this->order->user->set($this->user);
     $this->order->billingAddress->set($address);
     $this->order->shippingAddress->set($address);
     $this->order->save();
 }
 private static function getViewModel()
 {
     return ['account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'frequencies' => array(1 => 'Weekly', 2 => 'Two weeks', 3 => 'Four weeks', 4 => 'Monthly', 5 => 'Three months', 6 => 'Six months', 7 => 'Annually')];
 }
 public function getCMSFields()
 {
     // Get a list of available product classes
     $classnames = array_values(ClassInfo::subclassesFor("Product"));
     $product_types = array();
     foreach ($classnames as $classname) {
         $instance = singleton($classname);
         $product_types[$classname] = $instance->i18n_singular_name();
     }
     // If CMS Installed, use URLSegmentField, otherwise use text
     // field for URL
     if (class_exists('SiteTreeURLSegmentField')) {
         $baseLink = Controller::join_links(Director::absoluteBaseURL());
         $url_field = SiteTreeURLSegmentField::create("URLSegment");
         $url_field->setURLPrefix($baseLink);
     } else {
         $url_field = TextField::create("URLSegment");
     }
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main', TextField::create("Title", $this->fieldLabel('Title')), $url_field, HTMLEditorField::create('Content', $this->fieldLabel('Content'))->setRows(20)->addExtraClass('stacked'), ToggleCompositeField::create('Metadata', _t('CatalogueAdmin.MetadataToggle', 'Metadata'), array($metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), $metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta'))))->setHeadingLevel(4)), $tabSettings = new Tab('Settings', NumericField::create("BasePrice", _t("Catalogue.Price", "Price")), TextField::create("StockID", $this->fieldLabel('StockID'))->setRightTitle(_t("Catalogue.StockIDHelp", "For example, a product SKU")), DropdownField::create("TaxRateID", $this->fieldLabel('TaxRate'), TaxRate::get()->map())->setEmptyString(_t("Catalogue.None", "None")), TreeMultiSelectField::create("Categories", null, "CatalogueCategory"), DropdownField::create("ClassName", _t("CatalogueAdmin.ProductType", "Type of product"), $product_types))));
     // Help text for MetaData on page content editor
     $metaFieldDesc->setRightTitle(_t('CatalogueAdmin.MetaDescHelp', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help');
     $metaFieldExtra->setRightTitle(_t('CatalogueAdmin.MetaExtraHelp', "HTML tags for additional meta information. For example &lt;meta name=\"customName\" content=\"your custom content here\" /&gt;"))->addExtraClass('help');
     if ($this->ID) {
         $fields->addFieldToTab('Root.Images', SortableUploadField::create('Images', $this->fieldLabel('Images'), $this->Images()));
         $fields->addFieldToTab('Root.Related', GridField::create('RelatedProducts', "", $this->RelatedProducts(), new GridFieldConfig_CatalogueRelated("Product", null, 'SortOrder')));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Exemple #25
0
 private static function getViewModel()
 {
     return ['account' => Auth::user()->account, 'branches' => Branch::where('account_id', '=', Auth::user()->account_id)->where('id', Auth::user()->branch_id)->orderBy('public_id')->get(), 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'frequencies' => array(1 => 'Semanal', 2 => 'Cada 2 semanas', 3 => 'Cada 4 semanas', 4 => 'Mensual', 5 => 'Trimestral', 6 => 'Semestral', 7 => 'Anual')];
 }
    $category->save();
    $productcategory_id_arr[] = $category->id;
}
echo '.';
$list_order = 1;
foreach ($sugar_demodata['producttype_seed_data_names'] as $v) {
    $type = new ProductType();
    $type->name = $v;
    $type->list_order = $list_order;
    $type->save();
    $producttype_id_arr[] = $type->id;
    $list_order++;
}
echo '.';
foreach ($sugar_demodata['taxrate_seed_data'] as $v) {
    $taxrate = new TaxRate();
    $taxrate->name = $v['name'];
    $taxrate->value = $v['value'];
    $taxrate->status = "Active";
    $taxrate->list_order = "1";
    $taxrate->disable_num_format = TRUE;
    $taxrate->save();
    $taxrate_id_arr[] = $taxrate->id;
}
echo '.';
foreach ($sugar_demodata['currency_seed_data'] as $v) {
    if ($v['name'] == $_SESSION["default_currency_name"]) {
        continue;
    }
    $currency = new Currency();
    $currency->name = $v['name'];
<?php

// If subsites is installed
if (class_exists('Subsite')) {
    CatalogueProduct::add_extension('SubsiteCatalogueExtension');
    CatalogueCategory::add_extension('SubsiteCatalogueExtension');
    TaxRate::add_extension('SubsiteCatalogueExtension');
    CatalogueAdmin::add_extension('SubsiteMenuExtension');
}
// Setup google sitemaps
$catalogue_enabled = Catalogue::config()->enable_frontend;
if ($catalogue_enabled && class_exists("GoogleSitemap")) {
    GoogleSitemap::register_dataobject('CatalogueProduct');
    GoogleSitemap::register_dataobject('CatalogueCategory');
}
 private static function getViewModel()
 {
     $recurringHelp = '';
     foreach (preg_split("/((\r?\n)|(\r\n?))/", trans('texts.recurring_help')) as $line) {
         $parts = explode("=>", $line);
         if (count($parts) > 1) {
             $line = $parts[0] . ' => ' . Utils::processVariables($parts[0]);
             $recurringHelp .= '<li>' . strip_tags($line) . '</li>';
         } else {
             $recurringHelp .= $line;
         }
     }
     return ['account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_' . Auth::user()->maxInvoiceDesignId())->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'frequencies' => array(1 => 'Weekly', 2 => 'Two weeks', 3 => 'Four weeks', 4 => 'Monthly', 5 => 'Three months', 6 => 'Six months', 7 => 'Annually'), 'recurringHelp' => $recurringHelp];
 }
 /** @test */
 public function should_return_rate_as_percentage()
 {
     $this->assertEquals(19, $this->rate->percentage());
 }
Exemple #30
0
 public function testTaxClassesWithDefaultZoneAndMultipleTaxes()
 {
     $order = CustomerOrder::getNewInstance($this->user);
     $zone = $order->getDeliveryZone();
     $this->assertTrue($zone->isDefault());
     // default tax level
     TaxRate::getNewInstance($zone, $this->tax, 10)->save();
     $newTax = Tax::getNewInstance('test');
     $newTax->save();
     // diferent tax rate for books
     $books = TaxClass::getNewInstance('Books');
     $books->save();
     $booksRate = TaxRate::getNewInstance($zone, $this->tax, 5);
     $booksRate->taxClass->set($books);
     $booksRate->save();
     $booksRate = TaxRate::getNewInstance($zone, $newTax, 20);
     $booksRate->taxClass->set($books);
     $booksRate->save();
     // price = 100
     $cd = $this->product;
     $book = Product::getNewInstance(Category::getRootNode());
     $book->setPrice('USD', 50);
     $book->isEnabled->set(true);
     $book->taxClass->set($books);
     $book->save();
     $order->addProduct($cd, 1, true);
     $order->addProduct($book, 1, true);
     $order->currency->set($this->currency);
     $order->save();
     $this->assertEqual($order->getTaxAmount(), 19.41);
     $this->assertEqual($order->getTotal(true), 150);
     $service = ShippingService::getNewInstance($order->getDeliveryZone(), 'def', ShippingService::SUBTOTAL_BASED);
     $service->save();
     $shippingRate = ShippingRate::getNewInstance($service, 0, 10000000);
     $shippingRate->flatCharge->set(100);
     $shippingRate->save();
     $shipment = $order->getShipments()->get(0);
     $rates = $order->getDeliveryZone()->getShippingRates($shipment);
     $shipment->setAvailableRates($rates);
     $shipment->setRateId($rates->get(0)->getServiceID());
     $shipment->save();
     $this->assertEqual($order->getTotal(true), 250);
     $this->assertEqual((string) $order->getTaxAmount(), (string) 28.5);
 }