SetFont('helvetica', 'B', 8); $this->Cell(0, 0,'Recibo', 0, 0, 'L'); $this->Ln(); $margins = $this->getMargins(); $this->Line($margins['left'],$this->getY(),$this->getPageWidth()-$margins['right'],$this->getY(),array('width'=>0.3)); */ } // Page footer public function Footer() { // Position at 1.5 cm from bottom /* $this->SetY(-15); $margins = $this->getMargins(); $this->Line($margins['left'],$this->getY(),$this->getPageWidth()-$margins['right'],$this->getY(),array('width'=>0.3)); $this->SetFont('helvetica', '', 8); $this->Cell(0, 10, JText::_('Page').' '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, 0, 'C'); */ } } class vxcModelReceipt extends JModel { var $_id = 0; var $_item = null; /** * Constructor * * @access public * @return void */ function __construct() { parent::__construct(); $this->setDBO(VoxelCareDB::getDatabase()); }//function function SetId($id) { $this->_id = (int)$id; $this->_item = null; } function store(&$data) { $table =& $this->getTable('receipt'); $db =& $this->_db; $table->reset(); $id = (int)$data['id']; $table->load($id); if (!$table->bind($data)) return false; if (!$table->check()) return false; if (!$table->store(true)) return false; $this->SetId($table->id); $data['id'] = $this->_id; return true; } function getData() { if (empty($this->_item)) { $db =& $this->_db; $sql = "SELECT r.id id, r.orderid orderid, r.paid paid, r.paid_date paid_date, r.reference reference, o.price price, o.reference orderreference, o.paid_amount paid_amount, o.batch batch, CONCAT_WS(' ',NULLIF(c.name,''),NULLIF(c.middlename,''),NULLIF(c.surname,'')) customerfullname, u.name username FROM #__vxc_receipt r LEFT JOIN #__vxc_order o ON r.orderid = o.id LEFT JOIN #__vxc_user u ON u.id = o.user LEFT JOIN #__vxc_customer c ON o.customer = c.id WHERE r.id = ".$this->_id; $db->setQuery($sql); $row = $db->loadObject(); if (!$row) { $row = new stdClass(); $row->id = 0; } $this->_item = $row; } return $this->_item; } function generate() { $pdf = new ReceiptPDF(); $receipt =& $this->getData(); $price = JRequest::getVar('price'); $vat = JRequest::getVar('vat'); $total = (1.0 + $vat/100.0) * $price; $pdf->AddPage(); $logo = JPATH_BASE. '/components/com_vxc/assets/images/logo_perpedes.png'; $pdf->Image($logo, 0,10,100,-1); $pdf->Ln(25); $ident = 10; $pdf->Cell($ident,0,''); $pdf->Cell(0,0,'Fecha: '. date("d/m/Y H:i:s") ); $pdf->Ln(); $pdf->Cell($ident,0,''); $textName = $receipt->customerfullname?$receipt->customerfullname:$receipt->orderreference; $pdf->Cell(0,0,'Nombre: '. $textName); $pdf->Ln(); $offset = 70; $html = 'Para recibir sus ortesis, debe realizar un ingreso en la '. 'cuenta de "BANKINTER" según información indicada abajo.'. 'Este ingreso puede hacerlo directamente en cualquier oficina de '. '"BANKINTER" o mediante transferencia bancaria desde su '. 'banco habitual.'; $pdf->writeHTMLCell(120,0,40,$offset,$html); $html = ' '. "". ''. ''. "". "". ''. ''. "". "". ''. ''. "". "". ''. "". "
Nº CuentaES67-0128-0644-0905-0000-4393
Concepto'.$receipt->reference.'
Cantidad€ '.sprintf("%0.2f",$price).' + IVA '.$vat.'%
TOTAL '.sprintf("%0.2f",$total).' €
"; $pdf->writeHTMLCell(120,50,40,$offset+30,$html); $html = 'IMPORTANTE: El concepto es imprescindible en los '. 'ingresos para un correcto seguimiento de su pedido.'; $pdf->writeHTMLCell(120,50,40,$offset+60,$html); return $pdf->Output('','S'); } function getIdFromOrderId($orderId) { $sql = "SELECT r.id FROM #__vxc_receipt r WHERE r.orderid = ". $orderId; $this->_db->setQuery($sql); return $this->_db->loadResult(); } function SetStateName($state) { $data = array(); $data['id'] = $this->_id; $modelBatchStates = new vxcModelBatchStates(); $data['state'] = $modelBatchStates->getIdFromName($state); if ($state=='SHIPPED') { $dateNow = new JDate(); $data['shipping_date'] = $dateNow->toMySQL(); } $this->store($data); } function UpdateState() { $item =& $this->getData(); if ($item->statenameid=='SHIPPED') return; $orders = $this->getOrders(); $allmanufactured = true; foreach($orders as $order) if ($order->statenameid != 'MANUFACTURED') { $allmanufactured= false; break; } if ($allmanufactured) $state ='COMPLETED'; else $state ='INCOMPLETED'; if ($state!=$item->statenameid) { $this->SetStateName($state); } } }// class