execute(' '); } function zReport(){ return $this->execute(' '); } function controllaIntestazione(){ return $this->execute(' '); } function getSerial(){ return $this->execute(' '); } function salvaIntestazione(){ return $this->execute(' '); } function programmaIntestazione($righe){ $ret = ''; foreach($righe as $k=>$i){ $ret .= $this->execute(' '); } return $ret; } function setLogo($file, $formato = 'R', $index = '1'){//B = BMP o R = Raster (File created with Epson BMP to Raster utility) /* si può uploadare SOLO con printerNonFiscal */ return $this->execute(' '.base64_encode(file_get_contents($file)).' '). $this->execute(' '); } function resetLogos(){ return $this->execute(' '); } function displayText($testo){ if(is_array($testo)){ foreach($testo as $k=>$v) $testo[$k] = str_pad(substr($testo[$k], 0, 20), 20, " ", STR_PAD_BOTH); $testo = $testo[0].$testo[1]; } $this->execute(' '); return $testo;//displayText ritorna false (sempre?) } function htmlentitiesEpson($testo){//gli special chars funzionano sui nomi articoli, ma non sulle righe header e footer $testo = str_replace(array("€"), array("eur"), $testo); return htmlspecialchars($testo); } function printerFiscalReceipt( $articoli = array('desc'=>'','qta'=>0,'prezzo'=>0,'preText'=>'','postText'=>'','reparto'=>''), $headerLines = array(), $footerLines = array(), $payment = "", $codiceLotteria = "" ){ //se passo "" / null $paymentIndex = 0; $paymentType = 0; $paymentDescription = ""; if($payment){ if(!is_array($payment)) $paymentType = $payment; else{ $paymentType = $payment[0]; $paymentIndex = $payment[1]; $paymentDescription = $payment[2]; } } /* The maximum lengths are as follows: o Message type 4 – 38. o All other message types except message type 8 – 46. o Message type 8 – Not applicable. Attribute can be omitted. */ $printRecMessageMaxLenght = 46; $xml = ''; $j = 0; foreach($headerLines as $k=>$h){ foreach($h as $i){ $j++; $xml .= ''; } } $xml .= ''; //$xml .= ''; $totale = 0; $sconti = []; foreach($articoli as $a){ $totale += $a['qta']*$a['prezzo']; if($a['preText']) $xml .= ''; //justification: serve quando c'è la descrizione lunga 1 prende i primi 20 carattari, 2 prende gli utlimi 20 if($a['prezzo'] >= 0) $xml .= ''; // else $xml .= ''; else $sconti[] = $a; if($a['postText']) $xml .= ''; } // print_r_tnx($xml, $_SERVER['REMOTE_ADDR'] == '192.168.0.177') || die; /* SCONTO adjustmentType (printRecSubtotalAdjustment): <- USO QUESTO PERCHE' "Discounts and surcharges are applied automatically and proportionally to each department based on the individual department total for this specific commercial document or direct invoice." 1 = Discount on subtotal with subtotal printed out on the receipt. 2 = Discount on subtotal without subtotal printed out on the receipt. 6 = Uplift on subtotal with subtotal printed out on the receipt. 7 = Uplift on subtotal without subtotal printed out on the receipt. adjustmentType (printRecItemAdjustment): <- LO EVITO PERCHE' LEGATO A SINGOLO REPARTO 0 = Discount on last sale 3 = Discount on a department 5 = Surcharge on last sale 8 = Surcharge on a department 10 = Deposit (Acconto) 11 = Omaggio (Free of Charge) 12 = Buono monouso (single-use voucher) */ foreach($sconti as $a){ // if($_COOKIE['debugtnx']) $xml .= ''; // else $xml .= ''; } // $xml .= ''; // $xml .= ''; $j = 0; foreach($footerLines as $k=>$h){ // $h = str_split($h, $printRecMessageMaxLenght);//non è multibyte safe!!!! $h = preg_split('/(?<=\G.{'.$printRecMessageMaxLenght.'})/u', $h, -1, PREG_SPLIT_NO_EMPTY); foreach($h as $i){ $j++; $xml .= ''; } } /* GESTIONE PAGAMENTI E RESTO $xml .= ''; */ //SEND LOTTERY ID CODE //Lottery ID Code Check Digit Calculation //miei codici C5GIZ41V D2DPXE1I QK4I775J if($codiceLotteria) $xml .= ''; // $xml .= ''; // $xml .= ''; /* DA TASTIERA VIRTUALE EPSON */ $xml .= ''; /* BARCODE */ // $xml .= ''; $xml .= ''; $xml .= ''; // if($_COOKIE['debugtnx']) echo $xml;die; return $this->execute($xml); } function initJs($include_path = 'fiscalprint.js', $onreceiveCode = ''){//$include_path vuoto = non usare onload $return = ''; if($include_path) $return .= ''."\n"; $return .= ''; return $return; } function execute($xmlString){ if($this->js){ return 'epos.send("http'.($this->ssl?'s':'').'://'.$this->ip.'/cgi-bin/fpmate.cgi", "'.str_replace(array('\\', '"', "\n", "\r"), array('\\\\', '\\"', '', ''), $xmlString).'", 10000);'; } else return $this->serverExecute($xmlString); } function serverExecute($xmlString){ $res = $this->ePosRequest($xmlString); if(!$res || $res->count()) return false; $res = $res->xpath("//response"); // $xml->registerXPathNamespace("s", "http://schemas.xmlsoap.org/soap/envelope/"); return $res[0]['success'] == 'true'; } function ePosRequest($xmlString){ // $return = $this->get_html("http://$this->ip/cgi-bin/fpmate.cgi", $xmlString); $return = $this->get_html("http".($this->ssl?'s':'')."://$this->ip/cgi-bin/fpmate.cgi", ''.$xmlString.''); if($this->debug) echo "
".htmlentities($return)."
";
		$xml = simplexml_load_string($return);
		if(!$xml) return false;
		return $xml->children('soapenv', true);//ritorno i figli del namespace non-standard (":")
		
		
	}

}

?>