diff --git a/application/config/routes.php b/application/config/routes.php index a8f795ec..a1d03394 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -77,6 +77,8 @@ $route['emppayListings/(:num)'] = 'emppaydate/emppayListing/$1'; $route['attendance'] = 'monthlypay/attendanceLoad'; $route['publicholidays'] = 'monthlypay/loadPublicholidays'; $route['loanreports'] = 'payslip/loadLoanReport'; +$route['bonusreports'] = 'payslip/Bonusreport'; + $route['qualityreportlist'] = "quality/reportList"; $route['qualityreportlistinward'] = "quality/reportListInward"; diff --git a/application/controllers/payslip.php b/application/controllers/payslip.php index 756fea79..84ea9c06 100755 --- a/application/controllers/payslip.php +++ b/application/controllers/payslip.php @@ -340,7 +340,8 @@ class payslip extends BaseController $mpdf=new mPDF('utf-8','A4-P',10, 12,12, 10, 10, 38, 4, 6); $HTMLFooter = $this->load->view('includes/bankreport_footer',$data, true); $mpdf->SetDisplayMode('fullpage'); - /*$mpdf->SetTitle('Resico : PDF'.$filename);*/ + $mpdf->SetTitle('Resico : PDF'.$filename); + /*$mpdf->setTitle('Resico : PayrollReport');*/ //$mpdf->SetHTMLHeader($HtmlHeading); $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); // $mpdf->setFooter("Page {PAGENO} of {nb}"); @@ -526,6 +527,7 @@ class payslip extends BaseController $OT_Hrs_Worked = $j['OT Hours Worked in Hrs']; $Loan_Recovered = $j['Loan Recovered in ₹']; $Incentives = $j['Incentives in ₹']; + $Festival_Bonus = $j['Festival Bonus in ₹']; $Other_Deductions = $j['Other Deductions in ₹']; $Created_By = $this->session->userdata ( 'userId' ); @@ -572,6 +574,13 @@ class payslip extends BaseController { $ErrorFlag++; } + + $Festivalbonus_first = explode(".",$Festival_Bonus); + + if(!is_numeric($Festival_Bonus) || (strlen((string)$Festival_Bonus))>8 || (strlen((string)$Festivalbonus_first[0]))> 5) + { + $ErrorFlag++; + } $Other_Deductions_first = explode(".",$Other_Deductions); @@ -607,10 +616,11 @@ class payslip extends BaseController $Loan_Recovered = strtoupper($Loan_Recovered); } $Incentives = $j['Incentives in ₹']; + $Festival_Bonus = $j['Festival Bonus in ₹']; $Other_Deductions = $j['Other Deductions in ₹']; $Created_By = $this->session->userdata ( 'userId' ); - $monthlypaydata = array('Month_Year'=>$month,'EmpID'=>$EmpID,'Days_worked'=>$DaysWorked,'LOP_Days'=>$LOP_Days,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Other_Deductions'=>$Other_Deductions,'Created_By'=>$Created_By); + $monthlypaydata = array('Month_Year'=>$month,'EmpID'=>$EmpID,'Days_worked'=>$DaysWorked,'LOP_Days'=>$LOP_Days,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Festival_Bonus'=>$Festival_Bonus,'Other_Deductions'=>$Other_Deductions,'Created_By'=>$Created_By); $result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata); $total = $total + $result; } @@ -731,77 +741,79 @@ class payslip extends BaseController */ public function PrintPdf() { - $html=""; - $All = $this->input->post('All'); - if($All == '') - { + $filename=" "; + $html=""; + $All = $this->input->post('All'); + if($All == '') + { $this->form_validation->set_rules('Employee','Employee','trim|callback_Employee_validate'); - } - - $this->form_validation->set_rules('PayOn','PayOn','trim|callback_PayOn_validate'); - - if($this->form_validation->run() == FALSE) - { - $this->viewGenerator(); - } - else - { - $Payon = $this->input->post('PayOn'); - - if($All != '') - { - - $result = $this->payroll_model->getEmpAll($Payon); - - if($result > 0 ) - { - for($i=0; $ipayroll_model->GetPayslipdata($Payon,$EmpID); - - $totalsalary =$Data['PayDetails'][0]->LessAdvance; - $totalsalaryinwords = $this->convertNumber(round($totalsalary)); - $Data['amtinwords']=$totalsalaryinwords; - $Data['CompanyDetails '] = $this->payroll_model->Companydetails(); - - $html.=$this->load->view("payslipgenerateprint", $Data,true ); - - } - - } - } - else - { - $EmpID = $this->input->post('Employee'); - - $Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID); - - $totalsalary =$Data['PayDetails'][0]->LessAdvance; - $totalsalaryinwords = $this->convertNumber(round($totalsalary)); - $Data['amtinwords']=$totalsalaryinwords; - $Data['CompanyDetails'] = $this->payroll_model->Companydetails(); - - $html=$this->load->view("payslipgenerateprint", $Data,true ); - - } + } + $this->form_validation->set_rules('PayOn','PayOn','trim|callback_PayOn_validate'); - + if($this->form_validation->run() == FALSE) + { + $this->viewGenerator(); + } + else + { + $Payon = $this->input->post('PayOn'); + + $m =date("M", mktime(0, 0, 0, $Payon, 10)); + $y=substr($Payon,3); + + + if($All != '') + { + $filename='PayslipFor-'.$m.'-'.$y; + $result = $this->payroll_model->getEmpAll($Payon); + + if($result > 0 ) + { + for($i=0; $ipayroll_model->GetPayslipdata($Payon,$EmpID); + + $totalsalary =$Data['PayDetails'][0]->LessAdvance; + $totalsalaryinwords = $this->convertNumber(round($totalsalary)); + $Data['amtinwords']=$totalsalaryinwords; + + $html.=$this->load->view("payslipgenerateprint", $Data,true ); + + } + + } + } + else + { + $EmpID = $this->input->post('Employee'); + + $Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID); + + $fname=$Data['PayDetails'][0]->FName; + $filename='PayslipFor-'.$EmpID.' '.$fname.' '.$m.' '.$y; + + $totalsalary =$Data['PayDetails'][0]->LessAdvance; + $totalsalaryinwords = $this->convertNumber(round($totalsalary)); + $Data['amtinwords']=$totalsalaryinwords; + $html=$this->load->view("payslipgenerateprint", $Data,true ); + + } $mpdf=new mPDF('utf-8','A4-P',10, 10,10, 10, 10, 24, 4, 6); $mpdf->SetDisplayMode('fullpage'); - $mpdf->SetHTMLHeader($HtmlHeading); - /*$mpdf->SetTitle('Resico : PDF');*/ + $mpdf->SetHTMLHeader($HtmlHeading); $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}"); $mpdf->setFooter("Page {PAGENO} of {nb}"); $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; - $mpdf->WriteHTML($html); + $mpdf->WriteHTML($html); + $mpdf->SetTitle('Resico : Payslip'); $mpdf->Output("".$filename.'.pdf','I',$php); - - } -} + + } + } /** * To update payslip */ @@ -1049,6 +1061,30 @@ class payslip extends BaseController $result = $this->payroll_model->checkExistPayData($empid,$payon); echo json_encode(count($result)); + } + + /** + * For Bonus and Incentive report + */ + function Bonusreport() + { + + $this->global['pageTitle'] = 'Resico : Incentive and Bonus Reports'; + $fin_year = $this->input->post('finyear'); + $data['finyear'] = $fin_year; + $data['Reportvalue'] = $this->monthlypay_model->reportvalue($fin_year); + $this->loadViews("Bonusreport", $this->global,$data,NULL); + + } + + function MonthwiseBonusreport() + { + $EmployeeID = $_GET['EID']; + $Fin_year = $_GET['Finyear']; + $data['finyear'] = $Fin_year; + $this->global['pageTitle'] = 'Resico : Monthwise Incentive and Bonus Reports'; + $data['MonthwiseReport'] = $this->monthlypay_model->Monthwisereportvalue($Fin_year,$EmployeeID); + $this->loadViews("Bonusreportmonthwise", $this->global,$data,NULL); } /** diff --git a/application/controllers/rawmaterialdetails.php b/application/controllers/rawmaterialdetails.php index f3901a6f..f7640021 100644 --- a/application/controllers/rawmaterialdetails.php +++ b/application/controllers/rawmaterialdetails.php @@ -338,6 +338,17 @@ class rawmaterialdetails extends BaseController } } + /** + * To Check and display the already existing material list + */ + function checkmaterial() + { + $material = $this->input->post('id'); + $this->load->model('rawmaterialdetails_model'); + $query = $this->rawmaterialdetails_model->checkMaterialExists($material); + echo json_encode($query); + } + /** * To export report of material details in excel */ diff --git a/application/controllers/supplier.php b/application/controllers/supplier.php index fb23ad8c..b443d748 100644 --- a/application/controllers/supplier.php +++ b/application/controllers/supplier.php @@ -480,7 +480,16 @@ class supplier extends BaseController } } - + /** + * To Check and display the already existing supplier list + */ + function checksupplier() + { + $supp_name = $this->input->post('id'); + $this->load->model('supplier_model'); + $query = $this->supplier_model->checkSupplierExists($supp_name); + echo json_encode($query); + } /** * To export report of supplier details in excel */ diff --git a/application/controllers/user.php b/application/controllers/user.php index facfffa2..f7d29324 100755 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -38,7 +38,7 @@ class user extends BaseController $this->load->model('dahsboard_Model'); $data['EmpCount'] = $this->employeedetails_model->getEmployeeCount(); - + $data['UserCount'] = $this->dahsboard_Model->getUserCount(); $data['totalpurchaseorder']=$this->dahsboard_Model->totalpurchaseorder(); diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 3cda6ef0..c45e185e 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -1,16 +1,17 @@ - db->query($sql); return $query->result(); - } - + } + /* HR DASHBOART Model START*/ function totemp() { @@ -80,13 +81,21 @@ where Month_Year = ? and att.EmpID in (select EmpID from T_Attendance)"; function dayAllPersentEmpSalary($WH,$OT,$date) { - //echo $EmpID.'-'.$dates; + // echo $date; $sql="select EmpID,".$WH.",".$OT." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)"; $query = $this->db->query($sql,array($date)); //return return $query->result_array(); } +function yesterdayAllPersentEmpSalary($WH,$OT,$date) + { + // echo $date; + $sql="select EmpID,".$WH.",".$OT." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)"; + $query = $this->db->query($sql,array($date)); + //return + return $query->result_array(); +} function attendance($EmpID,$dates) @@ -164,90 +173,178 @@ $sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;"; function attendanceyear($EmpID,$MONTH) { - // $sql="select Att.EmpID,Att.Month_Year,Att.*,NoofDays,Days_Worked,emp.DateofJoining from T_Attendance Att - // join T_Employee_Details as emp on emp.EmpID = Att.EmpID - // where Att.Month_Year between ? and ? and Att.EmpID = ?"; +// //print_r($MONTH); +// $sql="select Att.EmpID,Att.Month_Year,Att.*,NoofDays,Days_Worked,emp.DateofJoining from T_Attendance Att +// join T_Employee_Details as emp on emp.EmpID = Att.EmpID +// where Att.Month_Year between ? and Att.EmpID = ?"; // else // (YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 ) - $sql = 'select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance where + // $sql = 'select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance where + // case + // when (month(Month_Year) >=4) then + // (YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE)+1 and MONTH(Month_Year) <= 3 )end and EmpID = ? and month(Month_Year) != month(current_date()) + // else + // (YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 )'; + + $sql = ' select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance where case - when (month(Month_Year) >=4) then - (YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE)+1 and MONTH(Month_Year) <= 3 ) - - end and EmpID = ? and month(Month_Year) != month(current_date());'; - $query= $this->db->query($sql,array($MONTH, $EmpID)); + when (MONTH(CURRENT_DATE) >=4) then + ((YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? )) and EmpID = ? and month(Month_Year) != MONTH(CURRENT_DATE) + else + ((YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >=4 and ? >= 4) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 and ? <=3 )) and Month(Month_Year) >= ? and EmpID = ? and month(Month_Year) != MONTH(CURRENT_DATE) + end'; + + +/*$sql='select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance + where EmpID= ? and (MONTH(Month_Year) >=4) or (MONTH(Month_Year) <3) +and (YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? )or ( YEAR(Month_Year) = YEAR(CURRENT_DATE)+1 and MONTH(Month_Year) <= 3 ) + and MONTH(Month_Year) != MONTH(current_date())';*/ + + + + $query= $this->db->query($sql,array($MONTH,$EmpID,$MONTH,$MONTH,$MONTH,$EmpID)); return $query->result(); } + 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(); +} + +function holiDaySalaryMonth($month,$year) +{ + $sql="SELECT H_Date FROM T_Public_Holidays where MONTH(H_Date)= ? and YEAR(H_Date) = ? "; + $query = $this->db->query($sql,array($month,$year)); + return $query->result(); +} +function fy() + { + $sql= "SELECT + CASE WHEN MONTH(Month_year)>=4 THEN + concat(YEAR(Month_year), '-',YEAR(Month_year)+1) + ELSE concat(YEAR(Month_year)-1,'-', YEAR(Month_year)) END AS financial_year + FROM T_Attendance +GROUP BY financial_year"; + $query = $this->db->query($sql); + return $query->result(); + } + +function per($fa,$aa,$m) + { + $sql= "SELECT year.Eid as Eid,year.ename as ename,year.active as active,month.days as days,month.Days_Worked as worked,month.percentage as percentage,year.days as yday,year.workd as yworkd,year.percentage as ypercentage +from (select em.EmpID as Eid,concat(em.FirstName,'.',em.LastName) as ename,em.IsActive as active,at.NoofDays as days, +Days_Worked,round((Days_Worked/NoofDays*100)) as percentage from +T_Employee_Details em +join T_Attendance at on at.EmpID = em.EmpID +where (Month_Year >= '".$fa."-04-01' and Month_Year <= '".$aa."-04-01') and monthname(Month_Year) = '".$m."' +) as month left join +(select em.EmpID as Eid,concat(em.FirstName,'.',em.LastName) as ename,em.IsActive as active,sum(at.NoofDays) as days, +sum(Days_Worked) workd,round((sum(Days_Worked)/sum(NoofDays)*100)) as percentage from +T_Employee_Details em +join T_Attendance at on at.EmpID = em.EmpID +where (Month_Year >= '".$fa."-04-01' and Month_Year <= '".$aa."-04-01') +group by Eid +) as year on year.Eid = month.Eid and year.ename = month.ename +group by Eid "; + +$query = $this->db->query($sql); + 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."' "; @@ -262,144 +359,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; } @@ -409,48 +506,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 @@ -460,7 +557,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 @@ -470,7 +567,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 @@ -481,194 +578,221 @@ 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())"; + 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 ROUND(sum(BudgetAmount),2) as totalimportbudget FROM T_CostCenter_Budget where BudgetType ='IMPORT' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31'"; $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()) "; + 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 sum(BudgetAmount) as totalcapitalbudget FROM T_CostCenter_Budget where BudgetType ='CAPITAL' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31' "; $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())"; + 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 ROUND(sum(BudgetAmount),2) as totalservicebudget FROM T_CostCenter_Budget where BudgetType ='SERVICE' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31'"; $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())"; + 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 ROUND(sum(BudgetAmount),2) as totalrevenuebudget FROM T_CostCenter_Budget where BudgetType ='REVENUE' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31'"; $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, -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', -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 ca, -sum(if(Cost_Center_Budget.BudgetType='SERVICE', -PO_Line_Item.Quantity * PO_Line_Item.Rate,0)) as sr, -sum(if(Cost_Center_Budget.BudgetType='REVENUE', -(PO_Line_Item.Quantity * PO_Line_Item.Rate)-T_Rev_Tax.AfterDiscount,0)) as rv - -from T_CostCenter_Budget Cost_Center_Budget -left join T_PurchaseOrder_LineItem PO_Line_Item on Cost_Center_Budget.CostCenterCode=PO_Line_Item.CostCenterCode -left JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.Status !='ST030' -left JOIN T_Revenue_Tax T_Rev_Tax on PO_Line_Item.LineItemNo=T_Rev_Tax.LineItemNo -JOIN T_CostCenter_Master Cost_Mast on Cost_Center_Budget.CostCenterCode=Cost_Mast.CostCenterCode -left JOIN T_Service_Tax st on st.LineItemNo = PO_Line_Item.LineItemNo -WHERE Cost_Center_Budget.BudgetType = po.POType and date(po.PODate) >= '".$fa."-04-01' and date(po.PODate) <= '".$aa."-03-31' -group by -Cost_Center_Budget.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 BudgetYear, +sum(if(BudgetType = 'SERVICE', +Util_Amount,0)) as sr, +sum(if(BudgetType = 'REVENUE', +Util_Amount,0)) as rv, +sum(if(BudgetType = 'IMPORT', +Util_Amount,0)) as im, +sum(if(BudgetType = 'CAPITAL', +Util_Amount,0)) as ca +FROM cost_center where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31'; "; $query = $this->db->query($sql); + //echo $sql; return $query->result(); } 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 JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO -JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo -JOIN T_Employee_Details as Emp_Det on Emp_Det.EmpID=Req.RequestedBy -JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Emp_Det.Departmentcode -JOIN T_CostCenter_Master as Cost on +left JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo +left JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Req.RequestedDept +left JOIN T_CostCenter_Master as Cost on Cost.CostCenterCode=Req.CostCenterCode JOIN T_CostCenter_Budget as Cost_Center_Bdgt on Cost.CostCenterCode=Cost_Center_Bdgt.CostCenterCode 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 -JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo -JOIN T_Employee_Details as Emp_Det on Emp_Det.EmpID=Req.RequestedBy -JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Emp_Det.Departmentcode -JOIN T_CostCenter_Master as Cost on +left JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO +left JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo +left JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Req.RequestedDept +left JOIN T_CostCenter_Master as Cost on Cost.CostCenterCode=Req.CostCenterCode JOIN T_CostCenter_Budget as Cost_Center_Bdgt on Cost.CostCenterCode=Cost_Center_Bdgt.CostCenterCode 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, @@ -693,66 +817,23 @@ 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, -case Cost_Center_Budget.BudgetType -when 'IMPORT' -then -sum(distinct if(Cost_Center_Budget.BudgetType='IMPORT', -(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0)) -when 'CAPITAL' -then -sum(distinct if(Cost_Center_Budget.BudgetType='CAPITAL', -if(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval),0)) -when 'SERVICE' -then -sum(distinct if(Cost_Center_Budget.BudgetType='SERVICE', -PO_Line_Item.Quantity * PO_Line_Item.Rate,0)) -when 'REVENUE' -then -sum(distinct if(Cost_Center_Budget.BudgetType='REVENUE', -(PO_Line_Item.Quantity * PO_Line_Item.Rate)-T_Rev_Tax.AfterDiscount,0)) -end -as Util_Amount, -case Cost_Center_Budget.BudgetType -when 'IMPORT' -then (Cost_Center_Budget.BudgetAmount - ifnull((sum(distinct if(Cost_Center_Budget.BudgetType='IMPORT', -(PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate,0))),0)) -when 'CAPITAL' -then (Cost_Center_Budget.BudgetAmount - ifnull(sum(distinct if(Cost_Center_Budget.BudgetType='CAPITAL', -if(CapitalRange=0,(( PO_Line_Item.Quantity * PO_Line_Item.Rate) * po.ExchangeRate),( PO_Line_Item.Quantity * PO_Line_Item.Rate) - st.Afterdiscountval),0)),0)) -when 'SERVICE' -then (Cost_Center_Budget.BudgetAmount - ifnull((sum(distinct if(Cost_Center_Budget.BudgetType='SERVICE', -PO_Line_Item.Quantity * PO_Line_Item.Rate,0))),0)) -when 'REVENUE' -then (Cost_Center_Budget.BudgetAmount - ifnull((sum(distinct if(Cost_Center_Budget.BudgetType='REVENUE', -(PO_Line_Item.Quantity * PO_Line_Item.Rate)-T_Rev_Tax.AfterDiscount,0))),0)) -end -as Avlbl_Amt -from T_CostCenter_Budget Cost_Center_Budget -left join T_PurchaseOrder_LineItem PO_Line_Item on Cost_Center_Budget.CostCenterCode=PO_Line_Item.CostCenterCode -left JOIN T_PurchaseOrder_Master po on po.PONO=PO_Line_Item.PONO and po.Status !='ST030' -left JOIN T_Revenue_Tax T_Rev_Tax on PO_Line_Item.LineItemNo=T_Rev_Tax.LineItemNo -JOIN T_CostCenter_Master Cost_Mast on Cost_Center_Budget.CostCenterCode=Cost_Mast.CostCenterCode -JOIN T_CostCenter_Departments CostCentDept on CostCentDept.CostCenterCode=Cost_Mast.CostCenterCode -JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode= CostCentDept.DEPCode -left JOIN T_Service_Tax st on st.LineItemNo = PO_Line_Item.LineItemNo -WHERE Cost_Center_Budget.BudgetType = po.POType and date(po.PODate) >= '".$fa."-04-01' and date(po.PODate) <= '".$aa."-03-31' -group by -Cost_Center_Budget.CostCenterCode,Cost_Center_Budget.BudgetYear,Cost_Center_Budget.BudgetType -order by Cost_Center_Budget.CostCenterCode"; + $sql="SELECT Cost_Center_Code,Cost_Center_Name,Dept_Name,BudgetType,BudgetYear,sum(Util_Amount) as Util_Amount, +budget - sum(Util_Amount) as Avlbl_Amt +FROM cost_center +where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31' +group by Cost_Center_Code,BudgetYear,BudgetType"; $query = $this->db->query($sql); + //echo $sql; return $query->result(); - - - + } - - - 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 @@ -767,8 +848,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"; @@ -778,8 +859,8 @@ group by po.SupplierID,pl.MaterialCode"; } - - function report_MMReceiptValue($fa,$aa,$m){ + + function report_MMReceiptValue($fa,$aa,$m){ $sql="select @@ -790,38 +871,112 @@ 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, 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, -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(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) ++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) ++ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) +- ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total + FROM T_PurchaseOrder_Master pm +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 +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 pm.Status != 'ST027'"; + +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."' + and date(pm.PODate) <= '".$tod."'"; + + } + if ($prod!= ''){ + + $sql.=" and mm.MaterialName = '".$prod."' "; + + } + + + +$sql.="group by pono,material_name,supplier_name"; +//echo $sql; + $query = $this->db->query($sql); + return $query->result(); + } + 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, +TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time, +mm.MaterialName as material_name,sd.SupplierName as supplier_name, +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)), @@ -839,41 +994,56 @@ left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where -pm.Status != 'ST030' and pm.Status != 'ST056' "; +pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; 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."' "; + + } + 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"; @@ -881,96 +1051,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){ - - - $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, -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, -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(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) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -- ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total - 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 -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' "; - -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."' - 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."' "; - - } - - - -$sql.="group by pono,material_name,supplier_name"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function report_finyear(){ + function report_finyear(){ $sql="SELECT @@ -985,16 +1066,16 @@ GROUP BY financial_year"; } - function report_year_wise(){ + function report_year_wise($a=null, $b=null){ $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 FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +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 left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and date(pm.POdate) >= '$a-04-01' and date(pm.PODate) <= '$b-03-31' group by month(created_date)"; $query = $this->db->query($sql); return $query->result(); @@ -1002,24 +1083,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 @@ -1027,12 +1108,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 left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and month(pm.PODate)= ? and year(pm.PODate) = ? +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and month(pm.PODate)= ? and year(pm.PODate) = ? 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 @@ -1040,17 +1121,17 @@ 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 left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName is not null and date(pm.POdate) >= '$a-04-01' and date(pm.PODate) <= '$b-03-31' +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and date(pm.POdate) >= '$a-04-01' and date(pm.PODate) <= '$b-03-31' 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) @@ -1090,42 +1171,42 @@ left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo where -pm.Status != 'ST030' and pm.Status != 'ST056' "; +pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; 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, @@ -1159,29 +1240,29 @@ FROM T_PurchaseOrder_Master pm join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' "; +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; 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,$sid=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, @@ -1192,19 +1273,19 @@ join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and -monthname(pm.PODate) = '".$m."' and sd.SupplierName = '".$cname."' and mm.MaterialCode = '".$mid."' "; +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and +monthname(pm.PODate) = '".$m."' and sd.SupplierID = '".$sid."' 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($sid=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, @@ -1215,18 +1296,26 @@ join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and sd.SupplierName = '".$cname."' and mm.MaterialCode = '".$mid."' "; +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierID = '".$sid."' 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(){ + 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 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 @@ -1234,13 +1323,8 @@ 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 -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 +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and +(pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31') 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 @@ -1248,7 +1332,7 @@ 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 +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and month(pm.PODate) = month(current_date()) group by supplier_name,material_name ) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name @@ -1258,7 +1342,7 @@ 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 +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and date(pm.PODate) = current_date() group by supplier_name,material_name ) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name @@ -1267,78 +1351,76 @@ 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 pm.Status != 'ST027' 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){ + 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 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 pm.Status != 'ST027' and sd.SupplierName is not null and +(pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31') + 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){ $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 -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."' +where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and +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 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 -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."' -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, + $sql="select im.IGRNO as igrn,im.PONO as pono,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,mm.UOM as UOM, sum(distinct id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,sum(distinct id.QuantityAsPerInvoice) * pl.Rate 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))) + if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull(sum(distinct id.QuantityAsPerInvoice * 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) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total,pb.FilePath as file - FROM T_PurchaseOrder_Master pm - join T_IGR_Master im on im.PONO = pm.PONO -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +from T_IGR_Master im +join T_IGR_Details id on id.IGRNO = im.IGRNO +join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo @@ -1347,43 +1429,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"; @@ -1391,94 +1473,90 @@ $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, + $sql="select im.IGRNO as igrn,im.PONO as pono,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,mm.UOM as UOM, sum(distinct id.QuantityAsPerInvoice) as quantity,pl.Rate as rate,sum(distinct id.QuantityAsPerInvoice) * pl.Rate 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))) + if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull(sum(distinct id.QuantityAsPerInvoice * 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) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total,pb.FilePath as file - FROM T_PurchaseOrder_Master pm - join T_IGR_Master im on im.PONO = pm.PONO -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +from T_IGR_Master im +join T_IGR_Details id on id.IGRNO = im.IGRNO +join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.PONO=pm.PONO -where pm.Status != 'ST030' "; +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"; @@ -1488,69 +1566,56 @@ $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($a,$b){ - $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 -FROM T_PurchaseOrder_Master pm -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 -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' -group by month(created_date)"; + $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value +from year_inward +where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' +group by month(CreatedDate) +"; +//echo $sql; $query = $this->db->query($sql); return $query->result(); } - - 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 -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 -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and sd.SupplierName is not null and month(im.CreatedDate)= ? and year(im.CreatedDate) = ? -group by supplier_name,material_name"; + $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total +from year_inward +where status != 'ST030' and month(dat)= ? and year(dat) = ? +group by material_name,supplier_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 -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 -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and sd.SupplierName is not null and date(im.CreatedDate) >= '$a-04-01' and date(im.CreatedDate) <= '$b-03-31' -group by supplier_name,material_name"; + $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total +from year_inward +where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' +group by material_name,supplier_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, - + $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(im.PONO) as counts,ifnull(sum(id.QuantityAsPerInvoice),0) as quantity,round(ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0),2) as value, + case pm.POType when 'IMPORT' -then ifnull((sum(distinct(pl.Quantity * pl.Rate) * pm.ExchangeRate) +then ifnull((sum(distinct(id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate) ),0) when 'CAPITAL' -then sum(distinct if(pm.CapitalRange=0,(( pl.Quantity * pl.Rate) * pm.ExchangeRate),( pl.Quantity * pl.Rate) +then sum(distinct if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate) - st.Afterdiscountval)) + ifnull(sum(distinct st.After_SGST),0) + ifnull(sum(distinct st.After_CGST),0) @@ -1559,7 +1624,7 @@ then sum(distinct if(pm.CapitalRange=0,(( pl.Quantity * pl.Rate) * pm.ExchangeR when 'SERVICE' -then ifnull(sum(distinct pl.Quantity * pl.Rate),0) +then ifnull(sum(distinct id.QuantityAsPerInvoice * pl.Rate),0) + ifnull(sum(distinct st.After_SGST),0) + ifnull(sum(distinct st.After_CGST),0) + ifnull(sum(distinct st.After_IGST),0) @@ -1567,7 +1632,7 @@ then ifnull(sum(distinct pl.Quantity * pl.Rate),0) - ifnull(sum(distinct st.Afterdiscountval),0) when 'REVENUE' -then ifnull(sum(distinct pl.Quantity * pl.Rate),0) +then ifnull(sum(distinct id.QuantityAsPerInvoice * pl.Rate),0) - ifnull(sum(distinct rt.AfterDiscount),0) + ifnull(sum(distinct rt.AfterSGST),0) + ifnull(sum(distinct rt.AfterCGST),0) @@ -1577,191 +1642,161 @@ then ifnull(sum(distinct pl.Quantity * pl.Rate),0) end as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +from T_IGR_Master im +join T_IGR_Details id on id.IGRNO = im.IGRNO +join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO +left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where -pm.Status != 'ST030' "; +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."'"; - - } - $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, -SUM(IF(month(im.CreatedDate) = 4, pl.Quantity, 0)) AS April, -SUM(IF(month(im.CreatedDate) = 5, pl.Quantity, 0)) AS May, -SUM(IF(month(im.CreatedDate) = 6, pl.Quantity, 0)) AS June, -SUM(IF(month(im.CreatedDate) = 7, pl.Quantity, 0)) AS July, -SUM(IF(month(im.CreatedDate) = 8, pl.Quantity, 0)) AS August, -SUM(IF(month(im.CreatedDate) = 9, pl.Quantity, 0)) AS September, -SUM(IF(month(im.CreatedDate) = 10, pl.Quantity, 0)) AS October, -SUM(IF(month(im.CreatedDate) = 11, pl.Quantity, 0)) AS November, -SUM(IF(month(im.CreatedDate) = 12, pl.Quantity, 0)) AS December, -SUM(IF(month(im.CreatedDate) = 1, pl.Quantity, 0)) AS January, -SUM(IF(month(im.CreatedDate) = 2, pl.Quantity, 0)) AS February, -SUM(IF(month(im.CreatedDate) = 3, pl.Quantity, 0)) AS March, -sum(pl.Quantity) as qtotal, -SUM(IF(month(im.CreatedDate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril, -SUM(IF(month(im.CreatedDate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay, -SUM(IF(month(im.CreatedDate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune, -SUM(IF(month(im.CreatedDate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly, -SUM(IF(month(im.CreatedDate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust, -SUM(IF(month(im.CreatedDate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember, -SUM(IF(month(im.CreatedDate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober, -SUM(IF(month(im.CreatedDate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember, -SUM(IF(month(im.CreatedDate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember, -SUM(IF(month(im.CreatedDate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary, -SUM(IF(month(im.CreatedDate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary, -SUM(IF(month(im.CreatedDate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch, -sum(pl.Quantity * pl.Rate) as vtotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' "; + $sql="select sid,mid,supplier_name,material_name, +SUM(IF(month(dat) = 4, quantity, 0)) AS April, +SUM(IF(month(dat) = 5, quantity, 0)) AS May, +SUM(IF(month(dat) = 6, quantity, 0)) AS June, +SUM(IF(month(dat) = 7, quantity, 0)) AS July, +SUM(IF(month(dat) = 8, quantity, 0)) AS August, +SUM(IF(month(dat) = 9, quantity, 0)) AS September, +SUM(IF(month(dat) = 10, quantity, 0)) AS October, +SUM(IF(month(dat) = 11, quantity, 0)) AS November, +SUM(IF(month(dat) = 12, quantity, 0)) AS December, +SUM(IF(month(dat) = 1, quantity, 0)) AS January, +SUM(IF(month(dat) = 2, quantity, 0)) AS February, +SUM(IF(month(dat) = 3, quantity, 0)) AS March, +sum(quantity) as qtotal, +SUM(IF(month(dat) = 4, value, 0)) AS vApril, +SUM(IF(month(dat) = 5, value, 0)) AS vMay, +SUM(IF(month(dat) = 6, value, 0)) AS vJune, +SUM(IF(month(dat) = 7, value, 0)) AS vJuly, +SUM(IF(month(dat) = 8, value, 0)) AS vAugust, +SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, +SUM(IF(month(dat) = 10, value, 0)) AS vOctober, +SUM(IF(month(dat) = 11, value, 0)) AS vNovember, +SUM(IF(month(dat) = 12, value, 0)) AS vDecember, +SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, +SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, +SUM(IF(month(dat) = 3, value, 0)) AS vMarch, +sum(value) as vtotal +FROM year_inward +where 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 supplier_name = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$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,$sid=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, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and -monthname(im.CreatedDate) = '".$m."' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; + $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total +from year_inward +where status != 'ST030' and +monthname(dat) = '".$m."' and sid = '".$sid."' and mid = '".$mid."' "; 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 (dat >= '".$fa."-04-01' and dat <= '".$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($sid=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, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and sd.SupplierName = '".$cname."' and mm.MaterialName = '".$prod."' "; + $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total +from year_inward +where status != 'ST030' and sid = '".$sid."' and mid = '".$mid."' "; 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 (dat >= '".$fa."-04-01' and dat <= '".$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(){ + 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 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 -FROM T_PurchaseOrder_Master pm -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 -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 +FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total +FROM year_inward +where status != 'ST030' and +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') 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 -FROM T_PurchaseOrder_Master pm -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()) +(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal +FROM year_inward +where status != 'ST030' and +month(dat) = month(current_date()) group by supplier_name,material_name ) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name left join -(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 -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 -date(im.CreatedDate) = current_date() +(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +date(dat) = current_date() group by supplier_name,material_name ) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name group by supplier_name,material_name @@ -1769,248 +1804,208 @@ 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 -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."' + $sql="SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +month(dat) = month(current_date()) and sid = '".$sup."' and mid = '".$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){ + 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 sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') + and sid = '".$sup."' and mid= '".$mat."' +group by supplier_name,material_name +"; + $query = $this->db->query($sql); + return $query->result(); + } + 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 -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 -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."' + $sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +date(dat) = current_date() and sid = '".$sup."' and mid = '".$mat."' group by supplier_name,material_name"; $query = $this->db->query($sql); return $query->result(); } - 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 -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 -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(){ + 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 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 -FROM T_PurchaseOrder_Master pm -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 -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 +FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total +FROM year_inward +where status != 'ST030' and +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') 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 -FROM T_PurchaseOrder_Master pm -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()) +(SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal +FROM year_inward +where status != 'ST030' and +month(dat) = month(current_date()) group by category ) as month on month.category=year.category left join -(SELECT mm.Category as category,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 -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 -date(im.CreatedDate) = current_date() +(SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +date(dat) = current_date() group by category ) as today on today.category=month.category group by category "; $query = $this->db->query($sql); return $query->result(); } - 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 -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 -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."' + function rawi_report_cum_year($cat=null){ + 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 category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +(dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31') + and 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 -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 mm.Category = '".$cat."' + $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +month(dat) = month(current_date()) and 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 -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 -date(im.CreatedDate) = current_date() and mm.Category = '".$cat."' + $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal +FROM year_inward +where status != 'ST030' and +date(dat) = current_date() and 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, -SUM(IF(month(im.CreatedDate) = 4, pl.Quantity, 0)) AS April, -SUM(IF(month(im.CreatedDate) = 5, pl.Quantity, 0)) AS May, -SUM(IF(month(im.CreatedDate) = 6, pl.Quantity, 0)) AS June, -SUM(IF(month(im.CreatedDate) = 7, pl.Quantity, 0)) AS July, -SUM(IF(month(im.CreatedDate) = 8, pl.Quantity, 0)) AS August, -SUM(IF(month(im.CreatedDate) = 9, pl.Quantity, 0)) AS September, -SUM(IF(month(im.CreatedDate) = 10, pl.Quantity, 0)) AS October, -SUM(IF(month(im.CreatedDate) = 11, pl.Quantity, 0)) AS November, -SUM(IF(month(im.CreatedDate) = 12, pl.Quantity, 0)) AS December, -SUM(IF(month(im.CreatedDate) = 1, pl.Quantity, 0)) AS January, -SUM(IF(month(im.CreatedDate) = 2, pl.Quantity, 0)) AS February, -SUM(IF(month(im.CreatedDate) = 3, pl.Quantity, 0)) AS March, -sum(pl.Quantity) as qtotal, -SUM(IF(month(im.CreatedDate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril, -SUM(IF(month(im.CreatedDate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay, -SUM(IF(month(im.CreatedDate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune, -SUM(IF(month(im.CreatedDate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly, -SUM(IF(month(im.CreatedDate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust, -SUM(IF(month(im.CreatedDate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember, -SUM(IF(month(im.CreatedDate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober, -SUM(IF(month(im.CreatedDate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember, -SUM(IF(month(im.CreatedDate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember, -SUM(IF(month(im.CreatedDate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary, -SUM(IF(month(im.CreatedDate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary, -SUM(IF(month(im.CreatedDate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch, -sum(pl.Quantity * pl.Rate) as vtotal -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' "; + $sql="select sid,mid,category,supplier_name,material_name, +SUM(IF(month(dat) = 4, quantity, 0)) AS April, +SUM(IF(month(dat) = 5, quantity, 0)) AS May, +SUM(IF(month(dat) = 6, quantity, 0)) AS June, +SUM(IF(month(dat) = 7, quantity, 0)) AS July, +SUM(IF(month(dat) = 8, quantity, 0)) AS August, +SUM(IF(month(dat) = 9, quantity, 0)) AS September, +SUM(IF(month(dat) = 10, quantity, 0)) AS October, +SUM(IF(month(dat) = 11, quantity, 0)) AS November, +SUM(IF(month(dat) = 12, quantity, 0)) AS December, +SUM(IF(month(dat) = 1, quantity, 0)) AS January, +SUM(IF(month(dat) = 2, quantity, 0)) AS February, +SUM(IF(month(dat) = 3, quantity, 0)) AS March, +sum(quantity) as qtotal, +SUM(IF(month(dat) = 4, value, 0)) AS vApril, +SUM(IF(month(dat) = 5, value, 0)) AS vMay, +SUM(IF(month(dat) = 6, value, 0)) AS vJune, +SUM(IF(month(dat) = 7, value, 0)) AS vJuly, +SUM(IF(month(dat) = 8, value, 0)) AS vAugust, +SUM(IF(month(dat) = 9, value, 0)) AS vSeptember, +SUM(IF(month(dat) = 10, value, 0)) AS vOctober, +SUM(IF(month(dat) = 11, value, 0)) AS vNovember, +SUM(IF(month(dat) = 12, value, 0)) AS vDecember, +SUM(IF(month(dat) = 1, value, 0)) AS vJanuary, +SUM(IF(month(dat) = 2, value, 0)) AS vFebruary, +SUM(IF(month(dat) = 3, value, 0)) AS vMarch, +sum(value) as vtotal +FROM year_inward +where 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 Category = '".$cname."'"; + + } + + + + if ($fa and $aa != ''){ + + $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$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, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and -monthname(im.CreatedDate) = '".$m."' and mm.Category = '".$cat."' "; + $sql="select category,sid,supplier_name,mid,material_name, +sum(Quantity) as quantity, +sum(value) as total +FROM year_inward +where status != 'ST030' and +monthname(dat) = '".$m."' and 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 (dat >= '".$fa."-04-01' and dat <= '".$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, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_IGR_Master im on im.PONO = pm.PONO -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and -mm.Category = '".$cat."' "; + $sql="select category,sid,supplier_name,mid,material_name, +sum(Quantity) as quantity, +sum(value) as total +FROM year_inward +where status != 'ST030' and +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 (dat >= '".$fa."-04-01' and dat <= '".$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 @@ -2020,112 +2015,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)); @@ -2142,87 +2137,95 @@ if ($cname!= ''){ } function yearwise_data($value='') { + 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 type,sum(total) as yearlydata from t_income_expense where - type = ? and ((YEAR(date) = YEAR(CURRENT_DATE) and MONTH(date) >= 4) or (YEAR(date) = YEAR(CURRENT_DATE)+1 and MONTH(date) <= 3))"; + type = ? and (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; $query = $this->db->query($sql,array($value)); 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; } @@ -2231,9 +2234,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 @@ -2248,95 +2251,95 @@ 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(); } diff --git a/application/models/monthlypay_model.php b/application/models/monthlypay_model.php index ec5cd68a..117123fb 100755 --- a/application/models/monthlypay_model.php +++ b/application/models/monthlypay_model.php @@ -8,14 +8,14 @@ class monthlypay_model extends CI_Model * @param date $current : This is current month and year * @return array $result : result of the query (returns monthly payment details) */ - function monthlyListing($current="") + function monthlyListing($current="") { $curr_split = explode('-',$current); $month_val = $curr_split[0]; $year_val = $curr_split[1]; $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); $lastdate = $year_val.'-'.$month_val.'-'.$date_val; - + $sql="select T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Loan_Master.Loan_ID,T_Payroll.Key from T_Monthly_Pay_Inputs left join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID and T_Employee_Details.DateofJoining <= ? @@ -26,11 +26,12 @@ class monthlypay_model extends CI_Model $query = $this->db->query($sql,array($lastdate,$current)); - $result = $query->result(); + $result = $query->result(); return $result; } + /** * To get employee payment details * @param date $current - Optional @@ -169,19 +170,22 @@ class monthlypay_model extends CI_Model function monthlyAttendance($current="") { - $month_val = date('m',strtotime($current)); + $month_val = date('m',strtotime($current)); $year_val = date('Y',strtotime($current)); $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); $lastdate = $year_val.'-'.$month_val.'-'.$date_val; - $this->db->select('T_Attendance.*,T_Employee_Details.FirstName,T_Employee_Details.LastName'); - $this->db->from('T_Attendance'); + + $this->db->select('T_Attendance.*,T_Employee_Details.FirstName,T_Employee_Details.LastName'); + $this->db->from('T_Attendance'); $this->db->join('T_Employee_Details','T_Attendance.EmpID=T_Employee_Details.EmpID'); $this->db->where('T_Employee_Details.DateofJoining <= ',$lastdate); $this->db->where('Month_Year',$current); $this->db->where('T_Employee_Details.IsActive',1); $this->db->order_by('T_Attendance.EmpID', 'asc'); - $query = $this->db->get(); - $result = $query->result(); + $query = $this->db->get(); + + $result = $query->result(); + return $result; } @@ -392,6 +396,48 @@ class monthlypay_model extends CI_Model /* Ends permissionslip models */ + function reportvalue($fin_year) + { + + + $curr_split = explode('-',$fin_year); + $pre_year = $curr_split[0]; + $curr_year = $curr_split[1]; + + $sql= "select T_Monthly_Pay_Inputs.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus + from T_Monthly_Pay_Inputs + join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID = T_Employee_Details.EmpID + where + substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? + and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) >= 4 + or substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? + and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) <= 3 + group by T_Monthly_Pay_Inputs.EmpID"; + + $query = $this->db->query($sql,array($pre_year,$curr_year)); + return $query->result(); + } + function Monthwisereportvalue($Fin_year,$EmployeeID) + { + + + $curr_split = explode('-',$Fin_year); + $pre_year = $curr_split[0]; + $curr_year = $curr_split[1]; + + $sql= "select T_Monthly_Pay_Inputs.EmpID,T_Monthly_Pay_Inputs.Month_Year,T_Employee_Details.FirstName,T_Employee_Details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus + from T_Monthly_Pay_Inputs + join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID = T_Employee_Details.EmpID + and T_Monthly_Pay_Inputs.EmpID = ? + where substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) >= 4 + or substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) <= 3 + group by T_Monthly_Pay_Inputs.Month_Year"; + + $query = $this->db->query($sql,array($EmployeeID,$pre_year,$curr_year)); + return $query->result(); + } + + } diff --git a/application/models/rawmaterialdetails_model.php b/application/models/rawmaterialdetails_model.php index ef5087c7..72b249db 100644 --- a/application/models/rawmaterialdetails_model.php +++ b/application/models/rawmaterialdetails_model.php @@ -163,6 +163,17 @@ class rawmaterialdetails_model extends CI_Model return $this->db->get('T_MaterialMaster as det')->result_array(); } + + function checkMaterialExists($material) + { + $this->db->select('MaterialCode,MaterialName,MaterialType,Category'); + $this->db->from('T_MaterialMaster'); + $this->db->like('REPLACE(MaterialName, " ", "")',$material); + + $query = $this->db->get(); + return $query->result(); + } + /** * This function is used to delete the user information * @param number $userId : This is user id diff --git a/application/models/supplier_model.php b/application/models/supplier_model.php index d00a069c..35307c27 100644 --- a/application/models/supplier_model.php +++ b/application/models/supplier_model.php @@ -174,6 +174,19 @@ class supplier_model extends CI_Model return $insert_id; } + function checkSupplierExists($supp_name) + { + + $this->db->select('SupplierID,SupplierName,Address'); + $this->db->from('T_SupplierDetailsN'); + $this->db->like('REPLACE(SupplierName, " ", "")', $supp_name); + + $query = $this->db->get(); + + return $query->result(); + + } + /** * To get Supplier's information for export xl */ diff --git a/application/views/Bonusreport.php b/application/views/Bonusreport.php new file mode 100644 index 00000000..831b1caf --- /dev/null +++ b/application/views/Bonusreport.php @@ -0,0 +1,212 @@ + + + + + + + + + + +
+ +
+

