<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class CT_operator_load extends CI_Controller {
    function __construct()
    {
       parent::__construct();
		if (!$this->dx_auth->is_logged_in()) {
            header('HTTP/1.1 401 Unauthorize');die('expire'); 
        }
        
        $uid = $this->session->userdata('DX_user_id');
        
        if(!permissionAuth(2) && $uid != RID){ 
            header('HTTP/1.1 401 Unauthorize');die('noaccess');
        }
		
		$this->load->model("production/mdl_production", 'mdl_production');
		
    }



    function view_operator(){  
  
        $this->load->view('pasi_operator/view_operator');
   } 
  
   function view_operator_new(){	
    $data['x'] ='';
    $data['id_operator'] = isset($_POST['id_operator'])?$_POST['id_operator']:'-1';
    $this->load->view('pasi_operator/view_operator_new',$data);
    }
    
    function view_operator_edit(){	
       
        $id_operator         = isset($_POST['id_operator'])?$_POST['id_operator']:die('Pilih Dokumen ');   
        $nama_operator       = isset($_POST['nama_operator'])?$_POST['nama_operator']:'';  //1 add
  
        $data['id_operator'] = $id_operator;
        $data['nama_operator'] = $nama_operator; 
      
        $this->load->view('pasi_operator/view_operator_edit',$data);
    } 




    function find_operator(){
		$findtext = isset($_REQUEST['findtext']) ? $_REQUEST['findtext']:'';  
		$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit']:'';  
		$xmldata = XMLbasic('dbo.SPX_FIND_OPERATOR');
		AddField($xmldata,'findtext',$findtext);   
		AddField($xmldata,'rows',$limit);  
		exec_sp_xml($xmldata, 'dbo.SPX_FIND_OPERATOR',$stsno,$stsdes,$rows,$detail);
		$i=0;
        foreach ($rows as $per_row) {
            $responce->rows[$i]['rID']=getXMLValue($per_row,'rID');
            $responce->rows[$i]['r1']=getXMLValue($per_row,'r1');
   
            $i++; 
        }
         if ($i==0)
		{
		 die('empty data'); 
  		}
        echo json_encode($responce);
   
    } 


    


    // END CONTROLS

}    

?>    