diff --git a/application/controllers/user.php b/application/controllers/user.php
index 44813b08..afc8783a 100755
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -43,10 +43,10 @@ class user extends BaseController
//print_r( $data['totalpurchaseorder']);
$data['totalordervalue']=$this->dahsboard_Model->totalordervalue();
$data['pendingpo']=$this->dahsboard_Model->pendingpo();
- $data['totalserviceamount']=$this->dahsboard_Model->totalserviceamount();
- $data['totalcapitalamount']=$this->dahsboard_Model->totalcapitalamount();
- $data['totalimportamount']=$this->dahsboard_Model->totalimportamount();
- $data['totalrevenueamount']=$this->dahsboard_Model->totalrevenueamount();
+ // $data['totalserviceamount']=$this->dahsboard_Model->totalserviceamount();
+ // $data['totalcapitalamount']=$this->dahsboard_Model->totalcapitalamount();
+ // $data['totalimportamount']=$this->dahsboard_Model->totalimportamount();
+ // $data['totalrevenueamount']=$this->dahsboard_Model->totalrevenueamount();
// $data['totalservicepo']=$this->dahsboard_Model->totalservicepo();
diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php
index 0875a8da..453479cc 100755
--- a/application/models/dahsboard_model.php
+++ b/application/models/dahsboard_model.php
@@ -129,7 +129,7 @@ where att.Month_Year = ? and att.EmpID = ?;";
function totalpurchaseorder(){
- $sql="select count(PONO) as totalpurchaseorder from T_PurchaseOrder_Master";
+ $sql="select count(PONO) as totalpurchaseorder from T_PurchaseOrder_Master where Status != 'ST030'";
$query = $this->db->query($sql);
return $query->result();
@@ -137,7 +137,7 @@ where att.Month_Year = ? and att.EmpID = ?;";
function totalordervalue(){
- $sql="select sum(totalordervalue) as totalordervalue from T_PurchaseOrder_Master";
+ $sql="select sum(totalordervalue) as totalordervalue from T_PurchaseOrder_Master where Status != 'ST030'";
$query = $this->db->query($sql);
return $query->result();
@@ -145,11 +145,36 @@ where att.Month_Year = ? and att.EmpID = ?;";
function pendingpo(){
- $sql="select count(PONO) as pending from T_PurchaseOrder_Master where status='ST020'";
+ $sql="select count(PONO) as pending from T_PurchaseOrder_Master where status='ST020' and Status != 'ST030'";
$query = $this->db->query($sql);
return $query->result();
}
+ function req_pending(){
+
+
+ $sql="SELECT count(Status) as TOTAL_PENDING_REQUESTS FROM T_Requestion_Master where Status = 'ST002';";
+ $query = $this->db->query($sql);
+ return $query->result();
+
+
+
+ }
+ function reqdetail(){
+
+
+ $sql="SELECT count(Status) as TODAY_REQUESTS FROM T_Requestion_Master where date(ReqDate) = date(now());";
+
+ $query = $this->db->query($sql);
+
+ // echo "from Model";
+ // print_r($query->result());
+
+ return $query->result();
+
+
+
+ }
function january(){
@@ -158,41 +183,51 @@ where att.Month_Year = ? and att.EmpID = ?;";
return $query->result();
}
- function totalserviceamount()
- {
- $sql="select sum(BudgetAmount) as totalserviceamount from T_CostCenter_Budget where BudgetType='SERVICE'";
- $query = $this->db->query($sql);
- return $query->result();
+ // function totalserviceamount()
+ // {
+ // $sql="select sum(BudgetAmount) as totalserviceamount from T_CostCenter_Budget where BudgetType='SERVICE'";
+ // $query = $this->db->query($sql);
+ // return $query->result();
- }
- function totalcapitalamount()
- {
- $sql="select sum(BudgetAmount) as totalcapitalamount from T_CostCenter_Budget where BudgetType='CAPITAL'";
- $query = $this->db->query($sql);
- return $query->result();
-}
-function totalimportamount()
- {
- $sql="select sum(BudgetAmount) as totalimportamount from T_CostCenter_Budget where BudgetType='IMPORT'";
- $query = $this->db->query($sql);
- return $query->result();
-}
-function totalrevenueamount()
- {
- $sql="select sum(BudgetAmount) as totalrevenueamount from T_CostCenter_Budget where BudgetType='REVENUE'";
- $query = $this->db->query($sql);
- return $query->result();
-}
+ // }
+ // function totalcapitalamount()
+ // {
+ // $sql="select sum(BudgetAmount) as totalcapitalamount from T_CostCenter_Budget where BudgetType='CAPITAL'";
+ // $query = $this->db->query($sql);
+ // return $query->result();
+// }
+// function totalimportamount()
+ // {
+ // $sql="select sum(BudgetAmount) as totalimportamount from T_CostCenter_Budget where BudgetType='IMPORT'";
+ // $query = $this->db->query($sql);
+ // return $query->result();
+// }
+// function totalrevenueamount()
+ // {
+ // $sql="select sum(BudgetAmount) as totalrevenueamount from T_CostCenter_Budget where BudgetType='REVENUE'";
+ // $query = $this->db->query($sql);
+ // return $query->result();
+// }
//totalservice
function getTotalServicePoCount(){
$i=1;
-
+ if (date('m') >= 4)
+ {
+ $yearl = date('Y').'-'.(date('Y')+1);
+ } else {
+ $yearl = (date('Y')-1).'-'.date('Y');
+ }
+ $ab=$yearl;
+ $fa=substr($ab,0,-5);
+ $aa=substr($ab,5,5);
while($i<=12){
+
$sql="SELECT count(cmast.PONO) as totalService FROM T_PurchaseOrder_Master cmast
- join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
- join T_Requestion_Master req on req.ReqNo=line.ReqNo
- where ReqType='SERVICE' and month(PODate) = $i ";
+ left join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
+ left join T_Requestion_Master req on req.ReqNo=line.ReqNo
+ where ReqType='SERVICE' and month(PODate) = $i
+ and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'";
$query = $this->db->query($sql);
$array_result[]=$query->result();
@@ -206,13 +241,23 @@ $i++;
function getTotalimportPoCount(){
$i=1;
-
+ if (date('m') >= 4)
+ {
+ $yearl = date('Y').'-'.(date('Y')+1);
+ } else {
+ $yearl = (date('Y')-1).'-'.date('Y');
+ }
+ $ab=$yearl;
+ $fa=substr($ab,0,-5);
+ $aa=substr($ab,5,5);
while($i<=12){
+
$sql="SELECT count(cmast.PONO) as totalImport FROM T_PurchaseOrder_Master cmast
- join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
- join T_Requestion_Master req on req.ReqNo=line.ReqNo
- where ReqType='IMPORT' and month(PODate) = $i ";
+ left join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
+ left join T_Requestion_Master req on req.ReqNo=line.ReqNo
+ where ReqType='IMPORT' and month(PODate) = $i
+ and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'";
$query = $this->db->query($sql);
$array_result[]=$query->result();
@@ -225,13 +270,22 @@ $i++;
}
function getTotalcapitalPoCount(){
$i=1;
-
+ if (date('m') >= 4)
+ {
+ $yearl = date('Y').'-'.(date('Y')+1);
+ } else {
+ $yearl = (date('Y')-1).'-'.date('Y');
+ }
+ $ab=$yearl;
+ $fa=substr($ab,0,-5);
+ $aa=substr($ab,5,5);
while($i<=12){
$sql="SELECT count(cmast.PONO) as totalcapital FROM T_PurchaseOrder_Master cmast
- join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
- join T_Requestion_Master req on req.ReqNo=line.ReqNo
- where ReqType='CAPITAL' and month(PODate) = $i ";
+ left join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
+ left join T_Requestion_Master req on req.ReqNo=line.ReqNo
+ where ReqType='CAPITAL' and month(PODate) = $i
+ and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'";
$query = $this->db->query($sql);
$array_result[]=$query->result();
@@ -244,13 +298,22 @@ $i++;
}
function getTotalrevenuePoCount(){
$i=1;
-
+ if (date('m') >= 4)
+ {
+ $yearl = date('Y').'-'.(date('Y')+1);
+ } else {
+ $yearl = (date('Y')-1).'-'.date('Y');
+ }
+ $ab=$yearl;
+ $fa=substr($ab,0,-5);
+ $aa=substr($ab,5,5);
while($i<=12){
$sql="SELECT count(cmast.PONO) as totalrevenue FROM T_PurchaseOrder_Master cmast
- join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
- join T_Requestion_Master req on req.ReqNo=line.ReqNo
- where ReqType='REVENUE' and month(PODate) = $i ";
+ left join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO
+ left join T_Requestion_Master req on req.ReqNo=line.ReqNo
+ where ReqType='REVENUE' and month(PODate) = $i
+ and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'";
$query = $this->db->query($sql);
$array_result[]=$query->result();
@@ -364,17 +427,14 @@ function capitalbud ()
function capitalbal ()
{
$sql="SELECT ROUND(sum(BudgetAmount)-(SELECT
-case po.CapitalRange
- when '0'
- then ifnull((sum(distinct(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate)),0)
- when '1'
- then ifnull((sum(distinct PO_Line_Item.Quantity * PO_Line_Item.Rate)),0)
- end
+ifnull(sum(distinct if(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval)),0)
as Util_Amount
from T_CostCenter_Budget Cost_Center_Budget
join T_PurchaseOrder_LineItem PO_Line_Item on Cost_Center_Budget.CostCenterCode=PO_Line_Item.CostCenterCode
-JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.POType=Cost_Center_Budget.BudgetType
-WHERE Cost_Center_Budget.BudgetType='CAPITAL' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())),2) as balcapitalbudget FROM T_CostCenter_Budget where BudgetType ='CAPITAL' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())";
+JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.POType=Cost_Center_Budget.BudgetType and po.Status !='ST030'
+left JOIN T_Service_Tax st on st.LineItemNo = PO_Line_Item.LineItemNo
+WHERE Cost_Center_Budget.BudgetType='CAPITAL' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())),2) as balcapitalbudget FROM T_CostCenter_Budget where BudgetType ='CAPITAL' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())
+";
$query = $this->db->query($sql);
return $query->result();
}
@@ -413,32 +473,8 @@ WHERE Cost_Center_Budget.BudgetType='REVENUE' and YEAR(STR_TO_DATE(`BudgetYear`,
$query = $this->db->query($sql);
return $query->result();
}
-function reqdetail(){
-
-
- $sql="SELECT count(Status) as TODAY_REQUESTS FROM T_Requestion_Master where date(ReqDate) = date(now());";
- $query = $this->db->query($sql);
-
- // echo "from Model";
- // print_r($query->result());
-
- return $query->result();
-
-
-
- }
-
- function req_pending(){
-
-
- $sql="SELECT count(Status) as TOTAL_PENDING_REQUESTS FROM T_Requestion_Master where Status = 'ST002';";
- $query = $this->db->query($sql);
- return $query->result();
-
-
-
- }
+
function req_list(){
@@ -618,7 +654,7 @@ order by monthname(matv.PODate)";
function report_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){
- $sql="SELECT pm.PONO as pono,date_format(pm.PODate,'%d-%m-%Y') as created_date,
+ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date,
TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time,
mm.MaterialName as material_name,sd.SupplierName as supplier_name,
ifnull(sum(pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(pl.Rate),0) as rate,
@@ -692,7 +728,7 @@ $sql.="group by pono,material_name,supplier_name";
function report_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d){
- $sql="SELECT pm.PONO as pono,date_format(pm.PODate,'%d-%m-%Y') as created_date,
+ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date,
TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time,
mm.MaterialName as material_name,sd.SupplierName as supplier_name,
ifnull(sum(pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(pl.Rate),0) as rate,
@@ -1077,7 +1113,7 @@ group by supplier_name,material_name";
function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){
- $sql="SELECT pm.PONO as pono,date_format(pm.PODate,'%d-%m-%Y') as created_date,
+ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date,
TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time,
mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,
ifnull(sum(pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(pl.Rate),0) as rate,
@@ -1155,7 +1191,7 @@ $sql.="group by pono,material_name,category,supplier_name";
function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat){
- $sql="SELECT pm.PONO as pono,date_format(pm.PODate,'%d-%m-%Y') as created_date,
+ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date,
TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time,
mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,
ifnull(sum(pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(pl.Rate),0) as rate,
@@ -1604,7 +1640,7 @@ group by supplier_name,material_name";
function rawi_report_consolidate($cname,$fa,$aa){
- $sql="select mm.Category as category,
+ $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,mm.Category as category,sd.SupplierName as supplier_name,mm.MaterialName as material_name,
SUM(IF(month(pm.PODate) = 4, pl.Quantity, 0)) AS April,
SUM(IF(month(pm.PODate) = 5, pl.Quantity, 0)) AS May,
SUM(IF(month(pm.PODate) = 6, pl.Quantity, 0)) AS June,
diff --git a/application/views/Report_Material_Master_ItemWise.php b/application/views/Report_Material_Master_ItemWise.php
index a5498742..17d4e64b 100755
--- a/application/views/Report_Material_Master_ItemWise.php
+++ b/application/views/Report_Material_Master_ItemWise.php
@@ -6,9 +6,10 @@ if(!empty($mmi))
}
?>
-
+
+