+
Employee Incentive and Bonus Reports
+

+
+
+ + +
+
+
+ +
+ +
+
+
+ + + + +
+
+ +
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoEmployee IdEmployee NameIncentives in ₹Festival Bonus in ₹
EmpID ?>FirstName ." ". $record->LastName ?>Incentives)){$total+=$record->Incentives; echo $record->Incentives;}else{echo "0.00";}?>Bonus)){$totalbonus+=$record->Bonus ;echo $record->Bonus;}else{echo "0.00";} ?>
+ +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/application/views/Bonusreportmonthwise.php b/application/views/Bonusreportmonthwise.php new file mode 100644 index 00000000..ec7946ec --- /dev/null +++ b/application/views/Bonusreportmonthwise.php @@ -0,0 +1,194 @@ + + + + + + +
+ +
+

+
" EmpID ?> - FirstName ." ". $MonthwiseReport[0]->LastName ?> " - Monthwise Incentive and Bonus Reports
+

+
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoEmployee IdEmployee NameMonth YearIncentives in ₹Festival Bonus in ₹
EmpID ?>FirstName ." ". $record->LastName ?>Month_Year); + $month_val = $split_val[0]; + $year_val = $split_val[1]; + $monthName = date("M", mktime(0, 0, 0, $month_val, 10)); + echo $monthName . " , ".$year_val + ?>Incentives)){$total+=$record->Incentives; echo $record->Incentives;}else{echo "0.00";}?>Bonus)){$totalbonus+=$record->Bonus ;echo $record->Bonus;}else{echo "0.00";} ?>
+ +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/application/views/addRawMaterial.php b/application/views/addRawMaterial.php index e3c48fb9..28849065 100644 --- a/application/views/addRawMaterial.php +++ b/application/views/addRawMaterial.php @@ -12,10 +12,10 @@ function isNumberKey(evt) function BlockSpecial(evt) { var charCode; - if (window.event - charCode = window.event.keyCode; //for IE - else - charCode = evt.which; //for firefox + // if (window.event) + // charCode = window.event.keyCode; //for IE + // else + // charCode = evt.which; //for firefox if (charCode >= 91 && charCode <= 96) return false; @@ -60,7 +60,7 @@ function BlockSpecial(evt) { -
+
Back
@@ -310,18 +310,64 @@ function Validate() +$('#MaterialName').change(function() { + var materialname = $('#MaterialName').val(); + //material = material.replace(/\s*$/,""); + var material = materialname.replace(/ /g,''); + $('#content').loader('show'); + $.ajax({ + data:{id:material}, + type:"POST", + url:"rawmaterialdetails/checkmaterial", + success:function(data) { + + var count = data.length; + + if(count >2 ){ + + $('#content').loader('hide'); + + swal({ + title: "'" + materialname + " already existed ! ", + // type: "info", + showCancelButton: true, + confirmButtonClass: "btn-danger", + confirmButtonText: "Material Details!", + closeOnConfirm: false + }, + function(){ + dat = JSON.parse(data); + var related_name = ""; + $.each(dat,function(i,obj){ + related_name += obj.MaterialCode +" - "+ obj.MaterialName+" - "+obj.MaterialType+" - "+obj.Category+"\n"; + + }); + + + swal( "'" + materialname + "' - related materials are ," , related_name); + $("#MaterialName").focus(); + + });//sweet alert closed.... + + } + + else{ + $('#content').loader('hide'); + } + } + }); + }); -//corrected $(document).ready(function(){ -// $("#MaterialType").select2(); - - // $("#MaterialCategory").select2(); - // $("#UOM").select2(); - // $("#Assetcode").select2(); - // $("#Costcenter").select2(); - // $("#conversionfactorUOM").select2(); + + $("#MaterialType").select2(); + $("#MaterialCategory").select2(); + $("#UOM").select2(); + $("#Assetcode").select2(); + $("#Costcenter").select2(); + $("#conversionfactorUOM").select2(); }); diff --git a/application/views/addsupplier.php b/application/views/addsupplier.php index 652cf2ab..9fa4db3d 100644 --- a/application/views/addsupplier.php +++ b/application/views/addsupplier.php @@ -328,7 +328,7 @@ $(function() {
-
+
@@ -703,5 +703,49 @@ if(!validateEmail()) } }); +$('#supplierName').change(function() { + + var suppliername = $('#supplierName').val(); + var supplier = suppliername.replace(/ /g,''); + $('#content').loader('show'); + $.ajax({ + data:{id:supplier}, + type:"POST", + url:"supplier/checksupplier", + success:function(data) { + var count = data.length; + + if(count >2 ){ + $('#content').loader('hide'); + + swal({ + title: " supplier already existed ! ", + // type: "info", + showCancelButton: true, + confirmButtonClass: "btn-danger", + confirmButtonText: "Material Details!", + closeOnConfirm: false + }, + function(){ + dat = JSON.parse(data); + var related_supplier = ""; + $.each(dat,function(i,obj){ + related_supplier += obj.SupplierID +" - "+ obj.SupplierName +" - "+obj.Address+"\n"; + }); + + swal("'" + suppliername + "' - related supplier are , " + " \n \n" + related_supplier); + $("#supplierName").focus(); + + });//sweet alert closed.... + } + else{ + $('#content').loader('hide'); + } + } + }); + }); + + + \ No newline at end of file diff --git a/application/views/attendance.php b/application/views/attendance.php index 2d354661..6fa04d89 100755 --- a/application/views/attendance.php +++ b/application/views/attendance.php @@ -5,23 +5,12 @@ "; -// echo count($attendance); -// echo "
"; -// print_r($emppay); -// echo "
"; -// echo count($emppay); -//print_r($datefordropdown); -//print_r($noofpublicholidays);print_r($publicholidaysarray); $datefordropdown = date_create($datefordropdown); $datefordropdown = date_format($datefordropdown,'M-Y'); -//echo $datefordropdown; + $attendance = array_merge($attendance,$emppay); date_default_timezone_set('Asia/Kolkata'); $currentday = date('d'); -// print_r($attendance); -// echo "
------------------------------
"; ?>