<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Requisition extends CI_Controller {

	public function all_requisition()
	{
		check_login();
		$data['all_requisition']=$this->Requisitions->all_requisition();
		
		$data['all_requisition_pro'] =$this->Requisitions->all_requisition_pro();
		//$data['remaining_requisition']=$this->Requisitions->remaining_requisition();
		$this->load->view('requisition/all_requisition',$data);

		      
	}

	
	public function view_boms_details(){
		check_login();

		$id=$this->input->post('id');

		$data['all_requisition_bom']=$this->Requisitions->boms_requisition($id);

		//print_r($data['all_requisition_bom']);
		echo json_encode (array('html'=>$this->load->view('requisition/show_boms',$data,true)));
	}
	
	public function moldingline(){

		check_login();
		$data['all_requisition']=$this->Requisitions->all_requisition_molding_line();
		/*print_r($data['all_requisition']);
		die;*/
		$this->load->view('requisition/moldingline',$data);

	}


	public function printingline(){

		check_login();
		$data['all_requisition_printing_line']=$this->Requisitions->all_requisition_printing_line();
		//print_r($data['all_requisition_printing_line']);
		//die;
		$this->load->view('requisition/printingline',$data);

	}


	public function assemblingline(){

		check_login();
		$data['all_requisition_assembling_line']=$this->Requisitions->all_requisition_assembling_line();
		//print_r($data['all_requisition_printing_line']);
		//die;
		$this->load->view('requisition/assemblingline',$data);

	}

	
	public function sealingline(){

		check_login();
		$data['all_requisition_sealing_line']=$this->Requisitions->all_requisition_sealing_line();
		//print_r($data['all_requisition_printing_line']);
		//die;
		$this->load->view('requisition/sealingline',$data);

	}


	public function packingline(){

		check_login();
		$data['all_requisition_packing_line']=$this->Requisitions->all_requisition_packing_line();
		//print_r($data['all_requisition_printing_line']);
		//die;
		$this->load->view('requisition/packingline',$data);

	}




	public function production_plan(){

		check_login();

		$data['all_requisition']=$this->Requisitions->all_requisition_molding_line();
		$this->load->view('production_plan/production_plan',$data);
	}
	
	
	public function user_production(){

		check_login();

		$data['all_requisition']=$this->Requisitions->all_requisition_molding_line();
		$this->load->view('production_plan/user_production',$data);
	}


	public function view_plan_details(){

		check_login();
		
		$id=$this->input->post('id');

		/*print_r($id);
		die;*/

		$data['get_plan_all']=$this->Requisitions->get_plan_data($id);

		$data['get_plan_all_compund']=$this->Requisitions->get_plan_all_compund($id);
		
		echo json_encode (array('html'=>$this->load->view('production_plan/get_plane_all_details',$data,true)));
	
	}


	public function view_production_plan(){
		check_login();
		$id = $this->uri->segment('3');


	/*	print_r($data['get_production_plan_data']);
		die;*/
		
		if($this->input->post())
		{
			 //$param = $this->input->post('id');
 			//$data = $this->Master_list->get_products_data($param);
			
			//print_r($data);
			//echo json_encode($data);
		}else{

			$data['get_production_plan_data']=$this->Requisitions->get_production_plan_data($id);

			$this->load->view('production_plan/production_plan_data',$data);
		}

	}


	public function view_Data_production_plan(){

			//$id = $this->input->post('id');
			 $so_id = $this->uri->segment('3');
			//$id = $this->uri->segment('3');
			$product = $this->uri->segment('4');
			$so_id_get_from_sopoboms = so_get_so_id($so_id);
			$data['get_so_data']=$this->Requisitions->get_so_data($so_id_get_from_sopoboms);
			/*print_r($so_id);
			die;*/
			$data['get_semi_data']=$this->Requisitions->get_production_plan_data_semi($so_id);
			/*$data['get_material_data']=$this->Requisitions->get_production_plan_data_material($so_id,$product);*/
			$data['get_material_data']=$this->Requisitions->get_production_plan_data_material_for_addproduction($so_id,$product);

			$data['get_molds_data']=$this->Requisitions->get_molds_data_products($product);

			$data['get_machine_data']=$this->Requisitions->get_machine_data();
			//$data['child_id'] = $id;
			$pro_name = product_name($product);
			$data['get_production'] = $this->Requisitions->get_production($so_id_get_from_sopoboms,$pro_name);


			$data['job_no']=$this->Requisitions->get_counter_number();
			
			if($data['job_no']==''){

				$data['job_no'] = '10001';

			}else{
				$xx = $data['job_no'][0]['job'];
				for ($job_no = 0; $job_no <= $xx; $job_no++) {
         
      		  				}

				$data['job_no'] = $job_no;
			}
			
			//echo json_encode (array('html'=>$this->load->view('production_plan/get_plane_data_materials',$data,true)));
			$this->load->view('production_plan/get_plane_data_materials',$data);
		}

		public function semi_finish_production_plan(){

			//$id = $this->input->post('id');
			$so_id = $this->uri->segment('3');
			//$id = $this->uri->segment('3');

			$data['get_semi_data']=$this->Requisitions->get_production_plan_data_semi($so_id);
			
			$this->load->view('production_plan/get_plane_semi_finish',$data);
		}

		public function get_production_qty(){


			if($this->input->post())
			{
				$id = $this->input->post('id');

				$pro_seg = $this->input->post('pro_seg');
				$so_id = $this->input->post('so_id');


				$data = $this->Requisitions->get_production_plan_qty($id,$pro_seg,$so_id);
				
				$data2 = $this->Stocks->get_total_material($id);
				$data3 = $this->Stocks->get_total_out_material($id);

				$data4 = $this->Requisitions->get_material($id);


				if($data2 =="")
				{	
				    $data['total_qty'] = 0;
				}else{

					$data['total_qty'] = $data2[0]['total_qty'] - $data3[0]['total_qty_out'];

				}			
				//$data = color_mat($data[0]['material_id']);
				//exit;
				//$data = $data1[0]['total'];
				//$data = $data1[0]['unit'];
				$data['total'] = $data[0]['total'];
				$data['unit'] = get_unit_name($data[0]['unit']);
				$data['color'] = $data4[0]['color'];
				echo json_encode($data);
				//echo json_encode (array('html'=>$this->load->view('production_plan/get_plane_data_materials',$data,true)));
			}


		}


		public function get_materials_detail(){

			if($this->input->post())
			{
				$id = $this->input->post('id');


				$data = $this->Requisitions->get_production_plan_material($id);
				//$data = color_mat($data[0]['material_id']);
				//exit;
				echo json_encode($data);
				//echo json_encode (array('html'=>$this->load->view('production_plan/get_plane_data_materials',$data,true)));
			}
		}

		public function add_plan_data()
			{
				 check_login();

			   
				if($this->input->post())
				{
					/*$last_job = $this->input->post('material_id');
					$child_id = $this->input->post('child_id');*/
					$so_id = $this->input->post('so_id');
					
					$get_so_po = check_so_for_bom($so_id);

					

					$so_ids = so_get_so_id($this->input->post('so_id'));
					$job = $this->input->post('job');
					$product_name = $this->input->post('product_name');
					$pro_qty = $this->input->post('pro_qty');
					$material_id = $this->input->post('material_id');
					$bom_qty = $this->input->post('bom_qty');
					$bom_unit = $this->input->post('bom_unit');
					$in_stock_qty = $this->input->post('in_stock_qty');
					$p_qty = $this->input->post('p_qty');
					$color_id = $this->input->post('color_id');
					$cqty = $this->input->post('cqty');
					$bom_unit_color = $this->input->post('bom_unit_color');
					$in_stock_qty_color = $this->input->post('in_stock_qty_color');
					$cutting_ratio = $this->input->post('cutting_ratio');
					$semi_standard  = $this->input->post('semi_standard');
					$weight_standard  = $this->input->post('weight_standard');
					$spec_no = $this->input->post('spec_no');
					$mold = $this->input->post('mold');
					$remarks = $this->input->post('remarks');
					$user_id = $this->input->post('user_id');
					$created = $this->input->post('created');
					$modified = $this->input->post('modified');
					$status = $this->input->post('status');
					$complete_status = $this->input->post('complete_status');


					$arrayName = array(
											'so_id' => $so_ids,
											'job' => $job,
											'product_name' => $product_name,
											'pro_qty'=>$pro_qty,
											'material_id'=>$material_id,
											'bom_qty'=>$bom_qty,
											'bom_unit'=>$bom_unit,
											'in_stock_qty'=>$in_stock_qty,
											'p_qty'=>$p_qty,
											'color_id'=>$color_id,
											'cqty'=>$cqty,
											'bom_unit_color'=>$bom_unit_color,
											'in_stock_qty_color'=>$in_stock_qty_color,
											'cutting_ratio'=>$cutting_ratio,
											'semi_standard' => $semi_standard,
											'weight_standard' => $weight_standard,
											'spec_no'=>$spec_no,
											'mold'=>$mold,
											'remarks'=>$remarks,
											
											'user_id' => $user_id,
											'created' => $created,
											'modified' => $modified
										);
						
					$pro_id = get_pro_id($product_name);
					
					$result=$this->Requisitions->add_plan_data($arrayName);
					$result=$this->Requisitions->update_so_po_for_bom($get_so_po,$material_id,$pro_id);
					
					$result1=$this->Requisitions->all_status_production($so_id);

			
					if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
					echo json_encode($plan);
				}
				
	}



		public function add_so_po_status(){

			$so_id = so_get_so_id($this->input->post('so_id'));

			$qqq = $this->Requisitions->check_datain_production($so_id);

			if($qqq !=""){ 

			$result=$this->Requisitions->update_so_plan_status($so_id);
			
			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
		}else if($qqq ==""){

			//echo json_encode("No Data");

			$plan=array('status'=>'false');
			echo json_encode($plan);
		}
			}
			
			
			public function edit_plan_production($id){
				check_login();

				   $so_id = sopoboms_id_get_so_id($this->uri->segment('4'));
				   $product_id = $this->uri->segment('5');
				   //$product = product_id($this->input->post('product_name'));

				 
				if($this->input->post())
				{
					

				   $job = $this->input->post('job');
				   $product_name = $this->input->post('product_name');
				   $party_id = $this->input->post('party_id');
				   $pro_qty = $this->input->post('pro_qty');
				   $material_id = $this->input->post('material_id');
				   $bom_qty = $this->input->post('bom_qty');
				   $bom_unit = $this->input->post('bom_unit');
				   $in_stock_qty = $this->input->post('in_stock_qty');
				   $p_qty = $this->input->post('p_qty');
				   $color_id = $this->input->post('color_id');
				   $cqty = $this->input->post('cqty');
				   $bom_unit_color = $this->input->post('bom_unit_color');
				   $in_stock_qty_color = $this->input->post('in_stock_qty_color');
				   $cutting_ratio = $this->input->post('cutting_ratio');
				   $semi_standard = $this->input->post('semi_standard');
				   $weight_standard = $this->input->post('weight_standard');
				   $spec_no = $this->input->post('spec_no');
				   $mold = $this->input->post('mold');
				   $remarks  = $this->input->post('remarks');
				   $user_id = $this->input->post('user_id');
				   $modified = $this->input->post('modified');
				   $complete_status = $this->input->post('complete_status');



				$complete_status = $this->input->post('complete_status');
				$product = product_id($this->input->post('product_name'));

				if($complete_status == 0){

					$dataarray =  array(
						    'job' => $job,
							'product_name' => $product_name,
							'party_id' => $party_id,
							'pro_qty' => $pro_qty,
							'material_id'=> $material_id,
							'bom_qty'=> $bom_qty,
							'bom_unit'=> $bom_unit,
							'in_stock_qty'=> $in_stock_qty,
							'p_qty'=> $p_qty,
							'color_id'=> $color_id,
							'cqty'=> $cqty,
							'bom_unit_color'=> $bom_unit_color,
							'in_stock_qty_color'=> $in_stock_qty_color,
							'cutting_ratio'=> $cutting_ratio,
							'semi_standard' => $semi_standard,
							'weight_standard' => $weight_standard,
							'spec_no'=> $spec_no,
							'mold'=> $mold,
							'remarks'=>$remarks,
							'complete_status'=>$complete_status,
							'user_id'=>$user_id,
							'modified'=>$modified
							 );

				$result=$this->Requisitions->update_product_plan_active($id,$dataarray);
				$result=$this->Requisitions->update_product_plan_machine_active($product_id,$so_id);
				}else{


				$dataarray =  array(
						    'job' => $job,
							'product_name' => $product_name,
							'party_id' => $party_id,
							'pro_qty' => $pro_qty,
							'material_id'=> $material_id,
							'bom_qty'=> $bom_qty,
							'bom_unit'=> $bom_unit,
							'in_stock_qty'=> $in_stock_qty,
							'p_qty'=> $p_qty,
							'color_id'=> $color_id,
							'cqty'=> $cqty,
							'bom_unit_color'=> $bom_unit_color,
							'in_stock_qty_color'=> $in_stock_qty_color,
							'cutting_ratio'=> $cutting_ratio,
							'semi_standard' => $semi_standard,
							'weight_standard' => $weight_standard,
							'spec_no'=> $spec_no,
							'mold'=> $mold,
							'remarks'=>$remarks,
							'complete_status'=>$complete_status,
							'user_id'=>$user_id,
							'modified'=>$modified
							 );
				$result=$this->Requisitions->update_product_plan_active($id,$dataarray);
				$result=$this->Requisitions->update_product_plan_machine($product_id,$so_id);
				}
				if($result){$res=array('status'=>'true');}else{$res=array('status'=>'false');}
				echo json_encode($res);
				}else{

				$data['get_plan']=$this->Requisitions->get_plan_id($id);
				$data['get_material_data']=$this->Requisitions->get_production_plan_data_material($so_id,$product_id);
				/*print_r($so_id);
				print_r($product);
				die;*/
				          $this->load->view('production_plan/edit_plan_production',$data);
				     }


				}


		



	public function view_save_plan(){

			$id = $this->input->post('id');

			$data['get_view']=$this->Requisitions->get_view($id);
			
			
			echo json_encode (array('html'=>$this->load->view('production_plan/all_get_plane_data',$data,true)));
		}

		public function view_production(){

			check_login();
			$id = $this->uri->segment('3');


			$data['get_data']=$this->Requisitions->get_all_data($id);

			$this->load->view('production_plan/view_productions',$data);

		}


		public function active_production(){

			check_login();
			$data['get_data']=$this->Requisitions->get_all_data_pro();

			$this->load->view('production_plan/active_productions',$data);

		}

		public function line_clear(){

			
			if($this->input->post())
				{
			
			$result=$this->Requisitions->add_line_clerence_data($_POST);
	
			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
				}else{
			$this->load->view('production_plan/line_clear_productions');
			}
		}

	public function inspection(){

		$mold = $this->uri->segment('3');
		$so_id1 = $this->uri->segment('4');
		$p_id = $this->uri->segment('5');
		if($this->input->post())
		{

					$so_id = $this->input->post('so_id');
					$para_id = $this->input->post('para_id');
					 $product_id = $this->input->post('product_id');

			        $sample_1 = $this->input->post('sample_1');
			        $sample_2 = $this->input->post('sample_2');
			        $sample_3 = $this->input->post('sample_3');
			        $sample_4 = $this->input->post('sample_4');
			        $sample_5 = $this->input->post('sample_5');
					$sample_6 = $this->input->post('sample_6');
					$sample_7 = $this->input->post('sample_7');
					$sample_8 = $this->input->post('sample_8');
					$sample_9 = $this->input->post('sample_9');
					$sample_10 = $this->input->post('sample_10');
					$sample_11 = $this->input->post('sample_11');
					$sample_12 = $this->input->post('sample_12');
					$sample_13 = $this->input->post('sample_13');
					$sample_14 = $this->input->post('sample_14');
					$sample_15 = $this->input->post('sample_15');
					$sample_16 = $this->input->post('sample_16');
					$sample_17 = $this->input->post('sample_17');
					$sample_18 = $this->input->post('sample_18');
					$sample_19 = $this->input->post('sample_19');
					$sample_20 = $this->input->post('sample_20');
					$sample_21 = $this->input->post('sample_21');
					$sample_22 = $this->input->post('sample_22');
					$sample_23 = $this->input->post('sample_23');
					$sample_24 = $this->input->post('sample_24');
					$remarks = $this->input->post('remarks');
					$user_id = $this->input->post('user_id');
			        $created = $this->input->post('created');
			        $modified = $this->input->post('modified');

			       $condition=$this->Requisitions->get_inspection_condition($so_id,$para_id);
			       if($condition == ""){

			        $result = $this->Requisitions->add_add_inspecdata($product_id,$so_id,$para_id,$sample_1,$sample_2,$sample_3,$sample_4,$sample_5,$sample_6,$sample_7,$sample_8,$sample_9,$sample_10,$sample_11,$sample_12,$sample_13,$sample_14,$sample_15,$sample_16,$sample_17,$sample_18,$sample_19,$sample_20,$sample_21,$sample_22,$sample_23,$sample_24,$remarks,$user_id,$created,$modified);
			        
			        if($result){$add_inspec=array('status'=>'true');}else{$add_inspec=array('status'=>'false');}
	            echo json_encode($add_inspec);


			       }else if($condition != ""){
					 	

			       		$add_inspec=array('status'=>'false');
			       		echo json_encode($add_inspec);
			       }

			       
				}else{


			$data['get_data']=$this->Requisitions->get_parameters_data($mold);

			$data['inspec_details']=$this->Requisitions->inspec_details($mold,$so_id1);

			/*print_r($data['inspec_details']);
			die;*/
			$data['all_inspec_details']=$this->Requisitions->all_inspec_details($mold,$so_id1);
			$data['all_inspec']=$this->Requisitions->all_inspec($mold);
			$data['all_columns_count']=$this->Requisitions->all_columns_count($mold,$so_id1);
			
			$this->load->view('production_plan/inspections',$data);
			}

	}


	
	public function complete_inspection()
		{
			 check_login();

			 $so_id = $this->input->post('so_id');
			 $mold = $this->input->post('mold');
			 $p_name = $this->input->post('product_id');
				//$result=$this->Requisitions->complete_inspection_so_po_status($so_id,$mold);
				$result=$this->Requisitions->complete_inspection_production($mold,$so_id,$p_name);

				$all_so_id=$this->Requisitions->get_condition_sopo_update($so_id);
				// $check_status = 5;
				
				$array_check_status = []; //Zk edit here

				foreach ($all_so_id as $key => $value) {
					$array_check_status[] = $value['status']; //Zk edit here

				}
				
				if(count(array_unique($array_check_status)) === 1 && (int)$array_check_status[0] == 5) { //Zk edit here
					$update_signal = 'Yes';					
				} else {
					$update_signal = 'No';
				}

				if($update_signal == 'Yes'){
					$result=$this->Requisitions->complete_inspection_so_po_status($so_id);

					if($result){$party=array('status'=>'true');}else{$party=array('status'=>'false');}
						echo json_encode($party);
				}

		     	
			
					
		}

	
		public function delete_parameter($id)
		{
			 check_login();
		
				$result=$this->Requisitions->delete_parameter($id);
		
				if($result){$party=array('status'=>'true');}else{$party=array('status'=>'false');}
				echo json_encode($party);
			
					
		}
		
		public function delete_plan($id)
			{
				 	check_login();
				 	$so_get_so_id = so_get_so_id($id);
				 	$result=$this->Requisitions->delete_so_po_boms($id);
					$result=$this->Requisitions->delete_parameter_plan($id);
					$result=$this->Requisitions->delete_plan($id);
					$result=$this->Requisitions->delete_machine($id);
					$result=$this->Requisitions->delete_moulds_plan($id);
					$result=$this->Requisitions->delete_bom_laod($so_get_so_id);
					$result=$this->Requisitions->compound_deleted($id);
					
					if($result){$product=array('status'=>'true');}else{$product=array('status'=>'false');}
					echo json_encode($product);
				
			}


		public function get_all_inspec(){

			check_login();
			
			if($this->input->post())
			{
				$id = $this->input->post('id');
	 			$data = $this->Requisitions->get_view_inspec($id);
				

				echo json_encode($data);
			}
	}

	
	public function add_inspecdata(){

			check_login();
			
			if($this->input->post())
			{
					$para_id = $this->input->post('para_id');
			        $sample_size = $this->input->post('sample_size');
			        $user_id = $this->input->post('user_id');
			        $created = $this->input->post('created');
			        $modified = $this->input->post('modified');

			        $result = $this->Requisitions->add_add_inspecdata($para_id,$sample_size,$user_id,$created,$modified);
			        if($result){$add_inspec=array('status'=>'true');}else{$add_inspec=array('status'=>'false');}
	            echo json_encode($add_inspec);
			}
	}


public function update_status(){

			check_login();

			
			if($this->input->post())
			{
					$para_id = $this->input->post('id');
			        
					

			        $result = $this->Requisitions->update_status($para_id);
			        if($result){$add_inspecs=array('status'=>'true');}else{$add_inspecs=array('status'=>'false');}
	            echo json_encode($add_inspecs);
			}
	}



	
	public function view_ins_samples_details(){

		check_login();
		
		$id=$this->input->post('id');
		$data['get_ins_all']=$this->Requisitions->view_ins_samples_details($id);
		
		echo json_encode (array('html'=>$this->load->view('production_plan/view_ins_samples_details',$data,true)));
		}


		

		public function mould_department(){

		
		
			
			$data['mould_depar']=$this->Requisitions->mould_depart_production();

			
			$this->load->view('production_plan/mould_department',$data);
			

	}


	public function machine_department(){

		
		if($this->input->post())
				{

				$so_id  = $this->input->post('so_id');	
				$product_id  = $this->input->post('product_id');
				$machine = $this->input->post('machine');
				$day_expected = $this->input->post('expected');
				$remarks = $this->input->post('remarks');
				$user_id = $this->input->post('user_id');
				$created = $this->input->post('created');

				$p_name = product_name($product_id);
			   
			    $machine_available=$this->Requisitions->machine_available($machine);
			    
			    /*print_r($machine_available);
			    die;*/
			    if($machine_available != "")
			    {
			    	 //var_dump($machine_available); exit;
			    	 $machine_available=array('status'=>'available');
						echo json_encode($machine_available);

			    }else
			    if($machine_available == "" ){

 				//var_dump($machine_available); exit;
				$arrayName = array(
									'so_id' => $so_id,
									'product_id' => $product_id,
									'machine' => $machine,
									'expected' => $day_expected,
									'remarks'=>$remarks,
									'user_id' => $user_id,
									'created' => $created
								);

				$result=$this->Requisitions->production_machine_remarks($arrayName);

				$result=$this->Requisitions->update_production_machine($so_id,$p_name);

				$all_so_id=$this->Requisitions->get_condition_sopo_update($so_id,$p_name);
				$check_status = 2;
				
					foreach ($all_so_id as $key => $value) {
						
						if($value['status'] == 1){
							$check_status = 'no';
							//break;
						}

					}

						if($check_status== 2){
							
							

							$result=$this->Requisitions->update_machine_so_po_mould($so_id);


						}

			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
			}	}else{

			
			$data['mould_depar']=$this->Requisitions->machine_depart_production();


			
			$this->load->view('production_plan/machine_department',$data);
			

		}
	}


	

	public function machine_config(){

		
		if($this->input->post())
				{

				$so_id  = $this->input->post('so_id');	
				$product_id  = $this->input->post('product_id');
				$machine = $this->input->post('machine');
				$day_expected = $this->input->post('expected');
				$remarks = $this->input->post('remarks');
				$user_id = $this->input->post('user_id');
				$created = $this->input->post('created');

				$p_name = product_name($product_id);
			   
			    $machine_available=$this->Requisitions->machine_available($machine);
			    
			    /*print_r($machine_available);
			    die;*/
			    if($machine_available != "")
			    {
			    	 //var_dump($machine_available); exit;
			    	 $machine_available=array('status'=>'available');
						echo json_encode($machine_available);

			    }else
			    if($machine_available == "" ){

 				//var_dump($machine_available); exit;
				$arrayName = array(
									'so_id' => $so_id,
									'product_id' => $product_id,
									'machine' => $machine,
									'expected' => $day_expected,
									'remarks'=>$remarks,
									'user_id' => $user_id,
									'created' => $created
								);

				$result=$this->Requisitions->production_machine_remarks($arrayName);

				$result=$this->Requisitions->update_production_machine($so_id,$p_name);

				$all_so_id=$this->Requisitions->get_condition_sopo_update($so_id,$p_name);
				$check_status = 2;
				
					foreach ($all_so_id as $key => $value) {
						
						if($value['status'] == 1){
							$check_status = 'no';
							//break;
						}

					}

						if($check_status== 2){
							
							

							$result=$this->Requisitions->update_machine_so_po_mould($so_id);


						}

			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
			}	}else{

			
			$data['mould_depar']=$this->Requisitions->machine_depart_production_config();


			
			$this->load->view('production_plan/machine_config',$data);
			

		}
	}

	
	public function add_machine_config(){
		check_login();
			
			if($this->input->post())
			{
					$product = $this->input->post('product');
			        $so_id = $this->input->post('so_id');
			        $machine = $this->input->post('machine');
			        $range1_max = $this->input->post('range1_max');
			        $range1_min = $this->input->post('range1_min');
					$range2_max = $this->input->post('range2_max');
			        $range2_min = $this->input->post('range2_min');
			        $range3_max = $this->input->post('range3_max');
					$range3_min = $this->input->post('range3_min');
					$range4_max = $this->input->post('range4_max');
			        $range4_min = $this->input->post('range4_min');
			        $range5_max = $this->input->post('range5_max');
					$range5_min = $this->input->post('range5_min');
					$range1_injp_max = $this->input->post('range1_injp_max');
			        $range1_injp_min = $this->input->post('range1_injp_min');
			        $range2_injs_max = $this->input->post('range2_injs_max');
					$range2_injs_min = $this->input->post('range2_injs_min');
					$range3_injt_sec_max = $this->input->post('range3_injt_sec_max');
					$range3_injt_sec_min = $this->input->post('range3_injt_sec_min');
					$range4_ct_sec_max = $this->input->post('range4_ct_sec_max');
					$range4_ct_sec_min = $this->input->post('range4_ct_sec_min');
					$range5_doz_mm_max = $this->input->post('range5_doz_mm_max');
					$range5_doz_mm_min = $this->input->post('range5_doz_mm_min');
					$oil_temperature = $this->input->post('oil_temperature');
					$max_min = $this->input->post('max_min');
			        $created = $this->input->post('created');
			       


					$arrayName = array(
						'product' => $product,
						'so_id' => $so_id,
						'machine' => $machine,
						'range1_max'=>$range1_max,
						'range1_min'=>$range1_min,
						'range2_max'=>$range2_max,
						'range2_min'=>$range2_min,
						'range3_max'=>$range3_max,
						'range3_min'=>$range3_min,
						'range4_max'=>$range4_max,
						'range4_min'=>$range4_min,
						'range5_max'=>$range5_max,
						'range5_min'=>$range5_min,
						'range1_injp_max'=>$range1_injp_max,
						'range1_injp_min' => $range1_injp_min,
						'range2_injs_max' => $range2_injs_max,
						'range2_injs_min'=>$range2_injs_min,
						'range3_injt_sec_max'=>$range3_injt_sec_max,
						'range3_injt_sec_min'=>$range3_injt_sec_min,
						
						'range4_ct_sec_max' => $range4_ct_sec_max,
						'range4_ct_sec_min' => $range4_ct_sec_min,
						'range5_doz_mm_max' => $range5_doz_mm_max,
						'range5_doz_mm_min' => $range5_doz_mm_min,
						'oil_temperature' => $oil_temperature,
						'max_min' => $max_min,
						'created' => $created,
						
					);

			        $result = $this->Requisitions->add_config($arrayName);
					$result=$this->Requisitions->update_config_machine($so_id,$product,$machine);
			        if($result){$add_inspec=array('status'=>'true');}else{$add_inspec=array('status'=>'false');}
	            echo json_encode($add_inspec);
			}else{

				$this->load->view('production_plan/add_machine_config');
				
			}
	}


	public function add_machine_config_ibm(){
		check_login();
			
			if($this->input->post())
			{
					$product = $this->input->post('product');
			        $so_id = $this->input->post('so_id');
			        $machine = $this->input->post('machine');
			        $range1_max = $this->input->post('range1_max');
			        $range1_min = $this->input->post('range1_min');
					$range2_max = $this->input->post('range2_max');
			        $range2_min = $this->input->post('range2_min');
					$range3_max = $this->input->post('range3_max');
			        $range3_min = $this->input->post('range3_min');
					$range4_max = $this->input->post('range4_max');
			        $range4_min = $this->input->post('range4_min');
					$range5_max = $this->input->post('range5_max');
					$range5_min = $this->input->post('range5_min');
			        $inj_pressure_max = $this->input->post('inj_pressure_max');
					$inj_pressure_min = $this->input->post('inj_pressure_min');
					$inj_speed_max = $this->input->post('inj_speed_max');
					$inj_speed_min = $this->input->post('inj_speed_min');
					$doz_pressure_max = $this->input->post('doz_pressure_max');
					$doz_pressure_min = $this->input->post('doz_pressure_min');
					$doz_speed_max = $this->input->post('doz_speed_max');
					$doz_speed_min = $this->input->post('doz_speed_min');
					$blast_time_max = $this->input->post('blast_time_max');
					$blast_time_min = $this->input->post('blast_time_min');
					$expect_max = $this->input->post('expect_max');
					$expect_min = $this->input->post('expect_min');
					$m_o_t_max = $this->input->post('m_o_t_max');
					$m_o_t_min = $this->input->post('m_o_t_min');
					
					$insert_date = $this->input->post('insert_date');
			        $created = $this->input->post('created');
					$user_id = $this->input->post('user_id');
					$remarks = $this->input->post('remarks');

					$arrayName = array(
						'product' => $product,
						'so_id' => $so_id,
						'machine' => $machine,
						'insert_date' => $insert_date,
						'range1_max'=>$range1_max,
						'range1_min'=>$range1_min,
						'range2_max'=>$range2_max,
						'range2_min'=>$range2_min,
						'range3_max'=>$range3_max,
						'range3_min'=>$range3_min,
						'range4_max'=>$range4_max,
						'range4_min'=>$range4_min,
						'range5_max'=>$range5_max,
						'range5_min'=>$range5_min,
						'inj_pressure_max'=>$inj_pressure_max,
						'inj_pressure_min'=>$inj_pressure_min,
						'inj_speed_max'=>$inj_speed_max,
						'inj_speed_min'=>$inj_speed_min,
						'doz_pressure_max'=>$doz_pressure_max,
						'doz_pressure_min'=>$doz_pressure_min,
						'doz_speed_max'=>$doz_speed_max,
						'doz_speed_min'=>$doz_speed_min,
						'blast_time_max'=>$blast_time_max,
						'blast_time_min'=>$blast_time_min,
						'expect_max'=>$expect_max,
						'expect_min'=>$expect_min,
						'm_o_t_max'=>$m_o_t_max,
						'm_o_t_min'=>$m_o_t_min,
						'remarks' =>$remarks,
						 'created' => $created,
						 'user_id' => $user_id
						
					);

			        $result = $this->Requisitions->add_config_ibm($arrayName);
					$result=$this->Requisitions->update_config_machine($so_id,$product,$machine);
			        if($result){$add_inspec=array('status'=>'true');}else{$add_inspec=array('status'=>'false');}
	            echo json_encode($add_inspec);
			}else{

				$this->load->view('production_plan/add_machine_config_ibm');
				
			}
	}

	public function line_clerence(){
		
			$data['mould_depar']=$this->Requisitions->lineclerence_depart_production();
			
			
			$this->load->view('production_plan/line_clerence_department',$data);
			
	}



	

	public function compound_production_department(){
		

		if($this->input->post())
				{

					$so_id  = $this->input->post('so_id');	
				    $id  = $this->input->post('production_id');
			
				$result=$this->Requisitions->add_compound_production_department($_POST);


				


	
			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
				}else{

			
			$data['mould_depar']=$this->Requisitions->compound_production_department();

			
			$this->load->view('production_plan/compound_production_department',$data);
			}
	}



	/*public function raw_mixing_department(){

		
		if($this->input->post())
				{
			
			$result=$this->Requisitions->add_line_clerence_data($_POST);



	
			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
				}else{

			
			$data['mould_depar']=$this->Requisitions->machine_depart_production();

			
			$this->load->view('production_plan/machine_department',$data);
			}

	}*/
	

	public function view_update_mold(){

		check_login();
		
		$item=$this->input->post('item');

		$so_id=$this->input->post('so_id');

		$items = product_name($item);
		
		$data['get_details_mould']=$this->Requisitions->get_details_mould($items,$so_id);
		
		echo json_encode (array('html'=>$this->load->view('production_plan/get_details_mould',$data,true)));

		
	}

	public function view_update_machine(){

		check_login();
		
		$item=$this->input->post('item');

		$so_id=$this->input->post('so_id');
		$items = product_name($item);

		/*print_r($so_id);
		die;
*/
		$data['get_details_mould']=$this->Requisitions->get_details_mould($items,$so_id);


		
		echo json_encode (array('html'=>$this->load->view('production_plan/line_clear_productions',$data,true)));

		
	}

	

	public function compound_production_form(){

		check_login();
		
		//$id=$this->input->post('id');
		$id = $this->uri->segment('3');
		$data['get_details_mould']=$this->Requisitions->get_details_mould($id);

		$data['qcr']=$this->Requisitions->get_counter_number_qcr();
		if($data['qcr']==""){


			$data['qcr'] = 10001;

		}else{

				$xx = $data['qcr'][0]['qcr'];
         
       		   for ($qcr = 0; $qcr <= $xx; $qcr++) {
         
      		     }

		    	$data['qcr'] = $qcr;

		}

		$material_id = get_production_material($id);

		$color_id = $this->Requisitions->get_color_ids($material_id);


		if(!empty($color_id)){
		$var = [];

		foreach ($color_id as $value) {



			$get_match = $this->Requisitions->get_match_color_bom($value);
		
				$var[] = $get_match;


		}
				

				$color_material_id = getbom_qty($var[0]);

				$total_ratio = $color_material_id *1000;
				
			    $data['getcolor_id'] = $total_ratio;
			}else{

				$data['getcolor_id'] = 0;
			}


			$data['code'] = material_codess($material_id);
		//echo json_encode (array('html'=>$this->load->view('production_plan/compound_production_form',$data,true)));
		$this->load->view('production_plan/compound_production_form',$data);
		
	}



	public function update_machine(){

		check_login();
		
		$item = product_name($this->input->post('item'));
		$so_id=$this->input->post('so_id');
		$data['get_details_moulds']=$this->Requisitions->get_details_mould($item,$so_id);
		$data['get_machine_data']=$this->Requisitions->get_machine_data();

		echo json_encode (array('html'=>$this->load->view('production_plan/machine_department_production',$data,true)));

		
	}


		public function update_assembled(){

		check_login();
		
		$id=$this->input->post('id');
		$data['get_details_assembled']=$this->Requisitions->get_details_assembled($id);
		/*$data['get_machine_data']=$this->Requisitions->get_machine_data();*/
			
		echo json_encode (array('html'=>$this->load->view('production_plan/assembled_production',$data,true)));

		
	}



	public function update_sealed(){

		check_login();
		
		$id=$this->input->post('id');
		$data['get_details_saealed']=$this->Requisitions->get_details_saealed($id);
		/*$data['get_machine_data']=$this->Requisitions->get_machine_data();*/
			
		echo json_encode (array('html'=>$this->load->view('production_plan/sealed_production',$data,true)));

		
	}


	public function update_printing(){

		check_login();
		
		$id=$this->input->post('id');
		$data['get_details_printing']=$this->Requisitions->get_details_printing($id);
		/*$data['get_machine_data']=$this->Requisitions->get_machine_data();*/
			
		echo json_encode (array('html'=>$this->load->view('production_plan/printing_line',$data,true)));

		
	}


	public function update_packing(){

		check_login();
		
		$id=$this->input->post('id');
		$data['get_details_packing']=$this->Requisitions->get_details_packing($id);
		/*$data['get_machine_data']=$this->Requisitions->get_machine_data();*/
			
		echo json_encode (array('html'=>$this->load->view('production_plan/packing_line',$data,true)));

		
	}


	public function update_assembled_data(){

		check_login();

		if($this->input->post())
		{

			$assembled_id = $this->input->post('assembled_id');
			$qty = $this->input->post('qty');
			$remarks = $this->input->post('remarks');
			$user_id = $this->input->post('user_id');
			$insert_date = $this->input->post('insert_date');
			$created = $this->input->post('created');

			

			$arrayName = array(
									'assembled_id' => $assembled_id,
									'qty' => $qty,
									'insert_date' => $insert_date,
									'remarks'=>$remarks,
									'created' => $created,
									'user_id' => $user_id
									
								);

			$result=$this->Requisitions->add_assembled_log($arrayName);
			$assembled = total_assemble($assembled_id);
            $assembled_log =  total_assembled_log($assembled_id);
            
			if($assembled==$assembled_log){

				$result=$this->Requisitions->update_assembled_status($assembled_id);

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);

			}else{

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
				echo json_encode($plan);
			}

			

		}else{

		$data['assembled_line']=$this->Stocks->get_assembled_line();

		$this->load->view('Stock/assembled_line',$data);

	 }
	}

	

	public function update_sealed_data(){

		check_login();

		if($this->input->post())
		{

			$sealed_id = $this->input->post('sealed_id');
			$qty = $this->input->post('qty');
			$remarks = $this->input->post('remarks');
			$user_id = $this->input->post('user_id');
			$insert_date = $this->input->post('insert_date');
			$created = $this->input->post('created');

			

			$arrayName = array(
									'sealed_id' => $sealed_id,
									'qty' => $qty,
									'insert_date' => $insert_date,
									'remarks'=>$remarks,
									'created' => $created,
									'user_id' => $user_id
									
								);

			$result=$this->Requisitions->add_sealed_log($arrayName);
			$sealed = total_sealed($sealed_id);
            $sealed_log =  total_sealed_log($sealed_id);
            
			if($sealed==$sealed_log){

				$result=$this->Requisitions->update_sealed_status($sealed_id);

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);

			}else{

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
				echo json_encode($plan);
			}

			

		}
	}



	public function update_printing_data(){

		check_login();

		if($this->input->post())
		{

			$printing_id = $this->input->post('printing_id');
			$qty = $this->input->post('qty');
			$remarks = $this->input->post('remarks');
			$user_id = $this->input->post('user_id');
			$insert_date = $this->input->post('insert_date');
			$created = $this->input->post('created');

			

			$arrayName = array(
									'printing_id' => $printing_id,
									'qty' => $qty,
									'insert_date' => $insert_date,
									'remarks'=>$remarks,
									'created' => $created,
									'user_id' => $user_id
									
								);

			$result=$this->Requisitions->add_printing_log($arrayName);
			$printing = total_printing($printing_id);
            $printing_log =  total_printing_log($printing_id);
            
			if($printing==$printing_log){

				$result=$this->Requisitions->update_printing_status($printing_id);

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);

			}else{

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
				echo json_encode($plan);
			}

			

		}
	}



		public function update_packing_data(){

		check_login();

		if($this->input->post())
		{

			$packing_id = $this->input->post('id');
			
			$moving_to = $this->input->post('moving_to');
			/*$user_id = $this->input->post('user_id');
			$insert_date = $this->input->post('insert_date');
			$created = $this->input->post('created');
*/

			$dataarray =  array(
					
					'moving_to' => $moving_to
					
					 );

			 	
				$result = $this->Stocks->update_stock_instock_logs($packing_id,$dataarray);		

				if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
				echo json_encode($plan);

		}
	}


	public function add_production_mould_status(){

		check_login();

		if($this->input->post())
		{

		$product_id=$this->input->post('product_id');

		$so_id = $this->input->post('so_id');
		$date = date('Y-m-d');
		$remarks = $this->input->post('remarks');
		$created = $this->input->post('created');
		$user_id = $this->input->post('user_id');

		$arrayName = array('so_id'=>$so_id,'product_id'=>$product_id,'date'=>$date,'remarks' => $remarks,'created' => $created,'user_id' => $user_id);
		$p_name = product_name($product_id);
		/*print_r($p_name);
		die;*/
		$result=$this->Requisitions->add_remarks_mould($arrayName);
		$result=$this->Requisitions->update_production_mould($so_id,$p_name);
		$all_so_id=$this->Requisitions->get_condition_sopo_update($so_id,$p_name);
		$check_status = 1;

		/*print_r($all_so_id);
		die;*/
		foreach ($all_so_id as $key => $value) {
			
			if($value['status'] == 0){
				$check_status = 'no';
				//break;
			}

		}

		 
		

		if($check_status== 1){
			

				$result=$this->Requisitions->update_so_po_mould($so_id);


			}

	

		if($result){$products=array('status'=>'true');}else{$products=array('status'=>'false');}
			echo json_encode($products);

		} 

	}



	public function add_production_machine_status(){

		check_login();

		if($this->input->post())
		{

		$id=$this->input->post('product_id');

		$so_id = $this->input->post('so_id');
		/*print_r($so_id);
		die;*/

		$p_name = product_name($id=$this->input->post('product_id'));
		$clear1 = $this->input->post('clear1');
		$clear2 = $this->input->post('clear2');
		$clear3 = $this->input->post('clear3');
		$clear4 = $this->input->post('clear4');
		$clear5 = $this->input->post('clear5');
		$clear6 = $this->input->post('clear6');
		$clear7 = $this->input->post('clear7');
		$clear8 = $this->input->post('clear8');
		$clear9 = $this->input->post('clear9');
		$clear10 = $this->input->post('clear10');
		$clear11 = $this->input->post('clear11');
		$clear12 = $this->input->post('clear12');
		$clear13 = $this->input->post('clear13');
		$remarks = $this->input->post('remarks');
		$user_id = $this->input->post('user_id');
		$created = $this->input->post('created');
		$date = date('Y-m-d');

		$arrayName = array('so_id'=>$so_id,'product_id'=>$id,'date'=>$date,'clear1' => $clear1,'clear2' => $clear2,'clear3' => $clear3,'clear4' => $clear4,'clear5' => $clear5,'clear6' => $clear6,'clear7' => $clear7,'clear8' => $clear8,'clear9' => $clear9,'clear10' => $clear10,'clear11' => $clear11,'clear12' => $clear12,'clear13' => $clear13,'remarks' => $remarks,'user_id' => $user_id,'created'=>$created);


		

		$result=$this->Requisitions->add_remarks_machine($arrayName);
		$result=$this->Requisitions->update_production_line_clerence($so_id,$p_name);
		$all_so_id=$this->Requisitions->get_condition_sopo_update($so_id,$p_name);

		
		$check_status = 4;
		foreach ($all_so_id as $key => $value) {
			
			if($value['status'] == 3){
				$check_status = 'no';
				//break;
			}

		}


		if($check_status== 4){
			

				$result=$this->Requisitions->update_so_po_line_clerence($so_id);


			}

	

		if($result){$products=array('status'=>'true');}else{$products=array('status'=>'false');}
			echo json_encode($products);

		} 

	}



	

	public function product_inspection(){
		

		if($this->input->post())
				{

					$so_id  = $this->input->post('so_id');	
				    $id  = $this->input->post('production_id');
			
				$result=$this->Requisitions->add_compound_production_department($_POST);


				


	
			if($result){$plan=array('status'=>'true');}else{$plan=array('status'=>'false');}
			echo json_encode($plan);
				}else{

			
			$data['mould_depar']=$this->Requisitions->product_inspection_department();

			
			$this->load->view('production_plan/product_inspection',$data);
			}
	}


	public function get_machine_code_production(){

		check_login();
		if($this->input->post())
			{
				$material_id = $this->input->post('material_id');

				$data4 = $this->Requisitions->get_total_machine_wast($material_id);
				
				$data['total_qty'] = $data4[0]['total_qty'];
				$data['wast_lot'] = $data4[0]['wast_lot'];
				
				echo json_encode ($data);
			}
		}


	public function out_stock_production(){
	check_login();
	
	if($this->input->post())
	{
		$so_id  = $this->input->post('so_id');	
		$material_id = $this->input->post('material_id');	
		$machine_id = $this->input->post('machine_id');
		$production_id = $this->input->post('production_id');
		$insert_date = $this->input->post('insert_date');
		$qcr = $this->input->post('qcr');
		$color_code = $this->input->post('color_code');
		$color_ratio = $this->input->post('color_ratio');
		$qty = $this->input->post('qty');
		$wlot = $this->input->post('wlot');
		$qty_wast = $this->input->post('qty_wast');
		$remarks = $this->input->post('remarks');
		$user_id = $this->input->post('user_id');
		$created = $this->input->post('created');
		$weight_wast = $this->input->post('weight_wast');

		$condition11  = $this->Requisitions->get_condition($material_id,$machine_id,$insert_date,$production_id);

		/*print_r($condition11);
		die;*/

		if($condition11 ==""){

		$condition  = $this->Requisitions->get_material_for_condition($material_id);


		
		 if($condition !=""){


		 	$dataarray =  array('material_id' => $material_id,
								'machine_id' => $machine_id,
								'insert_date' => $insert_date,
								'qcr' => $qcr,
								'color_code' => $color_code,
								'color_ratio' => $color_ratio,
								'qty'=>$qty,
								'wlot'=> $wlot,
								'weight_wast'=> $weight_wast,
								'remarks'=> $remarks,
								'user_id'=> $user_id,
								'created'=> $created
								 );

	     	$result = $this->Stocks->add_out_stock_production($dataarray);

	     	$result = $this->Stocks->update_waste_status($machine_id);

		 	$dataarray =  array(
		 						'production_id'=>$production_id,
		 						'material_id' => $material_id,
								'machine_id' => $machine_id,
								'insert_date' => $insert_date,
								'qcr' => $qcr,
								'color_code' => $color_code,
								'color_ratio' => $color_ratio,
								'qty'=>$qty,
								'wlot'=> $wlot,
								'qty_wast' => $qty_wast,
								'remarks'=> $remarks,
								
								'created'=> $created,
								'user_id'=> $user_id,
								 );

	     	    $result = $this->Requisitions->add_out_stock_production($dataarray);

	        	$result=$this->Requisitions->update_compound_production($production_id);
				$all_so_id=$this->Requisitions->get_condition_sopo_update($so_id);

				
				$check_status = 3;
				foreach ($all_so_id as $key => $value) {
					
					if($value['status'] == 2){
						$check_status = 'no';
						//break;
					}

				}


				if($check_status == 3){
					

						$result=$this->Requisitions->update_so_po_production_compound($so_id);


					}

	       if($result){$add_out=array('status'=>'true');}else{$add_out=array('status'=>'false');}
	        echo json_encode($add_out);
			}else{

				echo "Stock Not Available..!";
			}

		}else if($condition11 !=""){

		   $add_out1=array('status'=>'condition');

		   echo json_encode($add_out1);
		}
	   }

	}

		


	public function edit_mould_production(){


		 check_login();

	     $p_name = product_name($this->uri->segment('3'));
	     $so_id = $this->uri->segment('4');
	     
		if($this->input->post())
		{	

			$mould = $this->input->post('mold');
			$so_id = $this->input->post('so_id');
			
			
			
	     	
	          		 $result1=$this->Requisitions->edit_mould_production($so_id,$p_name,$mould);
			
					if($result1){$material=array('status'=>'true');}else{$party=array('status'=>'false');}
					echo json_encode($material);
				

				}else{
						
						$data['get_molds_data']=$this->Requisitions->get_molds_data();
			      		$data['get_production_mold']=$this->Requisitions->get_production_mold($p_name,$so_id);
						$this->load->view('production_plan/edit_mould_production',$data);
	      }
				
	
	}



	public function edit_machine_production(){


		check_login();

   			 $product_id = $this->uri->segment('3');
    		 $so_id = $this->uri->segment('4');

		if($this->input->post())
		{

		    $machine = $this->input->post('machine');
			$product_id =  $this->input->post('product_id');
    		$so_id = $this->input->post('so_id');

    		
		 $result1=$this->Requisitions->edit_machine_production($product_id,$so_id,$machine);

		if($result1){$material=array('status'=>'true');}else{$party=array('status'=>'false');}
		echo json_encode($material);


		}else{

			  $data['get_machine_data']=$this->Requisitions->get_machine_data();
		      $data['get_production_machine']=$this->Requisitions->get_production_machine($product_id,$so_id);
		      $this->load->view('production_plan/edit_machine_production',$data);
		     }


		}




	public function logout()
	{
		check_login();
		$this->session->sess_destroy();
		redirect(base_url(),'refresh'); 
	}

	
}
