1994 lines
69 KiB
PHP
1994 lines
69 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class cashbook_model extends CI_Model
|
|
{
|
|
|
|
function getAccounTypes()
|
|
{
|
|
$this->db->where('status',1);
|
|
$r = $this->db->get('t_accountcode');
|
|
return $r->result();
|
|
|
|
}
|
|
function getAccountpay()
|
|
{
|
|
$this->db->where('type',PAYMENT);
|
|
$r = $this->db->get('t_accountcode');
|
|
return $r->result();
|
|
|
|
}
|
|
function getAccounTypes1()
|
|
{
|
|
$this->db->select('name,type');
|
|
$r = $this->db->get('t_accountcode');
|
|
return $r->result();
|
|
|
|
}
|
|
|
|
function saveIncomeExpense($data)
|
|
{
|
|
$this->db->insert('t_income_expense',$data);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
// function addcashbook($bankcash1)
|
|
// {
|
|
// $this->db->insert('T_Bankmappingcashbook',$bankcash1);
|
|
// $r = $this->db->affected_rows();
|
|
// return $r;
|
|
// }
|
|
// function amountpaidcashbook()
|
|
// {
|
|
// $this->db->select('t_accountcode.namea,total,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
// $this->db->from('t_income_expense');
|
|
// $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left');
|
|
// $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left');
|
|
// $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left');
|
|
// $this->db->where('t_income_expense.IsActive',1);
|
|
// $this->db->where('t_income_expense.account_code !=','ADV001');
|
|
// $this->db->group_by('t_income_expense.account_code');
|
|
// // $this->db->order_by("date","desc");
|
|
// $r = $this->db->get();
|
|
// return $r->result();
|
|
|
|
// }
|
|
function getIncomeExpenseList($i="")
|
|
{
|
|
// echo $i;
|
|
$this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left');
|
|
$this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left');
|
|
$this->db->where('t_income_expense.IsActive',1);
|
|
$this->db->where('t_income_expense.account_code !=','ADV001');
|
|
$this->db->order_by("date","desc");
|
|
if(!empty($i))
|
|
{
|
|
$this->db->where('t_income_expense.id',$i);
|
|
|
|
}
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
function getIncomeExpense($firstyear,$secondyear,$frmdt,$todt)
|
|
{
|
|
$this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left');
|
|
$this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left');
|
|
$this->db->where('t_income_expense.IsActive',1);
|
|
$this->db->where('t_income_expense.account_code !=','ADV001');
|
|
$this->db->where('t_income_expense.account_code !=','0013');
|
|
if ($firstyear and $secondyear != '')
|
|
{
|
|
$finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'";
|
|
$this->db->where($finyear);
|
|
}
|
|
if ($frmdt and $todt != ''){
|
|
$fromdate= date("Y-m-d",strtotime($frmdt));
|
|
$todate=date("Y-m-d",strtotime($todt));
|
|
$date = "date(t_income_expense.date) >= '".$fromdate."'
|
|
and date(t_income_expense.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
$this->db->order_by("date","desc");
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
function getAdvanceList($i="")
|
|
{
|
|
// echo $i;
|
|
$this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left');
|
|
$this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left');
|
|
$this->db->where('t_income_expense.IsActive',1);
|
|
$this->db->where('t_income_expense.account_code','ADV001');
|
|
$this->db->or_where('t_income_expense.account_code','0013');
|
|
$this->db->order_by("date","desc");
|
|
if(!empty($i))
|
|
{
|
|
$this->db->where('t_income_expense.id',$i);
|
|
|
|
}
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
function getAdvance($firstyear,$secondyear,$frmdt,$todt)
|
|
{
|
|
$this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left');
|
|
$this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left');
|
|
$this->db->where('t_income_expense.IsActive',1);
|
|
$this->db->where('t_income_expense.account_code','ADV001');
|
|
$this->db->or_where('t_income_expense.account_code','0013');
|
|
if ($firstyear and $secondyear != ''){
|
|
$finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'";
|
|
$this->db->where($finyear);
|
|
}
|
|
if ($frmdt and $todt != ''){
|
|
$fromdate= date("Y-m-d",strtotime($frmdt));
|
|
$todate=date("Y-m-d",strtotime($todt));
|
|
$date = "date(t_income_expense.date) >= '".$fromdate."'
|
|
and date(t_income_expense.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
$this->db->order_by("date","desc");
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
function finyear(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(date)>=4 THEN
|
|
concat(YEAR(date), '-',YEAR(date)+1)
|
|
ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year
|
|
FROM t_income_expense
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
}
|
|
function getCompany()
|
|
{
|
|
$r = $this->db->get('T_Company_Details');
|
|
return $r->result();
|
|
|
|
|
|
}
|
|
|
|
function getAccounutInfo($i)
|
|
{
|
|
$this->db->select('t_accountcode.name,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code');
|
|
$this->db->order_by("date", "desc");
|
|
//$this->db->where('t_income_expense.id')
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
|
|
}
|
|
|
|
function Selectcash()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('t_accountcode');
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
function Selectadvance($i="")
|
|
{
|
|
// echo $i;
|
|
$this->db->select('T_SupplierDetailsN.SupplierName,t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*');
|
|
$this->db->from('t_income_expense');
|
|
$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left');
|
|
$this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left');
|
|
$this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=t_income_expense.Supplier_id' );
|
|
$this->db->order_by("date","desc");
|
|
$this->db->where_in('t_accountcode.code',[AReceipt,Apayment]);
|
|
if(!empty($i))
|
|
{
|
|
$this->db->where('t_income_expense.id',$i);
|
|
|
|
}
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
|
|
function viewdepartment($sid='')
|
|
{
|
|
$sql="SELECT ie.*,br.*,br.ID,ie.totalbankamount,ac.name,ie.id,date_format(ie.date,'%d-%m-%Y')as date FROM t_income_expense ie
|
|
left join t_accountcode ac on ac.code=ie.account_code
|
|
left join T_bankreport br on br.ID=ie.bankid
|
|
WHERE ie.id = ?";
|
|
$query = $this->db->query($sql,array($sid));
|
|
//print_r($this->db->last_query());
|
|
//echo $sql;
|
|
return $query->result();
|
|
}
|
|
function deletefile($cashid)
|
|
{
|
|
|
|
//echo $cashid;
|
|
$sql="UPDATE t_income_expense SET document = NULL
|
|
WHERE id = ?";
|
|
$query = $this->db->query($sql,array($cashid));
|
|
//print_r($this->db->last_query());
|
|
//echo $sql;
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
|
|
function updatedepartment($updateaccount,$id1)
|
|
{
|
|
$this->db->where('id', $id1);
|
|
$this->db->update('t_income_expense',$updateaccount);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
function bankfile($FileDetails)
|
|
{
|
|
$this->db->insert('T_bankingfile',$FileDetails);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function bankfiledata($filedataupload)
|
|
{
|
|
|
|
|
|
$this->db->select('reportdate,Narration,Balance');
|
|
$this->db->from('T_bankreport');
|
|
$this->db->where('reportdate',$filedataupload['reportdate']);
|
|
$this->db->where('Narration',$filedataupload['Narration']);
|
|
$this->db->where('Balance',$filedataupload['Balance']);
|
|
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0){
|
|
return true;
|
|
|
|
}
|
|
else{
|
|
$this->db->insert('T_bankreport', $filedataupload);
|
|
$r = $this->db->affected_rows();
|
|
//print_r($this->db->last_query());
|
|
return $r;
|
|
}
|
|
}
|
|
|
|
function balance($balance){
|
|
|
|
|
|
$this ->db->insert('T_bankbalance',$balance);
|
|
}
|
|
|
|
function getbalancedetails()
|
|
{
|
|
|
|
$subquery="SELECT openingbalance,closingbalance FROM T_bankbalance WHERE balance_keyid in (SELECT MAX(balance_keyid) FROM T_bankbalance)";
|
|
$query = $this->db->query($subquery);
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
function report_finyear(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(reportdate)>=4 THEN
|
|
concat(YEAR(reportdate), '-',YEAR(reportdate)+1)
|
|
ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year
|
|
FROM T_bankreport
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
function report_amountpaid(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(reportdate)>=4 THEN
|
|
concat(YEAR(reportdate), '-',YEAR(reportdate)+1)
|
|
ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year
|
|
FROM T_bankreport
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
function report_cashbook(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(date)>=4 THEN
|
|
concat(YEAR(date), '-',YEAR(date)+1)
|
|
ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year
|
|
FROM t_income_expense
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
function report_finyearunpaid(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(MaterialRcvdDate)>=4 THEN
|
|
concat(YEAR(MaterialRcvdDate), '-',YEAR(MaterialRcvdDate)+1)
|
|
ELSE concat(YEAR(MaterialRcvdDate)-1,'-', YEAR(MaterialRcvdDate)) END AS financial_year
|
|
FROM T_IGR_Master
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
function report_finyearamountreceived(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(reportdate)>=4 THEN
|
|
concat(YEAR(reportdate), '-',YEAR(reportdate)+1)
|
|
ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year
|
|
FROM T_bankreport
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
|
|
function report_finyearamountunreceived(){
|
|
|
|
|
|
$sql="SELECT
|
|
CASE WHEN MONTH(invoice_date_created)>=4 THEN
|
|
concat(YEAR(invoice_date_created), '-',YEAR(invoice_date_created)+1)
|
|
ELSE concat(YEAR(invoice_date_created)-1,'-', YEAR(invoice_date_created)) END AS financial_year
|
|
FROM ip_invoices
|
|
GROUP BY financial_year";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
|
|
function bankstatement($fdate,$tdate,$fa,$aa){
|
|
|
|
$sql="SELECT *,date_format(reportdate,'%d-%m-%Y')as date,tie.total,date_format(valuedate,'%d-%m-%Y')as valuedate from T_bankreport as br left join t_income_expense as tie on tie.bankid=br.ID where br.reportdate !=0 ";
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
$sql.=" and (reportdate >= '".$fa."-04-01' and reportdate<= '".$aa."-03-31')";
|
|
|
|
}
|
|
if ($fdate and $tdate != '')
|
|
{
|
|
|
|
$fdate= date("Y-m-d",strtotime($fdate));
|
|
$tdate=date("Y-m-d",strtotime($tdate));
|
|
|
|
$sql.= " and date(reportdate) >= '".$fdate."'
|
|
and date(reportdate) <= '".$tdate."'";
|
|
}
|
|
|
|
$sql.=" group by(br.ID) ";
|
|
$sql.=" ORDER BY br.ID+0 DESC ";
|
|
|
|
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
|
|
}
|
|
function cleareddebitbalance(){
|
|
|
|
$sql = "SELECT SUM(Balancetocleared) as debit FROM T_bankreport where Clearbalance >'0'";
|
|
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
|
|
}
|
|
function clearedcreditbalance(){
|
|
|
|
$sql = "SELECT SUM(cbalancetocleared) as credit FROM T_bankreport where cclearbalance >'0'";
|
|
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function suppliertotalfilter($fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
|
|
$status= array('ST027','ST056');
|
|
$this->db->select('pom.PONO,sum(pom.TotalOrderValue) as TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate');
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
$this->db->join('T_IGR_Master im','pom.PONO=im.PONO','left');
|
|
$this->db->join('T_SupplierDetailsN sd','pom.SupplierID=sd.SupplierID','left');
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
$this->db->where('pom.Paymentstatus',NO_PAIDIGR);
|
|
|
|
if ($fa and $aa != ''){
|
|
$year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
$month="monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
// $this->db->group_by(array("sd.SupplierID", "pom.PONO"));
|
|
$this->db->group_by('sd.SupplierID','pom.PONO');
|
|
//$this->db->group_by('pom.PONO');
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
|
|
|
|
}
|
|
function amountunpaid($supplierid1,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
$status= array('ST027','ST056');
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate,
|
|
im.IGRNO');
|
|
$this->db->from('T_PurchaseOrder_Master pom');
|
|
//$this->db->join('T_PurchaseOrder_BillUpload bu','pom.PONO=bu.PONO','left');,inward.FilePath as iwFpath,bu.FilePath as poFilePath
|
|
$this->db->join('T_IGR_Master im','im.PONO = pom.PONO','left');
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
// $this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left');
|
|
|
|
//$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =im.IGRNO','left');
|
|
|
|
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
$this->db->where('pom.Paymentstatus ',NO_PAIDIGR);
|
|
$this->db->where('sd.SupplierID',$supplierid1);
|
|
|
|
if ($fa and $aa != ''){
|
|
$year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
$month="monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
|
|
|
|
//$this->db->group_by('pom.PONO');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function amountunpaidfilter($sd,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
$status= array('ST027','ST056');
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate,
|
|
im.IGRNO');
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
//$this->db->join('T_PurchaseOrder_BillUpload bu','pom.PONO=bu.PONO','left');
|
|
$this->db->join('T_IGR_Master im','im.PONO=pom.PONO','left');
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
//$this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left');
|
|
|
|
//$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =im.IGRNO','left'); inward.FilePath as iwFpath,bu.FilePath as poFilePath,im.IGRNO
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
$this->db->where('pom.Paymentstatus',NO_PAIDIGR);
|
|
$this->db->where('sd.SupplierID',$sd);
|
|
|
|
if ($fa and $aa != ''){
|
|
$year="(im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
$month="monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('im.MaterialRcvdDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
|
|
|
|
// $this->db->group_by('pom.PONO');
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
function bankinvoice($Customer,$fdate,$tdate)
|
|
{
|
|
$this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,ic.client_id,BI.balancetoreceived,BI.amountreceived');
|
|
$this->db->from ('ip_invoice_amounts iva');
|
|
$this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id');
|
|
$this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left');
|
|
$this->db->join ('T_Bankinvoicereport BI','iv.invoice_number = BI.invoiceno and BI.IsActive= 1','left');
|
|
$this->db->where('iv.invoice_status_id','2');
|
|
$this->db->where('iv.receivedstatus !=','ST065');
|
|
// $this->db->where('BI.IsActive',1);
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(iv.invoice_date_created) >= '".$fromdate."'
|
|
and date(iv.invoice_date_created) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
if ($Customer != ''){
|
|
$this->db->where('ic.client_id',$Customer);
|
|
}
|
|
$this->db->group_by('iva.invoice_id');
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
function debitbankstatemet($Supplierid,$fdate,$tdate)
|
|
{
|
|
|
|
$status= array('ST027','ST056');
|
|
$this->db->select('pom.PONO,pom.TotalOrderValue,sd.SupplierName,sd.SupplierID,im.MaterialRcvdDate,im.CreatedDate,
|
|
bm.Balancetopay,bm.Amountpaid,im.IGRNO');
|
|
$this->db->from ('T_PurchaseOrder_Master pom');
|
|
$this->db->join('T_IGR_Master im','im.PONO=pom.PONO','left');
|
|
$this->db->join('T_SupplierDetailsN sd','sd.SupplierID=pom.SupplierID','left');
|
|
$this->db->join('T_Bankporeport bm','bm.PONO=pom.PONO and bm.IsActive = 1','left');
|
|
$this->db->or_where_in('pom.Status',$status);
|
|
$this->db->where('pom.Paymentstatus !=','ST070');
|
|
if ($Supplierid != ''){
|
|
$this->db->where('sd.SupplierID',$Supplierid);
|
|
}
|
|
if($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(im.CreatedDate) >= '".$fromdate."'
|
|
and date(im.CreatedDate) <= '".$todate."'";
|
|
$this->db->WHERE($date);
|
|
}
|
|
|
|
$this->db->group_by('pom.PONO');
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
|
|
|
|
}
|
|
function receivedamount($Customer,$fdate,$tdate)
|
|
{
|
|
// $status='ST065';
|
|
// $this->db->distinct();
|
|
$this->db->select('BI.balancetoreceived,BI.amountreceived');
|
|
$this->db->from ('T_Bankinvoicereport BI');
|
|
//$this->db->where('BI.IsActive',1);
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(BI.BankDate) >= '".$fromdate."'
|
|
and date(BI.BankDate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
if ($Customer != ''){
|
|
$this->db->where('BI.client_id',$Customer);
|
|
}
|
|
$this->db->group_by('BI.invoiceno');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
//print_r($this->db->last_query());
|
|
//die();
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
function receiptdata()
|
|
{
|
|
|
|
$this->db->distinct();
|
|
$this->db->select('inc.type,inc.date,inc.account_code,inc.towhom,inc.total');
|
|
$this->db->from ('t_income_expense inc');
|
|
$this->db->where('inc.type','RECEIPT');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function paymentdata()
|
|
{
|
|
|
|
$this->db->distinct();
|
|
$this->db->select('inc.type,inc.date,inc.account_code,inc.towhom,inc.total');
|
|
$this->db->from ('t_income_expense inc');
|
|
//$this->db->group_by('inc.account_code');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
function debitimage($igrno,$pono)
|
|
{
|
|
|
|
$this->db->select('*');
|
|
$this->db->from ('T_PurchaseOrder_BillUpload');
|
|
$this->db->where('IGRNO != "" ');
|
|
$this->db->where('IGRNO',$igrno);
|
|
$this->db->or_where('PONO',$pono);
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
// print_r($result);die;
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function debitpolistfilter($supplierID,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
$this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.Totalpoamount,bm.Podate,bm.BankDate,
|
|
bm.Balancetopay,bm.Amountpaid,bm.IGRNO,bm.IGRLineItemNo,br.Balancetocleared,br.Clearbalance,
|
|
inward.FilePath as igrfile,bu.FilePath as pofile');
|
|
$this->db->from ('T_Bankmappingpo bm');
|
|
// $this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo');
|
|
$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =bm.IGRNO','left');
|
|
$this->db->join('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left');
|
|
$this->db->join('T_bankreport br','br.ID=bm.mid','left');
|
|
$this->db->where('bm.SupplierID',$supplierID);
|
|
$this->db->where('bm.IsActive',1);
|
|
// $this->db->where('igr.BankStatus !=',ST072);
|
|
//$this->db->group_by('bm.mid');
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.BankDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(bm.BankDate) >= '".$fromdate."'
|
|
and date(bm.BankDate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
$this->db->group_by('bm.id');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
function igrmastersingle($igrno,$pono)
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select('IGRNO,file,PONO as pono');
|
|
$this->db->from('T_IGR_Master');
|
|
if(!empty($igrno) && !empty($pono)){
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->where('IGRNO',$igrno);
|
|
}else if(!empty($pono)){
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->where('IGRNO != ""');
|
|
}else{
|
|
$this->db->where('IGRNO',$IGRNO);
|
|
}
|
|
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function igrmastermultiple($igrno,$pono)
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select('BillNo,IGRNO,FilePath,PONO');
|
|
$this->db->from('T_Inwardgateregister_fileupload');
|
|
if(!empty($igrno) && !empty($pono)){
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->where('IGRNO',$igrno);
|
|
}else if(!empty($pono)){
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->where('IGRNO != ""');
|
|
}else{
|
|
$this->db->where('IGRNO',$IGRNO);
|
|
}
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function igrmastermultiple1($igrno,$pono)
|
|
{
|
|
|
|
|
|
$this->db->select('BillNo,IGRNO,FilePath,PONO');
|
|
$this->db->from('T_Inwardgateregister_fileupload');
|
|
// if(!empty($igrno) && !empty($pono)){
|
|
// $this->db->where('PONO',$pono);
|
|
$this->db->where('IGRNO',$igrno);
|
|
// }else if(!empty($pono)){
|
|
// $this->db->where('PONO',$pono);
|
|
// $this->db->where('IGRNO != ""');
|
|
// }else{
|
|
//$this->db->where('IGRNO',$IGRNO);
|
|
// }
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function debitpolist($bankid)
|
|
{
|
|
$this->db->select('bp.id,bp.mid,igrm.MaterialRcvdDate,bp.PONO,bp.Suppliername,bp.Totalpoamount,br.Debit,bp.Balancetopay,bp.Amountpaid,bp.IGRNO,bp.IGRLineItemNo,igrm.file,bu.FilePath,inward.FilePath as Fpath');
|
|
$this->db->from ('T_Bankmappingpo bp');
|
|
$this->db->join ('T_IGR_Master igrm','bp.IGRNO = igrm.IGRNO','left');
|
|
$this->db->join ('T_PurchaseOrder_BillUpload bu','bu.PONO = bp.PONO','left');
|
|
$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =igrm.IGRNO','left');
|
|
$this->db->join ('T_bankreport br','br.ID=bp.mid');
|
|
$this->db->where('bp.IsActive',1);
|
|
$this->db->where('bp.mid',(int)$bankid);
|
|
// $this->db->where('igrde.BankStatus !=','ST072');
|
|
$this->db->group_by('bp.id');
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
function creditinvoicelist($bankid)
|
|
{
|
|
|
|
$this->db->select('bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid,
|
|
bm.balancetoreceived,bm.amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared');
|
|
$this->db->from ('T_Bankmappingiv bm');
|
|
$this->db->join('T_bankreport br','br.ID=bm.bankid');
|
|
$this->db->where('bm.bankid',(int)$bankid);
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->group_by('bm.ID');
|
|
//$this->db->group_by('invoiceno');
|
|
$query = $this->db->get();
|
|
// $str = $this->db->last_query();
|
|
// print_r($str);
|
|
|
|
//print_r($query);
|
|
return $query->result();
|
|
|
|
}
|
|
function creditinvoicelistfilter($clientid,$fdate,$tdate,$fa,$aa,$m)
|
|
|
|
{
|
|
|
|
$this->db->select('bm.ID,bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid,
|
|
bm.balancetoreceived,bm.amountreceived,br.cclearbalance,br.cbalancetocleared,bm.BankDate');
|
|
$this->db->from ('T_Bankmappingiv bm');
|
|
$this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno');
|
|
$this->db->join ('ip_clients ic','ic.client_name = bm.customername','left');
|
|
$this->db->join('T_bankreport br','br.ID = bm.bankid');
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->where('bm.customerid',$clientid);
|
|
$this->db->where('iv.receivedstatus !=',ST066);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$month="monthname(bm.BankDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('bm.BankDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
|
|
//$this->db->group_by('invoiceno');
|
|
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function uncreditinvoicelistfilter($client,$fdate,$tdate,$fa,$aa,$m)
|
|
|
|
{
|
|
$this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_id,ic.client_name,BI.balancetoreceived,BI.amountreceived');
|
|
$this->db->from ('ip_invoice_amounts iva');
|
|
$this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id');
|
|
$this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left');
|
|
$this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left');
|
|
$this->db->where('iv.invoice_status_id','2');
|
|
$this->db->where('iv.receivedstatus',ST066);
|
|
$this->db->where('ic.client_id',$client);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(iv.invoice_date_created >= '".$fa."-04-01' and iv.invoice_date_created <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$month="monthname(iv.invoice_date_created) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('iv.invoice_date_created BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
// $this->db->group_by('iva.invoice_id');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
|
|
}
|
|
//for cashbook edit screen and update bankreport//
|
|
function invoiceamonut($bankid)
|
|
{
|
|
$this->db->select('sum(bm.amountreceived)as amountreceived');
|
|
$this->db->from ('T_Bankmappingiv bm');
|
|
$this->db->where('bm.bankid',(int)$bankid);
|
|
$this->db->where('bm.IsActive',1);
|
|
//$this->db->group_by('bm.ID');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
//for cashbook edit screen and update bankreport//
|
|
function poamonut($bankid)
|
|
{
|
|
$this->db->select('sum(Amountpaid)as amountpaid');
|
|
$this->db->from ('T_Bankmappingpo');
|
|
$this->db->where('mid',$bankid);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('invoiceno');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function cashbookamount($bankid)
|
|
{
|
|
$this->db->select('sum(total)as total');
|
|
$this->db->from ('t_income_expense');
|
|
$this->db->where('bankid',$bankid);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('invoiceno');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
function mappingcash($accountcode,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
$this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id,sd.SupplierName');
|
|
$this->db->from ('t_income_expense as ie');
|
|
$this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left');
|
|
$this->db->join ('T_SupplierDetailsN sd ','sd.SupplierID = ie.Supplier_id','left');
|
|
$this->db->where('ie.account_code',$accountcode);
|
|
$this->db->where('ie.amounttype','DEBIT');
|
|
$this->db->where('ie.IsActive',1);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(ie.date) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(ie.date) >= '".$fromdate."'
|
|
and date(ie.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function mappingcashbankid($bankid)
|
|
{
|
|
$this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id');
|
|
$this->db->from ('t_income_expense as ie');
|
|
$this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left');
|
|
$this->db->where('ie.bankid',(int)$bankid);
|
|
$this->db->where('ie.amounttype','DEBIT');
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('mid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function mappingcashcreditbankid($bankid)
|
|
{
|
|
$this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id');
|
|
$this->db->from ('t_income_expense as ie');
|
|
$this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left');
|
|
$this->db->where('ie.bankid',(int)$bankid);
|
|
$this->db->where('ie.amounttype','CREDIT');
|
|
$this->db->where('ie.IsActive',1);
|
|
//$this->db->group_by('mid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function mappingcashreceived($accountcode,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
$this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id,sd.SupplierName');
|
|
$this->db->from ('t_income_expense as ie');
|
|
$this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left');
|
|
$this->db->join ('T_SupplierDetailsN sd ','sd.SupplierID = ie.Supplier_id','left');
|
|
$this->db->where('ie.account_code',$accountcode);
|
|
$this->db->where('ie.amounttype','CREDIT');
|
|
$this->db->where('ie.IsActive',1);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(ie.date) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(ie.date) >= '".$fromdate."'
|
|
and date(ie.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
//$this->db->group_by('mid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function mappingcashfilter($accountcode,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
$this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id');
|
|
$this->db->from ('t_income_expense as ie');
|
|
$this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left');
|
|
$this->db->where('ie.account_code',$accountcode);
|
|
$this->db->where('ie.amounttype','DEBIT');
|
|
$this->db->where('IsActive',1);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(ie.date) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(ie.date) >= '".$fromdate."'
|
|
and date(ie.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function mappingcashreceivedfilter($accountcode,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
$this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id');
|
|
$this->db->from ('t_income_expense as ie');
|
|
$this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left');
|
|
$this->db->where('ie.account_code',$accountcode);
|
|
$this->db->where('ie.amounttype','CREDIT');
|
|
$this->db->where('IsActive',1);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(ie.date) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(ie.date) >= '".$fromdate."'
|
|
and date(ie.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function newcashbook()
|
|
{
|
|
$this->db->select('cdate,mid,btype,amount,boption,mappingamount,totalamount,amounttype,alreadycreditpaid');
|
|
$this->db->from ('T_Bankmappingcashbook');
|
|
//$this->db->where('mid',$bankid);
|
|
|
|
//$this->db->group_by('mid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
function debitlistpo($pono)
|
|
{
|
|
$this->db->select('bmp.mid,bmp.PONO,bmp.IGRLineItemNo,bmp.Amountpaid,br.Narration');
|
|
$this->db->from ('T_Bankmappingpo as bmp');
|
|
$this->db->join('T_bankreport br','br.ID = bmp.mid');
|
|
$this->db->where('bmp.PONO',$pono);
|
|
$this->db->where('bmp.IsActive',1);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
function creditlistinv($invno)
|
|
{
|
|
$this->db->select('bmp.bankid,bmp.invoiceno,bmp.amountreceived,br.Narration');
|
|
$this->db->from ('T_Bankmappingiv as bmp');
|
|
$this->db->join('T_bankreport br','br.ID = bmp.bankid');
|
|
$this->db->where('invoiceno',$invno);
|
|
$this->db->where('bmp.IsActive',1);
|
|
//$this->db->group_by('invoiceno');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
function getsupplier()
|
|
{
|
|
$this->db->select('SupplierName,SupplierID');
|
|
$this->db->from('T_SupplierDetailsN');
|
|
//$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code');
|
|
//$this->db->where('t_income_expense.id')
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
|
|
}
|
|
|
|
function checkMerchant($mer){
|
|
|
|
$temp[] = '' ;
|
|
$this->db->distinct();
|
|
$this->db->select('SupplierID,SupplierName');
|
|
$this->db->from('T_SupplierDetailsN');
|
|
$this->db->like('SupplierName',$mer);
|
|
$query = $this->db->get();
|
|
|
|
$temparr[] = '' ;
|
|
foreach($query->result() as $arr){
|
|
$temparr[] = $arr->SupplierName;
|
|
}
|
|
$temp['suggestions'] = $temparr;
|
|
|
|
return $temp;
|
|
}
|
|
|
|
function getsupp_dtls($s){
|
|
$this->db->select('GSTNO');
|
|
$this->db->from('T_SupplierDetailsN');
|
|
$this->db->where('SupplierName',$s);
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
}
|
|
|
|
function getcustomer()
|
|
{
|
|
$this->db->select('client_name,client_id');
|
|
$this->db->from('ip_clients');
|
|
//$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code');
|
|
//$this->db->where('t_income_expense.id')
|
|
$r = $this->db->get();
|
|
return $r->result();
|
|
|
|
}
|
|
function invoicedata($invoicedata)
|
|
{
|
|
$this->db->insert('T_Bankinvoicereport',$invoicedata);
|
|
// $this->db->where('PONO',$pono);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function podata($podata)
|
|
{
|
|
$this->db->insert('T_Bankporeport',$podata);
|
|
// $this->db->where('PONO',$pono);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
// function invicedata($invoicedata)
|
|
// {
|
|
// $this->db->insert('T_Bankinvoicereport',$invoicedata);
|
|
// $r = $this->db->affected_rows();
|
|
// return $r;
|
|
// }
|
|
function mappingpo($podata1)
|
|
{
|
|
print_r($podata1);
|
|
$this->db->insert('T_Bankmappingpo',$podata1);
|
|
// $this->db->where('PONO',$pono);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function mappinginvoice($invoicedata)
|
|
{
|
|
$this->db->insert('T_Bankmappingiv',$invoicedata);
|
|
// $this->db->where('PONO',$pono);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
|
|
public function getpono($igrlineitem)
|
|
{
|
|
$this->db->select('IGRLineItemNo');
|
|
$this->db->from('T_Bankporeport');
|
|
$this->db->where('IGRLineItemNo ',$igrlineitem);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function invoiceupdate($invid)
|
|
{
|
|
$this->db->select('invoiceno');
|
|
$this->db->from('T_Bankinvoicereport');
|
|
$this->db->where('invoiceno',$invid);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function bankid($pono)
|
|
{
|
|
$this->db->select('PONO');
|
|
$this->db->from('T_Bankporeport');
|
|
$this->db->where('PONO ',$pono);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function cashbankupdate($cashbookstatus,$bankid)
|
|
{
|
|
// echo $bankid;
|
|
$this->db->where('ID',$bankid);
|
|
$this->db->update('T_bankreport',$cashbookstatus);
|
|
return TRUE;
|
|
|
|
}
|
|
function cashcreditupdate($cashbookstatus1,$bankid)
|
|
{
|
|
|
|
$this->db->where('ID',$bankid);
|
|
$this->db->update('T_bankreport',$cashbookstatus1);
|
|
return TRUE;
|
|
}
|
|
public function bankupdate($bankdata,$bankid)
|
|
{
|
|
$this->db->where('ID ',$bankid);
|
|
$this->db->update('T_bankreport',$bankdata);
|
|
return TRUE;
|
|
|
|
}
|
|
public function bankcreditupdate($bankcreditdata,$bankid)
|
|
{
|
|
|
|
|
|
$this->db->where('ID ',$bankid);
|
|
$this->db->update('T_bankreport',$bankcreditdata);
|
|
|
|
// print_r( $this->db->last_query());
|
|
return TRUE;
|
|
|
|
}
|
|
public function getearlyamount($igrlineitem)
|
|
{
|
|
$this->db->select('Amountpaid');
|
|
$this->db->from('T_Bankporeport');
|
|
$this->db->where('IGRLineItemNo ',$igrlineitem);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function getearlyamountcredit($invid)
|
|
{
|
|
$this->db->select('amountreceived');
|
|
$this->db->from('T_Bankinvoicereport');
|
|
$this->db->where('invoiceno ',$invid);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function getearlymappingiv($invid)
|
|
{
|
|
$this->db->select('sum(amountreceived) as amountreceived');
|
|
$this->db->from('T_Bankmappingiv');
|
|
$this->db->where('invoiceno',$invid);
|
|
$this->db->where('IsActive',1);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function getalreadypaid($bankid)
|
|
{
|
|
$this->db->select('Clearbalance');
|
|
$this->db->from('T_bankreport');
|
|
$this->db->where('ID ',$bankid);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
public function getalreadyreceived($bankid)
|
|
{
|
|
$this->db->select('cclearbalance');
|
|
$this->db->from('T_bankreport');
|
|
$this->db->where('ID ',$bankid);
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
public function poupdate($podata,$pono)
|
|
{
|
|
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->update('T_Bankporeport',$podata);
|
|
|
|
return TRUE;
|
|
}
|
|
public function invoiceupdate1($invoicedata,$invid)
|
|
{
|
|
//print_r($invoicedata);
|
|
//print_r($invid);
|
|
$this->db->where('invoiceno',$invid);
|
|
$this->db->update('T_Bankinvoicereport',$invoicedata);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
function paided($supplierid,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
$this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.Totalpoamount,bm.Podate,bm.BankDate,
|
|
bm.Balancetopay,bm.Amountpaid,bm.IGRNO,bm.IGRLineItemNo,br.Balancetocleared,br.Clearbalance,
|
|
inward.FilePath as igrfile,bu.FilePath pofile');
|
|
$this->db->from ('T_Bankmappingpo bm');
|
|
//$this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo');
|
|
$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =bm.IGRNO','left');
|
|
$this->db->join('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left');
|
|
$this->db->join('T_bankreport br','br.ID=bm.mid','left');
|
|
$this->db->where('bm.SupplierID',$supplierid);
|
|
$this->db->where('bm.IsActive',1);
|
|
// $this->db->where('igr.BankStatus !=',ST072);
|
|
//$this->db->group_by('bm.mid');
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.BankDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(bm.BankDate) >= '".$fromdate."'
|
|
and date(bm.BankDate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
$this->db->group_by('bm.id');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function amountpaidsupplierwise()
|
|
{
|
|
$this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.SupplierID,bm.Totalpoamount,bm.Podate,
|
|
bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.IGRNO,bm.IGRLineItemNo');
|
|
$this->db->from ('T_Bankmappingpo bm');
|
|
//$this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo');
|
|
$this->db->where('bm.IsActive',1);
|
|
// $this->db->where('igr.BankStatus !=',ST072);
|
|
$this->db->group_by('bm.SupplierID');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function amountpaidcashbook()
|
|
{
|
|
$this->db->select('tac.name,sum(tie.total) as total,tie.account_code');
|
|
$this->db->from ('t_income_expense tie');
|
|
$this->db->join('t_accountcode tac','tac.code=tie.account_code');
|
|
$this->db->where('tie.amounttype','DEBIT');
|
|
$this->db->where('tie.cashtype','Bank');
|
|
$this->db->where('tie.IsActive',1);
|
|
//$this->db->where('t_income_expense.account_code !=','ADV001');
|
|
$this->db->group_by('tie.account_code');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function amountreceivedcashbook()
|
|
{
|
|
$this->db->select('tac.name,sum(tie.total)as total,tie.account_code');
|
|
$this->db->from ('t_income_expense tie');
|
|
$this->db->join('t_accountcode tac','tac.code=tie.account_code');
|
|
$this->db->where('tie.amounttype','CREDIT');
|
|
$this->db->where('tie.IsActive',1);
|
|
//$this->db->where('t_income_expense.account_code !=','ADV001');
|
|
$this->db->group_by('tie.account_code');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function amountpaidcashbookfilter($fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
//echo $m;
|
|
//die();
|
|
$this->db->select('tac.name,sum(tie.total)as total,tie.account_code');
|
|
$this->db->from ('t_income_expense tie');
|
|
$this->db->join('t_accountcode tac','tac.code=tie.account_code');
|
|
$this->db->where('tie.amounttype','DEBIT');
|
|
$this->db->where('tie.cashtype','BANK');
|
|
$this->db->where('tie.IsActive',1);
|
|
//$this->db->where('t_income_expense.account_code !=','ADV001');
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(tie.date >= '".$fa."-04-01' and tie.date <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(tie.date) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(tie.date) >= '".$fromdate."'
|
|
and date(tie.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$this->db->group_by('tie.account_code');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function amountreceivedcashbookfilter($fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
$this->db->select('tac.name,sum(tie.total)as total,tie.account_code');
|
|
$this->db->from ('t_income_expense tie');
|
|
$this->db->join('t_accountcode tac','tac.code=tie.account_code');
|
|
$this->db->where('tie.amounttype','CREDIT');
|
|
$this->db->where('tie.IsActive',1);
|
|
//$this->db->where('t_income_expense.account_code !=','ADV001');
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(tie.date >= '".$fa."-04-01' and tie.date <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(tie.date) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(tie.date) >= '".$fromdate."'
|
|
and date(tie.date) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$this->db->group_by('tie.account_code');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
function amountpaidsupplierwisefilter($fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
$this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.SupplierID,sum(bm.Totalpoamount)as Totalpoamount,
|
|
bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.Podate,bm.IGRLineItemNo,bm.BankDate');
|
|
$this->db->from ('T_Bankmappingpo bm');
|
|
$this->db->where('bm.IsActive',1);
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.BankDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(bm.BankDate) >= '".$fromdate."'
|
|
and date(bm.BankDate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
|
|
$this->db->group_by('bm.SupplierID');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
// function unpaided()
|
|
// {
|
|
// // $this->db->select('igd.IGRNO,igd.IGRItemNo,pom.PONO,sm.SupplierName');
|
|
// // $this->db->from('T_IGR_Details igd');
|
|
// // $this->db->join('T_IGR_Master igm','igm.IGRNO=igd.IGRNO');
|
|
// // $this->db->join('T_PurchaseOrder_LineItem poli','igm.PONO= poli.PONO and igd.MaterialCode=poli.MaterialCode');
|
|
// // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO=poli.PONO');
|
|
// // $this->db->join('T_SupplierDetailsN sm','sm.SupplierID=pom.SupplierID');
|
|
// // $this->db->where('igd.BankStatus','ST072');
|
|
// // $query = $this->db->get();
|
|
// // $result = $query->result();
|
|
// // return $result;
|
|
|
|
// }
|
|
function received($clientid,$fdate,$tdate,$fa,$aa,$m)
|
|
{
|
|
$this->db->select('bm.indate,bm.BankDate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid,bm.customerid,
|
|
bm.balancetoreceived,bm.amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared');
|
|
$this->db->from ('T_Bankmappingiv bm');
|
|
$this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno');
|
|
$this->db->join('T_bankreport br','br.ID=bm.bankid');
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->where('bm.customerid',$clientid);
|
|
$this->db->where('iv.receivedstatus !=',ST066);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$month="monthname(bm.BankDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('bm.BankDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
//$this->db->group_by('invoiceno');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
function creditinvoicesupplierwise()
|
|
{
|
|
$this->db->select('bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid,ic.client_id,bm.customerid as customerid,
|
|
bm.balancetoreceived,sum(bm.amountreceived)as amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared');
|
|
$this->db->from ('T_Bankmappingiv bm');
|
|
$this->db->join('T_bankreport br','br.ID=bm.bankid');
|
|
$this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno');
|
|
$this->db->join('ip_clients ic','ic.client_name=bm.customername','left');
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->group_by('bm.customerid');
|
|
$this->db->where('iv.receivedstatus !=',ST066);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function creditinvoicewisefilter($fdate,$tdate,$fa,$aa,$m)
|
|
{
|
|
$this->db->select('bm.indate,bm.BankDate,bm.invoiceno,bm.customername,bm.customerid as customerid,bm.totinvoiceamount,bm.bankid,ic.client_id,
|
|
bm.balancetoreceived,sum(bm.amountreceived)as amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared');
|
|
$this->db->from ('T_Bankmappingiv bm');
|
|
$this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno');
|
|
$this->db->join('T_bankreport br','br.ID=bm.bankid');
|
|
$this->db->join('ip_clients ic','ic.client_name=bm.customername','left');
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->where('iv.receivedstatus !=',ST066);
|
|
|
|
// $this->db->where('bm.customername',$Customer);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.BankDate) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(bm.BankDate) >= '".$fromdate."'
|
|
and date(bm.BankDate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$this->db->group_by('bm.customerid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function unreceived($clientname,$fdate,$tdate,$fa,$aa,$m)
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,BI.balancetoreceived,BI.amountreceived,ic.client_id');
|
|
$this->db->from ('ip_invoice_amounts iva');
|
|
$this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id','left');
|
|
$this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left');
|
|
$this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left');
|
|
$this->db->where('iv.receivedstatus',ST066);
|
|
$this->db->where('iv.invoice_status_id','2');
|
|
$this->db->where('ic.client_id',$clientname);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(iv.invoice_date_created >= '".$fa."-04-01' and iv.invoice_date_created <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$month="monthname(iv.invoice_date_created) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('iv.invoice_date_created BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"');
|
|
}
|
|
// $this->db->where('iv.receivedstatus','ST066');
|
|
|
|
$this->db->group_by('iva.invoice_id');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function unreceivedsupplier()
|
|
{
|
|
|
|
$this->db->select('iva.invoice_id,sum(iva.invoice_total)as invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_id,ic.client_name,BI.balancetoreceived,sum(BI.amountreceived)as amountreceived');
|
|
$this->db->from ('ip_invoice_amounts iva');
|
|
$this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id','left');
|
|
$this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left');
|
|
$this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left');
|
|
$this->db->where('iv.receivedstatus',ST066);
|
|
$this->db->where('iv.invoice_status_id','2');
|
|
|
|
|
|
$this->db->group_by('ic.client_name');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function uncreditinvoicewisefilter($fdate,$tdate,$fa,$aa,$m)
|
|
{
|
|
|
|
$this->db->select('iva.invoice_id,sum(iva.invoice_total)as invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_id,ic.client_name,BI.balancetoreceived,sum(BI.amountreceived)as amountreceived');
|
|
$this->db->from ('ip_invoice_amounts iva');
|
|
$this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id','left');
|
|
$this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left');
|
|
$this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left');
|
|
$this->db->where('iv.receivedstatus',ST066);
|
|
$this->db->where('iv.invoice_status_id','2');
|
|
|
|
// $this->db->where('bm.customername',$Customer);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(iv.invoice_date_created >= '".$fa."-04-01' and iv.invoice_date_created <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(iv.invoice_date_created) = '".$m."'";
|
|
$this->db->where($month);
|
|
// $sql.="and monthname(bm.Podate) = '".$m."'";
|
|
|
|
}
|
|
if ($fdate and $tdate != ''){
|
|
$fromdate= date("Y-m-d",strtotime($fdate));
|
|
$todate=date("Y-m-d",strtotime($tdate));
|
|
$date = "date(iv.invoice_date_created) >= '".$fromdate."'
|
|
and date(iv.invoice_date_created) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
|
|
$this->db->group_by('ic.client_name');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
// function podetailstatus($podetails,$pono)
|
|
// {
|
|
// echo $igrdetails;
|
|
// $this->db->where('PONO',$pono);
|
|
// $this->db->update('T_PurchaseOrder_Master',$podetails);
|
|
// $r = $this->db->affected_rows();
|
|
// return $r;
|
|
|
|
// }
|
|
function invoiceamountstatus($invoicemaster,$invid)
|
|
{
|
|
|
|
$this->db->where('invoice_number',$invid);
|
|
$this->db->update('ip_invoices',$invoicemaster);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
function poamountstatus($podetails,$pono)
|
|
{
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->update('T_PurchaseOrder_Master',$podetails);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
|
|
function Cashbook($cashbookdatas)
|
|
{
|
|
$code=$cashbookdatas['code'];
|
|
$type=$cashbookdatas['type'];
|
|
|
|
$count=0;
|
|
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('t_accountcode');
|
|
$this->db->where('type',$type);
|
|
$this->db->where('code',$code);
|
|
|
|
$isExits = $this->db->get();
|
|
$res = $isExits->result_array();
|
|
|
|
|
|
if(!empty($res))
|
|
{
|
|
$count = $res[0]['count'];
|
|
}
|
|
|
|
|
|
if($count == 0 )//for cashbook_insert
|
|
{
|
|
$cbi = $this->db->insert('t_accountcode', $cashbookdatas);
|
|
return $cbi;
|
|
}
|
|
elseif($count == 1)//for cashbook_update
|
|
{
|
|
$this->db->where('code',$code);
|
|
$cbu = $this->db->update('t_accountcode',$cashbookdatas);
|
|
return $cbu;
|
|
}
|
|
|
|
}
|
|
function deletemapping($Bankid,$updateamount,$updatebalancetoclear)
|
|
{
|
|
$this->db->set('Clearbalance',$updateamount);
|
|
$this->db->set('Balancetocleared',$updatebalancetoclear);
|
|
$this->db->where('ID',$Bankid);
|
|
$this->db->update('T_bankreport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function updatebankreportiv($bankid,$bankstatement)
|
|
{
|
|
$this->db->where('ID',$bankid);
|
|
$this->db->update('T_bankreport',$bankstatement);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
function PoStatusUpdate($pono,$PaymentStatus)
|
|
{
|
|
|
|
$this->db->set('Paymentstatus',$PaymentStatus);
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->update('T_PurchaseOrder_Master');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function deleteBankmappingpo($id,$IsActive)
|
|
{
|
|
$this->db->set('IsActive',$IsActive);
|
|
$this->db->where('id',$id);
|
|
$this->db->update('T_Bankmappingpo');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
// function updatemappingamount($igrno,$amountpaid)
|
|
// {
|
|
|
|
// $sql="update T_Bankmappingpo set Balancetopay=$amountpaid+Balancetopay where IGRLineItemNo='$igrno' and
|
|
// IsActive='1'";
|
|
// $query = $this->db->query($sql);
|
|
// return $query->result();
|
|
|
|
// // $this->db->set('Balancetopay',$amountpaid+'Balancetopay');
|
|
// // //$this->db->set('Balancetopay',$amountpaid);
|
|
// // $this->db->where('IGRLineItemNo',$igrno);
|
|
// // $this->db->where('IsActive',1);
|
|
// // $this->db->update('T_Bankmappingpo');
|
|
// // $r = $this->db->affected_rows();
|
|
// // return $r;
|
|
// }
|
|
function UpdateIpinvoiceStatus($invoiceno,$receivedstatus)
|
|
{
|
|
$this->db->set('receivedstatus',$receivedstatus);
|
|
$this->db->where('invoice_number',$invoiceno);
|
|
$this->db->update('ip_invoices');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
function deletemappinginvoice($mappingid,$IsActive)
|
|
{
|
|
$this->db->set('IsActive',$IsActive);
|
|
$this->db->where('ID',$mappingid);
|
|
$this->db->update('T_Bankmappingiv');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
// function updatemappinginvoice($invoiceno,$amountreceived)
|
|
// {
|
|
// $this->db->set('balancetoreceived',$amountreceived+'balancetoreceived');
|
|
// $this->db->where('invoiceno',$invoiceno);
|
|
// $this->db->where('IsActive',1);
|
|
// $this->db->update('T_Bankmappingiv');
|
|
// $query = $this->db->get();
|
|
// print_r(this->db->last_query());
|
|
// $r = $this->db->affected_rows();
|
|
// return $r;
|
|
// }
|
|
|
|
function updateBankporeport($pono,$balancetopayupdate,$amountpaidupdate,$IsAct)
|
|
{
|
|
$this->db->set('Balancetopay',$balancetopayupdate);
|
|
$this->db->set('Amountpaid',$amountpaidupdate);
|
|
$this->db->set('IsActive',$IsAct);
|
|
$this->db->where('PONO',$pono);
|
|
//$this->db->where('mid',$Bankid);
|
|
$this->db->update('T_Bankporeport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
|
|
function updatebankinvoicereport($invoiceno,$balancetoreceivedupdate,$amountreceivedupdate,$IsAct)
|
|
{
|
|
$this->db->set('balancetoreceived',$balancetoreceivedupdate);
|
|
$this->db->set('amountreceived',$amountreceivedupdate);
|
|
$this->db->set('IsActive',$IsAct);
|
|
$this->db->where('invoiceno',$invoiceno);
|
|
//$this->db->where('bankid',$bankid);
|
|
$this->db->update('T_Bankinvoicereport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function gettotalbankmappingpo($id)
|
|
{
|
|
$this->db->select('sum(Amountpaid)as Amountpaid');
|
|
$this->db->from ('T_Bankmappingpo');
|
|
$this->db->where('id',$id);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function gettotalbankmappingpocount($pono)
|
|
{
|
|
$this->db->select('count(Amountpaid)as countAmountpaid');
|
|
$this->db->from ('T_Bankmappingpo');
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function gettotalbankmappinginvoicecount($invoiceno)
|
|
{
|
|
$this->db->select('count(amountreceived)as countamountreceived');
|
|
$this->db->from ('T_Bankmappingiv');
|
|
$this->db->where('invoiceno',$invoiceno);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function gettotalbankpoamount($pono)
|
|
{
|
|
$this->db->select('Amountpaid,Balancetopay');
|
|
$this->db->from ('T_Bankporeport');
|
|
$this->db->where('PONO',$pono);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function gettotalbankreceivedamount($invoiceno)
|
|
{
|
|
$this->db->select('amountreceived,balancetoreceived');
|
|
$this->db->from ('T_Bankinvoicereport');
|
|
$this->db->where('invoiceno',$invoiceno);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function gettotalbankporeport($igrno)
|
|
{
|
|
$this->db->select('Amountpaid');
|
|
$this->db->from ('T_Bankporeport');
|
|
$this->db->where('IGRLineItemNo',$igrno);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function getlatestamount($mappingid,$invoiceno)
|
|
{
|
|
$this->db->select('min(balancetoreceived)as balancetoreceived');
|
|
$this->db->from ('T_Bankmappingiv');
|
|
$this->db->where('ID',$mappingid);
|
|
$this->db->where('invoiceno',$invoiceno);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('T_Bankmappingpo.IGRLineItemNo');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function getlatest($invoiceno)
|
|
{
|
|
$sql="select ID,balancetoreceived from T_Bankmappingiv where invoiceno='$invoiceno' and
|
|
ID in(select max(ID) from T_Bankmappingiv group by invoiceno)";
|
|
$query =$this->db->query($sql);
|
|
return $query->result();
|
|
}
|
|
function deletecashbookdata($Bankid,$updatebankamount,$clearbalance)
|
|
{
|
|
$this->db->set('Clearbalance',$clearbalance);
|
|
$this->db->set('Balancetocleared',$updatebankamount);
|
|
$this->db->where('ID',$Bankid);
|
|
$this->db->update('T_bankreport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function deletecashbookdatacredit($Bankid,$updateclearbalance,$updatebalancetoclear)
|
|
{
|
|
$this->db->set('cclearbalance',$updateclearbalance);
|
|
$this->db->set('cbalancetocleared',$updatebalancetoclear);
|
|
$this->db->where('ID',$Bankid);
|
|
$this->db->update('T_bankreport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function getaccountcode($accountname)
|
|
{
|
|
$this->db->select('code');
|
|
$this->db->from ('t_accountcode');
|
|
$this->db->where('name',$accountname);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function StatusUpadateCashbook($id,$IsActive)
|
|
{
|
|
$this->db->set('IsActive',$IsActive);
|
|
$this->db->where('id',$id);
|
|
$this->db->update('t_income_expense');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|