load->model('batchcard_model'); $this->load->model('inwardgateregister_model'); $this->load->model('rawmaterialdetails_model'); $this->load->model('dahsboard_model'); $this->isLoggedIn(); $this->load->helper(array('form','url')); date_default_timezone_set('Asia/Kolkata'); } public function index() { $data['emplist'] = $this->batchcard_model->getEmplistforReport(); $this->global['pageTitle'] = 'Siddharth : Hourly Batch Card'; $this->loadViews("hourly_batch_card", $this->global,$data,NULL); } function saveHourlyBatchCard() { //echo "done"; $data = $this->input->post('myData'); // print_r($data); //echo "*********************"; $reportdate = $data['curdate']; $reporttime = $data['usr_time']; $reportdate = date_format(date_create($reportdate),'Y-m-d'); $open_trp_reading = $data['open_trp_reading']; $close_trp_reading = $data['close_trp_reading']; $total_trp_reading = $data['total_trp_reading']; $auto_start = $data['auto_start']; $auto_stop = $data['auto_stop']; $atime = $data['atime']; $feed30sec = $data['feed30sec']; $feed1hr = $data['feed1hr']; $inlet_temp = $data['inlet_temp']; $outlet_temp = $data['outlet_temp']; $output_feed_30 = $data['output_feed_30']; $output_feed_1 = $data['output_feed_1']; $weight_rough = $data['weight_rough']; $weight_fine = $data['weight_fine']; $total = $data['total']; $cyclone = $data['cyclone']; $remarks = $data['remarks']; $cby = $data['cby']; $approvedby = $data['approvedby']; //echo "******************************"; $datatostore = array('report_date'=>$reportdate,'report_time'=>$reporttime,'opening_trp_reading'=>$open_trp_reading,'close_trp_reading'=>$close_trp_reading,'total_trp_reading'=>$total_trp_reading,'auto_start'=>$auto_start,'auto_stop'=>$auto_stop,'time'=>$atime,'feed30sec'=>$feed30sec,'feed1hr'=>$feed1hr,'inlet_temp'=>$inlet_temp,'outlet_temp'=>$outlet_temp,'output_feed_30'=>$output_feed_30,'output_feed_1'=>$output_feed_1,'weight_rough'=>$weight_rough,'weight_fine'=>$weight_fine,'total'=>$total,'cyclone'=>$cyclone,'remarks'=>$remarks,'checkedby'=>$cby,'approvedby'=>$approvedby); //print_r($datatostore);die(); $res = $this->batchcard_model->saveHourlyBatchInfo($datatostore); if($res == 1) { echo ""; } else { echo ""; } } function HourlyListing() { $data['allhourdata'] = $this->batchcard_model->getAllHourlyData(); //print_r($data['allhourdata']);die(); $this->global['pageTitle'] = 'Siddharth : Hourly Batch CardListing'; $this->loadViews("hourlybatchcardlisting", $this->global,$data,NULL); } function checkExistHour() { $bdate = $this->input->post('param1'); $btime = $this->input->post('param2'); //echo $bdate."-".$btime; $bdate = date_format(date_create($bdate),'Y-m-d'); //echo $bdate."-".$btime; $res = $this->batchcard_model->checkExistHourlyData($bdate,$btime); if($res[0]->count == 1) { echo "Duplicate Entry...!Data Exist for Same Time Information"; } } function filterHourlyBatchData() { $hid=''; $from = $this->input->post('fromdate'); $to = $this->input->post('todate'); $from = date_format(date_create($from),'Y-m-d'); $to = date_format(date_create($to),'Y-m-d'); //echo $from.'-'.$to;exit(); $data['allhourdata'] = $this->batchcard_model->getAllHourlyData($hid,$from,$to); $this->global['pageTitle'] = 'Siddharth : Hourly Batch CardListing'; $this->loadViews("hourlybatchcardlisting", $this->global,$data,NULL); } function editHourly() { $hid = $this->uri->segment(3); $data['emplist'] = $this->batchcard_model->getEmplistforReport(); $data['batchdata'] = $this->batchcard_model->getAllHourlyData($hid); $this->global['pageTitle'] = 'Siddharth : Edit Hourly Batch Card'; $this->loadViews("edit_hourly_batch_card", $this->global,$data,NULL); } function updateHourlyBatchCard() { $data = $this->input->post('myData'); // print_r($data); //echo "*********************"; $hid = $data['hid']; $reportdate = $data['curdate']; $reporttime = $data['usr_time']; $reportdate = date_format(date_create($reportdate),'Y-m-d'); $open_trp_reading = $data['open_trp_reading']; $close_trp_reading = $data['close_trp_reading']; $total_trp_reading = $data['total_trp_reading']; $auto_start = $data['auto_start']; $auto_stop = $data['auto_stop']; $atime = $data['atime']; $feed30sec = $data['feed30sec']; $feed1hr = $data['feed1hr']; $inlet_temp = $data['inlet_temp']; $outlet_temp = $data['outlet_temp']; $output_feed_30 = $data['output_feed_30']; $output_feed_1 = $data['output_feed_1']; $weight_rough = $data['weight_rough']; $weight_fine = $data['weight_fine']; $total = $data['total']; $cyclone = $data['cyclone']; $remarks = $data['remarks']; $cby = $data['cby']; $approvedby = $data['approvedby']; $datatostore = array('report_date'=>$reportdate,'report_time'=>$reporttime,'opening_trp_reading'=>$open_trp_reading,'close_trp_reading'=>$close_trp_reading,'total_trp_reading'=>$total_trp_reading,'auto_start'=>$auto_start,'auto_stop'=>$auto_stop,'time'=>$atime,'feed30sec'=>$feed30sec,'feed1hr'=>$feed1hr,'inlet_temp'=>$inlet_temp,'outlet_temp'=>$outlet_temp,'output_feed_30'=>$output_feed_30,'output_feed_1'=>$output_feed_1,'weight_rough'=>$weight_rough,'weight_fine'=>$weight_fine,'total'=>$total,'cyclone'=>$cyclone,'remarks'=>$remarks,'checkedby'=>$cby,'approvedby'=>$approvedby,'updatedby'=>$cby); //print_r($datatostore);die(); $res = $this->batchcard_model->updateHourlyBatchInfo($datatostore,$hid); if($res == 1) { echo ""; } else { echo ""; } } function loadDailyBatchCard() { $data['emplist'] = $this->batchcard_model->getEmplistforReport(); $this->global['pageTitle'] = 'Siddharth : Daily Batch Card'; $this->loadViews("dailybatchcard", $this->global,$data,NULL); } function dailyListing() { $data = array(); if(empty($this->uri->segment(3))) { $year = date("Y"); $month = date("m"); // $current = $current."-01"; $data['month'] = $month.'-'.$year; $data['monthdays'] = cal_days_in_month(CAL_GREGORIAN,$month,$year); $data['hourdata'] = $this->batchcard_model->getDailyBatchCardData($month); $data['datefordisplay'] = date('M-Y'); } else { $fromview = $this->uri->segment(3); $dmy = explode('-',$fromview); $fromview_month = date('m', strtotime($dmy[0])); $fromview_year = $dmy[1]; $data['month'] = $fromview_month.'-'.$fromview_year; $data['monthdays'] = cal_days_in_month(CAL_GREGORIAN,$fromview_month,$fromview_year); $data['hourdata'] = $this->batchcard_model->getDailyBatchCardData($fromview_month); $data['datefordisplay'] = $fromview; } //print_r($data['hourdata']);exit(); $this->global['pageTitle'] = 'Siddharth : Daily Batch Card Listing'; $this->loadViews("dailyBatchCardListing", $this->global,$data,NULL); } function saveDailyBatchCardData()//T_daily_batchcard_data { $ddate = $this->input->post('rdate'); $ddate = date_format(date_create($ddate),'y-m-d'); $description = $this->input->post('description'); $trp_running_hrs = $this->input->post('trp_running_hrs'); $feeding_start = $this->input->post('feeding_start'); $less_maintenance = $this->input->post('less_maintenance'); $less_break_down_hrs = $this->input->post('less_break_down_hrs'); $total_burner_running_time = $this->input->post('total_burner_running_time'); $total_feeding_hrs = $this->input->post('total_feeding_hrs'); // $gas_consumption_per_hour = $this->input->post('gas_consumption_per_hour'); // $gas_consumption_per_ton = $this->input->post('gas_consumption_per_ton'); // $total_gas_consumption = $this->input->post('total_gas_consumption'); $ed_running_hrs = $this->input->post('ed_running_hrs'); $ed_receipt = $this->input->post('ed_receipt'); $ed_issues = $this->input->post('ed_issues'); $rotatry_input = $this->input->post('rotary_input'); $rotatry_output = $this->input->post('rotatry_output'); $roughsand_receipt = $this->input->post('roughsand_receipt'); $roughsand_issues = $this->input->post('roughsand_issues'); $finesand_receipt = $this->input->post('finesand_receipt'); $finesand_issues = $this->input->post('finesand_issues'); $gastrip_receipt = $this->input->post('gastrip_receipt'); $gastrip_consumption = $this->input->post('gastrip_consumption'); $water_receipt = $this->input->post('water_receipt'); $water_consumpiton = $this->input->post('water_consumpiton'); $diesel_receipt = $this->input->post('diesel_receipt'); $diesel_consumption = $this->input->post('diesel_consumption'); $diesel_running_hrs = $this->input->post('diesel_running_hrs'); $diesel_rotary_receipt = $this->input->post('diesel_rotary_receipt'); $diesel_rotary_consumption = $this->input->post('diesel_rotary_consumption'); $diesel_rotary_running_hrs = $this->input->post('diesel_rotary_running_hrs'); $open_reading = $this->input->post('open_reading'); $close_reading = $this->input->post('close_reading'); $engineers = $this->input->post('engineers'); $operators = $this->input->post('operators'); $helpers = $this->input->post('helpers'); // $breakdown = $this->input->post('breakdown'); // $location = $this->input->post('location'); // $maintenance_description = $this->input->post('maintenance_description'); // $maintenance_reason = $this->input->post('maintenance_reason'); // $maintenance_time_from = $this->input->post('maintenance_time_from'); // $maintenance_time_to = $this->input->post('maintenance_time_to'); // $maintenance_total_hrs = $this->input->post('maintenance_total_hrs'); // $cost_material = $this->input->post('cost_material'); // $cost_labour = $this->input->post('cost_labour'); $remarks = $this->input->post('remarks'); $createdby = $this->session->userdata ( 'userId' ); $createdtime = date('y-m-d'); $approvedby = $this->input->post('approvedby'); $datatostore = array('ddate'=>$ddate,'description'=>$description,'total_trp_running_hrs'=>$trp_running_hrs,'less_feeding_start'=>$feeding_start,'less_maintenance'=>$less_maintenance,'less_break_down_hrs'=>$less_break_down_hrs,'total_burner_running_time'=>$total_burner_running_time,'total_feeding_hrs'=>$total_feeding_hrs,'ed_running_hrs'=>$ed_running_hrs,'ed_receipt'=>$ed_receipt,'ed_issues'=>$ed_issues,'rotary_input'=>$rotatry_input,'rotary_output'=>$rotatry_output,'trp_roughsand_receipt'=>$roughsand_receipt,'trp_roughsand_issues'=>$roughsand_issues,'trp_finesand_receipt'=>$finesand_receipt,'trp_finesand_issues'=>$finesand_issues,'water_receipt'=>$water_receipt,'water_consumption'=>$water_consumpiton,'diesel_receipt'=>$diesel_receipt,'diesel_consumption'=>$diesel_consumption,'diesel_runninig_hrs'=>$diesel_running_hrs,'diesel_dryer_receipt'=>$diesel_rotary_receipt,'diesel_dryer_consumption'=>$diesel_rotary_consumption,'diesel_dryer_runninig_hrs'=>$diesel_rotary_running_hrs,'power_open_reading'=>$open_reading,'power_close_reading'=>$close_reading,'engineers'=>$engineers,'operators'=>$operators,'helpers'=>$helpers,'gas_for_trip_receipt'=>$gastrip_receipt,'gas_for_trip_consumption'=>$gastrip_consumption,'remarks'=>$remarks,'createdby'=>$createdby,'createdon'=>$createdtime,'approvedby'=>$approvedby); //'total_gas_consumption'=>$total_gas_consumption,'gas_consumption_hr'=>$gas_consumption_per_hour,'gas_consumption_ton'=>$gas_consumption_per_ton,'maintenance_breakdown'=>$breakdown,'maintenance_location'=>$location,'maintenance_description'=>$maintenance_description,'maintenance_reason'=>$maintenance_reason,'maintenance_from_hrs'=>$maintenance_time_from,'maintenance_to_hrs'=>$maintenance_time_to,'maintenance_total_hrs'=>$maintenance_total_hrs,'cost_material'=>$cost_material,'cost_labour'=>$cost_labour //$datatostore = array('ddate'=>$ddate,'description'=>$description,'total_trp_running_hrs'=>$trp_running_hrs,'less_feeding_start'=>$feeding_start,'less_maintenance'=>$less_maintenance,'less_break_down_hrs'=>$less_break_down_hrs,'total_burner_running_time'=>$total_burner_running_time,'total_feeding_hrs'=>$total_feeding_hrs,'gas_consumption_hr'=>$gas_consumption_per_hour,'gas_consumption_ton'=>$gas_consumption_per_ton,'total_gas_consumption'=>$total_gas_consumption,'ed_running_hrs'=>$ed_running_hrs,'ed_receipt'=>$ed_receipt,'ed_issues'=>$ed_issues,'rotary_input'=>$rotatry_input,'rotary_output'=>$rotatry_output,'trp_roughsand_receipt'=>$roughsand_receipt,'trp_roughsand_issues'=>$roughsand_issues,'trp_finesand_receipt'=>$finesand_receipt,'trp_finesand_issues'=>$finesand_issues,'gas_for_trip_receipt'=>$gastrip_receipt,'gas_for_trip_consumption'=>$gastrip_consumption,'water_receipt'=>$water_receipt,'water_consumption'=>$water_consumpiton,'diesel_receipt'=>$diesel_receipt,'diesel_consumption'=>$diesel_consumption,'diesel_runninig_hrs'=>$diesel_running_hrs,'diesel_dryer_receipt'=>$diesel_rotary_receipt,'diesel_dryer_consumption'=>$diesel_rotary_consumption,'diesel_dryer_runninig_hrs'=>$diesel_rotary_running_hrs,'power_open_reading'=>$open_reading,'power_close_reading'=>$close_reading,'engineers'=>$engineers,'operators'=>$operators,'helpers'=>$helpers,'maintenance_breakdown'=>$breakdown,'maintenance_location'=>$location,'maintenance_description'=>$maintenance_description,'maintenance_reason'=>$maintenance_reason,'maintenance_from_hrs'=>$maintenance_time_from,'maintenance_to_hrs'=>$maintenance_time_to,'maintenance_total_hrs'=>$maintenance_total_hrs,'cost_material'=>$cost_material,'cost_labour'=>$cost_labour,'remarks'=>$remarks,'createdby'=>$createdby,'createdon'=>$createdtime,'approvedby'=>$approvedby); //print_r($datatostore); $res = $this->batchcard_model->saveDailyBatchCardData($datatostore); if($res == 1) { echo ""; } else { echo ""; } //exit(); } function checkExistDaily() { $rdate = $this->input->post('param1'); $rdate = date_format(date_create($rdate),'Y-m-d'); $res = $this->batchcard_model->checkExistDaily($rdate); echo $res[0]->count; } function getPowerConsumptionDetails() { $rdate = $this->input->post('param1'); $rdate = date_format(date_create($rdate),'Y-m-d'); $res = $this->batchcard_model->getPowerConsumptionDetails($rdate); //print_r($res);exit(); $counut = count($res); $data[open] = ''; $data[close] = ''; $data[start] = ''; $data[stop] = ''; for($i=0; $i<=$counut; $i++) { if($i == 0) { $data[open] = $res[$i]->opening_trp_reading; $data[start] = $res[$i]->auto_start; } if($i == ($counut-1)) { $data[close] = $res[$i]->close_trp_reading; $data[stop] = $res[$i]->auto_stop; } } echo json_encode($data); } function saveBatchCardtoExcel() { $abstractjsondata = $this->input->post('param1'); $month = $this->input->post('param2'); $abstractphpdata = json_decode($abstractjsondata,true); //print_r($abstractphpdata); $this->load->library('excel'); $this->excel->setActiveSheetIndex(0); $this->excel->getActiveSheet()->setTitle('Abstract Report for ' . $month); $this->excel->getActiveSheet()->setCellValue('A1', 'Abstrct Report for ' . $month); $this->excel->getActiveSheet()->setCellValue('A3', 'S.No.'); $this->excel->getActiveSheet()->setCellValue('B3', 'Description'); $this->excel->getActiveSheet()->setCellValue('C3', 'Running Hrs'); $this->excel->getActiveSheet()->setCellValue('D3', 'Per Hour'); $this->excel->getActiveSheet()->setCellValue('E3', 'Open Stock'); $this->excel->getActiveSheet()->setCellValue('F3', 'Receipt'); $this->excel->getActiveSheet()->setCellValue('G3', 'Total'); $this->excel->getActiveSheet()->setCellValue('H3', 'Consumption'); $this->excel->getActiveSheet()->setCellValue('I3', 'Closing Stock'); $this->excel->getActiveSheet()->setCellValue('J3', 'Physical Stock'); $this->excel->getActiveSheet()->setCellValue('K3', 'Difference'); $this->excel->getActiveSheet()->mergeCells('A1:K1'); $this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(16); $this->excel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setARGB('#333'); for($col = ord('A'); $col <= ord('K'); $col++){ $this->excel->getActiveSheet()->getColumnDimension(chr($col))->setAutoSize(true); $this->excel->getActiveSheet()->getStyle(chr($col))->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle(chr($col))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); } $this->excel->getActiveSheet() ->getStyle('A3:K3') ->getFill() ->setFillType(PHPExcel_Style_Fill::FILL_SOLID) ->getStartColor() ->setARGB('FF808080'); $this->excel->getActiveSheet() ->getStyle('A3:K3')-> getFont()->setBold(true); $i = 5; $j = 1; //print_r($abstractphpdata);die(); foreach($abstractphpdata as $row){ $this->excel->getActiveSheet()->setCellValue('A' . (string)($i),$j); $this->excel->getActiveSheet()->setCellValue('B' . (string)($i),$row['Particulars']); $this->excel->getActiveSheet()->setCellValue('C' . (string)($i),$row['Running Hrs']); $this->excel->getActiveSheet()->setCellValue('D' . (string)($i),$row['Per Hour']); $this->excel->getActiveSheet()->getStyle('D'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('E' . (string)($i),$row['Open Stock']); $this->excel->getActiveSheet()->getStyle('E'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('F' . (string)($i),$row['Receipt']); $this->excel->getActiveSheet()->getStyle('F'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('G' . (string)($i),$row['Total']); $this->excel->getActiveSheet()->getStyle('G'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('H' . (string)($i),$row['Consumption']); $this->excel->getActiveSheet()->getStyle('H'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('I' . (string)($i),$row['Closing Stock']); $this->excel->getActiveSheet()->getStyle('I'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('J' . (string)($i),$row['Physical Stock']); $this->excel->getActiveSheet()->getStyle('J'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $this->excel->getActiveSheet()->setCellValue('K' . (string)($i),$row['Difference']); $this->excel->getActiveSheet()->getStyle('K'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); //$this->excel->getActiveSheet()->setCellValue('A6','HI'); $i++; $j++; } $this->excel->getActiveSheet()->getProtection()->setSheet(true); $this->excel->getActiveSheet()->getProtection()->setSort(true); $this->excel->getActiveSheet()->getProtection()->setInsertRows(true); $this->excel->getActiveSheet()->getProtection()->setFormatCells(true); $filename='Abstrct Report for'.$month.'.xls'; header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="'.$filename.'"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); $objWriter->save('php://output'); } function editDailyData() { $did = $this->uri->segment(3); $data['emplist'] = $this->batchcard_model->getEmplistforReport(); $data['dailydata'] = $this->batchcard_model->getIndividualDailyData($did); $ddate = explode("-",$data['dailydata'][0]->ddate); $dateval =$ddate[2].'-'.$ddate[1].'-'.$ddate[0]; //$data['Maintenances'] = $this->batchcard_model->getmaint_dtl_MntDate($data['dailydata'][0]->ddate); $data['Maintenances'] = $this->batchcard_model->maintenancesdata($dateval); //$arraydata = $this->batchcard_model->maintenancesdata($date); $this->global['pageTitle'] = 'Siddharth : Daily Batch Card Edit'; $this->loadViews("editDailyData", $this->global,$data,NULL); } function updateDailyBatchCardData() { $did = $this->input->post('did'); $ddate = $this->input->post('rdate'); $ddate = date_format(date_create($ddate),'y-m-d'); $description = $this->input->post('description'); $trp_running_hrs = $this->input->post('trp_running_hrs'); $feeding_start = $this->input->post('feeding_start'); $less_maintenance = $this->input->post('less_maintenance'); $less_break_down_hrs = $this->input->post('less_break_down_hrs'); $total_burner_running_time = $this->input->post('total_burner_running_time'); $total_feeding_hrs = $this->input->post('total_feeding_hrs'); // $gas_consumption_per_hour = $this->input->post('gas_consumption_per_hour'); // $gas_consumption_per_ton = $this->input->post('gas_consumption_per_ton'); // $total_gas_consumption = $this->input->post('total_gas_consumption'); $ed_running_hrs = $this->input->post('ed_running_hrs'); $ed_receipt = $this->input->post('ed_receipt'); $ed_issues = $this->input->post('ed_issues'); $rotatry_input = $this->input->post('rotary_input'); $rotatry_output = $this->input->post('rotatry_output'); $roughsand_receipt = $this->input->post('roughsand_receipt'); $roughsand_issues = $this->input->post('roughsand_issues'); $finesand_receipt = $this->input->post('finesand_receipt'); $finesand_issues = $this->input->post('finesand_issues'); $gastrip_receipt = $this->input->post('gastrip_receipt'); $gastrip_consumption = $this->input->post('gastrip_consumption'); $water_receipt = $this->input->post('water_receipt'); $water_consumpiton = $this->input->post('water_consumpiton'); $diesel_receipt = $this->input->post('diesel_receipt'); $diesel_consumption = $this->input->post('diesel_consumption'); $diesel_running_hrs = $this->input->post('diesel_running_hrs'); $diesel_rotary_receipt = $this->input->post('diesel_rotary_receipt'); $diesel_rotary_consumption = $this->input->post('diesel_rotary_consumption'); $diesel_rotary_running_hrs = $this->input->post('diesel_rotary_running_hrs'); $open_reading = $this->input->post('open_reading'); $close_reading = $this->input->post('close_reading'); $engineers = $this->input->post('engineers'); $operators = $this->input->post('operators'); $helpers = $this->input->post('helpers'); // $breakdown = $this->input->post('breakdown'); // $location = $this->input->post('location'); // $maintenance_description = $this->input->post('maintenance_description'); // $maintenance_reason = $this->input->post('maintenance_reason'); // $maintenance_time_from = $this->input->post('maintenance_time_from'); // $maintenance_time_to = $this->input->post('maintenance_time_to'); // $maintenance_total_hrs = $this->input->post('maintenance_total_hrs'); // $cost_material = $this->input->post('cost_material'); // $cost_labour = $this->input->post('cost_labour'); $remarks = $this->input->post('remarks'); $createdby = $this->session->userdata ( 'userId' ); $createdtime = date('y-m-d'); $approvedby = $this->input->post('approvedby'); $datatostore = array('ddate'=>$ddate,'description'=>$description,'total_trp_running_hrs'=>$trp_running_hrs,'less_feeding_start'=>$feeding_start,'less_maintenance'=>$less_maintenance,'less_break_down_hrs'=>$less_break_down_hrs,'total_burner_running_time'=>$total_burner_running_time,'total_feeding_hrs'=>$total_feeding_hrs,'ed_running_hrs'=>$ed_running_hrs,'ed_receipt'=>$ed_receipt,'ed_issues'=>$ed_issues,'rotary_input'=>$rotatry_input,'rotary_output'=>$rotatry_output,'trp_roughsand_receipt'=>$roughsand_receipt,'trp_roughsand_issues'=>$roughsand_issues,'trp_finesand_receipt'=>$finesand_receipt,'trp_finesand_issues'=>$finesand_issues,'gas_for_trip_receipt'=>$gastrip_receipt,'gas_for_trip_consumption'=>$gastrip_consumption,'water_receipt'=>$water_receipt,'water_consumption'=>$water_consumpiton,'diesel_receipt'=>$diesel_receipt,'diesel_consumption'=>$diesel_consumption,'diesel_runninig_hrs'=>$diesel_running_hrs,'diesel_dryer_receipt'=>$diesel_rotary_receipt,'diesel_dryer_consumption'=>$diesel_rotary_consumption,'diesel_dryer_runninig_hrs'=>$diesel_rotary_running_hrs,'power_open_reading'=>$open_reading,'power_close_reading'=>$close_reading,'engineers'=>$engineers,'operators'=>$operators,'helpers'=>$helpers,'remarks'=>$remarks,'updatedby'=>$createdby,'approvedby'=>$approvedby); //'gas_consumption_hr'=>$gas_consumption_per_hour,'gas_consumption_ton'=>$gas_consumption_per_ton,'total_gas_consumption'=>$total_gas_consumption,'maintenance_breakdown'=>$breakdown,'maintenance_location'=>$location,'maintenance_description'=>$maintenance_description,'maintenance_reason'=>$maintenance_reason,'maintenance_from_hrs'=>$maintenance_time_from,'maintenance_to_hrs'=>$maintenance_time_to,'maintenance_total_hrs'=>$maintenance_total_hrs,'cost_material'=>$cost_material,'cost_labour'=>$cost_labour, //print_r($datatostore); $res = $this->batchcard_model->updateDailyBatchCardData($datatostore,$did); if($res == 1) { echo ""; } else { echo ""; } } function saveAbstractReport() { //echo "working"; $overalltotal = 0; $date = $this->input->post('param1'); $cur_day = date('Y-m',strtotime($date)); //echo $date; $jsondata = $this->input->post('param2'); $phpdata = json_decode($jsondata,TRUE); //print_r($phpdata); //die(); //$isExist = $this->batchcard_model->checkAbstractReport($date); $isExist = $this->batchcard_model->checkAbstractReport($cur_day); $c = $isExist[0]->count; if($c == 0){ foreach($phpdata as $d) { $abstract_report_date = $date; $abstract_details = $d['Particulars']; $running_hrs = $d['Running Hrs']; $per_hr = $d['Per Hour']; $open_stock = $d['Open Stock']; $receipt = $d['Receipt']; $total = $d['Total']; $consumption = $d['Consumption']; $close_stock = $d['Closing Stock']; $physical_stock = $d['Physical Stock']; $difference = $d['Difference']; $createdby = $this->session->userdata ( 'userId' ); $datatostore = array('abstract_report_date'=>$abstract_report_date,'abstract_details'=>$abstract_details,'running_hrs'=>$running_hrs,'per_hr'=>$per_hr,'open_stock'=>$open_stock,'receipt'=>$receipt,'total'=>$total,'consumption'=>$consumption,'close_stock'=>$close_stock,'physical_stock'=>$physical_stock,'difference'=>$difference,'createdby'=>$createdby); $res = $this->batchcard_model->saveAbstractReport($datatostore); $overalltotal += $res; } } else { foreach($phpdata as $d) { $abstract_report_date = $date; $abstract_details = $d['Particulars']; $running_hrs = $d['Running Hrs']; $per_hr = $d['Per Hour']; $open_stock = $d['Open Stock']; $receipt = $d['Receipt']; $total = $d['Total']; $consumption = $d['Consumption']; $close_stock = $d['Closing Stock']; $physical_stock = $d['Physical Stock']; $difference = $d['Difference']; $createdby = $this->session->userdata ( 'userId' ); $datatostore = array('abstract_details'=>$abstract_details,'running_hrs'=>$running_hrs,'per_hr'=>$per_hr,'open_stock'=>$open_stock,'receipt'=>$receipt,'total'=>$total,'consumption'=>$consumption,'close_stock'=>$close_stock,'physical_stock'=>$physical_stock,'difference'=>$difference,'updatedby'=>$createdby); //$res = $this->batchcard_model->updateAbstractReport($datatostore,$date,$abstract_details); $res = $this->batchcard_model->updateAbstractReport($datatostore,$cur_day,$abstract_details); $overalltotal += $res; } } echo $overalltotal.' - Details Saved Successfully..!'; } function getPreviousMonthAbstractDetails() { $month = $this->input->post('param1'); $year = $this->input->post('param2'); $currmonthyear = date('Y-m',strtotime($this->input->post('param3'))); $isExist = $this->batchcard_model->checkAbstractReport($currmonthyear); $c = $isExist[0]->count; if($c == 0){//echo " for closestock"; $res = $this->batchcard_model->getPreviousMonthAbstractDetails($month,$year); echo json_encode($res); } else{ //echo " for openstock"; $arr = $this->batchcard_model->getMonthAbstractDetails($currmonthyear); echo json_encode($arr); } } function getMonthAbstractDetails(){ $month = $this->input->post('param1'); $year = $this->input->post('param2'); $arr = $this->batchcard_model->getMonthAbstractDetails($month,$year); echo json_encode($arr); } function getStockDetails() { //echo "hi"; if(!empty($this->input->post('fromdate')) && $this->input->post('stockname')) { $sn = $this->input->post('stockname'); $snforview = $sn; $fd = $this->input->post('fromdate'); $fm = date_format(date_create($fd),'m'); $fy = date_format(date_create($fd),'Y'); $string = $fy.$fm.'01'.'last month'; $py = date_format(date_create($string),'Y-m'); $py = explode('-',$py); // echo 'CURRENT'.$fm.'-'.$fy.'
'; // echo 'PREVOIUS'.$py[0].'-'.$py[1].'
'; // echo $sn; switch($sn) { case 1: $sn = '(sum(ed_receipt) - sum(ed_issues)) as lastmonthclosinged'; $sd1 = 'ed_receipt'; $sd2 = 'ed_issues'; break; case 2: $sn = '(sum(rotary_input) - sum(rotary_output)) as lastmonthclosingrotary'; $sd1 = 'rotary_input as ed_receipt'; $sd2 = 'rotary_output as ed_issues'; break; case 3: $sn = '(sum(diesel_dryer_receipt) - sum(diesel_dryer_consumption)) as lastmonthclosingdryerdiesel'; $sd1 = 'diesel_dryer_receipt as ed_receipt'; $sd2 = 'diesel_dryer_consumption as ed_issues'; break; case 4: $sn = '(sum(diesel_receipt) - sum(diesel_consumption)) as lastmonthclosingbull'; $sd1 = 'diesel_receipt as ed_receipt'; $sd2 = 'diesel_consumption as ed_issues'; break; case 5: $sn = '(sum(trp_roughsand_receipt) - sum(trp_roughsand_issues)) as lastmonthclosingrough'; $sd1 = 'trp_roughsand_receipt as ed_receipt'; $sd2 = 'trp_roughsand_issues as ed_issues'; break; case 6: $sn = '(sum(trp_finesand_receipt) - sum(trp_finesand_issues)) as lastmonthclosingfine'; $sd1 = 'trp_finesand_receipt as ed_receipt'; $sd2 = 'trp_finesand_issues as ed_issues'; break; case 7: $sn = '(sum(gas_for_trip_receipt) - sum(gas_for_trip_consumption)) as lastmonthclosinggas'; $sd1 = 'gas_for_trip_receipt as ed_receipt'; $sd2 = 'gas_for_trip_consumption as ed_issues'; break; case 8: $sn = '(sum(water_receipt) - sum(water_consumption)) as lastmonthclosingewater'; $sd1 = 'water_receipt as ed_receipt'; $sd2 = 'water_consumption as ed_issues'; break; } $data['previousmonthclosingstock'] = $this->batchcard_model->getPreviousMonthClosedStockDetails($py[0],$py[1],$sn); //print_r($data['previousmonthclosingstock']);echo '
';die(); $data['currentmonthstockdetails'] = $this->batchcard_model->currentMonthStockDetails($fm,$fy,$sd1,$sd2); $data['selmonth'] = $fd; $data['selstockvalue'] = $snforview; //print_r($data['currentmonthstockdetails']);echo '
';die(); } else { } $this->global['pageTitle'] = 'Siddharth : Stock Details'; $this->loadViews("batchcard_stockdetails", $this->global,$data,NULL); } function getMaintenancesDetails(){ $date = $this->input->post('id1'); // echo $date; // die(); $arraydata = $this->batchcard_model->maintenancesdata($date); if(count($arraydata) != 0){ echo json_encode($arraydata);} } function getMaintListing(){ if ($this->input->post('btn_submit')) { $fdate = $this->input->post('from_date'); $tdate = $this->input->post('to_date'); $type = $this->input->post('mySelect'); } $data['MaintListing'] = $this->batchcard_model->getmaint_dtl( $fdate,$tdate, $type ); $this->global['pageTitle'] = 'Siddharth : Maintenance/Breakdown Listing'; $this->loadViews("BatchcardMaintListing", $this->global,$data,NULL); } function addMaint(){ $data['emplist'] = $this->batchcard_model->getEmplistforReport(); $data['supplist'] = $this->batchcard_model->getSupplierlist(); $data['MachineList'] = $this->batchcard_model->getmachine_codename(); $this->global['pageTitle'] = 'Siddharth : Add Maintenance/Breakdown'; $this->loadViews("BatchcardMaintAdd", $this->global,$data,NULL); } function editMaint(){ $MntID = base64_decode(urldecode($this->uri->segment(3))); $data['emplist'] = $this->batchcard_model->getEmplistforReport(); $data['MachineList'] = $this->batchcard_model->getmachine_codename(); $data['supplist'] = $this->batchcard_model->getSupplierlist(); $data['MaintEdit'] = $this->batchcard_model->getmaint_dtl_MntID($MntID); $data['MaintFileEdit'] = $this->batchcard_model->getfiledetails($MntID); //print_r($data); $this->global['pageTitle'] = 'Siddharth : Edit Maintenance/Breakdown'; $this->loadViews("BatchcardMaintEdit", $this->global,$data,NULL); } function addmntbr(){ $type = $this->input->post('radiobtn'); //$maintenance_date = $this->input->post('maintenance_date'); $machinecode = $this->input->post('machine'); if($type == '0'){ $maintenance_subtype = $this->input->post('maintenance_subtype'); if($maintenance_subtype == '1'){ $supplier = $this->input->post('supplier'); } else{ $supplier = NULL; } } else{ $maintenance_subtype = NULL;$supplier = NULL; } //$maintenance_time= $this->input->post('maintenance_time'); $location = $this->input->post('location'); $maintenance_description = $this->input->post('maintenance_description'); $maintenance_reason = $this->input->post('maintenance_reason'); // $maintenance_time_from = $this->input->post('maintenance_time_from'); // $maintenance_time_to = $this->input->post('maintenance_time_to'); $maintenance_date_time = $this->input->post('maintenance_date_time'); $maintenance_date_time = explode(" - ",$maintenance_date_time); $maintenance_time_from = $maintenance_date_time[0]; $maintenance_time_to = $maintenance_date_time[1]; $maintenance_total_hrs = $this->input->post('maintenance_total_hrs'); $cost_material = $this->input->post('cost_material'); $cost_labour = $this->input->post('cost_labour'); $createdby = $this->session->userdata ( 'userId' ); $approvedby = $this->input->post('approvedby'); $workdoneby = $this->input->post('workdoneby'); $addmntbr = array('Type'=>$type,'Machine_Code'=>$machinecode,'Maint_Subtype'=>$maintenance_subtype, 'Maint_Supplier'=>$supplier,'Maint_Location'=>$location, 'Maint_Description'=>$maintenance_description, 'Maint_Reason'=>$maintenance_reason, 'Maint_Time_from'=>$maintenance_time_from, 'Maint_Time_to'=>$maintenance_time_to, 'Maint_Total_hrs'=>$maintenance_total_hrs, 'Cost_Material'=>$cost_material, 'Cost_Labour'=>$cost_labour,'WorkDone_By'=>$workdoneby,'Approved_By'=>$approvedby,'CreatedBy'=>$createdby); //'Maint_Date'=>$maintenance_date,'Maint_Time'=>$maintenance_time, //print_r($addmntbr); //die(); $added = $this->batchcard_model->addmaint_dtl($addmntbr); $maint_id = ''; if(count($added)>0) { foreach ($added as $key ) { $maint_id=$key->Maint_ID; } } $count = $this->input->post('hidecounter'); $constant = $this->input->post('hideconstant'); for($i=1;$i<=$constant;$i++){ $pathname = 'browseFiles'.$i; if(!empty($_FILES[$pathname]['name'])) { $varname = 'filename'.$i; $temp = $this->input->post($varname); $Picture = $this->add($pathname); $arr[] = array($temp,$Picture); } } foreach($arr as $ma){ $index = 0; foreach($ma as $key=>$value){ $index++; if($index == 1){ $file_descrpition = $value; } if($index == 2){ $filename = $value; } } $addfilelist = array( 'Machine_code/Maint_id'=>$maint_id, 'File_name'=>$filename, 'Status'=>"1", 'Status_description'=>($type == '0') ? ('Maintenaces related files') : ('Breakdown related files') ); $this->batchcard_model->addfiledetails($addfilelist); //print_r($addfilelist); //die(); } if(count($added)>0) { echo ""; } //print_r($addmntbr); } function editmntbr(){ $type = $this->input->post('radiobtn'); $mntid = $this->input->post('mntid'); $machinecode = $this->input->post('machine'); if($type == '0'){ $maintenance_subtype = $this->input->post('maintenance_subtype'); if($maintenance_subtype == '1'){ $supplier = $this->input->post('supplier'); } else{ $supplier = NULL; } } else{ $maintenance_subtype = NULL; $supplier = NULL; } // $maintenance_date = $this->input->post('maintenance_date'); // $maintenance_time= $this->input->post('maintenance_time'); $location = $this->input->post('location'); $maintenance_description = $this->input->post('maintenance_description'); $maintenance_reason = $this->input->post('maintenance_reason'); // $maintenance_time_from = $this->input->post('maintenance_time_from'); // $maintenance_time_to = $this->input->post('maintenance_time_to'); $maintenance_date_time = $this->input->post('maintenance_date_time'); $maintenance_date_time = explode(" - ",$maintenance_date_time); $maintenance_time_from = $maintenance_date_time[0]; $maintenance_time_to = $maintenance_date_time[1]; $maintenance_total_hrs = $this->input->post('maintenance_total_hrs'); $cost_material = $this->input->post('cost_material'); $cost_labour = $this->input->post('cost_labour'); $updatedby = $this->session->userdata ( 'userId' ); $approvedby = $this->input->post('approvedby'); $workdoneby = $this->input->post('workdoneby'); // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $updatedon = $date->format('d-m-Y H:i:s'); $editmntbr = array('Type'=>$type,'Machine_Code'=>$machinecode,'Maint_Subtype'=>$maintenance_subtype, 'Maint_Supplier'=>$supplier,'Maint_Location'=>$location, 'Maint_Description'=>$maintenance_description, 'Maint_Reason'=>$maintenance_reason, 'Maint_Time_from'=>$maintenance_time_from, 'Maint_Time_to'=>$maintenance_time_to, 'Maint_Total_hrs'=>$maintenance_total_hrs, 'Cost_Material'=>$cost_material, 'Cost_Labour'=>$cost_labour,'WorkDone_By'=>$workdoneby,'Approved_By'=>$approvedby,'UpdatedBy'=>$updatedby); //'Maint_Date'=>$maintenance_date,'Maint_Time'=>$maintenance_time, //print_r($editmntbr); //die(); // echo $type; // echo $mntid; // die(); $updated = $this->batchcard_model->updatemaint_dtl($editmntbr,$mntid); $count = $this->input->post('hidecounter'); $constant = $this->input->post('hideconstant'); for($i=1;$i<=$constant;$i++){ $pathname = 'browseFiles'.$i; if(!empty($_FILES[$pathname]['name'])) { $varname = 'filename'.$i; $temp = $this->input->post($varname); $Picture = $this->add($pathname); $arr[] = array($temp,$Picture); } } foreach($arr as $ma){ $index = 0; foreach($ma as $key=>$value){ $index++; if($index == 1){ $file_descrpition = $value; } if($index == 2){ $filename = $value; } } $addfilelist = array( 'Machine_code/Maint_id'=>$mntid, 'File_name'=>$filename, 'Status'=>"1", 'Status_description'=>($type == '0') ? ('Maintenaces files') : ('Breakdown files') ); $this->batchcard_model->addfiledetails($addfilelist); //$updatefilelist= array_filter(array_map('array_filter',$updatefilelist )); } if($updated >= 0) { echo ""; } } function getHistListing() { $data['HistListing'] = $this->batchcard_model->getHist_mstr(); $this->global['pageTitle'] = 'Siddharth : Machine Master/History Listing'; $this->loadViews("BatchcardHistListing", $this->global,$data,NULL); } function getPODtls(){ $pono = $this->input->post('id'); $podtls = $this->batchcard_model->getpo_dtls($pono); echo json_encode($podtls); } function addHist(){ $data['HistDeptList'] = $this->batchcard_model->getdept_dtls(); $data['HistPONOList'] = $this->batchcard_model->getpono(); $this->global['pageTitle'] = 'Siddharth : Add Machine Master/History '; $this->loadViews("BatchcardHistAdd", $this->global,$data,NULL); } function autocomplete() { $mc = $this->input->get('query'); $query= $this->batchcard_model->checkMachineCategory($mc); echo json_encode($query); } function add($pathname) { // echo "add files"; // die(); // echo $pathname; $picture = ''; if(!empty($_FILES[$pathname]['name'])) { $config['upload_path'] = 'uploads/images/'; $config['allowed_types'] = '*'; //$config['allowed_types'] = 'jpg|jpeg|png|gif'; $config['file_name'] = $_FILES[$pathname]['name']; //print_r($config); //Load upload library and initialize configuration $this->load->library('upload',$config); $this->upload->initialize($config); if($this->upload->do_upload($pathname)) { $uploadData = $this->upload->data(); $picture = $uploadData['file_name']; } else { $error = array('error' => $this->upload->display_errors()); $picture = ''; } } else { $picture = ''; } return $picture ; } function addHist_mstr(){ $machinename= $this->input->post('mach_name'); $make= $this->input->post('tomake'); $capacity= $this->input->post('machs_capacity'); $category= strtoupper($this->input->post('machs_category')); $categoryarray = $this->batchcard_model->getmachineCategory(); foreach($categoryarray as $mc){ $TempArr[] = $mc->ConfigValue; } if (in_array($category, $TempArr)){} else { $configcode = 'C028'; $config = array('Config_ID'=>$configcode,'ConfigValue'=>$category); $query= $this->batchcard_model->insertvalueintoconfig($config); } $dept= $this->input->post('machs_dept'); $location= $this->input->post('machs_locn'); $PONO= $this->input->post('machs_pono'); $POdate= $this->input->post('machs_podate'); $supplier = $this->input->post('machs_supplier'); $instalizationdate= $this->input->post('install_date'); $machineslifetime = $this->input->post('machs_lifetime'); $commencementdate = $this->input->post('machs_comm_date'); $createdby = $this->session->userdata ('userId'); $add = array( 'Machine_Name' => $machinename, 'Machines_Make' => $make, 'Machines_Capacity' => $capacity, 'Machines_Category' => $category, 'Machines_Dept' => $dept, 'Factory_Loc' => $location, 'Machines_PONO' => $PONO, 'Machines_POdate' => $POdate, 'Machines_Supplier' => $supplier , 'Instalization_Date' => $instalizationdate, 'Machines_Lifetime' => $machineslifetime , 'Commencement_Date' => $commencementdate , 'CreatedBy' => $createdby); $addedmaster = $this->batchcard_model->addhist_mstr($add); $mach_code = ''; if(count($addedmaster)>0) { foreach ($addedmaster as $key ) { $mach_code=$key->Machine_Code; } } $count = $this->input->post('hidecounter'); $constant = $this->input->post('hideconstant'); for($i=1;$i<=$constant;$i++){ $pathname = 'browseFiles'.$i; if(!empty($_FILES[$pathname]['name'])) { $varname = 'filename'.$i; $temp = $this->input->post($varname); $Picture = $this->add($pathname); $arr[] = array($temp,$Picture); } } foreach($arr as $ma){ $index = 0; foreach($ma as $key=>$value){ $index++; if($index == 1){ $file_descrpition = $value; } if($index == 2){ $filename = $value; } } $addfilelist = array( 'Machine_code/Maint_id'=>$mach_code, 'File_name'=>$filename, 'Status'=>"0", 'Status_description'=>"Machine file" ); $this->batchcard_model->addfiledetails($addfilelist); //print_r($addfilelist); //die(); } $range = $this->input->post('machs_range'); $operatingrange = $this->input->post('machs_operating_range'); $leastcount = $this->input->post('machs_least_count'); $calibrationagency = $this->input->post('machs_calibration_agency'); $Calibrationon = $this->input->post('machs_calibration_on'); $Calibrationdue = $this->input->post('machs_calibration_due'); if($category == 'LAB'){ $Acctcriteria = $this->input->post('machs_acceptence_criteria'); } else{ $Acctcriteria = NULL; } $addchild = array( 'Machine_Code' => $mach_code, 'Machine_Name'=> $machinename, 'Range' => $range, 'Operating_Range' => $operatingrange, 'Least_Count' => $leastcount, 'Calibration_Agency' => $calibrationagency, 'Calibration_On' => $Calibrationon, 'Calibration_Due' => $Calibrationdue, 'Acceptence_Criteria'=> $Acctcriteria ); $addedchild = $this->batchcard_model->addhist_dtl($addchild); echo ""; } function editHist(){ //echo 'i am a edit function'; //$MachineCode = $_GET['Machcode']; $MachineCode = base64_decode(urldecode($this->uri->segment(3))); //echo $MachineCode; $data['TableDatas'] = $this->batchcard_model->getHist_tbls($MachineCode); $data['HistMstrEdit'] = $this->batchcard_model->getHist_mstr($MachineCode); $data['HistDtlsEdit'] = $this->batchcard_model->getHist_dtls($MachineCode); $data['HistFileEdit'] = $this->batchcard_model->getfiledetails($MachineCode); $data['HistDeptList'] = $this->batchcard_model->getdept_dtls(); $data['HistPONOList'] = $this->batchcard_model->getpono(); //echo count($data['HistFileEdit']); //echo "
"; //echo sizeof($data['HistFileEdit']); $this->global['pageTitle'] = 'Siddharth : Edit Machine Master/History '; $this->loadViews("BatchcardHistEdit", $this->global,$data,NULL); } function Removefiledetails(){ $id = $this->input->post('id'); $name = $this->input->post('name'); $deletedata = $this->batchcard_model->deletefiledetails($id,$name); echo $deletedata; } function editHist_mstr(){ $code_and_name= $this->input->post('mach_name'); $machcn = explode("-",$code_and_name); //$machinename = $machcn[1]; $machinecode = $machcn[0]; $make= $this->input->post('tomake'); $capacity= $this->input->post('machs_capacity'); $category= strtoupper($this->input->post('machs_category')); $categoryarray = $this->batchcard_model->getmachineCategory(); foreach($categoryarray as $mc){ $TempArr[] = $mc->ConfigValue; } if (in_array($category, $TempArr)){} else { $configcode = 'C028'; $config = array('Config_ID'=>$configcode,'ConfigValue'=>$category); $query= $this->batchcard_model->insertvalueintoconfig($config); } $dept= $this->input->post('machs_dept'); $location= $this->input->post('machs_locn'); $PONO= $this->input->post('machs_pono'); $POdate= $this->input->post('machs_podate'); $supplier = $this->input->post('machs_supplier'); $instalizationdate= $this->input->post('install_date'); $machineslifetime = $this->input->post('machs_lifetime'); $commencementdate = $this->input->post('machs_comm_date'); $updatedby = $this->session->userdata ('userId'); $update = array( //'Machine_Name' => $machinename, 'Machines_Make' => $make, 'Machines_Capacity' => $capacity, 'Machines_Category' => $category, 'Machines_Dept' => $dept, 'Factory_Loc' => $location, 'Machines_PONO' => $PONO, 'Machines_POdate' => $POdate, 'Machines_Supplier' => $supplier , 'Instalization_Date' => $instalizationdate, 'Machines_Lifetime' => $machineslifetime , 'Commencement_Date' => $commencementdate , 'UpdatedBy' => $updatedby); $updatedmaster = $this->batchcard_model->edithist_mstr($update,$machinecode); $range = $this->input->post('machs_range'); $operatingrange = $this->input->post('machs_operating_range'); $leastcount = $this->input->post('machs_least_count'); $calibrationagency = $this->input->post('machs_calibration_agency'); $Calibrationon = $this->input->post('machs_calibration_on'); $Calibrationdue = $this->input->post('machs_calibration_due'); if($category == 'LAB'){ $Acctcriteria = $this->input->post('machs_acceptence_criteria'); } else{ $Acctcriteria = NULL; } $updatechild = array( //'Machine_Code' => $machinecode, //'Machine_Name'=> $machinename, 'Range' => $range, 'Operating_Range' => $operatingrange, 'Least_Count' => $leastcount, 'Calibration_Agency' => $calibrationagency, 'Calibration_On' => $Calibrationon, 'Calibration_Due' => $Calibrationdue, 'Acceptence_Criteria'=> $Acctcriteria ); //print_r($updatechild); //die(); $updatedchild = $this->batchcard_model->edithist_dtl($updatechild,$machinecode); $count = $this->input->post('hidecounter'); $constant = $this->input->post('hideconstant'); for($i=1;$i<=$constant;$i++){ $pathname = 'browseFiles'.$i; if(!empty($_FILES[$pathname]['name'])) { $varname = 'filename'.$i; $temp = $this->input->post($varname); $Picture = $this->add($pathname); $arr[] = array($temp,$Picture); } } foreach($arr as $ma){ $index = 0; foreach($ma as $key=>$value){ $index++; if($index == 1){ $file_descrpition = $value; } if($index == 2){ $filename = $value; } } $addfilelist = array( 'Machine_code/Maint_id'=>$machinecode, 'File_name'=>$filename, 'Status'=>"0", 'Status_description'=>"Machine File" ); $this->batchcard_model->addfiledetails($addfilelist); //$updatefilelist= array_filter(array_map('array_filter',$updatefilelist )); } echo ""; //echo ""; } function FinalProductCalculation() { $data['inv_final_product'] = $this->batchcard_model->getinvoice_products(); $data['consumable_material']= $this->batchcard_model->get_consumablematerials(); $data['Raw_material'] = $this->batchcard_model->get_rawmaterials(); $data['Pack_material'] = $this->batchcard_model->get_packmaterials(); $data['rawsupplier'] = $this->batchcard_model->Rawsupplier(); $data['consusupplier'] = $this->batchcard_model->Consupplier(); $data['packsupplier'] = $this->batchcard_model->Pacsupplier(); $data['stock_value'] = $this->batchcard_model->getStockValue(); $data['Records'] = $this->rawmaterialdetails_model->reOrderListing(); $data['productprices'] = $this->batchcard_model->getSalesProductvalue(); $data['reclaation'] = $this->batchcard_model->GetReclamationMaterial(); //echo count($data['rawsupplier']);die(); $this->global['pageTitle'] = 'Siddharth : Finished Product Batch Card'; $this->loadViews("FinalProduct", $this->global,$data,NULL); } function EditFinalProduct() { $FPId = $_GET['FPId']; $data['check'] = $_GET['check']; $data['masterproduct'] = $this->batchcard_model->getmasterProductDetails($FPId); $data['rawmaterial'] = $this->batchcard_model->getrawmaterialDetails($FPId); $data['consumaterial'] = $this->batchcard_model->getconsumaterialDetails($FPId); $data['packagematerial'] = $this->batchcard_model->getpackagematerialDetails($FPId); $data['coproductmaterial'] = $this->batchcard_model->getcoproductmaterial($FPId); $data['inv_final_product'] = $this->batchcard_model->getinvoice_products(); $data['consumable_material']= $this->batchcard_model->get_consumablematerials(); $data['Raw_material'] = $this->batchcard_model->get_rawmaterials(); $data['Pack_material'] = $this->batchcard_model->get_packmaterials(); $data['supplier'] = $this->batchcard_model->getSupplierlist(); $data['stock_value'] = $this->batchcard_model->getStockValue(); $data['reclaation'] = $this->batchcard_model->GetReclamationMaterial(); $data['Records'] = $this->rawmaterialdetails_model->reOrderListing(); $data['rawsupplier'] = $this->batchcard_model->Rawsupplier(); $data['consusupplier'] = $this->batchcard_model->Consupplier(); $data['packsupplier'] = $this->batchcard_model->Pacsupplier(); $this->global['pageTitle'] = 'Siddharth : Finished Product Batch Card'; $this->loadViews("editFinalProduct", $this->global,$data,NULL); // $this->loadViews("finaledit", $this->global,$data,NULL); } function FinalProductlisting() { $data['final_product'] = $this->batchcard_model->getFinalProductDetaisl(); $this->global['pageTitle'] = 'Siddharth : Finished Product Batch Card Listing'; $this->loadViews("FinalProductlisting", $this->global,$data,NULL); } function FinalProductHistory() { $data['inv_final_product'] = $this->batchcard_model->getinvoice_products(); $this->global['pageTitle'] = 'Siddharth : Finished Product Batch Card History'; $this->loadViews("FinalProductHistory", $this->global,$data,NULL); } function MaterailAdjustment() { $data['MaterialCode'] = $this->batchcard_model->getMaterial(); $data['Supplier'] = $this->batchcard_model->getSupplierlist(); $data['stock_value'] = $this->batchcard_model->getStockValue(); $this->global['pageTitle'] = 'Siddharth : Material Adjustment'; $this->loadViews("materialadjustment", $this->global,$data,NULL); } function MaterailAdjustmentlist() { $data['materailAdjustmentlist'] = $this->batchcard_model->getAllMaterialAdjustments(); $this->global['pageTitle'] = 'Siddharth : Material Adjustment'; $this->loadViews("materialadjustmentlist", $this->global,$data,NULL); } function getQuantity() { $MaterialCode = $this->input->post('materialcode'); $date = $this->input->post('date'); $Supplier = $this->input->post('Supplier'); $netQtyarray = $this->batchcard_model->GetNetQty($MaterialCode,$date,$Supplier); echo json_encode($netQtyarray); //print_r($netQtyarray); // echo $MaterialCode; // echo $date; // echo $Supplier; } function getFinishedProduct() { $starting_date = $this->input->post('from_date'); $end_date = $this->input->post('to_date'); $product_id = $this->input->post('productid'); $productlist = $this->batchcard_model->GetFinishedProductList($starting_date,$end_date,$product_id); $obj=json_encode($productlist); echo $obj; //print_r($productlist); } // function displaying_stockvalues() // { // $MaterialCode = $this->input->post('MaterialCode'); // $date = $this->input->post('date'); // $Qtyarray = $this->batchcard_model->GettotalQty($MaterialCode,$date); // //print_r($Qtyarray); // $obj=json_encode($Qtyarray); // echo $obj; // } function displaying_stockvalues() { $AdjustmentId = $this->input->post('AdjustmentId'); $historydetais = $this->batchcard_model->GetMaterialHistory($AdjustmentId); $SupplierID=''; // if(!empty($historydetais)) // { // foreach($historydetais as $hi) // { // $SupplierID = $hi->SupplierID; // } // } $obj=json_encode($historydetais); echo $obj; } function addNewMaterialHistory() { $supplier = $this->input->post('supplier'); $materialcode = $this->input->post('materialcode'); $date = $this->input->post('date'); $ActualQty = $this->input->post('ActualQty'); $Qty = $this->input->post('AdjustableQty'); $reason = $this->input->post('reason'); $Description = $this->input->post('Description'); $status = $this->input->post('transtatus'); $CreatedBy = $this->session->userdata('userId'); $absaluteQty = abs($Qty); $Isactive=1; // echo $Qty; // echo "abs"; // echo abs($Qty); //die(); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); //echo $dt; // echo $createddt; // die(); $adjustmentaarray = array('MaterialCode'=>$materialcode,'ActualQuantity'=>$ActualQty,'Quantity'=>$absaluteQty,'SupplierID'=>$supplier,'Reason'=>$reason,'Description'=>$Description,'CreatedOn'=>$createddt, 'CreatedBy'=>$CreatedBy,'Isactive'=>$Isactive); $materialadjust = $this->batchcard_model->AddmaterialAdjustment($adjustmentaarray); $adjustId =''; if(!empty($materialadjust)) { foreach($materialadjust as $ig) { $adjustId = $ig->AdjustmentId; } } $historytable = array('SupplierID'=>$supplier,'MaterialCode'=>$materialcode,'Transaction_type'=>$status,'Ref_Type'=>'Adjust','Quantity'=>$absaluteQty,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt,'Ref_No'=>$adjustId,'Isactive'=>$Isactive); $historyadd = $this->batchcard_model->AddMaterialHistory($historytable); $get_pre_qty= $this->inwardgateregister_model->get_CurrentQty($materialcode); $av_qty=0; if(!empty($get_pre_qty)) { foreach($get_pre_qty as $gt) { $av_qty=$gt->Current_stock; } } if($status == 'Add') { $currentav_qty=$av_qty+$absaluteQty; } else if($status == 'Reduce') { $currentav_qty=$av_qty-$absaluteQty; } $current_qty= array('Current_stock'=>$currentav_qty); $this->inwardgateregister_model->addmaterialmaster($current_qty,$materialcode); if((count($materialadjust)>0) &&(count($historyadd))) { echo "Material Details Added Successfully"; } else { echo "Something Went Wrong,Please Try Again"; } } function Final_Product_Save() { $final_product = $this->input->post('DEPTFN'); $final_qty = $this->input->post('Quantity'); $product_date = $this->input->post('Date'); //$pdt = $product_date->format('Y-m-d'); $pdt = date("Y-m-d", strtotime($product_date)); $product_value = $this->input->post('values'); $createdby = $this->session->userdata('userId'); $final_master =array('MaterialCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'CreatedBy'=>$createdby,'ProductDate'=>$pdt,'ProductType'=>'Inward'); $final_master_save =$this->batchcard_model->insert_final_product($final_master); //$final_product_id= $final_master_save[0]['PId']; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); if(!empty($final_master_save)) { foreach($final_master_save as $pm) { $final_product_id = $pm->PId; } } $final_history= array('RefID'=>$final_product_id,'ProductCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'Transactiondate'=>$createddt,'TransactionType'=>'Inward'); $final_history_save= $this->batchcard_model->SaveFinalHistory($final_history); $Getmaterial_code = $this->batchcard_model->GetMaterialCode($final_product); $material_code=''; foreach($Getmaterial_code as $mas) { $material_code = $mas->MaterialCode; } $finalproducthistory= array('MaterialCode'=>$material_code,'Transaction_type'=>'Add','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'Quantity'=>$final_qty,'ItemValue'=>$product_value,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt); $this->batchcard_model->save_rawmaterialto_materialHistory($finalproducthistory); $rawilne = $this->input->post('RawRow'); $consuline = $this->input->post('ConsuRow'); $packline = $this->input->post('PkgRow'); $coproline = $this->input->post('CopRow'); //echo $coproline; for($i=1;$i<=$rawilne;$i++) { $rawmaterial = $this->input->post('rawmaterialcode'.$i); $rawsupplier =$this->input->post('rawSupplierID'.$i); $rawqty = $this->input->post('rawQty'.$i); $rawvalue = $this->input->post('rawprice'.$i); $rawarray =array('FPId'=>$final_product_id,'MaterialCode'=>$rawmaterial,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'Price'=>$rawvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); $rawmaterialhistory= array('MaterialCode'=>$rawmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'ItemValue'=>$rawvalue,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); $this->batchcard_model->save_rawmaterialto_materialHistory($rawmaterialhistory); $rawget_pre_qty= $this->inwardgateregister_model->get_CurrentQty($rawmaterial); $av_qty=0; if(!empty($rawget_pre_qty)) { foreach($rawget_pre_qty as $gt) { $av_qty=$gt->Current_stock; } } $currentav_qty=$av_qty-$rawqty; $current_qty= array('Current_stock'=>$currentav_qty); $this->inwardgateregister_model->addmaterialmaster($current_qty,$rawmaterial); //print_r($rawarray); $this->batchcard_model->save_finalraw($rawarray); } for($i=1;$i<=$consuline;$i++) { $conmaterial = $this->input->post('consumematerialcode'.$i); $consupplier =$this->input->post('consumeSupplierID'.$i); $conqty = $this->input->post('consumeQty'.$i); $convalue = $this->input->post('consumeprice'.$i); $conarray =array('FPId'=>$final_product_id,'MaterialCode'=>$conmaterial,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'Price'=>$convalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); $consuhistory= array('MaterialCode'=>$conmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'ItemValue'=>$convalue,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); $this->batchcard_model->save_rawmaterialto_materialHistory($consuhistory); $conget_pre_qty= $this->inwardgateregister_model->get_CurrentQty($conmaterial); $conav_qty=0; if(!empty($conget_pre_qty)) { foreach($conget_pre_qty as $gt) { $conav_qty=$gt->Current_stock; } } $concurrentav_qty=$conav_qty-$conqty; $concurrent_qty= array('Current_stock'=>$concurrentav_qty); $this->inwardgateregister_model->addmaterialmaster($concurrent_qty,$conmaterial); $this->batchcard_model->save_finalcon($conarray); } for($i=1;$i<=$packline;$i++) { $packmaterial = $this->input->post('packmaterialcode'.$i); $packsupplier =$this->input->post('packSupplierID'.$i); $packqty = $this->input->post('packQty'.$i); $packvalue = $this->input->post('packprice'.$i); $packarray =array('FPId'=>$final_product_id,'MaterialCode'=>$packmaterial,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'Price'=>$packvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); $packmathistory= array('MaterialCode'=>$packmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'ItemValue'=>$packvalue,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); $this->batchcard_model->save_rawmaterialto_materialHistory($packmathistory); $pacget_pre_qty= $this->inwardgateregister_model->get_CurrentQty($packmaterial); $pacav_qty=0; if(!empty($pacget_pre_qty)) { foreach($pacget_pre_qty as $gt) { $pacav_qty=$gt->Current_stock; } } $paccurrentav_qty=$pacav_qty-$packqty; $paccurrent_qty= array('Current_stock'=>$paccurrentav_qty); $this->inwardgateregister_model->addmaterialmaster($paccurrent_qty,$packmaterial); $this->batchcard_model->save_finalpacking($packarray); } for($i=1;$i<=$coproline;$i++) { $copmaterial = $this->input->post('Copmaterialcode'.$i); $codate =$this->input->post('CopDate'.$i); $copqty = $this->input->post('CopQty'.$i); $copvalue = $this->input->post('Copprice'.$i); $coparray =array('FPId'=>$final_product_id,'MaterialCode'=>$copmaterial,'CoDate'=>$codate,'Quantity'=>$copqty,'Price'=>$copvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); // print_r($coparray); $this->batchcard_model->save_finalcoproduct($coparray); $copfinal_history = array('RefID'=>$final_product_id,'ProductCode'=>$copmaterial,'Quantity'=>$copqty,'Price'=>$copvalue,'Transactiondate'=>$createddt,'TransactionType'=>'Inward'); $Getmaterial_code = $this->batchcard_model->GetMaterialCode($copmaterial); $material_code=''; foreach($Getmaterial_code as $mas) { $material_code = $mas->MaterialCode; } $copproducthistory= array('MaterialCode'=>$material_code,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'Quantity'=>$copqty,'ItemValue'=>$copvalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt); $this->batchcard_model->save_rawmaterialto_materialHistory($copproducthistory); //$final_cophistory_save= $this->batchcard_model->SaveFinalHistory($copfinal_history); } echo "Details Saved Successfully"; } function UpdateFinal_Product_Save() { $FPID = $this->input->post('FPId'); $final_product = $this->input->post('DEPTFN'); $final_qty = $this->input->post('Quantity'); $product_date = $this->input->post('Date'); //$pdt = $product_date->format('Y-m-d H:i:s'); //$pdt = date("Y-m-d", strtotime($product_date)); $product_value = $this->input->post('values'); $createdby = $this->session->userdata('userId'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $final_master =array('MaterialCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'CreatedBy'=>$createdby,'ProductDate'=>$product_date); // / print_r($final_master); $final_master_save =$this->batchcard_model->update_final_product($final_master,$FPID); $lastId=''; $final_history= array('ProductCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'Transactiondate'=>$createddt,'TransactionType'=>'Inward'); //print_r($final_history); //die(); $finalHistoryupdate = $this->batchcard_model->UpdateFinalHistory($final_history,$FPID,$final_product); $Getmaterial_code = $this->batchcard_model->GetMaterialCode($final_product); $material_code=''; foreach($Getmaterial_code as $mas) { $material_code = $mas->MaterialCode; } $FPhistory= array('MaterialCode'=>$material_code,'Transaction_type'=>'Add','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'Quantity'=>$final_qty,'ItemValue'=>$product_value,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt); $this->batchcard_model->update_rawmaterialto_materialHistory($FPhistory,$material_code,$FPID); $rawilne = $this->input->post('RawRow'); $consuline = $this->input->post('ConsuRow'); $packline = $this->input->post('PkgRow'); $coproline = $this->input->post('CopRow'); for($i=1;$i<=$rawilne;$i++) { $rawmaterial = $this->input->post('rawmaterialcode'.$i); $rawsupplier =$this->input->post('rawSupplierID'.$i); $rawqty = $this->input->post('rawQty'.$i); $rawvalue = $this->input->post('rawprice'.$i); $rawilneno = $this->input->post('RawId'.$i); $beforawqty = $this->input->post('beforerawQty'.$i); // echo $beforawqty; // die(); //echo $rawilneno; if($rawmaterial == '' && $rawsupplier == '' & $rawqty == '') { } else { $rawarray =array('FPId'=>$FPID,'MaterialCode'=>$rawmaterial,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'Price'=>$rawvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); $rawmaterialhistory= array('MaterialCode'=>$rawmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'ItemValue'=>$rawvalue,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); $checkrawid=$this->batchcard_model->GetRawid($rawilneno); $checkrawhistory = $this->batchcard_model->GetRawCheck($rawmaterial,$FPID); $rawget_pre_qty= $this->inwardgateregister_model->get_CurrentQty($rawmaterial); $av_qty=0; if(!empty($rawget_pre_qty)) { foreach($rawget_pre_qty as $gt) { $av_qty=$gt->Current_stock; } } // echo $av_qty; // die(); $qty_dif= $rawqty - $beforawqty; //echo $qty_dif; // if($qty_dif >0) // { // echo 'if'; // $currentav_qty=$av_qty+$qty_dif; // } // else // { // echo 'else'; $currentav_qty=$av_qty-$qty_dif; // } //echo $currentav_qty; //die(); $current_qty= array('Current_stock'=>$currentav_qty); //print($current_qty); $this->inwardgateregister_model->addmaterialmaster($current_qty,$rawmaterial); if(count($checkrawid)==0) { $this->batchcard_model->save_finalraw($rawarray); $this->batchcard_model->save_rawmaterialto_materialHistory($rawmaterialhistory); } else { $this->batchcard_model->update_finalraw($rawarray,$rawilneno); $this->batchcard_model->update_rawmaterialto_materialHistory($rawmaterialhistory,$rawmaterial,$FPID); //$this->batchcard_model->save_rawmaterialto_materialHistory($rawmaterialhistory); } } } //echo $consuline; for($i=1;$i<=$consuline;$i++) { $conmaterial = $this->input->post('consumematerialcode'.$i); $consupplier =$this->input->post('consumeSupplierID'.$i); $conqty = $this->input->post('consumeQty'.$i); $convalue = $this->input->post('consumeprice'.$i); $consulinee = $this->input->post('Consumable'.$i); $beforeconqty = $this->input->post('beforeconsumeQty'.$i); if($conmaterial == '' && $consupplier == '' & $conqty == '') { } else { $conarray =array('FPId'=>$FPID,'MaterialCode'=>$conmaterial,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'Price'=>$convalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); //echo $consuline; //print_r($conarray); $consuhistory= array('MaterialCode'=>$conmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'ItemValue'=>$convalue,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); $checkconsuid=$this->batchcard_model->Getconsuid($consulinee); $conget_pre_qty= $this->inwardgateregister_model->get_CurrentQty($conmaterial); $conav_qty=0; if(!empty($conget_pre_qty)) { foreach($conget_pre_qty as $gt) { $conav_qty=$gt->Current_stock; } } $conqty_dif= $conqty - $beforeconqty; // if($conqty_dif >0) // { // $concurrentav_qty=$conav_qty+$conqty_dif; // } // else // { $concurrentav_qty=$conav_qty-$conqty_dif; //} // $concurrentav_qty=$conav_qty-$conqty; $concurrent_qty= array('Current_stock'=>$concurrentav_qty); $this->inwardgateregister_model->addmaterialmaster($concurrent_qty,$conmaterial); if(count($checkconsuid)>0) { //echo 'if'; $this->batchcard_model->update_finalconsu($conarray,$consulinee); $this->batchcard_model->update_rawmaterialto_materialHistory($consuhistory,$conmaterial,$FPID); } else { echo 'else'; $this->batchcard_model->save_finalcon($conarray); $this->batchcard_model->save_rawmaterialto_materialHistory($consuhistory); } } } for($i=1;$i<=$packline;$i++) { $packmaterial = $this->input->post('packmaterialcode'.$i); $packsupplier =$this->input->post('packSupplierID'.$i); $packqty = $this->input->post('packQty'.$i); $packvalue = $this->input->post('packprice'.$i); $packlineId = $this->input->post('packId'.$i); $beforepacqty = $this->input->post('beforepackQty'.$i); if($packmaterial == '' && $packsupplier == '' & $packqty == '') { } else{ $packarray =array('FPId'=>$FPID,'MaterialCode'=>$packmaterial,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'Price'=>$packvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); //print_r($packarray); $packmathistory= array('MaterialCode'=>$packmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'ItemValue'=>$packvalue,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); $checkpackid=$this->batchcard_model->Getpackid($packlineId); $pacget_pre_qty= $this->inwardgateregister_model->get_CurrentQty($packmaterial); $pacav_qty=0; if(!empty($pacget_pre_qty)) { foreach($pacget_pre_qty as $gt) { $pacav_qty=$gt->Current_stock; } } $pacqty_dif= $packqty - $beforepacqty; // if($pacqty_dif >0) // { // $paccurrentav_qty=$pacav_qty+$pacqty_dif; // } // else // { $paccurrentav_qty=$pacav_qty-$pacqty_dif; //} // $paccurrentav_qty=$pacav_qty-$packqty; $paccurrent_qty= array('Current_stock'=>$paccurrentav_qty); $this->inwardgateregister_model->addmaterialmaster($paccurrent_qty,$packmaterial); if(count($checkpackid)>0) { $this->batchcard_model->update_finalpacking($packarray,$packlineId); $this->batchcard_model->update_rawmaterialto_materialHistory($packmathistory,$packmaterial,$FPID); } else { $this->batchcard_model->save_rawmaterialto_materialHistory($packmathistory); $this->batchcard_model->save_finalpacking($packarray); } } //echo "Updated"; } for($i=1;$i<=$coproline;$i++) { $copmaterial = $this->input->post('Copmaterialcode'.$i); $codate =$this->input->post('CopDate'.$i); $cddt = date("Y-m-d", strtotime($codate) ); $copqty = $this->input->post('CopQty'.$i); $copvalue = $this->input->post('Copprice'.$i); $coplineId = $this->input->post('CopId'.$i); if($copmaterial == '' && $codate == '' & $copqty == '') { } else { $coparray =array('FPId'=>$FPID,'MaterialCode'=>$copmaterial,'CoDate'=>$cddt,'Quantity'=>$copqty,'Price'=>$copvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt); $checkpackid=$this->batchcard_model->Getcopid($coplineId); // $copfinal_history = array('ProductCode'=>$copmaterial,'Quantity'=>$copqty,'Price'=>$copvalue,'Transactiondate'=>$createddt,'TransactionType'=>'Inward'); $copfinal_history = array('RefID'=>$FPID,'ProductCode'=>$copmaterial,'Quantity'=>$copqty,'Price'=>$copvalue,'Transactiondate'=>$createddt,'TransactionType'=>'Inward'); $Getmaterial_code = $this->batchcard_model->GetMaterialCode($copmaterial); $material_code=''; foreach($Getmaterial_code as $mas) { $material_code = $mas->MaterialCode; } $Cophistory= array('MaterialCode'=>$material_code,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'Quantity'=>$copqty,'ItemValue'=>$copvalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt); // $this->batchcard_model->update_rawmaterialto_materialHistory($FPhistory,$final_product,$FPID); // print_r($coparray); if(count($checkpackid)>0) { $this->batchcard_model->update_finalcoproduct($coparray,$coplineId); $finalHistoryupdate = $this->batchcard_model->UpdateFinalHistory($copfinal_history,$FPID,$copmaterial); $this->batchcard_model->update_rawmaterialto_materialHistory($Cophistory,$material_code,$FPID); } else { $this->batchcard_model->save_finalcoproduct($coparray); $final_cophistory_save= $this->batchcard_model->SaveFinalHistory($copfinal_history); $this->batchcard_model->save_rawmaterialto_materialHistory($Cophistory); } } } echo "Updated Successfully"; } function EditMaterialAdjustment() { $AdjustmentId = $_GET['AdjustmentId']; $Supplier = $_GET['sn']; $date =$_GET['date']; $MaterialCode =$_GET['mc']; $this->global['pageTitle'] = 'Siddharth : Material Adjustment'; $data['netQuantityarray'] = $this->batchcard_model->GetNetQty($MaterialCode,$date,$Supplier); //print_r($data['netQuantityarray']); $data['materailAdjustmentlist'] = $this->batchcard_model->getEditMaterialAdjustments($AdjustmentId); $data['materiallist'] = $this->batchcard_model->getMaterial(); $data['getSupplierlist'] = $this->batchcard_model->getSupplierlist(); $this->loadViews("editmaterialadjustment", $this->global,$data,NULL); //return true; } function material_history() { $this->global['pageTitle'] = 'Siddharth : Material History'; if ($this->input->post('btn_submit')) { $prod = $this->input->post('item_name'); $frm = $this->input->post('from_date'); $t = $this->input->post('to_date'); $data['material']=$this->batchcard_model->getMaterial_history($prod,$frm,$t); } $data['material_name']=$this->batchcard_model->material_name(); $this->loadviews("MaterialHistory",$this->global,$data,NULL); } function UpdateQuantity() { $adjquantity =$this->input->post('adjquantity'); $reason =$this->input->post('reason'); $id = $this->input->post('adid'); //echo $id; $adjustquantity = $this->input->post('editquantity'); $description = $this->input->post('desc'); $updatequantitydes = array('Quantity'=>$adjustquantity,'Description'=>$description,'Reason'=>$reason,'ActualQuantity'=>$adjquantity); //print_r($updatequantitydes); $updatequantity=array('Quantity'=>$adjustquantity); $UpdateQuantityHistory = $this->batchcard_model->updateQuantityStockHistory($updatequantity,$id); $UpdateQuantityAdj = $this->batchcard_model->updateQuantityAdjusment($updatequantitydes,$id); // print_r($updatequantityadj); if((count($updatequantityadj)>0) &&(count($updatequantityhistory))) { echo "Details Added Successfully"; } else { echo "Something Went Wrong,Please Try Again"; } //$this->loadViews("editmaterialadjustment", $this->global,$data,NULL); } function Deletequantity() { $AdjustmentId = $_GET['AdjustmentId']; $Isactive=0; $Updateactive =array('Isactive'=>$Isactive); $this->batchcard_model->updateisactiveadjusment($Updateactive,$AdjustmentId); $this->batchcard_model->updateisactiveastockhistory($Updateactive,$AdjustmentId); $this->loadViews("editmaterialadjustment", $this->global,$data,NULL); } function getAvgPrice() { $MaterialCode = $this->input->post('materialcode'); $date = $this->input->post('date'); $Supplier = $this->input->post('Supplier'); $pricearray = $this->batchcard_model->GetAvgPrice($MaterialCode,$date,$Supplier); echo json_encode($pricearray); } function get_Product_Supplier() { $MaterialCode = $this->input->post('materialcode'); $type = $this->input->post('type'); $supplierlist = $this->batchcard_model->Get_Product_Supplier($MaterialCode,$type); echo json_encode($supplierlist); } function MaterailStockReport() { //$data['materailAdjustmentlist'] = $this->batchcard_model->getAllMaterialAdjustments(); $data['finyear']=$this->batchcard_model->finyear(); if ($this->input->post('btn_submit')) { $search['year'] =$this->input->post('Finyear'); $search['from_date'] = $this->input->post('fdate'); $search['to_date'] = $this->input->post('tdate'); $search['month'] = $this->input->post('month'); $data['getdata'] = $this->batchcard_model->GetStockAbstract($search); $data['field_det'] = $search; //print_r($data['getdata']);die(); } $this->global['pageTitle'] = 'Siddharth : Stock Report'; $this->loadViews("materialStockReport", $this->global,$data,NULL); } function IndividualStockDetails() { //$PONO = $_GET['PONO']; $get['year'] = $_GET['year']; $get['materialcode'] = $_GET['MaterialCode']; $get['month'] = $_GET['month']; $get['fdate'] = $_GET['fromdate']; $get['tdate'] = $_GET['todate']; $get['open'] = $_GET['openingstock']; $get['addition'] = $_GET['Add']; $get['reduce'] = $_GET['Reduce']; $data['finyear']=$this->batchcard_model->finyear(); if($get['tdate'] == '') { $get['tdate']='0'; } else if($get['fdate'] =='') { $get['fdate']='0'; } //die(); $data['getdata'] = $this->batchcard_model->GetStockAbstractdetails($get); $data['field_det'] = $get; $this->global['pageTitle'] = 'Siddharth : Stock Report'; $this->loadViews("individualStockdetails", $this->global,$data,NULL); } function DeleteFinalProduct() { $FPId = $_GET['FPId']; $data['check'] = $_GET['check']; $deletedata =$this->batchcard_model->Delete_ProductBatchCard($FPId); $data['final_product'] = $this->batchcard_model->getFinalProductDetaisl(); $this->global['pageTitle'] = 'Siddharth : Finished Product Batch Card Listing'; $this->loadViews("FinalProductlisting", $this->global,$data,NULL); } } ?>