Posted By

bedomax on 05/26/09


Tagged


Versions (?)

Urbano


 / Published in: PHP
 

  1. <?
  2.  
  3.  
  4. /**
  5. *
  6. */
  7. class Urbano_BarraCode
  8. {
  9. public $shipper,$ciclo,$producto,$cliente,$zon_codigo,$zon_nombre,$ciudad,$shipper_codigo,$nextel_informix;
  10.  
  11. function __construct($barra_code,&$nextel_informix){
  12. //Obtén Shipper
  13. $this->nextel_informix=$nextel_informix;
  14. $ban=0;
  15. $pos=1;
  16. $suma=1;
  17. $arreglo_shippers=array("0","5","9","1","8","7","6");
  18. $this->shipper=substr($barra_code,0,$pos);
  19. for($i=0;$i<count($arreglo_shippers);$i++){
  20. if($this->shipper==$arreglo_shippers[$i]){
  21. $ban=1;
  22. $pos++;
  23. $suma=2;
  24. }
  25. }
  26. if($ban==1){
  27. $this->shipper=substr($barra_code,0,2);
  28. }
  29. $this->producto=substr($barra_code,$pos,$pos);
  30. $this->ciclo=substr($barra_code,$pos+$suma,4);
  31. $this->cliente=str_replace($this->shipper.$this->producto.$this->ciclo,"",$barra_code);
  32. //Obtén Shipper
  33. }
  34. function get_zona(){
  35.  
  36.  
  37. $query='select * from urbano20@ol_urbanoprv:shipper WHERE shi_id="'.$this->shipper.'";';
  38. $sqlquery = $this->nextel_informix->SelectLimit($query) or die($this->nextel_informix->ErrorMsg());
  39. while (!$sqlquery->EOF){
  40. $shipper_codigo=$sqlquery->Fields("shi_codigo");
  41. $sqlquery->MoveNext();
  42. }
  43. $this->shipper_codigo=$shipper_codigo;
  44.  
  45. $query='select * from urbano20@ol_urbanoprv:zonifica WHERE shi_codigo="'.$shipper_codigo.'" and pro_codigo="'.$this->producto.'" and cli_codigo="'.$this->cliente.'" order by aud_fecha_proc DESC;';
  46. $sqlquery = $this->nextel_informix->SelectLimit($query) or die($this->nextel_informix->ErrorMsg());
  47.  
  48. $this->zon_codigo=$sqlquery->Fields("zon_codigo");
  49. $ciudad=$sqlquery->Fields("cli_ciudad");
  50.  
  51. $query='select * from urbano20@ol_urbanoprv:zona WHERE zon_codigo="'.$this->zon_codigo.'" ;';
  52. $sqlquery = $this->nextel_informix->SelectLimit($query) or die($this->nextel_informix->ErrorMsg());
  53.  
  54. $this->zon_nombre=$sqlquery->Fields("zon_nombre");
  55.  
  56.  
  57. $query='select * from urbano20@ol_urbanoprv:provincia WHERE prov_nombre="'.$ciudad.'" ;';
  58. $sqlquery = $this->nextel_informix->SelectLimit($query) or die($this->nextel_informix->ErrorMsg());
  59. $this->ciudad=$sqlquery->Fields("prov_codigo");
  60. }
  61.  
  62. function set_zona(){
  63.  
  64.  
  65. $fecha=getdate();
  66. $fecha_set=$fecha["mday"]."/".$fecha["mon"]."/".$fecha["year"];
  67. $hora=$fecha["hours"].":".$fecha["minutes"].":".$fecha["seconds"];
  68. $query='INSERT INTO urbano20@ol_urbanoprv:lector_npi VALUES("'.$this->shipper_codigo.'",
  69. "'.$this->producto.'","'.$this->cliente.'","'.$this->ciudad.'","'.$this->zon_codigo.'","webservice_prueba",
  70. "'.$fecha_set.'","'.$hora.'","'.$this->shipper.'")';
  71. $sqlquery = $this->nextel_informix->SelectLimit($query) or die($this->nextel_informix->ErrorMsg());
  72.  
  73. }
  74.  
  75. }
  76.  
  77.  
  78.  
  79. ?>

Report this snippet  

You need to login to post a comment.