195 lines
5.4 KiB
PHP
195 lines
5.4 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class batchcard_model extends CI_Model
|
|
{
|
|
|
|
function getEmplistforReport()
|
|
{
|
|
$this->db->select('T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.Departmentcode,T_DepartmentDetails.shortName,');
|
|
$this->db->from('T_Employee_Details');
|
|
$this->db->join('T_DepartmentDetails','T_Employee_Details.Departmentcode=T_DepartmentDetails.DEPCode');
|
|
//$this->db->join('ip_invoice_items','ip_invoices.invoice_number=ip_invoice_items.invoice_number');
|
|
//$this->db->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id');
|
|
//$this->db->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62');
|
|
$this->db->order_by('T_Employee_Details.EmpID');
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
|
|
}
|
|
|
|
function saveHourlyBatchInfo($datatostore)
|
|
{
|
|
$this->db->insert('T_hourly_batch_info',$datatostore);
|
|
$res = $this->db->affected_rows();
|
|
|
|
return $res;
|
|
}
|
|
|
|
function saveDailyBatchCardData($datatostore)
|
|
{
|
|
$this->db->insert('T_daily_batchcard_data',$datatostore);
|
|
$res = $this->db->affected_rows();
|
|
return $res;
|
|
}
|
|
|
|
function updateHourlyBatchInfo($datatostore,$hid)
|
|
{
|
|
$this->db->where('hourlyid',$hid);
|
|
$this->db->update('T_hourly_batch_info',$datatostore);
|
|
$res = $this->db->affected_rows();
|
|
|
|
return $res;
|
|
}
|
|
|
|
function getAllHourlyData($hid='',$from='',$to='')
|
|
{
|
|
//echo "Model".$from.'-'.$to;
|
|
|
|
$this->db->select('T_hourly_batch_info.*,T_Employee_Details.FirstName as F,T_Employee_Details.LastName as L');
|
|
$this->db->from('T_hourly_batch_info');
|
|
$this->db->join('tbl_users','T_hourly_batch_info.checkedby=tbl_users.userId');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID');
|
|
if(!empty($hid))
|
|
{
|
|
$this->db->where('hourlyid',$hid);
|
|
}
|
|
if(!empty($from) && !empty($to))
|
|
{
|
|
$this->db->where('T_hourly_batch_info.report_date <=',$to);
|
|
$this->db->where('T_hourly_batch_info.report_date >=',$from);
|
|
}
|
|
$this->db->order_by('hourlyid','desc');
|
|
$res = $this->db->get();
|
|
//print_r($res->result());die();
|
|
return $res->result();
|
|
}
|
|
|
|
|
|
function checkExistHourlyData($bdate,$btime)
|
|
{
|
|
//echo 'Model'.$bdate.'-'.$btime;
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('T_hourly_batch_info');
|
|
$this->db->where('report_date',$bdate);
|
|
$this->db->where('report_time',$btime);
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
}
|
|
|
|
|
|
function getPowerConsumptionDetails($rdate)
|
|
{
|
|
|
|
$this->db->select('hourlyid,report_time,opening_trp_reading,close_trp_reading,auto_start,auto_stop');
|
|
$this->db->from('T_hourly_batch_info');
|
|
$this->db->where('report_date',$rdate);
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
}
|
|
|
|
function getDailyBatchCardData($month)
|
|
{
|
|
// $this->db->select('*');
|
|
// $this->db->from('T_daily_batchcard_data');
|
|
// $this->db->where('month(ddate)',$month);
|
|
$sql = 'select * from T_daily_batchcard_data where month(ddate) = ?';
|
|
$res = $this->db->query($sql,array($month));
|
|
return $res->result();
|
|
}
|
|
|
|
function getIndividualDailyData($did)
|
|
{
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('T_daily_batchcard_data');
|
|
$this->db->where('dailyid',$did);
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
|
|
}
|
|
|
|
function checkExistDaily($rdate)
|
|
{
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('T_daily_batchcard_data');
|
|
$this->db->where('ddate',$rdate);
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
}
|
|
|
|
function updateDailyBatchCardData($datatostore,$did)
|
|
{
|
|
$this->db->where('dailyid',$did);
|
|
$this->db->update('T_daily_batchcard_data',$datatostore);
|
|
$res = $this->db->affected_rows();
|
|
|
|
return $res;
|
|
}
|
|
|
|
function checkAbstractReport($date)
|
|
{
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('T_abstract_report');
|
|
$this->db->where('abstract_report_date',$date);
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
}
|
|
|
|
function saveAbstractReport($datatostore)
|
|
{
|
|
$this->db->insert('T_abstract_report',$datatostore);
|
|
$res = $this->db->affected_rows();
|
|
return $res;
|
|
}
|
|
|
|
function updateAbstractReport($datatostore,$date,$abstract_details)
|
|
{
|
|
$this->db->where('abstract_report_date',$date);
|
|
$this->db->where('abstract_details',$abstract_details);
|
|
$this->db->update('T_abstract_report',$datatostore);
|
|
$res = $this->db->affected_rows();
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
function getPreviousMonthAbstractDetails($month,$year)
|
|
{
|
|
$sql = "select abstract_details,close_stock 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 getPreviousMonthClosedStockDetails($y,$m,$sn)
|
|
{
|
|
$month = 'month(ddate)';
|
|
$year = 'year(ddate)';
|
|
$this->db->select($sn);
|
|
$this->db->from('T_daily_batchcard_data');
|
|
$this->db->where($month,$m);
|
|
$this->db->where($year,$y);
|
|
$this->db->order_by('ddate','desc');
|
|
$this->db->limit(1);
|
|
$res = $this->db->get();
|
|
//print_r($res->result());
|
|
return $res->result();
|
|
}
|
|
|
|
function currentMonthStockDetails($m,$y,$sd1,$sd2)
|
|
{
|
|
$month = 'month(ddate)';
|
|
$year = 'year(ddate)';
|
|
$list = array('ddate',$sd1,$sd2);
|
|
$this->db->select($list);
|
|
$this->db->from('T_daily_batchcard_data');
|
|
$this->db->where($month,$m);
|
|
$this->db->where($year,$y);
|
|
$this->db->order_by('ddate','asc');
|
|
$res = $this->db->get();
|
|
//print_r($res->result());
|
|
return $res->result();
|
|
}
|
|
}
|
|
|
|
?>
|