<?php header('Content-Type: text/html; charset=utf-8');?>
<?php 


if(count(get_included_files()) ==1) exit("Direct access not permitted.");?>
<?php 
class DatabaseFunctions{
private $db_name;
     
private $tbl_ctmcd;
private $tbl_area;
private $tbl_chk;
private $tbl_factors;
private $tbl_gps;
private $tbl_gps_users;
private $tbl_kol;
private $tbl_maser;
private $tbl_naghd;
private $tbl_newsalsefactor;
private $tbl_prc;
private $tbl_report;
private $tbl_report_resualt;
private $tbl_setting;
private $tbl_tafseal;
private $tbl_users;
private $tbl_lasttot;
private $tbl_visitor_hasab;
private $tbl_visitor_kala;
private $tbl_cmps;


private $connectionss;
 
    function __construct($db){
        $this -> db_name = 'shirazsa_prctest';
 
        $this -> tbl_ctmcd = "tbl_ctmcd";
        
        $this -> tbl_area = "area";
        $this -> tbl_chk = "chk";
        $this -> tbl_factors = "factors";
        $this -> tbl_gps = "gps";
        $this -> tbl_gps_users = "gps_users";
        $this -> tbl_kol = "kol";
        $this -> tbl_maser = "maser";
        $this -> tbl_naghd = "naghd";
        $this -> tbl_newsalsefactor = "newsalsefactor";
        $this -> tbl_prc = "prc";
        $this -> tbl_report = "report";
        $this -> tbl_report_resualt = "report_resualt";
        $this -> tbl_setting = "setting";
        $this -> tbl_tafseal = "tafseal";
        $this -> tbl_users = "users";
        $this -> tbl_lasttot = "lasttot";
        $this -> tbl_visitor_hasab = "visitor_hasab";
        $this -> tbl_visitor_kala = "visitor_kala";
        $this -> tbl_cmps = "cmps";
        
 
       
        $this -> connectionss = OdbcSimulator::getConnection(); 
        
   }
    
    //Get All Tables
    
	function getConnection(){
		return $this -> connectionss;
	}
	
    function convertinput($data){return iconv("Windows-1256", "UTF-8", $data);}
    
    function reverseconvertinput($data){return iconv("UTF-8", "Windows-1256", $data);}
    
