<?php
	$this->load->library('printer');
	$this->load->library('enletras');
	
	$phpPrinter = new Printer();
	$phpInletters = new EnLetras();
	
	$acum = 0;
	
	/*Init*/
	$printer = printer_open("EPSON LX-300+II ESC/P");

	printer_set_option($printer, PRINTER_MODE, 'RAW');

	printer_start_doc($printer, 'Devolucion Factura Numero: '.$doc_numero);

	printer_start_page($printer);
	
	/*Body*/
	
	$font = printer_create_font('Arial', 9, 7, PRINTER_FW_THIN, false, false, false, 0);	
	printer_select_font($printer, $font);
	
	/*Ghost*/
	$phpPrinter->printString(strtoupper(utf8_decode(substr(" ",0,24))),2,$printer,$acum,13,11,70);
	$phpPrinter->tabPrinter($acum,50);
	
	$phpPrinter->printString(strtoupper(utf8_decode("DEVOLUCION")),2,$printer,$acum,13,11,100);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("Fecha"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($fecha),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("Cliente"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($cliente),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("DUI"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($dui_cliente),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("NIT"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($nit_cliente),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("TOTAL GLOBAL"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($totales['totalTotal']),2,$printer,$acum,13,0,300);
	$phpPrinter->printString(utf8_decode("EXENTO"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode("0"),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("NO SUJETO"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode("0"),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("TOTAL"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($totales['totalTotal']),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("Forma"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($forma),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);	
	$phpPrinter->printString(utf8_decode("Cajero"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($cajero),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,35);
	$phpPrinter->printString(utf8_decode("F:____________________________________"),2,$printer,$acum,13,11,100);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("Ref"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($referencia),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,35);	
	
	$phpPrinter->printString(strtoupper(utf8_decode("VENTA")),2,$printer,$acum,13,11,100);
	$phpPrinter->tabPrinter($acum,5);
	$phpPrinter->printString(utf8_decode("Documento"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($doc_anulado),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);	
	$phpPrinter->printString(utf8_decode("Numero"),2,$printer,$acum,13,11,100);
	$phpPrinter->printString(utf8_decode($doc_anulado_numero),2,$printer,$acum,13,0,300);
	$phpPrinter->tabPrinter($acum,5);	
	
	printer_delete_font($font);
	
	printer_end_page($printer);

	printer_end_doc($printer);

	printer_close($printer);
?>