diff --git a/application/config/routes.php b/application/config/routes.php index f603baaa..6bbaee2f 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -243,6 +243,7 @@ $route['Report_pending_purchase'] = "report/pending_purchase"; $route['cashbookreport']="report/cashbook"; $route['cashbookmonthlyexpenses']="report/monthexpenses"; $route['cashbookyearlyexpenses']="report/yearexpenses"; +$route['Empperform']="user/empPerFormation"; // Company Information $route['companyview'] = 'companycontroller/companyview'; diff --git a/application/controllers/user.php b/application/controllers/user.php index d3b0041e..9049b47e 100755 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -422,13 +422,20 @@ class user extends BaseController return $result; } -function monthattendance() +function monthattendance($empID ='') { $date = date('Y-m'); //echo $date; $dates = $date . '-01'; + $EmpID = ''; + if(empty($empID)){ $EmpID = $this->input->post('id'); + } + else + { + $EmpID = $empID; + } // echo $EmpID;die; $monthabs = $this->dahsboard_Model->attendance($EmpID, $dates); $persent_month = date('t');//current month of days 31 @@ -573,19 +580,29 @@ function monthattendance() $month['present_percentage'] = 0; } - echo json_encode($month); + if(empty($empID)){ + echo json_encode($month); + } + else{ + return $month; + } } -function attendanceyear() +function attendanceyear($empID ='') { //echo "hai";die; $CURMONTH = date('m'); $CURDATE = date('d'); $CURYEAR = date('Y'); + $EmpID = ''; + if(empty($empID)){ $EmpID = $this->input->post('id'); - // $month = $this->monthattendance($EmpID); - // echo json_encode($month); + } + else + { + $EmpID = $empID; + } $day = array(); $datejoin = $this->dahsboard_Model->joindate($EmpID); $DateofJoiningInString = $datejoin[0]->DateofJoining; @@ -758,8 +775,48 @@ function attendanceyear() } - echo json_encode($data); - + if(empty($empID)){ + + echo json_encode($data); + } + else{ + return $data; + } +} + + + +function empPerFormation() + { + + // $this->global['pageTitle'] = 'Siddharth : Reports'; +//echo "welcome"; + $EmpLists =$this->dahsboard_Model->getEmployee(); + + //print_r($EmpLists);die; + $index = 0; + $data['emp_performence_details'] = array(); + foreach ($EmpLists as $Emp) { + $EmpID = $Emp->EmpID; + $FirstName =$Emp->FirstName; + $LastName =$Emp->LastName; + $IsActive =$Emp->IsActive; + +//echo $EmpID; + $currentmonthemp = $this-> monthattendance($EmpID); + $fineyearemp = $this->attendanceyear($EmpID); +$a = array($EmpID,$FirstName,$LastName,$IsActive,$currentmonthemp,$fineyearemp); + $data['emp_performence_details'][$index]= $a; + //pre($data[$EmpID]['month']);die; +$index++; +} + + //print_r($data['emp_performence_details']);die; + +$this->loadViews("empperform", $this->global, $data, NULL); + + + } /****************HR DASHBOART Controller END **************************************/ diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index c8deeb3c..5f116baf 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -3,7 +3,7 @@ class dahsboard_Model extends CI_Model { - + /* HR DASHBOART Model START*/ function totemp() { @@ -175,72 +175,105 @@ $sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;"; } + function getEmployee(){ +$sql="select EmpID,FirstName,LastName,IsActive FROM T_Employee_Details "; + $query =$this->db->query($sql); + return $query->result(); + +} + + + +function get_all_employee($Month) +{ + $sql = "select T_Attendance.*,emp.EmpID,emp.FirstName,emp.LastName,emp.IsActive from T_Attendance +join T_Employee_Details emp on T_Attendance.EmpID = emp.EmpID +where Month_Year=?;"; + $query = $this->db->query($sql,array($Month)); + return $query->result(); +} + + +function get_all_employee1($finStart,$finEnd) +{ + + + $sql = "select att.EmpID,att.*,att.Month_Year,emp.FirstName,emp.DateofJoining from T_Attendance att + join T_Employee_Details emp on emp.EmpID = att.EmpID + where att.Month_Year between ? and ?"; + $query = $this->db->query($sql,array($finStart,$finEnd)); + return $query->result(); +} + + + + /* HR DASHBOARD Model END*/ - - function totalpurchaseorder(){ - - - $sql="select count(PONO) as totalpurchaseorder from T_PurchaseOrder_Master pm where Status != 'ST030' - and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end"; + + function totalpurchaseorder(){ + + + $sql="select count(PONO) as totalpurchaseorder from T_PurchaseOrder_Master pm where Status != 'ST030' + and case + when (month(pm.PODate) >=4) then + (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) + else + (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + end"; $query = $this->db->query($sql); - return $query->result(); - - } - function totalordervalue(){ - - - $sql="select sum(totalordervalue) as totalordervalue from T_PurchaseOrder_Master pm where Status != 'ST030' - and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end"; + return $query->result(); + + } + function totalordervalue(){ + + + $sql="select sum(totalordervalue) as totalordervalue from T_PurchaseOrder_Master pm where Status != 'ST030' + and case + when (month(pm.PODate) >=4) then + (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) + else + (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + end"; $query = $this->db->query($sql); - return $query->result(); - - } - function pendingpo(){ - - - $sql="select count(PONO) as pending from T_PurchaseOrder_Master pm where status='ST020' and Status != 'ST030' - and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end"; + return $query->result(); + + } + function pendingpo(){ + + + $sql="select count(PONO) as pending from T_PurchaseOrder_Master pm where status='ST020' and Status != 'ST030' + and case + when (month(pm.PODate) >=4) then + (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) + else + (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + end"; $query = $this->db->query($sql); - return $query->result(); - - } - function req_pending(){ + return $query->result(); + + } + function req_pending(){ $sql="SELECT count(Status) as TOTAL_PENDING_REQUESTS FROM T_Requestion_Master pm where Status = 'ST002' - and case - when (month(pm.ReqDate) >=4) then - (YEAR(pm.ReqDate) = YEAR(CURRENT_DATE) and MONTH(pm.ReqDate) >= 4 ) or ( YEAR(pm.ReqDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.ReqDate) <= 3 ) - else - (YEAR(pm.ReqDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.ReqDate) >= 4 ) or ( YEAR(pm.ReqDate) = YEAR(CURRENT_DATE) and MONTH(pm.ReqDate) <= 3 ) - end"; + and case + when (month(pm.ReqDate) >=4) then + (YEAR(pm.ReqDate) = YEAR(CURRENT_DATE) and MONTH(pm.ReqDate) >= 4 ) or ( YEAR(pm.ReqDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.ReqDate) <= 3 ) + else + (YEAR(pm.ReqDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.ReqDate) >= 4 ) or ( YEAR(pm.ReqDate) = YEAR(CURRENT_DATE) and MONTH(pm.ReqDate) <= 3 ) + end"; $query = $this->db->query($sql); return $query->result(); } - function reqdetail(){ + function reqdetail(){ $now= date('Y-m-d'); $sql="SELECT count(Status) as TODAY_REQUESTS FROM T_Requestion_Master where date(ReqDate) = '".$now."' "; @@ -255,144 +288,144 @@ $sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;"; } - function january(){ - - - $sql="select count(PONO) as pending from T_PurchaseOrder_Master where status='ST020'"; + function january(){ + + + $sql="select count(PONO) as pending from T_PurchaseOrder_Master where status='ST020'"; $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(); + 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(); + // { + // $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(); + // { + // $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); + 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 where POType='SERVICE' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; + and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; $query = $this->db->query($sql); $array_result[]=$query->result(); $i++; } - + return $array_result; } 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); + 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 where POType='IMPORT' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; + and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; $query = $this->db->query($sql); $array_result[]=$query->result(); $i++; } - + return $array_result; } 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); + 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 where POType='CAPITAL' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; + and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; $query = $this->db->query($sql); $array_result[]=$query->result(); $i++; } - + return $array_result; } 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); + 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 where POType='REVENUE' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; + and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; $query = $this->db->query($sql); $array_result[]=$query->result(); $i++; } - + return $array_result; } @@ -402,48 +435,48 @@ $i++; function serviceprogress() - { + { $sql="SELECT count(cmast.PONO) as serviceprogress 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 join T_Status sta on sta.statusCode=req.status where ReqType='SERVICE' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); + $query = $this->db->query($sql); + return $query->result(); } function revenueprogress() - { + { $sql="SELECT count(cmast.PONO) as revenueprogress 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 join T_Status sta on sta.statusCode=req.status where ReqType='REVENUE' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); + $query = $this->db->query($sql); + return $query->result(); } function importprogress() - { + { $sql="SELECT count(cmast.PONO) as importprogress 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 join T_Status sta on sta.statusCode=req.status where ReqType='IMPORT' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); + $query = $this->db->query($sql); + return $query->result(); } function capitalprogress() - { + { $sql="SELECT count(cmast.PONO) as capitalprogress 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 join T_Status sta on sta.statusCode=req.status where ReqType='CAPITAL' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); + $query = $this->db->query($sql); + return $query->result(); } function totalservicepo () { - $sql="SELECT count(cmast.PONO) as totalservicepo FROM T_PurchaseOrder_Master cmast + $sql="SELECT count(cmast.PONO) as totalservicepo 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 join T_Status sta on sta.statusCode=req.status @@ -453,7 +486,7 @@ function totalservicepo () } function totalrevenuepo () { - $sql="SELECT count(cmast.PONO) as totalrevenuepo FROM T_PurchaseOrder_Master cmast + $sql="SELECT count(cmast.PONO) as totalrevenuepo 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 join T_Status sta on sta.statusCode=req.status @@ -463,7 +496,7 @@ function totalrevenuepo () } function totalimportpo () { - $sql="SELECT count(cmast.PONO) as totalimportpo FROM T_PurchaseOrder_Master cmast + $sql="SELECT count(cmast.PONO) as totalimportpo 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 join T_Status sta on sta.statusCode=req.status @@ -474,43 +507,43 @@ function totalimportpo () function importbudgt () { - $sql="SELECT ROUND(sum(BudgetAmount),2) as totalimportbudget FROM T_CostCenter_Budget where BudgetType ='IMPORT' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())"; + $sql="SELECT ROUND(sum(BudgetAmount),2) as totalimportbudget FROM T_CostCenter_Budget where BudgetType ='IMPORT' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())"; $query = $this->db->query($sql); return $query->result(); } function capitalbud () { - $sql="SELECT sum(BudgetAmount) as totalcapitalbudget FROM T_CostCenter_Budget where BudgetType ='CAPITAL' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW()) "; + $sql="SELECT sum(BudgetAmount) as totalcapitalbudget FROM T_CostCenter_Budget where BudgetType ='CAPITAL' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW()) "; $query = $this->db->query($sql); return $query->result(); } function servicebudgt () { - $sql="SELECT ROUND(sum(BudgetAmount),2) as totalservicebudget FROM T_CostCenter_Budget where BudgetType ='SERVICE' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())"; + $sql="SELECT ROUND(sum(BudgetAmount),2) as totalservicebudget FROM T_CostCenter_Budget where BudgetType ='SERVICE' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())"; $query = $this->db->query($sql); return $query->result(); } function revenuebudgt () { - $sql="SELECT ROUND(sum(BudgetAmount),2) as totalrevenuebudget FROM T_CostCenter_Budget where BudgetType ='REVENUE' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())"; + $sql="SELECT ROUND(sum(BudgetAmount),2) as totalrevenuebudget FROM T_CostCenter_Budget where BudgetType ='REVENUE' and YEAR(STR_TO_DATE(`BudgetYear`,'%Y')) = YEAR(NOW())"; $query = $this->db->query($sql); return $query->result(); } function typebal () { - 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); - $sql="SELECT Cost_Center_Budget.BudgetYear as BudgetYear, + 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); + $sql="SELECT Cost_Center_Budget.BudgetYear as BudgetYear, sum(if(Cost_Center_Budget.BudgetType='IMPORT', (PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0)) as im, sum(if(Cost_Center_Budget.BudgetType='CAPITAL', @@ -537,42 +570,42 @@ Cost_Center_Budget.BudgetYear function req_list($fa,$aa,$m,$frm,$t,$agf,$agt){ - $sql="select date_format(mas.ReqDate,'%d-%m-%Y') as ReqDate,mas.ReqNo,emp.FirstName as Requestedby,dep.DepartmentName,mas.ReqType,DATEDIFF(CURDATE(),mas.ReqDate) AS Aging from T_Requestion_Master as mas - join T_CostCenter_Master cos on cos.CostCenterCode = mas.CostCenterCode - join T_Employee_Details emp on emp.EmpID = mas.Requestedby - join T_DepartmentDetails dep on dep.DEPCode=emp.Departmentcode - where mas.Status = 'ST002' - "; - if ($fa and $aa != ''){ - - $sql.=" and (mas.ReqDate >= '".$fa."-04-01' and mas.ReqDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(mas.ReqDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(mas.ReqDate) >= '".$fromd."' + $sql="select date_format(mas.ReqDate,'%d-%m-%Y') as ReqDate,mas.ReqNo,emp.FirstName as Requestedby,dep.DepartmentName,mas.ReqType,DATEDIFF(CURDATE(),mas.ReqDate) AS Aging from T_Requestion_Master as mas + join T_CostCenter_Master cos on cos.CostCenterCode = mas.CostCenterCode + join T_Employee_Details emp on emp.EmpID = mas.Requestedby + join T_DepartmentDetails dep on dep.DEPCode=emp.Departmentcode + where mas.Status = 'ST002' + "; + if ($fa and $aa != ''){ + + $sql.=" and (mas.ReqDate >= '".$fa."-04-01' and mas.ReqDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(mas.ReqDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(mas.ReqDate) >= '".$fromd."' and date(mas.ReqDate) <= '".$tod."'"; - - } - if ($agf and $agt != ''){ - - $sql.="and DATEDIFF(CURDATE(),mas.ReqDate) >= '".$agf."' + + } + if ($agf and $agt != ''){ + + $sql.="and DATEDIFF(CURDATE(),mas.ReqDate) >= '".$agf."' and DATEDIFF(CURDATE(),mas.ReqDate) <= '".$agt."'"; - - } + + } $query = $this->db->query($sql); - //print_r($this->db->last_query()); - return $query->result(); - } - + //print_r($this->db->last_query()); + return $query->result(); + } + function report_relpo($fa,$aa,$m,$frm,$t,$agf,$agt){ $sql="select Mast.PONO,Mast.POType,date_format(Mast.PODate,'%d-%m-%Y') as PODate,date_format(Mast.ReleasedOn,'%d-%m-%Y') as ReleasedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue from T_PurchaseOrder_Master Mast @@ -586,36 +619,36 @@ JOIN T_CostCenter_Budget as Cost_Center_Bdgt on Cost.CostCenterCode=Cost_Center_ where Mast.Status='ST026' "; if ($fa and $aa != ''){ - - $sql.=" and (Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(Mast.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(Mast.PODate) >= '".$fromd."' + + $sql.=" and (Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(Mast.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(Mast.PODate) >= '".$fromd."' and date(Mast.PODate) <= '".$tod."'"; - - } - if ($agf and $agt != ''){ - - $sql.="and Mast.TotalOrderValue >= '".$agf."' + + } + if ($agf and $agt != ''){ + + $sql.="and Mast.TotalOrderValue >= '".$agf."' and Mast.TotalOrderValue <= '".$agt."'"; - - } - $sql.=" group by Mast.PONO"; + + } + $sql.=" group by Mast.PONO"; $query = $this->db->query($sql); return $query->result(); } - - function report_openpending($fa,$aa,$m,$frm,$t,$agf,$agt){ + + function report_openpending($fa,$aa,$m,$frm,$t,$agf,$agt){ $sql="select Mast.PONO as PONO,Mast.POType as POType,date_format(Mast.PODate,'%d-%m-%Y') as PODate,date_format(Mast.ApprovedOn,'%d-%m-%Y') as ApprovedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue from T_PurchaseOrder_Master Mast JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO @@ -628,40 +661,40 @@ JOIN T_CostCenter_Budget as Cost_Center_Bdgt on Cost.CostCenterCode=Cost_Center_ where (Mast.Status='ST025' or Mast.Status='ST005') "; if ($fa and $aa != ''){ - - $sql.=" and (Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(Mast.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(Mast.PODate) >= '".$fromd."' + + $sql.=" and (Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(Mast.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(Mast.PODate) >= '".$fromd."' and date(Mast.PODate) <= '".$tod."'"; - - } - if ($agf and $agt != ''){ - - $sql.="and Mast.TotalOrderValue >= '".$agf."' + + } + if ($agf and $agt != ''){ + + $sql.="and Mast.TotalOrderValue >= '".$agf."' and Mast.TotalOrderValue <= '".$agt."'"; - - } - $sql.=" group by PONO,POType,Dept_Name"; + + } + $sql.=" group by PONO,POType,Dept_Name"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - - function report_total($fa,$aa){ + + function report_total($fa,$aa){ $sql="select ifnull(Dept_Details.DepartmentName,'-') As Dept_Name, @@ -686,8 +719,8 @@ group by Dept_Name"; } - - function report_ccr($fa,$aa){ + + function report_ccr($fa,$aa){ $sql="SELECT Cost_Center_Budget.CostCenterCode as Cost_Center_Code, CostCenterName as Cost_Center_Name,group_concat(distinct Dept_Details.DepartmentName) as Dept_Name,Cost_Center_Budget.BudgetType as BudgetType,Cost_Center_Budget.BudgetYear as BudgetYear, @@ -743,9 +776,9 @@ order by Cost_Center_Budget.CostCenterCode"; } - - - function report_MMSupplier(){ + + + function report_MMSupplier(){ $sql="select po.PODate as Material_Date,po.SupplierID,sup.SupplierName,pl.MaterialCode,mm.MaterialName,mm.MaterialType,mm.UOM,mm.HSNCODE @@ -760,8 +793,8 @@ group by po.SupplierID,pl.MaterialCode"; } - - function report_MMItem(){ + + function report_MMItem(){ $sql="SELECT MaterialCode,MaterialName,UOM,Category,HSNCODE FROM T_MaterialMaster group by MaterialCode"; @@ -771,8 +804,8 @@ group by po.SupplierID,pl.MaterialCode"; } - - function report_MMReceiptValue($fa,$aa,$m){ + + function report_MMReceiptValue($fa,$aa,$m){ $sql="select @@ -783,24 +816,24 @@ join T_PurchaseOrder_Master pm on pm.CreatedDate = matv.CreatedDate join T_MaterialMaster mat on matv.MaterialCode=mat.MaterialCode where pm.PODate != 0 "; if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - $sql.=" group by matv.MaterialCode"; - $sql.=" order by monthname(pm.PODate)"; + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(pm.PODate) = '".$m."'"; + + } + $sql.=" group by matv.MaterialCode"; + $sql.=" order by monthname(pm.PODate)"; $query = $this->db->query($sql); return $query->result(); } - function report_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ + function report_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date, @@ -835,38 +868,38 @@ where pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(pm.PODate) >= '".$fromd."' + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(pm.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(pm.PODate) >= '".$fromd."' and date(pm.PODate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + $sql.="group by pono,material_name,supplier_name"; @@ -874,7 +907,7 @@ $sql.="group by pono,material_name,supplier_name"; $query = $this->db->query($sql); return $query->result(); } - function report_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d){ + function report_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d){ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date, @@ -909,53 +942,53 @@ where pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(pm.PODate) >= '".$fromd."' + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(pm.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(pm.PODate) >= '".$fromd."' and date(pm.PODate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($sid!= ''){ - - $sql.=" and sd.SupplierID = '".$sid."' "; - - } - if ($mid!= ''){ - - $sql.=" and mm.MaterialCode = '".$mid."' "; - - } - if ($d!= ''){ - - $sql.=" and date(pm.PODate) = '".$d."' "; - - } - + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + if ($sid!= ''){ + + $sql.=" and sd.SupplierID = '".$sid."' "; + + } + if ($mid!= ''){ + + $sql.=" and mm.MaterialCode = '".$mid."' "; + + } + if ($d!= ''){ + + $sql.=" and date(pm.PODate) = '".$d."' "; + + } + $sql.="group by pono,material_name,supplier_name"; @@ -963,7 +996,7 @@ $sql.="group by pono,material_name,supplier_name"; $query = $this->db->query($sql); return $query->result(); } - function report_finyear(){ + function report_finyear(){ $sql="SELECT @@ -978,7 +1011,7 @@ GROUP BY financial_year"; } - function report_year_wise(){ + function report_year_wise(){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,pm.POdate as created_date,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total @@ -995,24 +1028,24 @@ group by month(created_date)"; } - function customer_name(){ + function customer_name(){ $sql="SELECT distinct SupplierName FROM T_SupplierDetailsN;"; $query = $this->db->query($sql); return $query->result(); } - function material_name(){ + function material_name(){ $sql="SELECT distinct MaterialName FROM T_MaterialMaster;"; $query = $this->db->query($sql); return $query->result(); } - function category(){ + function category(){ $sql="SELECT distinct Category FROM T_MaterialMaster;"; $query = $this->db->query($sql); return $query->result(); } - function report_month_wise($mont){ + function report_month_wise($mont){ $month= date("m",strtotime($mont)); - $year = date("Y",strtotime($mont)); + $year = date("Y",strtotime($mont)); $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total FROM T_PurchaseOrder_Master pm @@ -1025,7 +1058,7 @@ group by supplier_name,material_name"; $query = $this->db->query($sql,array($month,$year)); return $query->result(); } - function report_year_wise_total($a,$b){ + function report_year_wise_total($a,$b){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total FROM T_PurchaseOrder_Master pm @@ -1038,12 +1071,12 @@ group by supplier_name,material_name"; $query = $this->db->query($sql,array()); return $query->result(); } - - function report_supplier($cname,$fa,$aa,$m,$frm,$t){ + + function report_supplier($cname,$fa,$aa,$m,$frm,$t){ $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(pm.PONO) as counts,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, - + case pm.POType when 'IMPORT' then ifnull((sum(distinct(pl.Quantity * pl.Rate) * pm.ExchangeRate) @@ -1086,39 +1119,39 @@ where pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(pm.PODate) >= '".$fromd."' + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(pm.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(pm.PODate) >= '".$fromd."' and date(pm.PODate) <= '".$tod."'"; - - } - $sql.= "group by supplier_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); + + } + $sql.= "group by supplier_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); } - function report_consolidate($cname,$fa,$aa){ + function report_consolidate($cname,$fa,$aa){ $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,mm.MaterialName as material_name, @@ -1155,26 +1188,26 @@ join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and pm.Status != 'ST056' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - - $sql.= "group by supplier_name,material_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + + $sql.= "group by supplier_name,material_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); } - function consolidate_month($m=null,$cname=null,$mid=null,$fa=null,$aa=null){ + function consolidate_month($m=null,$cname=null,$mid=null,$fa=null,$aa=null){ $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, sum(pl.Quantity) as quantity, @@ -1188,16 +1221,16 @@ left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where pm.Status != 'ST030' and pm.Status != 'ST056' and monthname(pm.PODate) = '".$m."' and sd.SupplierName = '".$cname."' and mm.MaterialCode = '".$mid."' "; if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + $sql.= "group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; return $query->result(); } - function consolidate_year($cname=null,$mid=null,$fa=null,$aa=null){ + function consolidate_year($cname=null,$mid=null,$fa=null,$aa=null){ $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, sum(pl.Quantity) as quantity, @@ -1210,16 +1243,16 @@ left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName = '".$cname."' and mm.MaterialCode = '".$mid."' "; if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; + + $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + + } + $sql.= "group by supplier_name,material_name"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - function report_cumulative(){ + function report_cumulative(){ $sql="SELECT year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal FROM (SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total @@ -1229,11 +1262,11 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end + when (month(pm.PODate) >=4) then + (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) + else + (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + end group by supplier_name,material_name ) as year left join (SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as mquantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as mtotal @@ -1260,19 +1293,19 @@ group by supplier_name,material_name $query = $this->db->query($sql); return $query->result(); } - function report_cum_month($sup=null,$mat=null){ + function report_cum_month($sup=null,$mat=null){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and month(pm.PODate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and month(pm.PODate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function report_cum_year($sup=null,$mat=null){ + function report_cum_year($sup=null,$mat=null){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1281,17 +1314,17 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.POdate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end - and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' + when (month(pm.PODate) >=4) then + (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.POdate) <= 3 ) + else + (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) + end + and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function report_cum_day($sup=null,$mat=null){ + function report_cum_day($sup=null,$mat=null){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1299,30 +1332,30 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and -date(pm.PODate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +date(pm.PODate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ + function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(im.CreatedDate,'%d-%m-%Y') as created_date, TIME_FORMAT(im.CreatedDate,'%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, -round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate, -ifnull(if(POType = 'REVENUE',sum(rt.AfterSGST),sum(st.After_SGST)),0) as sgst, -ifnull(if(POType = 'REVENUE',sum(rt.AfterCGST),sum(st.After_CGST)),0) as cgst, -ifnull(if(POType = 'REVENUE',sum(rt.AfterIGST),sum(st.After_IGST)),0) as igst, -ifnull(if(POType = 'REVENUE',sum(rt.AfterDiscount),sum(st.Afterdiscountval)),0) as discount, -ifnull(if(POType = 'REVENUE',sum(rt.AfterFreightValue),sum(st.AfterFreightValue)),0) as freight, -ifnull(if(POType = 'REVENUE',sum(rt.AfterPackagingValue),0),0) as Package, +ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, +round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, +if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0) as discount, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) as freight, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) as Package, round(( if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(pl.Quantity * pl.Rate),0))) +ifnull(sum(distinct pl.Quantity * pl.Rate),0))) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) @@ -1340,43 +1373,43 @@ left join T_PurchaseOrder_BillUpload pb on pb.PONO=pm.PONO where pm.Status != 'ST030' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(im.CreatedDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(im.CreatedDate) >= '".$fromd."' + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(im.CreatedDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(im.CreatedDate) >= '".$fromd."' and date(im.CreatedDate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($cat!= ''){ - - $sql.=" and mm.Category = '".$cat."' "; - - } - + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + if ($cat!= ''){ + + $sql.=" and mm.Category = '".$cat."' "; + + } + $sql.="group by pono,material_name,category,supplier_name"; @@ -1384,25 +1417,25 @@ $sql.="group by pono,material_name,category,supplier_name"; $query = $this->db->query($sql); return $query->result(); } - function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat){ + function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat){ $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(im.CreatedDate,'%d-%m-%Y') as created_date, TIME_FORMAT(im.CreatedDate,'%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, -round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(pm.ExchangeRate),0) as exchange_rate, -ifnull(if(POType = 'REVENUE',sum(rt.AfterSGST),sum(st.After_SGST)),0) as sgst, -ifnull(if(POType = 'REVENUE',sum(rt.AfterCGST),sum(st.After_CGST)),0) as cgst, -ifnull(if(POType = 'REVENUE',sum(rt.AfterIGST),sum(st.After_IGST)),0) as igst, -ifnull(if(POType = 'REVENUE',sum(rt.AfterDiscount),sum(st.Afterdiscountval)),0) as discount, -ifnull(if(POType = 'REVENUE',sum(rt.AfterFreightValue),sum(st.AfterFreightValue)),0) as freight, -ifnull(if(POType = 'REVENUE',sum(rt.AfterPackagingValue),0),0) as Package, +ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, +round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, +if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0) as discount, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) as freight, +ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) as Package, round(( if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(pl.Quantity * pl.Rate),0))) +ifnull(sum(distinct pl.Quantity * pl.Rate),0))) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) @@ -1420,58 +1453,58 @@ left join T_PurchaseOrder_BillUpload pb on pb.PONO=pm.PONO where pm.Status != 'ST030' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(im.CreatedDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(im.CreatedDate) >= '".$fromd."' + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(im.CreatedDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(im.CreatedDate) >= '".$fromd."' and date(im.CreatedDate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($sid!= ''){ - - $sql.=" and sd.SupplierID = '".$sid."' "; - - } - if ($mid!= ''){ - - $sql.=" and mm.MaterialCode = '".$mid."' "; - - } - if ($d!= ''){ - - $sql.=" and date(im.CreatedDate) = '".$d."' "; - - } - if ($cat!= ''){ - - $sql.=" and mm.Category = '".$cat."' "; - - } - + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + if ($sid!= ''){ + + $sql.=" and sd.SupplierID = '".$sid."' "; + + } + if ($mid!= ''){ + + $sql.=" and mm.MaterialCode = '".$mid."' "; + + } + if ($d!= ''){ + + $sql.=" and date(im.CreatedDate) = '".$d."' "; + + } + if ($cat!= ''){ + + $sql.=" and mm.Category = '".$cat."' "; + + } + $sql.="group by pono,material_name,category,supplier_name"; @@ -1481,8 +1514,8 @@ $sql.="group by pono,material_name,category,supplier_name"; $query = $this->db->query($sql); return $query->result(); } - - function ireport_year_wise(){ + + function ireport_year_wise(){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,im.CreatedDate as created_date,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total @@ -1500,10 +1533,10 @@ group by month(created_date)"; } - - function ireport_month_wise($mont){ + + function ireport_month_wise($mont){ $month= date("m",strtotime($mont)); - $year = date("Y",strtotime($mont)); + $year = date("Y",strtotime($mont)); $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total FROM T_PurchaseOrder_Master pm @@ -1517,7 +1550,7 @@ group by supplier_name,material_name"; $query = $this->db->query($sql,array($month,$year)); return $query->result(); } - function ireport_year_wise_total($a,$b){ + function ireport_year_wise_total($a,$b){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total FROM T_PurchaseOrder_Master pm @@ -1531,12 +1564,12 @@ group by supplier_name,material_name"; $query = $this->db->query($sql,array()); return $query->result(); } - - function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){ + + function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){ $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(pm.PONO) as counts,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, - + case pm.POType when 'IMPORT' then ifnull((sum(distinct(pl.Quantity * pl.Rate) * pm.ExchangeRate) @@ -1580,39 +1613,39 @@ where pm.Status != 'ST030' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(im.CreatedDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(im.CreatedDate) >= '".$fromd."' + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(im.CreatedDate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(im.CreatedDate) >= '".$fromd."' and date(im.CreatedDate) <= '".$tod."'"; - - } - $sql.= "group by supplier_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); + + } + $sql.= "group by supplier_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); } - function ireport_consolidate($cname,$fa,$aa){ + function ireport_consolidate($cname,$fa,$aa){ $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,mm.MaterialName as material_name, @@ -1652,26 +1685,26 @@ left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where pm.Status != 'ST030' "; if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - - $sql.= "group by supplier_name,material_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); + + $sql.="and sd.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + + $sql.= "group by supplier_name,material_name"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); } - function i_consolidate_month($m=null,$cname=null,$prod=null,$fa=null,$aa=null){ + function i_consolidate_month($m=null,$cname=null,$prod=null,$fa=null,$aa=null){ $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, sum(pl.Quantity) as quantity, @@ -1686,16 +1719,16 @@ left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where pm.Status != 'ST030' and monthname(im.CreatedDate) = '".$m."' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + $sql.= "group by supplier_name,material_name"; + $query = $this->db->query($sql); + //echo $sql; return $query->result(); } - function i_consolidate_year($cname=null,$prod=null,$fa=null,$aa=null){ + function i_consolidate_year($cname=null,$prod=null,$fa=null,$aa=null){ $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, sum(pl.Quantity) as quantity, @@ -1709,16 +1742,16 @@ left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where pm.Status != 'ST030' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + $sql.= "group by supplier_name,material_name"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - function ireport_cumulative(){ + function ireport_cumulative(){ $sql="SELECT year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal FROM (SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total @@ -1729,11 +1762,11 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and case - when (month(im.CreatedDate) >=4) then - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) - else - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) - end + when (month(im.CreatedDate) >=4) then + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) + else + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) + end group by supplier_name,material_name ) as year left join (SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as mquantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as mtotal @@ -1762,7 +1795,7 @@ group by supplier_name,material_name $query = $this->db->query($sql); return $query->result(); } - function ireport_cum_month($sup=null,$mat=null){ + function ireport_cum_month($sup=null,$mat=null){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1770,12 +1803,12 @@ join T_IGR_Master im on im.PONO = pm.PONO left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and month(im.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +where pm.Status != 'ST030' and month(im.CreatedDate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function ireport_cum_year($sup=null,$mat=null){ + function ireport_cum_year($sup=null,$mat=null){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1785,17 +1818,17 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and case - when (month(im.CreatedDate) >=4) then - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) - else - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) - end - and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' + when (month(im.CreatedDate) >=4) then + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) + else + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) + end + and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function ireport_cum_day($sup=null,$mat=null){ + function ireport_cum_day($sup=null,$mat=null){ $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1804,12 +1837,12 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and -date(im.CreatedDate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' +date(im.CreatedDate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function rawi_report_cumulative(){ + function rawi_report_cumulative(){ $sql="SELECT year.category as category,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal FROM (SELECT mm.Category as category,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total @@ -1820,11 +1853,11 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and case - when (month(im.CreatedDate) >=4) then - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) - else - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) - end + when (month(im.CreatedDate) >=4) then + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) + else + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) + end group by category ) as year left join (SELECT mm.Category as category,ifnull(sum(pl.Quantity),0) as mquantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as mtotal @@ -1852,7 +1885,7 @@ group by category "; $query = $this->db->query($sql); return $query->result(); } - function rawi_report_cum_year($cat=null){ + function rawi_report_cum_year($cat=null){ $sql="SELECT mm.Category as category,sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1862,18 +1895,18 @@ left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and case - when (month(im.CreatedDate) >=4) then - (YEARim.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) - else - (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) - end - and mm.Category = '".$cat."' + when (month(im.CreatedDate) >=4) then + (YEARim.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)+1 and MONTH(im.CreatedDate) <= 3 ) + else + (YEAR(im.CreatedDate) = YEAR(CURRENT_DATE)-1 and MONTH(im.CreatedDate) >= 4 ) or ( YEAR(im.CreatedDate) = YEAR(CURRENT_DATE) and MONTH(im.CreatedDate) <= 3 ) + end + and mm.Category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - function rawi_report_cum_month($cat=null){ + function rawi_report_cum_month($cat=null){ $sql="SELECT mm.Category as category,sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1882,12 +1915,12 @@ left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and -month(im.CreatedDate) = month(current_date()) and mm.Category = '".$cat."' +month(im.CreatedDate) = month(current_date()) and mm.Category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - function rawi_report_cum_day($cat=null){ + function rawi_report_cum_day($cat=null){ $sql="SELECT mm.Category as category,sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm @@ -1899,10 +1932,10 @@ where pm.Status != 'ST030' and date(im.CreatedDate) = current_date() and mm.Category = '".$cat."' group by supplier_name,material_name"; $query = $this->db->query($sql); - echo $sql; + echo $sql; return $query->result(); } - function rawi_report_consolidate($cname,$fa,$aa){ + function rawi_report_consolidate($cname,$fa,$aa){ $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,mm.Category as category,sd.SupplierName as supplier_name,mm.MaterialName as material_name, @@ -1940,26 +1973,26 @@ join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' "; if ($cname!= ''){ - - $sql.="and mm.Category = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - - $sql.= "group by category"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); + + $sql.="and mm.Category = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + + $sql.= "group by category"; + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); } - function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){ + function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){ $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, sum(pl.Quantity) as quantity, @@ -1972,16 +2005,16 @@ join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and monthname(im.CreatedDate) = '".$m."' and mm.Category = '".$cat."' "; if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - $sql.= "group by category,supplier_name,material_name"; + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + $sql.= "group by category,supplier_name,material_name"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - function rawi_consolidate_year($cat=null,$sup=null,$fa=null,$aa=null){ + function rawi_consolidate_year($cat=null,$sup=null,$fa=null,$aa=null){ $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, sum(pl.Quantity) as quantity, @@ -1994,16 +2027,16 @@ join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID where pm.Status != 'ST030' and mm.Category = '".$cat."' "; if ($fa and $aa != ''){ - - $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - - } - $sql.= "group by category,supplier_name,material_name"; + + $sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; + + } + $sql.= "group by category,supplier_name,material_name"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - function pending_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ + function pending_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ $sql="select po.PONO as po,date_format(po.PODate,'%d-%m-%Y') as pdate,sup.SupplierName as supplier,mm.MaterialName as material,mm.Category as category,pl.Quantity as quantity,pl.ReceivedQuantity as received, (pl.Quantity - pl.ReceivedQuantity) as pending from T_PurchaseOrder_LineItem pl @@ -2013,112 +2046,112 @@ join T_MaterialMaster mm on mm.MaterialCode=pl.MaterialCode where po.Status != 'ST030' and po.Status = 'ST026' "; if ($cname!= ''){ - - $sql.="and sup.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (po.PODate >= '".$fa."-04-01' and po.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(po.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(po.PODate) >= '".$fromd."' + + $sql.="and sup.SupplierName = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (po.PODate >= '".$fa."-04-01' and po.PODate <= '".$aa."-03-31')"; + + } + if ($m!= ''){ + + $sql.="and monthname(po.PODate) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromd= date("Y-m-d",strtotime($frm)); + $tod=date("Y-m-d",strtotime($t)); + + $sql.="and date(po.PODate) >= '".$fromd."' and date(po.PODate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - // if ($cat!= ''){ - - // $sql.=" and mm.Category = '".$cat."' "; - - // } - $sql.="order by po.PONO"; + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + // if ($cat!= ''){ + + // $sql.=" and mm.Category = '".$cat."' "; + + // } + $sql.="order by po.PONO"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } - function cashbook() - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, + function cashbook() + { + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code "; - $query = $this->db->query($sql); - return $query->result(); - } - //home --this month// - function monthexpensereport() - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then sum(tinc.total) - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then sum(tinc.total) - end, '0') as income, + $query = $this->db->query($sql); + return $query->result(); + } + //home --this month// + function monthexpensereport() + { + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then sum(tinc.total) + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then sum(tinc.total) + end, '0') as income, ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, tinc.total,tinc.towhom,tinc.description,monthname(tinc.date)as month,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where month(tinc.date)= month(current_date())group by tinc.account_code"; - $query = $this->db->query($sql); - return $query->result(); - - } - //home--this year// - function yearexpensereport($fa,$aa) - { - $sql="select monthname(date) as month, + $query = $this->db->query($sql); + return $query->result(); + + } + //home--this year// + function yearexpensereport($fa,$aa) + { + $sql="select monthname(date) as month, sum(if(type='PAYMENT',total,0)) as exp, sum(if(type='RECEIPT',total,0)) as inc, sum(total) as total from t_income_expense - where date >= '".$fa."-04-01' and date <= '".$aa."-03-31' + where date >= '".$fa."-04-01' and date <= '".$aa."-03-31' group by month "; - $query = $this->db->query($sql); - return $query->result(); - - } - - //home--report--Day Wise Report // - function today_data($value='') + $query = $this->db->query($sql); + return $query->result(); + + } + + //home--report--Day Wise Report // + function today_data($value='') { $sql="SELECT type,Sum(total) as todaydata FROM t_income_expense WHERE type = ? AND DATE(date) = CURRENT_DATE"; $query = $this->db->query($sql,array($value)); @@ -2143,79 +2176,79 @@ if ($cname!= ''){ return $query->result(); } - function departmentwise($sid='',$d='',$c='') + function departmentwise($sid='',$d='',$c='') { $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,.tinc.description, ac.name FROM - t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code - WHERE account_code = '$sid' and monthname(date)='$d' and tinc.type='$c'"; + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,.tinc.description, ac.name FROM + t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code + WHERE account_code = '$sid' and monthname(date)='$d' and tinc.type='$c'"; $query = $this->db->query($sql); - //print_r($this->db->last_query()); - //echo $sql; + //print_r($this->db->last_query()); + //echo $sql; return $query->result(); } - //yearwise/month// - function yearmonthwise($sid='') + //yearwise/month// + function yearmonthwise($sid='') { $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then sum(tinc.total) - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then sum(tinc.total) - end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then sum(tinc.total) + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then sum(tinc.total) + end, '0') as income, ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.account_code,sum(tinc.total)as total,monthname(tinc.date)as month,tinc.description,tinc.towhom,tinc.account_code,ac.name FROM t_income_expense tinc - join t_accountcode ac on ac.code=tinc.account_code - WHERE monthname(date) = ? group by tinc.account_code"; + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.account_code,sum(tinc.total)as total,monthname(tinc.date)as month,tinc.description,tinc.towhom,tinc.account_code,ac.name FROM t_income_expense tinc + join t_accountcode ac on ac.code=tinc.account_code + WHERE monthname(date) = ? group by tinc.account_code"; $query = $this->db->query($sql,array($sid)); - //print_r($this->db->last_query()); + //print_r($this->db->last_query()); return $query->result(); } - //for dashboard graph in cashbook// - function gettoptotal(){ + //for dashboard graph in cashbook// + function gettoptotal(){ $i=1; - + while($i<=12){ $sql="SELECT sum(total) as tot FROM t_income_expense where month(date)= $i"; // $sql="SELECT sum(total)as ttl,concat(sum(total),'-',account_code)as atotal FROM t_income_expense where month(date)= $i // group by account_code order by ttl desc limit 4"; $query = $this->db->query($sql); - //print_r($this->db->last_query()); - //return $query->result(); + //print_r($this->db->last_query()); + //return $query->result(); $array_result[]=$query->result(); $i++; } - + return $array_result; } @@ -2224,9 +2257,9 @@ function INRSymbol() $sql='select FontCode2000 from T_Currency_Details where Currency_Code="INR"'; $query=$this->db->query($sql); return $query->result(); - } - - function cashbookfinyear(){ + } + + function cashbookfinyear(){ $sql="SELECT @@ -2241,97 +2274,97 @@ function INRSymbol() } - function today() + function today() { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, tinc.total,tinc.towhom,tinc.description,tinc.document,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE DATE(date) = CURRENT_DATE"; - $query = $this->db->query($sql); - return $query->result(); - } + $query = $this->db->query($sql); + return $query->result(); + } // $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,tinc.description,tinc.account_code,tac.name FROM t_income_expense tinc // LEFT JOIN t_accountcode tac ON tac.code = tinc.account_code // WHERE DATE(date) = CURRENT_DATE"; // $query = $this->db->query($sql); // return $query->result(); //} - - function monthlypayments() + + function monthlypayments() { $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,.tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE MONTH(date) = MONTH(curdate()) group by account_code"; - $query = $this->db->query($sql); - //print_r($this->db->last_query()); + $query = $this->db->query($sql); + //print_r($this->db->last_query()); return $query->result(); } - - //home page --Reports// - function departmentmenu($fdate,$tdate,$fa,$aa) + + //home page --Reports// + function departmentmenu($fdate,$tdate,$fa,$aa) { - + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.document,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where tinc.date !=0 "; - if ($fdate and $tdate != ''){ - $fdate= date("Y-m-d",strtotime($fdate)); - $tdate=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(tinc.date) >= '".$fdate."' + if ($fdate and $tdate != ''){ + $fdate= date("Y-m-d",strtotime($fdate)); + $tdate=date("Y-m-d",strtotime($tdate)); + + $sql.="and date(tinc.date) >= '".$fdate."' and date(tinc.date) <= '".$tdate."'"; - } - if ($fa and $aa != ''){ - - $sql.=" and (tinc.date >= '".$fa."-04-01' and tinc.date <= '".$aa."-03-31')"; - - } - - - $query = $this->db->query($sql); - //echo $fdate; - //print_r($this->db->last_query()); - //echo $sql; + } + if ($fa and $aa != ''){ + + $sql.=" and (tinc.date >= '".$fa."-04-01' and tinc.date <= '".$aa."-03-31')"; + + } + + + $query = $this->db->query($sql); + //echo $fdate; + //print_r($this->db->last_query()); + //echo $sql; return $query->result(); } - function menudepartmentwise($sid='') + function menudepartmentwise($sid='') { $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code - WHERE account_code = '$sid'"; + WHERE account_code = '$sid'"; $query = $this->db->query($sql); - //print_r($this->db->last_query()); - //echo $sql; + //print_r($this->db->last_query()); + //echo $sql; return $query->result(); } } -?> \ No newline at end of file +?> diff --git a/application/views/empperform.php b/application/views/empperform.php new file mode 100644 index 00000000..e833141f --- /dev/null +++ b/application/views/empperform.php @@ -0,0 +1,172 @@ + + + + + + + + + + +
+ +
+ +
+
+
+
+ +

Report - Employees Performance

+ +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EmpIDEmployee Name StatusMonthWorkingMonthPresentMonthPercentageYearWorkingYearPresentYearPercentage
+ + +
+
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/views/reportslink.php b/application/views/reportslink.php index 0f67131b..86722d51 100755 --- a/application/views/reportslink.php +++ b/application/views/reportslink.php @@ -74,6 +74,8 @@

  Attendance

Employee Attendance

+ + Employee Performance