From e46ff495318802fc4e88847da4ebe65923d501e5 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Mon, 7 May 2018 17:34:52 +0530 Subject: [PATCH] batchcard stock detail changes --- application/controllers/batchcard.php | 34 ++++++++++++++++---- application/models/batchcard_model.php | 20 +++++++++--- application/views/batchcard_stockdetails.php | 26 +++++++++++++-- application/views/dailyBatchCardListing.php | 25 ++++++++------ 4 files changed, 82 insertions(+), 23 deletions(-) diff --git a/application/controllers/batchcard.php b/application/controllers/batchcard.php index 3016b1a3..ffb71b85 100755 --- a/application/controllers/batchcard.php +++ b/application/controllers/batchcard.php @@ -524,12 +524,14 @@ class batchcard extends BaseController //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($date); + $isExist = $this->batchcard_model->checkAbstractReport($cur_day); $c = $isExist[0]->count; if($c == 0){ foreach($phpdata as $d) @@ -574,7 +576,8 @@ class batchcard extends BaseController $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,$date,$abstract_details); + $res = $this->batchcard_model->updateAbstractReport($datatostore,$cur_day,$abstract_details); $overalltotal += $res; } @@ -589,13 +592,30 @@ class batchcard extends BaseController { $month = $this->input->post('param1'); $year = $this->input->post('param2'); - - $res = $this->batchcard_model->getPreviousMonthAbstractDetails($month,$year); - echo json_encode($res); - + $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() { diff --git a/application/models/batchcard_model.php b/application/models/batchcard_model.php index a4c1e4ef..c21bc292 100755 --- a/application/models/batchcard_model.php +++ b/application/models/batchcard_model.php @@ -133,7 +133,8 @@ class batchcard_model extends CI_Model { $this->db->select('count(*) as count'); $this->db->from('T_abstract_report'); - $this->db->where('abstract_report_date',$date); + //$this->db->where('abstract_report_date',$date); + $this->db->where("date_format(abstract_report_date,'%Y-%m')",$date); $res = $this->db->get(); return $res->result(); } @@ -147,7 +148,8 @@ class batchcard_model extends CI_Model function updateAbstractReport($datatostore,$date,$abstract_details) { - $this->db->where('abstract_report_date',$date); + //$this->db->where('abstract_report_date',$date); + $this->db->where("date_format(abstract_report_date,'%Y-%m')",$date); $this->db->where('abstract_details',$abstract_details); $this->db->update('T_abstract_report',$datatostore); $res = $this->db->affected_rows(); @@ -158,17 +160,27 @@ class batchcard_model extends CI_Model function getPreviousMonthAbstractDetails($month,$year) { - $sql = "select abstract_details,close_stock from T_abstract_report where month(abstract_report_date) =? and year(abstract_report_date) =? "; + //$sql = "select abstract_details,close_stock from T_abstract_report where month(abstract_report_date) =? and year(abstract_report_date) =? "; + $sql = "select abstract_details,close_stock as Available from T_abstract_report where month(abstract_report_date) =? and year(abstract_report_date) =? "; $res = $this->db->query($sql,array($month,$year)); return $res->result(); } + + function getMonthAbstractDetails($month_year) + { + $sql = "select abstract_details,close_stock,open_stock as Available,physical_stock from T_abstract_report where date_format(abstract_report_date,'%Y-%m') = ? "; + $res = $this->db->query($sql,array($month_year)); + + return $res->result(); + } function getPreviousMonthClosedStockDetails($y,$m,$sn) { $month = 'month(ddate)'; $year = 'year(ddate)'; - $this->db->select($sn); + //$this->db->select($sn); + $this->db->select($sn,'ddate'); $this->db->from('T_daily_batchcard_data'); $this->db->where($month,$m); $this->db->where($year,$y); diff --git a/application/views/batchcard_stockdetails.php b/application/views/batchcard_stockdetails.php index 26862cd6..474ed417 100755 --- a/application/views/batchcard_stockdetails.php +++ b/application/views/batchcard_stockdetails.php @@ -1,14 +1,34 @@ '; +// $value = array_keys($data['previousmonthclosingstock']); +// echo $array[$value[0]]; +if(!empty($previousmonthclosingstock)) { - $premonopen = $data['previousmonthclosingstock']; + //print_r($previousmonthclosingstock[0]); + //$value = array_keys($previousmonthclosingstock[0]); + //$premonopen = $previousmonthclosingstock[0]->$value[0]; + foreach($previousmonthclosingstock[0] as $key=>$value){ + //echo $value; + $premonopen = $value; + } + } else { $premonopen = 0; } -;?> +// if(!empty($data['previousmonthclosingstock'])) +// { +// $premonopen = $data['previousmonthclosingstock']; +// } +// else +// { +// $premonopen = 0; +// } +?> diff --git a/application/views/dailyBatchCardListing.php b/application/views/dailyBatchCardListing.php index 7b522053..c55ac922 100755 --- a/application/views/dailyBatchCardListing.php +++ b/application/views/dailyBatchCardListing.php @@ -188,7 +188,7 @@ $currentday = date('d'); color:#000 ! important; text-decoration:underline; } - + } /**/
@@ -1067,8 +1067,13 @@ $(function(){ var currentmonth = $('#month').val(); currentmonth = currentmonth.split("-"); var monthnumber = new Date(Date.parse(currentmonth[0] +" 1, 2018")).getMonth()+1; + var currentyearmonth = currentmonth[1]+'-'+(monthnumber <= 9 ? '0'+monthnumber : monthnumber ); //alert(monthnumber); //alert(currentmonth[1]); + alert(currentyearmonth); + var currmonth = monthnumber; + var curryear = currentmonth[1]; + if(monthnumber == 1) { monthnumber = 12; @@ -1080,7 +1085,7 @@ $(function(){ //alert(currentmonth[1]); $('.content').loader('show'); $.ajax({ - data:{param1:monthnumber,param2:currentmonth[1]}, + data:{param1:monthnumber,param2:currentmonth[1],param3:currentyearmonth}, type:"POST", url:"", success:function(data){ @@ -1099,11 +1104,13 @@ $(function(){ // } if(index < 10) { - //if(index != 7){ - var id = 'OS'+index; - - //document.getElementById(id).textContent = value.close_stock; - //} + if(index != 7){ + var id = 'OS'+index; + //document.getElementById(id).textContent = value.close_stock; + document.getElementById(id).textContent = value.Available; + var PSid = 'PS'+index; + document.getElementById(PSid).textContent = value.physical_stock; + } } }); } @@ -1112,7 +1119,7 @@ $(function(){ } }); - setTimeout(function(){ whileModalShow(); }, 2000); + setTimeout(function(){ whileModalShow(); }, 4000); //ED Details