load->model('batchcard_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,'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('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); $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,'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,'updatedby'=>$createdby,'approvedby'=>$approvedby); //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'); //echo $date; $jsondata = $this->input->post('param2'); $phpdata = json_decode($jsondata,TRUE); //print_r($phpdata); //die(); $isExist = $this->batchcard_model->checkAbstractReport($date); $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); $overalltotal += $res; } } echo $overalltotal.' - Details Saved Successfully..!'; } function getPreviousMonthAbstractDetails() { $month = $this->input->post('param1'); $year = $this->input->post('param2'); $res = $this->batchcard_model->getPreviousMonthAbstractDetails($month,$year); echo json_encode($res); } 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 = '(ed_receipt - ed_issues) as lastmonthclosinged'; $sd1 = 'ed_receipt'; $sd2 = 'ed_issues'; break; case 2: $sn = '(rotary_input - rotary_output) as lastmonthclosingrotary'; $sd1 = 'rotary_input as ed_receipt'; $sd2 = 'rotary_output as ed_issues'; break; case 3: $sn = '(diesel_dryer_receipt - diesel_dryer_consumption) as lastmonthclosingdryerdiesel'; $sd1 = 'diesel_dryer_receipt as ed_receipt'; $sd2 = 'diesel_dryer_consumption as ed_issues'; break; case 4: $sn = '(diesel_receipt - diesel_consumption) as lastmonthclosingbull'; $sd1 = 'diesel_receipt as ed_receipt'; $sd2 = 'diesel_consumption as ed_issues'; break; case 5: $sn = '(trp_roughsand_receipt - trp_roughsand_issues) as lastmonthclosingrough'; $sd1 = 'trp_roughsand_receipt as ed_receipt'; $sd2 = 'trp_roughsand_issues as ed_issues'; break; case 6: $sn = '(trp_finesand_receipt - trp_finesand_issues) as lastmonthclosingfine'; $sd1 = 'trp_finesand_receipt as ed_receipt'; $sd2 = 'trp_finesand_issues as ed_issues'; break; case 7: $sn = '(gas_for_trip_receipt - 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 = '(water_receipt - 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); } } ?>