<?php   
        $formasPago = $data['formas_pago'];
        $taxable_sales = $data['taxable_sales'];         
        $data = $data['data'];                        
        
        $pdf = new PDF();
        $pdf->AddPage('P','');
        
        $empresaRepo = new CompanyRepository();
        $empresaData = $empresaRepo->getById(1);
        
        $sucursalNameString = '';
        $storeRepo = new StoreRepository();
        $storesName = $storeRepo->getListSelectStores();
        
        $options = $this->getOptions();        
        if(!empty($options['store_id'])){
            if(is_array($options['store_id'])){
                foreach($options['store_id'] as $key => $value){
                    $sucursalNameString .= $storesName[$value].' - ';
                }
            }else{
                $sucursalNameString .= $storesName[$options['store_id']];
            }
        }
        
        $login = new Login();
        
        $pdf->SetFont('Arial','B','10');     
        $pdf->Cell(190, 12,  $this->headerExcelReport, '0', 1, 'C'); //<== margin left   
        $pdf->Cell(190, 4, trim($sucursalNameString,'- '), '0', 1, 'C'); //<== margin left      
        
        $pdf->ln(5);
        $pdf->SetFont('Arial','','10');
        $pdf->cell(50,5,'','',0);/*margin*/
        $pdf->cell(45,5,' Net Sales','0',0);
        $pdf->cell(45,5,'$'.number_format($data['importe'],2),'0',1,'R');
        
        /*
        $pdf->cell(50,5,'','',0);
        $pdf->cell(45,5,'- Discounts','0',0);
        $pdf->cell(45,5,'$'.number_format($data['descuentos'],2),'0',1,'R');
        
        $subtotal = (float)$data['importe'] - (float)$data['descuentos'];
        $pdf->cell(50,5,'','',0);
        $pdf->cell(45,5,'= Subtotal','0',0);
        $pdf->cell(45,5,'$'.number_format($subtotal,2),'0',1,'R');*/        
                
        $pdf->cell(50,5,'','',0);
        $pdf->cell(45,5,'Taxed sales','0',0);
        $pdf->cell(45,5,'$'.number_format($taxable_sales['taxables_sales'],2),'0',1,'R');
        
        $pdf->cell(50,5,'','',0);
        $pdf->cell(45,5,'Taxes','0',0);
        $pdf->cell(45,5,'$'.number_format($data['impuestos'],2),'0',1,'R');
        /*
        $total = (float)$data['total_venta'];
        $pdf->cell(50,5,'','',0);
        $pdf->cell(45,5,'= Total Sales','T',0);
        $pdf->cell(45,5,'$'.number_format($total,2),'T',1,'R');     */
        
        
        $pdf->ln(5);
        $pdf->SetFont('Arial','B','10');
        $pdf->cell(50,5,'','',0);/*margin*/
        $pdf->cell(45,5,'Sales by payment method','0',1);
        
        $translationPaymentMethod = array("Efectivo"=>'Cash','Tarjeta de credito'=>'Credit card','Tarjeta de debito'=>'Debit card','Cheque'=>'Check','EBT'=>'EBT');        
        $totalPaymentSales = 0;
        $pdf->SetFont('Arial','','10');
        foreach($formasPago as $payment){
            $paymentMethodName = $payment['metodo_pago_'];
            if(key_exists($payment['metodo_pago_'], $translationPaymentMethod)){$paymentMethodName = $translationPaymentMethod[$payment['metodo_pago_']];}
        
            $totalPaymentSales += (float)$payment['monto'];
            $pdf->cell(50,5,'','',0);
            $pdf->cell(45,5,$paymentMethodName,'0',0);
            $pdf->cell(45,5,'$'.number_format($payment['monto'],2),'0',1,'R');
        }                
        
        $pdf->cell(50,5,'','',0);
        $pdf->cell(45,5,'Total payments','T',0);
        $pdf->cell(45,5,'$'.number_format($totalPaymentSales,2),'T',1,'R');
       
      
        if($this->saveFile == true){    
            $pdf->Output($this->getTempFolder()."/".$this->getNombreArchivo().".pdf","F");
        }else{
            $pdf->Output();
        }
        
        
        
       

    

