2221 lines
84 KiB
PHP
2221 lines
84 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(Podate)>=4 THEN
|
|
concat(YEAR(Podate), '-',YEAR(Podate)+1)
|
|
ELSE concat(YEAR(Podate)-1,'-', YEAR(Podate)) END AS financial_year
|
|
FROM T_Bankporeport
|
|
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(indate)>=4 THEN
|
|
concat(YEAR(indate), '-',YEAR(indate)+1)
|
|
ELSE concat(YEAR(indate)-1,'-', YEAR(indate)) END AS financial_year
|
|
FROM T_Bankinvoicereport
|
|
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 debitbankstatemet($Supplierid,$fdate,$tdate){
|
|
|
|
|
|
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate as CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID as SupplierID,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
|
|
|
|
round((
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total
|
|
from T_IGR_Master im
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
|
|
where im.IGRStatus = 'ST027' and id.BankStatus!='ST070' ";
|
|
|
|
|
|
if ($Supplierid!= ''){
|
|
|
|
$sql.="and sd.SupplierID = '".$Supplierid."'";
|
|
|
|
}
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
$sql.="and date(im.CreatedDate) >= '".$fromd."'
|
|
and date(im.CreatedDate) <= '".$tod."'";
|
|
|
|
}
|
|
|
|
|
|
$sql.="group by id.IGRItemNo";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
}
|
|
function debitbankstatemet1(){
|
|
|
|
|
|
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate as CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID as SupplierID,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
|
|
|
|
round((
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total
|
|
from T_IGR_Master im
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
|
|
where im.IGRStatus = 'ST027' and id.BankStatus !='ST070'" ;
|
|
|
|
$sql.=" group by id.IGRItemNo";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
}
|
|
|
|
function bank_finyear(){
|
|
|
|
$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 debitbankstatemet($Supplierid,$fdate,$tdate)
|
|
// {
|
|
// echo $Supplierid;
|
|
// $status='ST057';
|
|
// //echo $tdate;
|
|
// //die();
|
|
// // +rt.SGST/100+rt.IGST/100))
|
|
// //$Supplierid;
|
|
// $this->db->distinct();
|
|
// $this->db->select('igr.PONO,igrli.IGRItemNo,igr.IGRNO,supp.SupplierName,igrli.CreatedDate,BR.Balancetopay,BR.Amountpaid,pom.Status,igrli.QuantityAsPerInvoice ,poli.Rate,(igrli.QuantityAsPerInvoice * poli.Rate) as total,((igrli.QuantityAsPerInvoice * poli.Rate)+(rt.FreightValue)-(rt.DiscountValue))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.CGST/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.SGST as rtsgst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.IGST as rtigst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.IGST as stigst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.SGST as stsgst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.CGST /100)) as finalamount');
|
|
|
|
// $this->db->from ('T_IGR_Details igrli');
|
|
// $this->db->join('T_IGR_Master igr','igrli.IGRNO = igr.IGRNO','left');
|
|
// $this->db->join('T_PurchaseOrder_LineItem poli','igr.PONO= poli.PONO and igrli.MaterialCode=poli.MaterialCode');
|
|
// $this->db->join('T_PurchaseOrder_Master pom','poli.PONO =pom.PONO');
|
|
// $this->db->join('T_SupplierDetailsN supp','pom.SupplierID =supp.SupplierID');
|
|
// $this->db->join('T_Revenue_Tax rt','poli.LineItemNo=rt.LineItemNo','left');
|
|
// $this->db->join('T_Service_Tax st','poli.LineItemNo=st.LineItemNo','left');
|
|
// $this->db->join ('T_Bankporeport BR','igrli.IGRItemNo = BR.IGRLineItemNo','left');
|
|
// if ($fdate and $tdate != ''){
|
|
// $fromdate= date("Y-m-d",strtotime($fdate));
|
|
// $todate=date("Y-m-d",strtotime($tdate));
|
|
// $date = "date(igr.CreatedDate) >= '".$fromdate."'
|
|
// and date(igr.CreatedDate) <= '".$todate."'";
|
|
// $this->db->where($date);
|
|
// }
|
|
// if ($Supplierid != ''){
|
|
// $this->db->where('supp.SupplierID',$Supplierid);
|
|
// }
|
|
// $this->db->where_in('igr.IGRStatus','ST027');
|
|
// //$this->db->where_in('pom.Status',[ST044,ST056]);
|
|
// $this->db->where('igrli.BankStatus !=','ST070');
|
|
// $this->db->group_by('igrli.IGRItemNo');
|
|
// $query = $this->db->get();
|
|
// return $query->result();
|
|
|
|
// }
|
|
|
|
function suppliertotal()
|
|
{
|
|
$sql="select sd.SupplierName as SupplierName,sd.SupplierID,im.CreatedDate,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
|
|
|
|
sum(round((
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2)) as total
|
|
from T_IGR_Master im
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
|
|
where im.IGRStatus = 'ST027' and id.BankStatus ='ST072'";
|
|
|
|
|
|
if ($Supplierid!= ''){
|
|
|
|
$sql.="and sd.SupplierID = '".$Supplierid."'";
|
|
|
|
}
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
$sql.="and date(im.CreatedDate) >= '".$fromd."'
|
|
and date(im.CreatedDate) <= '".$tod."'";
|
|
|
|
}
|
|
|
|
|
|
$sql.="group by sd.SupplierName";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
}
|
|
function suppliertotalfilter($fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
|
|
$sql="select sd.SupplierName as SupplierName,sd.SupplierID,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
|
|
|
|
sum(round((
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2)) as total
|
|
from T_IGR_Master im
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
|
|
where im.IGRStatus = 'ST027' and id.BankStatus ='ST072'";
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$sql.="and monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
}
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
$sql.="and date(im.MaterialRcvdDate) >= '".$fromd."'
|
|
and date(im.MaterialRcvdDate) <= '".$tod."'";
|
|
|
|
}
|
|
|
|
|
|
$sql.="group by sd.SupplierName";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
}
|
|
function amountunpaid($supplierid,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate,im.DeliveryChellanDate,im.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,bu.FilePath as poFilePath ,bu.BillNo,inward.FilePath as iwFpath, sd.SupplierID,im.DeliveryChellanOrInvoiceNo,DATEDIFF(CURDATE(),id.CreatedDate)as days,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterSGST),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(st.After_SGST )),0),2) as sgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterCGST),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(st.After_CGST)),0),2) as cgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterIGST),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(st.After_IGST)),0),2) as igst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
|
|
|
|
round((
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total
|
|
from T_IGR_Master im
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
|
|
left join T_Inwardgateregister_fileupload inward on inward.IGRNO =im.IGRNO
|
|
left join T_PurchaseOrder_BillUpload bu on bu.PONO=pm.PONO
|
|
where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' and sd.SupplierID='".$supplierid."'";
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$sql.="and monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
}
|
|
|
|
|
|
if ($fdate and $tdate != ''){
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
$sql.="and date(im.MaterialRcvdDate) >= '".$fromd."'
|
|
and date(im.MaterialRcvdDate) <= '".$tod."'";
|
|
|
|
}
|
|
$sql.="group by id.IGRItemNo";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
}
|
|
function amountunpaidfilter($sd,$fa,$aa,$m,$fdate,$tdate)
|
|
{
|
|
|
|
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,im.MaterialRcvdDate,im.DeliveryChellanDate,im.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,sd.SupplierID,im.DeliveryChellanOrInvoiceNo,DATEDIFF(CURDATE(),id.CreatedDate)as days,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterSGST),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(st.After_SGST )),0),2) as sgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterCGST),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(st.After_CGST)),0),2) as cgst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(rt.AfterIGST),
|
|
(id.QuantityAsPerInvoice * pl.Rate)+(st.After_IGST)),0),2) as igst,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
|
|
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
|
|
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
|
|
round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
|
|
|
|
round((
|
|
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
|
|
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
|
|
+ round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
|
|
- round(ifnull(if(POType = 'REVENUE',
|
|
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
|
|
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total
|
|
from T_IGR_Master im
|
|
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
|
|
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
|
|
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
|
|
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
|
|
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
|
|
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
|
|
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
|
|
where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' and sd.SupplierID='".$sd."'";
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')";
|
|
|
|
}
|
|
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$sql.="and monthname(im.MaterialRcvdDate) = '".$m."'";
|
|
|
|
}
|
|
|
|
if ($fdate and $tdate != ''){
|
|
$fromd= date("Y-m-d",strtotime($fdate));
|
|
$tod=date("Y-m-d",strtotime($tdate));
|
|
|
|
$sql.="and date(im.MaterialRcvdDate) >= '".$fromd."'
|
|
and date(im.MaterialRcvdDate) <= '".$tod."'";
|
|
|
|
}
|
|
|
|
|
|
$sql.="group by id.IGRItemNo";
|
|
//echo $sql;
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
}
|
|
function bankinvoice($Customer,$fdate,$tdate)
|
|
{
|
|
// $status='ST065';
|
|
$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,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','left');
|
|
//$this->db->where('iva.receivedstatus !=','ST065');
|
|
$this->db->where('iv.invoice_status_id','2');
|
|
$this->db->where('iv.receivedstatus !=','ST065');
|
|
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');
|
|
//$this->db->where('inc.type','PAYMENT');
|
|
$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)
|
|
{
|
|
// echo $suppliername+'sn';
|
|
$this->db->select('bm.id,bm.mid,bm.Podate,bm.PONO,bm.Suppliername,bm.Totalpoamount,
|
|
bm.Balancetopay,bm.Amountpaid,bm.IGRNO,igrm.file,bm.IGRLineItemNo,br.Clearbalance,br.Balancetocleared,bu.FilePath,bu.BillNo,inward.FilePath as Fpath');
|
|
$this->db->from ('T_Bankporeport bm');
|
|
$this->db->join ('T_IGR_Master igrm','igrm.PONO = bm.PONO or igrm.IGRNO = bm.IGRNO ','left');
|
|
//$this->db->join ('T_IGR_Details igrde','igrde.IGRNO=igrm.IGRNO');
|
|
$this->db->join ('T_SupplierDetailsN sd','sd.SupplierName = bm.Suppliername');
|
|
$this->db->join ('T_bankreport br','br.ID=bm.mid');
|
|
$this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =igrm.IGRNO','left');
|
|
$this->db->join ('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left');
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->where('bm.SupplierID',$supplierID);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.Podate >= '".$fa."-04-01' and bm.Podate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.Podate) = '".$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.Podate) >= '".$fromdate."'
|
|
and date(bm.Podate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
|
|
$this->db->group_by('bm.IGRLineItemNo');
|
|
$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',$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_Bankinvoicereport bm');
|
|
$this->db->join('T_bankreport br','br.ID=bm.bankid');
|
|
$this->db->where('bm.bankid',$bankid);
|
|
$this->db->where('bm.IsActive',1);
|
|
//$this->db->group_by('invoiceno');
|
|
$query = $this->db->get();
|
|
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');
|
|
$this->db->from ('T_Bankinvoicereport bm');
|
|
|
|
$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);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.indate >= '".$fa."-04-01' and bm.indate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$month="monthname(bm.indate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('bm.indate 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(amountreceived)as amountreceived');
|
|
$this->db->from ('T_Bankmappingiv');
|
|
$this->db->where('bankid',$bankid);
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('invoiceno');
|
|
$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');
|
|
$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 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',$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',$bankid);
|
|
$this->db->where('ie.amounttype','CREDIT');
|
|
$this->db->where('IsActive',1);
|
|
//$this->db->group_by('mid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
function mappingcashreceived($accountcode,$fdate,$tdate,$fa,$aa,$m)
|
|
{
|
|
$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);
|
|
}
|
|
//$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($igrlineitem)
|
|
{
|
|
$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.IGRLineItemNo',$igrlineitem);
|
|
$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($podata)
|
|
{
|
|
$this->db->insert('T_Bankmappingpo',$podata);
|
|
// $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 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,$igrlineitem)
|
|
{
|
|
|
|
$this->db->where('IGRLineItemNo',$igrlineitem);
|
|
$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.Balancetopay,bm.Amountpaid,bm.IGRNO,bm.IGRLineItemNo,br.Balancetocleared,br.Clearbalance,
|
|
inward.FilePath as igrfile,bu.FilePath pofile');
|
|
$this->db->from ('T_Bankporeport bm');
|
|
$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);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.Podate >= '".$fa."-04-01' and bm.Podate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.Podate) = '".$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.Podate) >= '".$fromdate."'
|
|
and date(bm.Podate) <= '".$todate."'";
|
|
$this->db->where($date);
|
|
}
|
|
$this->db->group_by('bm.IGRLineItemNo');
|
|
$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_Bankporeport bm');
|
|
$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)
|
|
{
|
|
$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.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');
|
|
$this->db->from ('T_Bankporeport bm');
|
|
|
|
|
|
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.Podate >= '".$fa."-04-01' and bm.Podate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.Podate) = '".$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.Podate) >= '".$fromdate."'
|
|
and date(bm.Podate) <= '".$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.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_Bankinvoicereport bm');
|
|
$this->db->join('T_bankreport br','br.ID=bm.bankid');
|
|
$this->db->where('bm.IsActive',1);
|
|
$this->db->where('bm.customerid',$clientid);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.indate >= '".$fa."-04-01' and bm.indate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
}
|
|
if ($m!= ''){
|
|
|
|
//$sql.="and monthname(im.CreatedDate) = '".$m."'";
|
|
$month="monthname(bm.indate) = '".$m."'";
|
|
$this->db->where($month);
|
|
|
|
}
|
|
if($fdate!='' && $tdate!='')
|
|
{
|
|
$this->db->where('bm.indate 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_Bankinvoicereport bm');
|
|
$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->group_by('bm.customerid');
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function creditinvoicewisefilter($fdate,$tdate,$fa,$aa,$m)
|
|
{
|
|
$this->db->select('bm.indate,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_Bankinvoicereport bm');
|
|
$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('bm.customername',$Customer);
|
|
if ($fa and $aa != ''){
|
|
|
|
//$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')";
|
|
$year="(bm.indate >= '".$fa."-04-01' and bm.indate <= '".$aa."-03-31')";
|
|
$this->db->where($year);
|
|
|
|
}
|
|
if ($m!= ''){
|
|
//$this->db->where('MONTH(pel.tgl_pembelian)',$bulan);
|
|
$month="monthname(bm.indate) = '".$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.indate) >= '".$fromdate."'
|
|
and date(bm.indate) <= '".$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('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->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 igrdetailstatus($igrdetails,$igrlineitem)
|
|
{
|
|
$this->db->where('IGRItemNo',$igrlineitem);
|
|
$this->db->update('T_IGR_Details',$igrdetails);
|
|
$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 poamountstatus1($pomaster1,$pono)
|
|
// {
|
|
// $this->db->where('PONO', $pono);
|
|
// $this->db->update('T_PurchaseOrder_Master',$pomaster1);
|
|
// $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 IgrDetailsStatusUpdate($igrno,$BankStatus)
|
|
{
|
|
|
|
$this->db->set('BankStatus',$BankStatus);
|
|
$this->db->where('IGRItemNo',$igrno);
|
|
$this->db->update('T_IGR_Details');
|
|
$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 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 updateBankporeportpo($igrno,$totalbalancetopay,$updatebankpoamount,$Bankid,$IsActive)
|
|
{
|
|
$this->db->set('Balancetopay',$totalbalancetopay);
|
|
$this->db->set('Amountpaid',$updatebankpoamount);
|
|
$this->db->set('IsActive',$IsActive);
|
|
$this->db->where('IGRLineItemNo',$igrno);
|
|
$this->db->where('mid',$Bankid);
|
|
$this->db->update('T_Bankporeport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
|
|
}
|
|
function updatebankinvoicereport($invoiceno,$bankid,$updatebalancetoreceived,$updateamountreceived,$IsActive)
|
|
{
|
|
$this->db->set('balancetoreceived',$updatebalancetoreceived);
|
|
$this->db->set('amountreceived',$updateamountreceived);
|
|
$this->db->set('IsActive',$IsActive);
|
|
$this->db->where('invoiceno',$invoiceno);
|
|
$this->db->where('bankid',$bankid);
|
|
$this->db->update('T_Bankinvoicereport');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
function gettotalbankmappingpo($igrno)
|
|
{
|
|
$this->db->select('sum(Amountpaid)as Amountpaid');
|
|
$this->db->from ('T_Bankmappingpo');
|
|
$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;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|