MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/cloud_cafsinfotech_in/application/controllers/Shift_muster_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Shift_muster_report  extends Action_controller{	
	public function __construct(){
		parent::__construct('shift_muster_report');
		
	}
	
	// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
	public function index(){
		//* EMPLOYEE COMPONENT PICKLIST
		$get_match_columns = 'SELECT prime_form_id,prime_module_id,label_name,view_name FROM `cw_form_setting` WHERE prime_module_id = "employees" and label_name not in ("emp_name","employee_code","role") and transaction_type in ("1","4") order by view_name asc';
		$match_column_info   = $this->db->query("CALL sp_a_run ('SELECT','$get_match_columns')");
		$match_column_result = $match_column_info->result();
		$match_column_info->next_result();
		$match_columns[""] = "---- Select Column ----";
		foreach($match_column_result as $match_column){
			$prime_form_id = $match_column->prime_form_id;
			$column_value  = $match_column->label_name;
			$view_name     = $match_column->view_name;
			$match_columns[$this->xss_clean($column_value)] = $this->xss_clean($view_name);			
		}
		$from_query = 'select * from cw_form_setting where prime_module_id = "employees" and field_show = "1"  and label_name != "role" ORDER BY input_for,field_sort asc';
		$form_data   = $this->db->query("CALL sp_a_run ('SELECT','$from_query')");
		$form_result = $form_data->result();
		$form_data->next_result();	
		$this->fliter_list    = $this->get_filter_data($form_result);
		$data['fliter_list']  = $this->fliter_list;	
		$data['emp_component_list'] = $match_columns;
		$this->load->view("$this->control_name/manage",$data);
	}
	
	//LOAD TABEL WITH FILTERS
	public function search(){
		//SEARCH INFO FUNCTION
		$this->search_info();
		$module_sts       = (int)$this->module_sts;
		if(!$module_sts){
			echo json_encode(array('success' => FALSE, 'message' => "Search  Info Query Process Error..!"));
			exit(0);
		}else{
			$draw         = $this->input->post('draw');
			$start        = $this->input->post('start');
			$per_page     = $this->input->post('length');
			$order        = $this->input->post('order');
			$order_col    = $this->input->post('columns');
			$search       = $this->input->post('search');
			$column       = $order[0]['column'];
			$order_sor    = $order[0]['dir'];
			$order_col    = $order_col[$column]['data'];
			$search       = trim($search['value']);
			$search_query = str_replace("@SELECT@",$this->select_query,$this->base_query);
		
			$search_result    = array();
			//ADDED BASIC,FILTER,COMMON QUERY HERE 
			$role_condition   = "";
			if($this->role_condition){
				$role_condition = $this->role_condition;
			}
			
			$fliter_query = "";
			foreach($this->fliter_list as $fliter){
				$label_id         = $fliter->label_name;
				$field_isdefault  = (int)$fliter->field_isdefault;
				$field_type       = (int)$fliter->field_type;
				$prime_form_id 	  = $fliter->prime_form_id;

				if($field_isdefault === 1){
					$column_name = $this->prime_table .".$label_id";
					$search_val  = $this->input->post("$label_id");
					if($search_val){
						if($field_type === 4){
							$search_val    = date('Y-m-d',strtotime($search_val));
							$fliter_query .= ' and '.$column_name.' = "'.$search_val.'"';
						}else
						if(($field_type === 5) || ($field_type === 7)){
							$search_val    = trim(implode('","',$search_val));
							$fliter_query .= ' and '.$column_name.' in ("'.$search_val.'")';  
						}else
						if($field_type === 9){
							$search_id     = 'filter_'.$label_id.'_hidden_'.$prime_form_id;
							$search_val    = $this->input->post("$search_id");
							$fliter_query .= ' and '.$column_name.' in ("'.$search_val.'")';  
						}else
						if($field_type === 13){
							$search_val    = date('Y-m-d H:i:s',strtotime($search_val));
							$fliter_query .= ' and '.$column_name.' = "'.$search_val.'"';
						}else{
							$fliter_query .= ' and '.$column_name.' LIKE "'.$search_val.'%"';
						}
					}
				}
			}
			
			$common_search = "";
			if($search){
				foreach($this->table_head as $setting){
					$prime_form_id      = $setting->prime_form_id;
					$field_type         = (int)$setting->field_type;
					$pick_list          = $setting->pick_list;
					$pick_table         = $setting->pick_table;
					$pick_list_type     = $setting->pick_list_type;
					$input_view_type    = (int)$setting->input_view_type;
					$auto_prime_id      = $setting->auto_prime_id;
					$auto_dispaly_value = $setting->auto_dispaly_value;
					$label_id           = strtolower(str_replace(" ","_",$setting->label_name));
					$field_isdefault    = (int)$setting->field_isdefault;
					if($field_isdefault === 1){
						if(($input_view_type === 1) || ($input_view_type === 2)){
							$search_label = "$this->prime_table.$label_id";
							$search_val   = "";
							if($field_type === 4){ // having issues in date search
								if(strtotime($search)){
									$search_val = date('Y-m-d',strtotime($search));
									$common_search .= ' or '. $search_label .' like "'.$search_val.'%"';
								}
							}else
							if(($field_type === 5) || ($field_type === 7) || ($field_type === 9)){
								$result = array_filter($this->pick_list[$label_id]['array_list'], function ($item) use ($search) {
									if (stripos($item, $search) !== false) {
										return true;
									}
									return false;
								});
								if($result){
									$pick_key = implode('", "', array_keys($result));
									$common_search .= ' or '. $search_label .' in("'.$pick_key.'")';
								}
							}else{
								$common_search .= ' or '. $search_label .' like "'.$search.'%"';
							}
						}
					}
				}
				if($common_search){
					$common_search = ltrim($common_search,' or ');
					$common_search = " and ($common_search)";
					$common_search = str_replace("(,","(",$common_search);
					$common_search = str_replace("()","(0)",$common_search);
				}
			}
			$count_all_query    = str_replace("@SELECT@","count(*) as allcount",$this->base_query);
			$count_query        = $count_all_query.' where '.$this->prime_table.'.trans_status = 1 '.$role_condition.$fliter_query.$common_search;
			
			$search_query      .= " where $this->prime_table.trans_status = 1 $role_condition $fliter_query $common_search";
			$search_query      .= " ORDER BY  $order_col $order_sor";
			if((int)$per_page !== -1){
				$search_query  .= " LIMIT  $start,$per_page";
			}		
			$search_pro_qry     = [];
			$search_pro_qry[]   = array("return"=>"total_count","qry"=>$count_all_query);
			$search_pro_qry[]   = array("return"=>"filtered_count","qry"=>$count_query);
			$search_pro_qry[]   = array("return"=>"search_result","qry"=>$search_query);

			$search_info_rslt   = $this->run_multi_qry($search_pro_qry);
			$total_count        = $search_info_rslt->rslt->total_count[0]->allcount;
			$filtered_count     = $search_info_rslt->rslt->filtered_count[0]->allcount;
			
			$search_result      = json_decode(json_encode($search_info_rslt->rslt->search_result),true);

			if($search_result === null || $search_result === ''){
				$search_result  = [];
			}
			echo json_encode(array("draw" => intval($draw),"recordsTotal" => $total_count,"recordsFiltered" => $filtered_count,"data" => $search_result));	
		}
	}
	
	//LOAD MODEL PAGE VIEW WITH DATA
	public function view($form_view_id=-1){
		//VIEW INFO FUNCTION
		$this->view_info($form_view_id);
		$data['module_sts']             = (int)$this->module_sts;
		//VIEW, FORM INPUT
		$data['view_info']              = $this->view_info;
		$data['form_info']              = $this->form_info;
		$data['formula_result']         = $this->formula_result;//for label color change
		$data['role_based_condition']   = $this->role_based_condition;//for label name readonly options
		$data['all_pick']               = $this->pick_list;//all pick result

		//DEPENDENT AUTO PICKLIST
		$data['auto_pick']              = $this->depen_auto_list;//dependent auto result			
		$data['condition_list']         = $this->form_condition_list;

		//VIEW DATA
		$base_query          = str_replace("@SELECT@",$this->view_select,$this->base_query);
		$form_view_qry       = $base_query .' where '.$this->prime_table.'.'.$this->prime_id.' = '.$form_view_id.' and '.$this->prime_table.'.trans_status = 1';
		$row_view_qry        = 'select * from cw_form_view_setting where  prime_view_module_id = "'.$this->control_name.'" and  form_view_type = "3" and trans_status = 1';
		
		$view_pro_qry        = [];
		$view_pro_qry[]      = array("return"=>"form_view","qry"=>$form_view_qry);
		$view_pro_qry[]      = array("return"=>"row_view_list","qry"=>$row_view_qry);	

		$view_info_rslt      = $this->run_multi_qry($view_pro_qry);
		$form_view_rslt      = $view_info_rslt->rslt->form_view[0];			
		$row_view_rslt       = $view_info_rslt->rslt->row_view_list;

		$data['form_view']   = $form_view_rslt;
		
		$row_view_list       = array();
		foreach($row_view_rslt as $view){
			$prime_form_view_id   = $view->prime_form_view_id;
			$row_set_data         = $this->get_row_set_data($prime_form_view_id,$form_view_id);
			$row_view_list[$prime_form_view_id] = $row_set_data;
		}
		$data['row_view_list']   = $row_view_list;
		//FOR DEPENDENT
		$data['get_depend_prime_id']   = $this->get_depend_fun();
		$data['depend_label_id']   	   = $this->depend_label_fun();	
		$this->load->view("$this->control_name/form",$data);
	}
	
	//SAVE MODEL DATA TO DATA BASE
	public function generate_muster_report(){
		//SEARCH INFO FUNCTION
		$this->search_info();
		$fliter_label      = $this->input->post('fliter_label');
		$fliter_type       = $this->input->post('fliter_type');
		$filter_cond       = $this->input->post('filter_cond');
		$fliter_val        = $this->input->post('fliter_val');
		$filter_count      = count($fliter_label);
		$search_count      = 0;
		$fliter_query 	   = "";
		for($i=0;$i<=(int)$filter_count;$i++){
			$db_name     = $fliter_label[$i];
			$table_name  = $fliter_type[$i];
			$db_cond     = $filter_cond[$i];
			$db_value    = $fliter_val[$i];
			$field_type  = $field_type[$i];
			if(($db_cond) && ($db_value)){
				$search_count++;
				if((int)$field_type === 4){
					$search_val = date("Y-m-d",strtotime($db_value));
				}else{
					$search_val = $db_value;
				}
				if($db_cond === "LIKE"){ $search_val = "$db_value%"; }
				if((int)$table_name === 1){
					$this->prime_table = "cw_employees";
					$fliter_query .= ' and '. $this->prime_table .".". $db_name ." ". $db_cond .' "'.$search_val.'"'; 
				}
			}			
		}
	
		$emp_component            = ltrim(implode('","',$this->input->post('emp_component[]')),',');

		$report_period            = (int)$this->input->post('report_period');
		$month_and_year           = $this->input->post('month_and_year');
		$process_date             = date("Y-m-d",strtotime("01-".$month_and_year));
		$start_date               = date("Y-m-d",strtotime("01-".$month_and_year));
		if($report_period === 1){
			//report type 1   
			$start_date     = $process_date;
			$end_date       = date('Y-m-t',strtotime($process_date));
			
		}else{
			//report type 2   
			$start_date     = date("Y-m-d",strtotime($this->input->post('from_date')));

			$end_date       = date("Y-m-d",strtotime($this->input->post('to_date')));
		}
		if($start_date > $end_date){
			echo json_encode(array('success' => false,'message' => "From Date Should Be Less Than To Date"));
			exit(0);
		}
		if($emp_component){
			//FOR DATE FORMAT AND PICKLIST VALUE SHOW IN TABLE ROW OR EXCEL ROW
			$find_label_qry   = 'select * from cw_form_setting where trans_status = 1 and prime_module_id = "employees" and label_name in ("'.$emp_component.'")';
			$find_label_info  = $this->db->query("CALL sp_a_run ('SELECT','$find_label_qry')");
			$label_result     = $find_label_info->result();
			$find_label_info->next_result();
			$select_query     = "";
			foreach($label_result as $rslt){
				$prime_form_id      = (int)$rslt->prime_form_id;
				$prime_module_id    = $rslt->prime_module_id;
				$input_view_type    = (int)$rslt->input_view_type;
				$input_for          = (int)$rslt->input_for;
				$field_type         = (int)$rslt->field_type;
				$label_id           = $rslt->label_name;
				$label_name         = ucwords($rslt->view_name);
				$field_length       = $rslt->field_length;
				$field_decimals     = $rslt->field_decimals;
				$pick_list_type     = (int)$rslt->pick_list_type;
				$pick_list          = $rslt->pick_list;
				$pick_table         = $rslt->pick_table;
				$auto_prime_id      = $rslt->auto_prime_id;
				$auto_dispaly_value = $rslt->auto_dispaly_value;
				$field_isdefault    = (int)$rslt->field_isdefault;
				$pick_display       = $rslt->pick_display_value;
				$table_name         = "cw_employees";
				if($field_isdefault === 1){
					$pick_sel_table = "$table_name";
				}
				if((int)$prime_form_id === 0){
					$label_name = ucwords(str_replace("_"," ",$label_list));
					$label_id   = $label_list;
				}
				
				//TABLE HEADER
				$table_array[]  = array('field_type'=>$field_type,'label_name'=>$label_id,'view_name'=>$label_name);
				$array_list = array();
				//SEARCH FILTERS
				if($field_type === 4){
					$select_query .= ',CASE WHEN '.$pick_sel_table.'.'.$label_id.' IS NULL or '.$pick_sel_table.'.'.$label_id.' = "1970-01-01" or '.$pick_sel_table.'.'.$label_id.' = "0000-00-00" then "" else DATE_FORMAT('.$pick_sel_table.'.'.$label_id.', "%d-%m-%Y") end as '.$label_id;
				}else
				if(($field_type === 5) || ($field_type === 7)){
					if($pick_list_type === 1){
						$pick_list_val   = explode(",",$pick_list);
						$pick_list_val_1 = $pick_list_val[0];
						$pick_list_val_2 = $pick_list_val[1];
						//pick query for get a picklist data
						$pick_query = "select $pick_list from $pick_table where trans_status = 1 $where_condition";
						$pick_data   = $this->db->query("CALL sp_a_run ('SELECT','$pick_query')");
						$pick_result = $pick_data->result();
						$pick_data->next_result();
						
						$array_list[""] = "---- $label_name ----";
						foreach($pick_result as $pick){
							$pick_key = $pick->$pick_list_val_1;
							$pick_val = $pick->$pick_list_val_2;
							$array_list[$pick_key] = $pick_val;
						}
						// $this->all_pick[$prime_form_id] = $array_list;
						$pick_query_as = $pick_table."_".$prime_form_id;
						if(($input_view_type === 1) || ($input_view_type === 2)){
							if($pick_table === "cw_employees"){
								$select_query .= ',CONCAT_WS(" - ", '.$pick_query_as.'.'.$pick_list_val_1.','.$pick_query_as.'.'.$pick_list_val_2.') as '.$label_id;
							}else{
								$select_query .= ",$pick_query_as.$pick_list_val_2 as $label_id";
							}
							$pick_query_join .= " left join $pick_table as $pick_query_as on $pick_query_as.$pick_list_val_1 = $pick_sel_table.$label_id ";
						}
					}else
					if($pick_list_type === 2){ 
						$pick_list_val_1 = $pick_table."_id";
						$pick_list_val_2 = $pick_table."_value";
						$pick_list_val_3 = $pick_table."_status";
						
						$pick_query = "select $pick_list_val_1,$pick_list_val_2 from $pick_table where $pick_list_val_3 = 1";
						$pick_data   = $this->db->query("CALL sp_a_run ('SELECT','$pick_query')");
						$pick_result = $pick_data->result();
						$pick_data->next_result();
						
						$array_list[""] = "---- $label_name ----";
						foreach($pick_result as $pick){
							$pick_key = $pick->$pick_list_val_1;
							$pick_val = $pick->$pick_list_val_2;
							$array_list[$pick_key] = $pick_val;
						}
						// $this->all_pick[$prime_form_id] = $array_list;
						$pick_query_as = $pick_table."_".$prime_form_id;
						if(($input_view_type === 1) || ($input_view_type === 2)){
							$select_query .= ",$pick_query_as.$pick_list_val_2 as $label_id";
							$pick_query_join .= " left join $pick_table as $pick_query_as on $pick_query_as.$pick_list_val_1 = $pick_sel_table.$label_id ";
						}
					}
				}else
				if($field_type === 9){
					$pick_query_as = $pick_table."_".$prime_form_id;
					if(($input_view_type === 1) || ($input_view_type === 2)){
						$select_query .= ",$pick_query_as.$auto_dispaly_value as $label_id";
						$pick_query_join .= " left join $pick_table as $pick_query_as on $pick_query_as.$auto_prime_id = $pick_sel_table.$label_id ";
					}
				}else
				if($field_type === 13){
					$select_query .= ',DATE_FORMAT('.$pick_sel_table.'.'.$label_id.', "%d-%m-%Y %H:%i:%s") as '.$label_id;
				}else{
					if(($input_view_type === 1) || ($input_view_type === 2)){
						if($field_isdefault === 1){
							$select_query .= ",$pick_sel_table.$label_id";
						}else
						if($field_isdefault === 2){
							$select_query .= ",$pick_sel_table.$label_id";
						}
					}
				}
			}
		}

		$role_condition      = "";
		if($this->role_condition){
			$role_condition = $this->role_condition; //$start_date
		}
		// $select_query     = rtrim($select_query,",");
		$emp_qry 	  = 'SELECT cw_employees.employee_code,cw_employees.emp_name,cw_category.category_name as role '.$select_query.' FROM `cw_employees` inner join cw_category on cw_category.prime_category_id = cw_employees.role '.$pick_query_join.' where cw_employees.trans_status = 1 and (cw_employees.termination_status = 0 or cw_employees.resignation_date >= "'.$start_date.'") '.$fliter_query.' '.$role_condition;

		$emp_info     = $this->db->query("CALL sp_a_run ('SELECT','$emp_qry')");
		$emp_rslt     = $emp_info->result_array();
		$emp_info->next_result();
		$filter_list = $this->get_filter_data($emp_rslt);
		
		$shift_name_qry    = 'SELECT cw_shift_master.short_name,cw_shift_import.shift_date,employee_code FROM cw_shift_import inner join cw_shift_master on cw_shift_master.prime_shift_master_id = cw_shift_import.shift_name  WHERE cw_shift_import.trans_status = 1 and shift_date >="'.$start_date.'" and shift_date <="'.$end_date.'"';
		
		$shift_info     = $this->db->query("CALL sp_a_run ('SELECT','$shift_name_qry')");
		$shift_rslt     = $shift_info->result_array();
		$shift_info->next_result();

		$shift_name_arr    = array_reduce($shift_rslt, function ($result, $arr) {	
		    $result[$arr['employee_code']][$arr['shift_date']] = $arr['short_name'];
	    	return $result;
		}, array());
		
		$emp_comp_arr   = explode('","', $emp_component);
		$date_period  = new DatePeriod(
		     new DateTime($start_date),
		     new DateInterval('P1D'),
		     new DateTime(date("Y-m-d",strtotime("+1 days",strtotime($end_date))))
		);

	   $weekoff_import_qry = 'SELECT employee_code,employee_name,weekoff_date,weekoff_type FROM `cw_weekoff_import` WHERE  trans_status = 1 and weekoff_date >="'.$start_date.'" and weekoff_date <="'.$end_date.'"';
	   $weekoff_info     = $this->db->query("CALL sp_a_run ('SELECT','$weekoff_import_qry')");
		$weekoff_rslt     = $weekoff_info->result_array();
		$weekoff_info->next_result();

		$weekoff_import_arr    = array_reduce($weekoff_rslt, function ($result, $arr) {	
		    $result[$arr['employee_code']][$arr['weekoff_date']] = $arr['weekoff_type'];
	    	return $result;
		}, array());

		$tr_line = "";
		foreach($emp_rslt as $key => $emp_data){
			$employee_code   = $emp_data['employee_code'];
			// echo "HRX $employee_code <br/>";
			$emp_name        = $emp_data['emp_name'];
			$category        = $emp_data['role'];			
			$tr_head         = "<tr><th>Category</th><th>Employee Code</th><th>Employee Name</th>";
			$comp_line = "";
			foreach ($emp_comp_arr as $key => $value){
				$comp_val = $emp_data[$value];
			 	if($value === "role"){
					$value  = 'Category';
				}
			 	$value      = str_replace("_"," ",$value);
				$tr_head   .= "<th>$value</th>";
				$comp_line .= "<td>$comp_val</td>";
			}
			$date_line       = "";
			foreach ($date_period as $key => $value){
				$day             = $value->format('d');
				$shift_date      = $value->format('Y-m-d');
				$weekoff_date    = $value->format('Y-m-d');
				$shift_details   = $shift_name_arr[$employee_code][$shift_date];
				$weekoff_details = $weekoff_import_arr[$employee_code][$weekoff_date]; 
				$tr_head    .= "<th>$day</th>";
				if($weekoff_details && $shift_details){				
					$date_line  .= "<td style='white-space: nowrap;'> W | $shift_details </td>";
	            }else
	            if($weekoff_details){
					$date_line  .= "<td style='white-space: nowrap;'>W | - </td>";
	            }else
	            if($shift_details){
					$date_line  .= "<td style='white-space: nowrap;'>$shift_details</td>";
	            }else{
	            	$date_line  .= "<td>-</td>";
	            }
			}
            $tr_line  .= "<tr><td>$category</td><td>$employee_code</td><td>$emp_name</td>$comp_line $date_line</tr>";
			$tr_head   = "<tr>$tr_head</tr>";
		}
			$table_content = "<div style='margin:20px;'>
					<table class='table table-striped table-bordered' id='shift_muster_report'>
						<thead>
							$tr_head
						</thead>
						<tbody>
							$tr_line
						</tbody>
					</table>
				</div>";
			// echo $table_content; die;
		echo json_encode(array('success'=>true,'table_content'=>$table_content));
}
public function get_filter_data($form_result){
		$filter = array();
		foreach($form_result as $setting){
			$prime_form_id      = (int)$setting->prime_form_id;
			$prime_module_id    = $setting->prime_module_id;
			$input_view_type    = (int)$setting->input_view_type;
			$input_for          = (int)$setting->input_for;
			$field_type         = (int)$setting->field_type;
			$label_id           = $setting->label_name;
			$label_name         = ucwords($setting->view_name);
			$field_length       = $setting->field_length;
			$field_decimals     = $setting->field_decimals;
			$pick_list_type     = (int)$setting->pick_list_type;
			$pick_list          = $setting->pick_list;
			$pick_table         = $setting->pick_table;
			$auto_prime_id      = $setting->auto_prime_id;
			$auto_dispaly_value = $setting->auto_dispaly_value;
			$field_isdefault    = (int)$setting->field_isdefault;
			$file_type          = (int)$setting->file_type;
			$mandatory_field    = (int)$setting->mandatory_field;
			$unique_field       = (int)$setting->unique_field;
			$search_show        = (int)$setting->search_show;
			$array_list = array();
			if( $label_id != 'employee_code' && $label_id != 'emp_name'){
				if(($field_type === 5) || ($field_type === 7)){
					if($pick_list_type === 1){
						$pick_list_val   = explode(",",$pick_list);
						$pick_list_val_1 = $pick_list_val[0];
						$pick_list_val_2 = $pick_list_val[1];
						if($pick_table == "cw_category"){
							$qry = " and prime_category_id != 1";
							}else{
							$qry = "";
						}
						if($pick_table == "cw_payroll_formula"){
							$pick_query = "select $pick_list from $pick_table where trans_status = 1";
							$pick_data   = $this->db->query("CALL sp_a_run ('SELECT','$pick_query')");
							$pick_result = $pick_data->result();
							$pick_data->next_result();
							$array_list[""] = "---- $label_name ----";
							foreach($pick_result as $pick){
								$pick_key = $pick->$pick_list_val_1;
								$pick_val = ucwords(str_replace("_"," ",$pick->$pick_list_val_2));
								$array_list[$pick_key] = $pick_val;
							}
						}else{
							if($label_id === "excemption_component"){
								$pick_query = "select $pick_list from $pick_table where trans_status = 1 and tax_section = 1 $qry";
								}else{
								$pick_query = "select $pick_list from $pick_table where trans_status = 1 $qry";
							}
							$pick_data   = $this->db->query("CALL sp_a_run ('SELECT','$pick_query')");
							$pick_result = $pick_data->result();
							$pick_data->next_result();
				
							$array_list[""] = "---- $label_name ----";
							foreach($pick_result as $pick){
								$pick_key = $pick->$pick_list_val_1;
								$pick_val = $pick->$pick_list_val_2;
								$array_list[$pick_key] = $pick_val;
							}
						}
					}else
					if($pick_list_type === 2){ 
						$pick_list_val_1 = $pick_table."_id";
						$pick_list_val_2 = $pick_table."_value";
						$pick_list_val_3 = $pick_table."_status";
						
						$pick_query = "select $pick_list_val_1,$pick_list_val_2 from $pick_table where $pick_list_val_3 = 1";
						$pick_data   = $this->db->query("CALL sp_a_run ('SELECT','$pick_query')");
						$pick_result = $pick_data->result();
						$pick_data->next_result();
						
						$array_list[""] = "---- $label_name ----";
						foreach($pick_result as $pick){
							$pick_key = $pick->$pick_list_val_1;
							$pick_val = $pick->$pick_list_val_2;
							$array_list[$pick_key] = $pick_val;
						}
					}
				}		
				if(($input_view_type === 1) || ($input_view_type === 2)){
					$filter[] = array('label_id'=> $label_id, 'field_isdefault'=> $field_isdefault, 'array_list'=> $array_list, 'field_type'=> $field_type);
				}
			}
		}  
		return $filter;
}
	
	//IMPORT FILE VIEW INFORMATION
	public function import(){
		$data['module_id']     = $this->control_name;		
		$excel_format_qry = 'select prime_excel_format_id,excel_name from cw_util_excel_format where excel_module_id = "'.$this->control_name.'" and trans_status = 1';
		$excel_format   = $this->db->query("CALL sp_a_run ('SELECT','$excel_format_qry')");
		$excel_result    = $excel_format->result();
		$excel_format->next_result();
		$excel_format_drop[""] = "---- Excel Format ----";
		foreach($excel_result as $excel){
			$prime_excel_format_id = $excel->prime_excel_format_id;
			$excel_name            = $excel->excel_name;
			$excel_format_drop[$prime_excel_format_id] = $excel_name;
		}
		$data['excel_format_drop'] = $excel_format_drop;
		
		$this->load->view("$this->control_name/import",$data);
	}
}
?>