if ($_GET["id_hotel"]==null) die(""); if ($_GET["id_control_interno"]==null) die(""); $id_control_interno=$_GET["id_control_interno"]; $id_hotel=$_GET["id_hotel"]; $TOTAL=$id_habitacion=0; //---------------------------- $conex = this_my_conn(); $db = this_my_db($conex); $sql="SELECT id_recepcionista, id_punto_venta, id_mesa, correlativo,fecha_consumo, num_reserva, id_garzon, cantidad_personas, descuento, estado FROM t_control_interno$id_hotel WHERE id_control_interno$id_hotel='$id_control_interno'"; $result=mysql_query($sql); while ($i=mysql_fetch_array($result)){ $id_recepcionista = $i["id_recepcionista"]; $id_punto_venta = $i["id_punto_venta"]; $id_mesa = $i["id_mesa"]; $correlativo = $i["correlativo"]; $fecha_consumo = $i["fecha_consumo"]; $num_reserva = $i["num_reserva"]; $estado = $i["estado"]; $nombre_garzon = leeCampo("nombre_recepcionista","id_recepcionista",$i["id_garzon"],"t_recepcionista"); if ($estado=="P"){ $id_habitacion =leeCampo("id_habitacion","id_control_interno$id_hotel","$id_control_interno","t_control_interno".$id_hotel."_pago"); $id_habitacion = substr($id_habitacion,1, strlen($id_habitacion)-1); } $cantidad_personas = $i["cantidad_personas"]; $DESCUENTO = $i["descuento"]; } $sql="SELECT id_plato, id_menu, id_servicio, cantidad, valor, total FROM t_control_interno$id_hotel"."_det WHERE id_control_interno$id_hotel='$id_control_interno'"; // die($sql."
"); $result_detalle =mysql_query($sql); //---------------------------- if (strpos($HTTP_USER_AGENT,"Linux")){ $serial_port = fopen("/dev/ttyS0", "w+b"); }else{ if (strpos($HTTP_USER_AGENT,"Windows")){ $cmd_str="MODE COM2 BAUD=19200 DATA=8 STOP=1 PARITY=n"; exec($cmd_str); $serial_port = fopen("COM2", "w+b"); } } if ($serial_port){ } else { die(""); } $ALIGN_RIGHT = "\x1B\x61\x32"; $ALIGN_CENTER = "\x1B\x61\x31"; $ALIGN_LEFT = "\x1B\x61\x30"; $TAB = "\x09"; $CUT_PAGE = "\x1B\x69"; $nbps = "\x1B\x20"; $FONT_SIZE_10 = "\x1B\x21\x30"; $FONT_SIZE_12 = "\x1B\x21\x31"; $FONT_SIZE_PROP = "\x1B\x21\x32"; $FONT_SIZE_COMPRI = "\x1B\x21\x34"; //$FONT_NEGRITA = chr(27).chr(56); $str = null; $str = $ALIGN_CENTER; $str.= chr(27)."!".chr(32); $str.= "\nHOTEL "; $str.= "PEULLA\n\n"; $str.= chr(27)."!".chr(0); $str .= $ALIGN_CENTER; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str = $ALIGN_CENTER; $str.= "Fecha..:".date("d-m-Y"); $str.= "$TAB"; $str.= "Hora..:".date("h:i:s"); $str.= "\n\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str = $ALIGN_LEFT; $str.= "C.I...:". $id_control_interno." (".$correlativo.")"; $str.= "$TAB$TAB"; $str.= "Mesa..:".$id_mesa." (".$cantidad_personas.")\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.=$ALIGN_LEFT."Garzon..:".$nombre_garzon; $str.= "$TAB"; $str.= "Hab:".$id_habitacion."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= $ALIGN_LEFT . "\n-----------------------------------------\n"; $result=fwrite($serial_port, $str); fflush($serial_port); while ($z=mysql_fetch_array($result_detalle)){ $tbl = "t_control_interno$id_hotel"."_voucher"; $condiciones = "id_control_interno$id_hotel=$id_control_interno AND id_plato='{$z["id_plato"]}' AND id_menu={$z["id_menu"]}"; if (!existeCampoCondiciones($condiciones,$tbl)){ $str=$z["cantidad"]." ".leeNombre($z["id_plato"],$z["id_menu"],$z["id_servicio"]).formatStr(number_format($z["total"], 0 , "," ,"."),9)."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $TOTAL+=$z["total"]; } } $result=fwrite($serial_port, "\n"); fflush($serial_port); $str = null; $str.= " SUB-TOTAL"; $str.= formatStr(number_format($TOTAL, 0 , "," ,"."),9)."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $TOTDESCTO=($DESCUENTO * $TOTAL/100); $str = null; $str.= " DESCUENTO"; $str.= formatStr(number_format($TOTDESCTO, 0 , "," ,"."),9)."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= " TOTAL"; $str.= formatStr(number_format(($TOTAL - $TOTDESCTO), 0 , "," ,"."),9)."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = "\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str = " TOTAL USD"; $valorDolar= leeCampo("cambio","id_moneda","2", "t_moneda"); $TOTAL_DOLAR+= ($TOTAL / $valorDolar) ; $str.= formatStr(number_format( $TOTAL_DOLAR, 1, ".", ","),9)."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str = " Propina Tip"; $str.= " _________"."\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= $ALIGN_LEFT . "\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= $ALIGN_CENTER . "--------------------------------\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= $ALIGN_CENTER . "Nombre Pasajero\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = ""; $str.= $ALIGN_CENTER . "\n\n------------------- --------------------\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= $ALIGN_CENTER ." Firma Pasaporte\n\n"; $result=fwrite($serial_port, $str); fflush($serial_port); $str = null; $str.= $ALIGN_CENTER . " ** no valido como comprobante de pago **"; $result=fwrite($serial_port, $str); fflush($serial_port); $str ="\n\n\n\n\n$CUT_PAGE"; $result=fwrite($serial_port, $str); mysql_close($conex); function formatStr($STR, $top){ $str=null; if(strlen($STR)<$top){ for($i=strlen($STR);$i< ($top);$i++) $str.=" "; } return $str.$STR; } function formatStr2($STR, $top){ $str=null; if(strlen($STR)<$top){ for($i=strlen($STR);$i< ($top);$i++) $str.=" "; } return $STR.$str; } function leeNombre($id_plato, $id_menu, $id_servicio){ if ($id_plato!=0){ return formatStr2(strtolower(substr(leeCampo("nombre_plato", "id_plato" ,$id_plato,"t_plato"),0,30)), 31); } if ($id_menu!=0){ return formatStr2(strtolower(leeCampo("nombre_menu", "id_menu" ,$id_menu,"t_menu")), 31); } if ($id_servicio!=0){ return formatStr2(strtolower(leeCampo("nombre_servicio", "id_servicio" ,$id_servicio,"t_servicio")), 31); } } function leeCampo($objetivo, $nomKey, $id, $tbl){ global $conex, $db; $sql="SELECT $objetivo FROM $tbl WHERE $nomKey=$id"; $result=mysql_query($sql); $i=mysql_fetch_row($result); return $i[0]; } function existeCampoCondiciones($condiciones,$tbl){ //DEVUELVE FALSE SI NO EXISTE UN CAMPO QUE CUMPLA global $conex, $db; //UNA, O VARIAS, CONDICIONES (CONDICI�N MULTIPLE) //echo $tbl; $sql="Select * from $tbl where $condiciones"; //echo $sql."
"; $result=mysql_query($sql); if (mysql_error()!="") die(mysql_error()."
".$sql); //echo mysql_errno(), ":" , mysql_error(), "
\n" ; $r=mysql_fetch_row($result); mysql_free_result($result); if (mysql_error()!=null) die(mysql_error()); if ($r[0]!="") return true; if (mysql_error()!=null) die(mysql_error()); return false; } function this_my_conn(){ return(mysql_connect("192.168.1.21","peulla","peulla")); } function this_my_db($conn){ $db=mysql_select_db("peulla",$conn); return($db); }