    function getarea($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "area_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_nam")), 
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")), 
                    "area_cod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_cod")), 
                    "precod_area" => $this -> convertinput(OdbcSimulator::odbc_result($result, "precod_area")));
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
	     

        
    function getchk($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){

                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "sh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sh")),
                    "mab" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mab")),
                    "nowdate" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nowdate")),
                    "paydate" => $this -> convertinput(OdbcSimulator::odbc_result($result, "paydate")),
                    "idcast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcast")),
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh")),
                    "bank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bank")),
                    "numfacto" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numfacto")),
                    "totid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "totid")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "idbank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idbank")),
                    "idcstt" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcstt")),
                    "idfax" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idfax")),
                    "shhasab" => $this -> convertinput(OdbcSimulator::odbc_result($result, "shhasab")),
                    "travel" => $this -> convertinput(OdbcSimulator::odbc_result($result, "travel")),
                    "exitdate" => $this -> convertinput(OdbcSimulator::odbc_result($result, "exitdate")),
                    "idtafseal" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idtafseal")),
                    "idts" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idts")),
                    "tz" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tz")),
                    "idkarpardaz" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idkarpardaz")),
                    "fn_stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "fn_stut")),
                    "idoutput" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idoutput")),
                    "rec_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rec_nam")),
                    "city" => $this -> convertinput(OdbcSimulator::odbc_result($result, "city")),
                    "chk_stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "chk_stut")),
                    "del_chk_stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "del_chk_stut")),
                    "idvosuli" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idvosuli")),
                    "knam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "knam")),
                    "faxbank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "faxbank")),
                    "idcsttnam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcsttnam")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad")),
                    "d_sms" => $this -> convertinput(OdbcSimulator::odbc_result($result, "d_sms")),
                    "id_daryaft" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_daryaft")),
                    "esterdad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "esterdad")),
                    "ebtal" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ebtal")));
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
            
    function getfactors($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){

                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "cod_cast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cod_cast")),
                    "tasvieh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tasvieh")),
                    "day_numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "day_numb")),
                    "usernam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "usernam")),
                    "factorid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "factorid")),
                    "count_kala" => $this -> convertinput(OdbcSimulator::odbc_result($result, "count_kala")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad")),
                    "dat" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
             
    function getgps($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            while (OdbcSimulator::odbc_fetch_row($result)){

                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "idcast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcast")),
                    "x" => $this -> convertinput(OdbcSimulator::odbc_result($result, "x")),
                    "y" => $this -> convertinput(OdbcSimulator::odbc_result($result, "y")),
                    "p1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "p1")),
                    "dat" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
       
    function getgpsusers($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            while (OdbcSimulator::odbc_fetch_row($result)){

                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "sharkatnam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharkatnam")),
                    "pass" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pass"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
           
    function getkol($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "idkol" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idkol")),
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "koltypeid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "koltypeid")),
                    "lockstut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lockstut")),
                    "taraztypeid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "taraztypeid")),
                    "idold" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idold")),
                    "is_cast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "is_cast"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
       
    function getlasttot($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            while (OdbcSimulator::odbc_fetch_row($result)){

                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "idcast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcast")),
                    "mand" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand")),
                    "tsh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tsh")),
                    "dat" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat")),
                    "sum1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sum1")),
                    "sum2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sum2")),
                    "sum3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sum3")),
                    "sum4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sum4")),
                    "ref" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ref")),
                    "ref_ranking" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ref_ranking")),
                    "dat_tasvie" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat_tasvie")),
                    "trans" => $this -> convertinput(OdbcSimulator::odbc_result($result, "trans")),
                    "factors" => $this -> convertinput(OdbcSimulator::odbc_result($result, "factors"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
       
    function getmaser($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "maser_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "maser_nam")),
                    "area_id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_id")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "visitor_id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "visitor_id")),
                    "precod_maser" => $this -> convertinput(OdbcSimulator::odbc_result($result, "precod_maser"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
      
    function getnaghd($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){

                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "numfact" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numfact")),
                    "idsanad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idsanad")),
                    "bas" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bas")),
                    "bed" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bed")),
                    "dat" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh")),
                    "sstut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sstut")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad")),
                    "idcast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcast")),
                    "idcuruser" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcuruser")),
                    "curusernam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "curusernam")),
                    "lastrec" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lastrec")),
                    "idchk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idchk")),
                    "idpc" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idpc")),
                    "firstrec" => $this -> convertinput(OdbcSimulator::odbc_result($result, "firstrec")),
                    "idkol" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idkol")),
                    "idmoin" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idmoin")),
                    "idtafseal" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idtafseal")),
                    "item" => $this -> convertinput(OdbcSimulator::odbc_result($result, "item")),
                    "radifid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "radifid")),
                    "takh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "takh")),
                    "mand" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand")),
                    "tsh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tsh")),
                    "idsaz" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idsaz")),
                    "idbank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idbank")),
                    "salbon" => $this -> convertinput(OdbcSimulator::odbc_result($result, "salbon")),
                    "sarmaya" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sarmaya")),
                    "pay" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pay")),
                    "nowdate" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nowdate")),
                    "edit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "edit")),
                    "date_edit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "date_edit")),
                    "iduser_edit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "iduser_edit")),
                    "idvisitor" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idvisitor")),
                    "idvosuli" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idvosuli")),
                    "rec_date" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rec_date")),
                    "rec_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rec_nam")),
                    "del_naghd_stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "del_naghd_stut")),
                    "idoutput" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idoutput")),
                    "radifid_pakhsh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "radifid_pakhsh")),
                    "bank_asi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bank_asi")),
                    "mab_taid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mab_taid")),
                    "yad_bank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad_bank")),
                    "fdate" => $this -> convertinput(OdbcSimulator::odbc_result($result, "fdate")),
                    "edate" => $this -> convertinput(OdbcSimulator::odbc_result($result, "edate")),
                    "mand_tasvie" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand_tasvie")),
                    "monprice" => $this -> convertinput(OdbcSimulator::odbc_result($result, "monprice")),
                    "koltype" => $this -> convertinput(OdbcSimulator::odbc_result($result, "koltype")),
                    "idrel" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idrel")),
                    "shresid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "shresid")),
                    "efte" => $this -> convertinput(OdbcSimulator::odbc_result($result, "efte")),
                    "mand2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand2")),
                    "tsh2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tsh2")),
                    "radifid2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "radifid2")),
                    "send_sms" => $this -> convertinput(OdbcSimulator::odbc_result($result, "send_sms")),
                    "id_tasvie" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_tasvie")),
                    "id_daryaft" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_daryaft")),
                    "id_sanadtmp_eft" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_sanadtmp_eft")),
                    "sec_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sec_nam")),
                    "sharh_user" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh_user")),
                    "aghsati" => $this -> convertinput(OdbcSimulator::odbc_result($result, "aghsati")),
                    "id_rel" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_rel")),
                    "lvl7" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lvl7")),
                    "lvl8" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lvl8"))
                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
          
    function getnewsalsefactor($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "cod_cast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cod_cast")),
                    "tasvieh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tasvieh")),
                    "day_numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "day_numb")),
                    "cod_kala" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cod_kala")),
                    "numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb")),
                    "price" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price")),
                    "usernam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "usernam")),
                    "factorid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "factorid")),
                    "part" => $this -> convertinput(OdbcSimulator::odbc_result($result, "part")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad")),
                    "trans" => $this -> convertinput(OdbcSimulator::odbc_result($result, "trans")),
                    "unic_id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unic_id"))
                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
     
    function getprc($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
 
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
                    "unit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit")), 
                    "unit2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit2")), 
                    "numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb")), 
                    "box" => $this -> convertinput(OdbcSimulator::odbc_result($result, "box")), 
                    "price" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price")), 
                    "pv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pv")), 
                    "pric" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pric")), 
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")), 
                    "unam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unam")), 
                    "price1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price1")), 
                    "pv1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pv1")), 
                    "price2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price2")), 
                    "pv2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pv2")), 
                    "mainid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mainid")), 
                    "idanbar" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idanbar")), 
                    "prictmp" => $this -> convertinput(OdbcSimulator::odbc_result($result, "prictmp")), 
                    "numbtmp" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numbtmp")), 
                    "wi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "wi")), 
                    "tp" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tp")), 
                    "barcod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "barcod")), 
                    "err_numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "err_numb")), 
                    "minnumb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "minnumb")), 
                    "vi_numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "vi_numb")), 
                    "ptk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ptk")), 
                    "lowprice" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lowprice")), 
                    "hightprice" => $this -> convertinput(OdbcSimulator::odbc_result($result, "hightprice")), 
                    "groupid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "groupid")), 
                    "vpercent" => $this -> convertinput(OdbcSimulator::odbc_result($result, "vpercent")), 
                    "f_j" => $this -> convertinput(OdbcSimulator::odbc_result($result, "f_j")), 
                    "per_ma" => $this -> convertinput(OdbcSimulator::odbc_result($result, "per_ma")), 
                    "per_av" => $this -> convertinput(OdbcSimulator::odbc_result($result, "per_av")), 
                    "calc_chk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "calc_chk")), 
                    "price3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price3")), 
                    "pv3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pv3")), 
                    "price4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price4")), 
                    "pv4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pv4")), 
                    "price5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price5")), 
                    "pv5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pv5")), 
                    "id_ma_av" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_ma_av")), 
                    "producer_id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "producer_id")), 
                    "lastpric" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lastpric")), 
                    "add1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "add1")), 
                    "add2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "add2")), 
                    "add3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "add3")), 
                    "add4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "add4")), 
                    "takh1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "takh1")), 
                    "takh2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "takh2")), 
                    "takh3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "takh3")), 
                    "takh4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "takh4")), 
                    "use_tozih1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "use_tozih1")), 
                    "use_tozih2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "use_tozih2")), 
                    "avg_price" => $this -> convertinput(OdbcSimulator::odbc_result($result, "avg_pric")), 
                    "ptk_tozih1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ptk_tozih1")), 
                    "ptk_tozih2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ptk_tozih2")), 
                    "black_list" => $this -> convertinput(OdbcSimulator::odbc_result($result, "black_list")), 
                    "unit3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit3")), 
                    "numb2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb2")), 
                    "daynumb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "daynumb")), 
                    "trans" => $this -> convertinput(OdbcSimulator::odbc_result($result, "trans")), 
                    "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver")), 
                    "pricemasraf" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pricemasraf")),
                    "pic_path" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pic_path")),
                    "ver_update" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver_update")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad"))
					);
                
                  array_push($resro, $temp);  
              }

            
        }
 
             //$resarr= array("getresult" => $resro);
			 $resarr= array("getresult" => $resro);
			 //$resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
              
    function getreport($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh"))
                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                  
    function getreport_resualt($que){
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh")),
                    "idv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idv")),
                    "idreport" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idreport"))
                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                  
    function getsetting($que){
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "gfs1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs1")),
                    "gfs2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs2")),
                    "gfs3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs3")),
                    "gfs4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs4")),
                    "gfs5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs5")),
                    "gfs6" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs6")),
                    "gfs7" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs7")),
                    "gfs8" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs8")),
                    "gfs9" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs9")),
                    "gfs10" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs10")),
                    "gfs11" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs11")),
                    "gfs12" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs12")),
                    "gfs13" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs13")),
                    "gfs14" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs14")),
                    "gfs15" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs15")),
                    "gfs16" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs16")),
                    "gfs17" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs17")),
                    "gfs18" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs18")),
                    "gfs19" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs19")),
                    "gfs20" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs20"))
                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                      
    function gettafseal($que){
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "idkol" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idkol")),
                    "tafseal" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tafseal")),
                    "idmoin" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idmoin")),
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")),
                    "adr" => $this -> convertinput(OdbcSimulator::odbc_result($result, "adr")),
                    "tel" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tel")),
                    "fax" => $this -> convertinput(OdbcSimulator::odbc_result($result, "fax")),
                    "dat" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "unam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unam")),
                    "pricetype" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pricetype")),
                    "subcast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "subcast")),
                    "subchk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "subchk")),
                    "cr" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cr")),
                    "idgroup" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idgroup")),
                    "isf" => $this -> convertinput(OdbcSimulator::odbc_result($result, "isf")),
                    "cod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cod")),
                    "sh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sh")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad")),
                    "daystut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "daystut")),
                    "locks" => $this -> convertinput(OdbcSimulator::odbc_result($result, "locks")),
                    "idbank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idbank")),
                    "cr2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cr2")),
                    "monid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "monid")),
                    "idnaghd_edit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idnaghd_edit")),
                    "ctrl1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl1")),
                    "ctrl2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl2")),
                    "ctrl_av_ma" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_av_ma")),
                    "nonaghd_bas" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nonaghd_bas")),
                    "nonaghd_bed" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nonaghd_bed")),
                    "ctrl_mprc" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_mprc")),
                    "idpersonel" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idpersonel")),
                    "p_visitor" => $this -> convertinput(OdbcSimulator::odbc_result($result, "p_visitor")),
                    "ctrl_avma_bay" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_avma_bay")),
                    "ctrl_avma_sell" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_avma_sell")),
                    "ctrl_haz1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_haz1")),
                    "ctrl_haz2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_haz2")),
                    "ctrl_haz3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_haz3")),
                    "ctrl_haz4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_haz4")),
                    "lockstut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "lockstut")),
                    "shopname" => $this -> convertinput(OdbcSimulator::odbc_result($result, "shopname")),
                    "black_list" => $this -> convertinput(OdbcSimulator::odbc_result($result, "black_list")),
                    "max_notasvie" => $this -> convertinput(OdbcSimulator::odbc_result($result, "max_notasvie")),
                    "cr_koli" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cr_koli")),
                    "yad_blacklist" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad_blacklist")),
                    "kart_bank" => $this -> convertinput(OdbcSimulator::odbc_result($result, "kart_bank")),
                    "trans" => $this -> convertinput(OdbcSimulator::odbc_result($result, "trans")),
                    "nam2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam2")),
                    "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver")),
                    "ctrl_out" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ctrl_out")),
                    "CoVisitor" => $this -> convertinput(OdbcSimulator::odbc_result($result, "CoVisitor")),
                    "IsDistributor" => $this -> convertinput(OdbcSimulator::odbc_result($result, "IsDistributor")),
                    "IsCollector" => $this -> convertinput(OdbcSimulator::odbc_result($result, "IsCollector")),
                    "IsDriver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "IsDriver")),
                    "IsStoreKeeper" => $this -> convertinput(OdbcSimulator::odbc_result($result, "IsStoreKeeper")),
                    "IsStMng" => $this -> convertinput(OdbcSimulator::odbc_result($result, "IsStMng")),
                    "ver2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver2")),
                    "ver_update" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver_update")),
                    "bima_taf" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bima_taf")),
                    "per_bima" => $this -> convertinput(OdbcSimulator::odbc_result($result, "per_bima")),
                    "bima_taf_haz" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bima_taf_haz"))
                    

                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                          
    function getusers($que){
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")),
                    "pass" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pass")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut"))
                    

                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                              
    function getvisitorhasab($que){ 
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
             
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "idtafseal" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idtafseal")),
                    "idvisitor" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idvisitor"))
                    

                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                                  
    function getvisitorkala($que){
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){
            
            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "rowi" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
                    "rowv" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowv")), 
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
     
                    "idp" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idp")),
                    "idprc" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idprc"))
                    

                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $resarr= array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
    
	function updatetblversions($que){
	   $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
	}
    
    //Mobile Side
    
        
    function getCastWithCode($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
        
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
                    "shopname" => $this -> convertinput(OdbcSimulator::odbc_result($result, "shopname")), 
                    "adr" => $this -> convertinput(OdbcSimulator::odbc_result($result, "adr")), 
                    "sumchk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sumchk")), 
                    "mand" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand")), 
                    "factors" => $this -> convertinput(OdbcSimulator::odbc_result($result, "factors")), 
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")), 
                    "pricetype" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pricetype")), 
                    "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver")), 
                    "unam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unam")));
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("getcastwithcod" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
         
    function getCastWithVer($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
        
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
                    "shopname" => $this -> convertinput(OdbcSimulator::odbc_result($result, "shopname")), 
                    "adr" => $this -> convertinput(OdbcSimulator::odbc_result($result, "adr")), 
                    "sumchk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sumchk")), 
                    "mand" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand")), 
                    "factors" => $this -> convertinput(OdbcSimulator::odbc_result($result, "factors")), 
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")), 
                    "pricetype" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pricetype")), 
                    "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver")), 
                    "unam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unam")));
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("getcastwithver" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
          
    function getGpsWithCode($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "idcast" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idcast")), 
                    "x" => $this -> convertinput(OdbcSimulator::odbc_result($result, "x")), 
                    "y" => $this -> convertinput(OdbcSimulator::odbc_result($result, "y"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("getgpswithcod" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
         
    function getPrcWithCode($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "pic_path" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pic_path")),
                    "cod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cod")),
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")),
                    "price" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price")),
                    "price1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price1")),
                    "price2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price2")),
                    "price3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price3")),
                    "price4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price4")),
                    "price5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price5")),
                    "box" => $this -> convertinput(OdbcSimulator::odbc_result($result, "box")),
                    "barcod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "barcod")),
                    "numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb")),
                    "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver")),
                    "unit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "unam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unam")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad"))
                );

                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("getprcwithcod" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
         
    function getPrcWithVer($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "pic_path" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pic_path")),
                    "cod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "cod")),
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")),
                    "price" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price")),
                    "price1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price1")),
                    "price2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price2")),
                    "price3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price3")),
                    "price4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price4")),
                    "price5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price5")),
                    "box" => $this -> convertinput(OdbcSimulator::odbc_result($result, "box")),
                    "barcod" => $this -> convertinput(OdbcSimulator::odbc_result($result, "barcod")),
                    "numb" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb")),
                    "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver")),
                    "unit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "unam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unam")),
                    "yad" => $this -> convertinput(OdbcSimulator::odbc_result($result, "yad"))
                );

                  array_push($resro, $temp);  
              }

        }
 
             array_push($resarr, array("getprcwithver" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }

    function getUser($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = false;
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
				 $resfromdb = $this -> convertinput(OdbcSimulator::odbc_result($result, "id"));
				 if($resfromdb == '0'){
					 $resro = "[\"resualt = False\"]";
				 }else{
					 $resro = "[\"resualt = True\"]";
				 }
                 

                  
              }

        }
 
            // array_push($resarr, array("resualt" => $resro));
            // return json_encode($resarr, JSON_UNESCAPED_UNICODE);
			
             return $resro;
        
     }
	
    function getUserInfo($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array(); 
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
				 $id = $this -> convertinput(OdbcSimulator::odbc_result($result, "id"));
				 $name = $this -> convertinput(OdbcSimulator::odbc_result($result, "nam"));
 
                 
                 $temp = array("id" => $id, "name" => $name);
                 array_push($resro,$temp);
                  
              }

        }
 
              array_push($resarr, array("resualt" => $resro));
              return json_encode($resarr, JSON_UNESCAPED_UNICODE);
			
              
        
     }
	

    function getUserztestz($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = false;
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
				 $resfromdb = $this -> convertinput(OdbcSimulator::odbc_result($result, "id"));
				 if($resfromdb == '0'){
					 $resro = "[\"resualt = False\"]";
				 }else{
					 $resro = "[\"resualt = True\"]";
				 }
                 

                  
              }

        }
 
            // array_push($resarr, array("resualt" => $resro));
            // return json_encode($resarr, JSON_UNESCAPED_UNICODE);
			
             return $resro;
       
        
     }
	

    function getUserTwo($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = false;

 
            // array_push($resarr, array("resualt" => $resro));
            // return json_encode($resarr, JSON_UNESCAPED_UNICODE);
		return OdbcSimulator::odbc_fetch_row($result);
          
        
     }


    function getSettings($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				
				   "gfs1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs1")), 
				   "gfs2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs2")), 
				   "gfs3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs3")), 
				   "gfs4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs4")), 
				   "gfs5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs5")), 
				   "gfs6" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs6")), 
				   "gfs7" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs7")), 
				   "gfs8" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs8")), 
				   "gfs9" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs9")), 
				   "gfs10" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs10")), 
				   "gfs11" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs11")), 
				   "gfs12" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs12")), 
				   "gfs13" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs13")), 
				   "gfs14" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs14")), 
				   "gfs15" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs15")), 
				   "gfs16" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs16")), 
				   "gfs17" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs17")), 
				   "gfs18" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs18")), 
				   "gfs19" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs19")), 
				   "gfs20" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gfs20"))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             //array_push($resarr, array("getcastwithcod" => $resro));
             return json_encode($resro, JSON_UNESCAPED_UNICODE);
        
     }

    function prepareAddGPS($gps,$p1,$p2,$adid,$que){
        
       $resro = 'False';
       $result= json_decode($gps,true);			 
		
            foreach ($result as $item ) {
		        $idc  = $item['idc'];
                $x     = $item['x'];
                $y    = $item['y'];
                $tempQu = "EXEC gps_sp @idcast = $idc , @x = $x , @y = $y , @p1 = $p1 , @p2 = $p2, @adid = $adid";
                $resro = $this->addGPS($tempQu);
			}  
 
 
             array_push($resarr, array("resualt" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }

    function addGPS($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        return $result;
        
     }

            
    function getGPSForMaser($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
                    "x" => $this -> convertinput(OdbcSimulator::odbc_result($result, "x")), 
                    "y" => $this -> convertinput(OdbcSimulator::odbc_result($result, "y"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("gps_get_for_maser" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                   
    function getGPSForArea($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "area_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_nam"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
		$jsn = json_encode($resro, JSON_UNESCAPED_UNICODE);
        $jsn = '{"gps_area":' . $jsn . '}';
        return $jsn;
        
     }
                          
    function getGPSMaser($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "maser_nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "maser_nam")),
                    "area_id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_id"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             $jsn = json_encode($resro, JSON_UNESCAPED_UNICODE);
             $jsn = '{"gps_maser":' . $jsn . '}';
             return $jsn;
        
     }
    
    function getGPSUser($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = 'False';
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                 $resro = 'True';

                  
              }

        }
		$jsn = json_encode($resro);
		$jsn = '{"gpsusers":'.$jsn.'}';
        return $jsn;
        
     }
    
                              
    function getReports($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("report" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
    
                                  
    function getReportDetails($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh"))
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("report_detail" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
                                      
    function viewFactor($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
                    "box" => $this -> convertinput(OdbcSimulator::odbc_result($result, "box")), 
                    "numb1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb1")), 
                    "unit" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit")), 
                    "numb2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "numb2")), 
                    "unit2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "unit2")), 
                    "price" => $this -> convertinput(OdbcSimulator::odbc_result($result, "price")), 
                    "ptk" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ptk")), 
                    "pricekol" => $this -> convertinput(OdbcSimulator::odbc_result($result, "pricekol"))
                    
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("view_factor" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
    
    
    
    function prepareAddFactor($factor,$p1,$p2){
        
       $resro = 'False';
       $result= json_decode($factor,true);	
		$resarr=array();
       $i=0;
            foreach ($result as $item ) {
                
                $partnumber  = $item['partnumber'];
                $tasvieh     = $item['tasvieh'];
                $day_numb    = $item['day_numb'];
                $cod_cast    = $item['cod_cast'];
                $cod_kala    = $item['cod_kala'];
                $numb        = $item['numb'];
                $price       = $item['price'];
                $usernam    = $item['username'];
                $factorid    = $item['factorid'];
                $count    = $item['countf'];
				//$yad    = this -> convertinput($item['yad']);
				$yad    = iconv("UTF-8","Windows-1256",  $item['yad']);

				$i=$i+1;

                $tempQu = "EXEC insert_newsalsefactor_sp @st=1,@partnumber = $partnumber , @cod_cast = $cod_cast  , @tasvieh = $tasvieh ,@day_numb = $day_numb, @cod_kala =$cod_kala,@numb = $numb , @price =$price, @usernam = '$usernam' , @factorid = $factorid
		, @p1 = $p1 , @p2 = $p2,@count_f=$count, @yad = N'".$yad."'";
                
               $resro = $this->addFactor($tempQu);
			 

                $tempQuTwo = "EXEC insert_newsalsefactor_main_sp @count = $count , @cod_cast = $cod_cast  , @tasvieh = $tasvieh , @usernam = '$usernam' , @factorid = $factorid,@p1 = $p1 , @p2 = $p2,@day_numb = $day_numb";
                
              
				$resro = $this->addFactorSecond($tempQuTwo);
 
            // array_push($resarr, array("resualt" => $resro));
				} 
             return $tempQu;
        
     }
	
	
	    
    
    function prepareAddFactorWithDiscount($factor,$p1,$p2){
        
       $resro = 'False';
       $result= json_decode($factor,true);	
		$resarr=array();
       $i=0;
            foreach ($result as $item ) {
                
                $partnumber  = $item['partnumber'];
                $tasvieh     = $item['tasvieh'];
                $day_numb    = $item['day_numb'];
                $cod_cast    = $item['cod_cast'];
                $cod_kala    = $item['cod_kala'];
                $numb        = $item['numb'];
                $price       = $item['price'];
                $usernam    = $item['username'];
                $factorid    = $item['factorid'];
                $count    = $item['countf'];
                $pdis    = $item['pdis'];
                $fdis    = $item['fdis'];
				$yad    = iconv("UTF-8","Windows-1256",  $item['yad']);

				$i=$i+1;

                $tempQu = "EXEC insert_newsalsefactor_withdiscount_sp @st=1,@partnumber = $partnumber , @cod_cast = $cod_cast  , @tasvieh = $tasvieh ,@day_numb = $day_numb, @cod_kala =$cod_kala,@numb = $numb , @price =$price, @usernam = '$usernam' , @factorid = $factorid
		, @p1 = $p1 , @p2 = $p2,@count_f=$count, @yad = N'".$yad."', @fdis = $fdis, @pdis = $pdis";
                
               $resro = $this->addFactor($tempQu);
			 

                $tempQuTwo = "EXEC insert_newsalsefactor_main_sp @count = $count , @cod_cast = $cod_cast  , @tasvieh = $tasvieh , @usernam = '$usernam' , @factorid = $factorid,@p1 = $p1 , @p2 = $p2,@day_numb = $day_numb";
                
              
				$resro = $this->addFactorSecond($tempQuTwo);
 
            // array_push($resarr, array("resualt" => $resro));
				} 
             return $tempQu;
        
     }
	
	
    function addFactor($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        return $result;
        
     }

    
    function addFactorSecond($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        return $result;
        
     }
	
    
    
    function viewforreport($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
                    

                    "dat" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat")),
                    "idtot" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idtot")),
                    "sharh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh")),
                    "bed" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bed")),
                    "bas" => $this -> convertinput(OdbcSimulator::odbc_result($result, "bas")),
                    "mand" => $this -> convertinput(OdbcSimulator::odbc_result($result, "mand")),
                    "tsh" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tsh")),
                    "stut" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
                    "radifid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "radifid"))
					);
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("view" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
	
    function getGPSMaserDetails($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
				
                $temp = array(
                    
                    "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
                    "nam" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
                    "tel" => $this -> convertinput(OdbcSimulator::odbc_result($result, "tel")), 
                    "shopname" => $this -> convertinput(OdbcSimulator::odbc_result($result, "shopname")), 
                    "x" => $this -> convertinput(OdbcSimulator::odbc_result($result, "x")), 
                    "y" => $this -> convertinput(OdbcSimulator::odbc_result($result, "y")),
                    "color" => "1"
                );
                
                  array_push($resro, $temp);  
              }

            
        }
 
             array_push($resarr, array("gps_get_for_maser" => $resro));
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }

    

    function getAreaForReport($que,$req){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				
				   "resulttype" => $req, 
				   "code" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
				   "name" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_nam")), 
				   "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver"))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
    
    function getMasirForReport($que,$req){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				   "resulttype" => $req, 
				   "code" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
				   "name" => $this -> convertinput(OdbcSimulator::odbc_result($result, "maser_nam")), 
				   "areacode" => $this -> convertinput(OdbcSimulator::odbc_result($result, "area_id")), 
				   "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver"))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
        
    function getVisitorForReport($que,$req){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				   "resulttype" => $req, 
				   "code" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
				   "name" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
				   "ver" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ver"))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("getresult" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
	
    
	
    function handleReportOptions($data){
		
		if($data == "1"){
			return true;
		}else{
			return false;
		}
		
		
	}
	
    function getAvailableReportList($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(),$que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				   "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi")), 
				   "name" => $this -> convertinput(OdbcSimulator::odbc_result($result, "sharh")), 
				   "date" => $this -> handleReportOptions($this -> convertinput(OdbcSimulator::odbc_result($result, "flag_dat"))),
				   "visitor" => $this -> handleReportOptions($this -> convertinput(OdbcSimulator::odbc_result($result, "flag_visitor"))),
				   "customer" => $this -> handleReportOptions($this -> convertinput(OdbcSimulator::odbc_result($result, "flag_castmoer"))),
				   "product" => $this -> handleReportOptions($this -> convertinput(OdbcSimulator::odbc_result($result, "flag_kala"))),
				   "area" => $this -> handleReportOptions($this -> convertinput(OdbcSimulator::odbc_result($result, "flag_area"))),
				   "masir" => $this -> handleReportOptions($this -> convertinput(OdbcSimulator::odbc_result($result, "flag_maser")))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("reports" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
	

	function addReportRequest($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(), $que);
        return "ok";
        
     }
	
	 function handleRequestedReportStatus($data){
		$result = "صف انتظار";
		if($data == 1){
			$result = "صف انتظار";
		}else if($data == 2){
			$result = "دریافت اطلاعات";
		}else if($data == 3){
			$result = "آماده مشاهده";
		}else if($data == 4){
		   $result = "بدون نتیجه";
		}else if($data == 5){
		  $result = "بدون نتیجه";
		}
		
		return $result;
	}

	
    function getAvailableRequestedReportList($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(),$que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				   "name" => $this -> convertinput(OdbcSimulator::odbc_result($result, "reportname")), 
				   "code" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")), 
				   "reportid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_report")), 
				   "statusname" => $this -> handleRequestedReportStatus($this -> convertinput(OdbcSimulator::odbc_result($result, "stut"))),
				   "status" => $this -> convertinput(OdbcSimulator::odbc_result($result, "stut")),
				   "requesttitle" => $this -> convertinput(OdbcSimulator::odbc_result($result, "requesttitle"))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("reports" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
    
        function chkvaliduser($uone, $utwo){

 
        $completeList=  array();
        $counter = 0;
        
        $result = OdbcSimulator::odbc_exec($this->getConnection(), "EXEC getvaliduser @p1 = $uone , @p2 = $utwo");
        if(!$result){
               die("Failed To Fetch getvaliduser");
         }else{
            
             while (OdbcSimulator::odbc_fetch_row($result)){
                
                $bowl = array(
                    
                    "uid" => $this -> convertinput(OdbcSimulator::odbc_result($result, "ucid"))
                );
                
                  array_push($completeList, $bowl["uid"]);  
              }
            
        }
 
        return $completeList;
            
        
    }
	
	function getReportResultData($que){
		$result = OdbcSimulator::odbc_exec($this->getConnection(),$que);

        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
					"id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id")),
				   "iduser" => $this -> convertinput(OdbcSimulator::odbc_result($result, "iduser")),
				   "idreport" => $this -> convertinput(OdbcSimulator::odbc_result($result, "idreport")),
				   "id_request" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id_request")),
				   "type" => $this -> convertinput(OdbcSimulator::odbc_result($result, "type")),
				   "col1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col1")),
				   "col2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col2")),
				   "col3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col3")),
				   "col4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col4")),
				   "col5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col5")),
				   "col6" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col6")),
				   "col7" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col7")),
				   "col8" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col8")),
				   "col9" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col9")),
				   "col10" => $this -> convertinput(OdbcSimulator::odbc_result($result, "col10")),
				   "gcol1" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gcol1")),
				   "gcol2" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gcol2")),
				   "gcol3" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gcol3")),
				   "gcol4" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gcol4")),
				   "gcol5" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gcol5")),
				   "gcol6" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gcol6")),
					"gxt" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gxt")),
					"gyt" => $this -> convertinput(OdbcSimulator::odbc_result($result, "gyt")),
					"chart" => $this -> convertinput(OdbcSimulator::odbc_result($result, "chart"))
				   
				);
                     
        
                    
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("reportresultdata" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
		
	}
    
     function deleteReportRequestResults($reqid, $ucid){
		

        $result = OdbcSimulator::odbc_exec($this->getConnection(), "EXEC deleterequestresult @req = $reqid , @ucid = $ucid");
        return "ok";
        
     }
	
	function getMessages($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(),$que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				   "content" => $this -> convertinput(OdbcSimulator::odbc_result($result, "matn")), 
				   "date" => $this -> convertinput(OdbcSimulator::odbc_result($result, "dat")),
				   "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "rowi"))
				);
                     
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("messages" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
	
	function makeMessageRead($q){
		

       $result = OdbcSimulator::odbc_exec($this->getConnection(), $q);
        //return "ok";
        
     }
	
	
	function getKalagroups($que){
 
        $result = OdbcSimulator::odbc_exec($this->getConnection(),$que);
        $resarr = array(); 
        $resro = array();  
        if($result){

            while (OdbcSimulator::odbc_fetch_row($result)){
                
                $temp = array(
				   "name" => $this -> convertinput(OdbcSimulator::odbc_result($result, "nam")), 
				   "code" => $this -> convertinput(OdbcSimulator::odbc_result($result, "groupcode")),
                   "id" => $this -> convertinput(OdbcSimulator::odbc_result($result, "id"))
				);
                     
                
                  array_push($resro, $temp);  
              }

            
        }
 
             
			 $resarr = array("kalagroups" => $resro);
             return json_encode($resarr, JSON_UNESCAPED_UNICODE);
        
     }
	
        
}
?>