From f05c2a0c5332189ea312fd0ef716eb18e0c8c63d Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 28 Sep 2018 17:19:38 +0530 Subject: [PATCH] call tracking and expense report changes --- Apollo/api/application/controllers/Report.php | 10 +- .../api/application/models/Reports_model.php | 145 +++++++++++++++++- .../js/controllers/report_certificateCtrl.js | 2 +- .../js/controllers/report_expenseCtrl.js | 18 ++- .../assets/js/controllers/report_leadCtrl.js | 97 +++++++----- .../controllers/report_markcard_statusCtrl.js | 2 +- Apollo/assets/views/report_expense.html | 34 +++- Apollo/assets/views/report_lead.html | 63 ++++---- 8 files changed, 285 insertions(+), 86 deletions(-) diff --git a/Apollo/api/application/controllers/Report.php b/Apollo/api/application/controllers/Report.php index a297650c..b5eadac7 100755 --- a/Apollo/api/application/controllers/Report.php +++ b/Apollo/api/application/controllers/Report.php @@ -340,11 +340,15 @@ class Report extends REST_Controller { } public function lead_post() { + $univ = $this->post('university'); + $act = $this->post('activity'); + $sta = $this->post('status'); + $ass = $this->post('assigned'); $from = $this->post('from'); $to = $this->post('to'); $br = $this->post('branch'); - $getStatus = $this->report_model->lead($from,$to,$br); + $getStatus = $this->report_model->lead($univ,$act,$sta,$ass,$from,$to,$br); //print_r($getStatus); if ($getStatus) { @@ -366,7 +370,9 @@ class Report extends REST_Controller { public function filters_post() { $br = $this->post('branch'); - $getStatus = $this->report_model->getUniversity($br); + $getStatus['Univ'] = $this->report_model->getUniv($br); + $getStatus['Activity'] = $this->report_model->getActivity($br); + $getStatus['Staff'] = $this->report_model->getStaff($br); //print_r($getStatus); if ($getStatus) { diff --git a/Apollo/api/application/models/Reports_model.php b/Apollo/api/application/models/Reports_model.php index ad0c0ffa..f434329e 100755 --- a/Apollo/api/application/models/Reports_model.php +++ b/Apollo/api/application/models/Reports_model.php @@ -73,14 +73,30 @@ group by sid,sem) as apdate on apdate.sid=sms.sid and apdate.sem=sms.sem } public function filters($br){ - + //University name $sql = "SELECT distinct UniversityID as uid,UniversityName as university FROM T_UniversityMaster where BranchCode = '".$br."'"; $b=$this->db->query($sql); $batch = $b->result(); + //staff Name + $sql_staf = "select StaffID,concat(Firstname,Lastname) as staff_name from T_StaffDetails where IsActive = 1 and BranchCode = '".$br."'"; + $staff=$this->db->query($sql_staf); + $staff_list = $staff->result(); + //Activity Name + $sql_act = "select ActivityID,ActivityName from T_ActivityMaster where IsActive = 1 and BranchCode = '".$br."'"; + $act=$this->db->query($sql_act); + $act_name = $act->result(); + //Status + $sql_staf = "select StaffID,concat(Firstname,Lastname) as staff_name from T_StaffDetails where IsActive = 1 and BranchCode = '".$br."'"; + $staff=$this->db->query($sql_staf); + $staff_list = $staff->result(); + if (count($batch) > 0) { $results['univlist'] = true; $results['university'] = $batch; + $results['staff'] = $staff_list; + $results['activity_name'] = $act_name; + $results['activity_name'] = $act_name; } else { $results['univlist'] = false; $results['message'] = 'No record found'; @@ -375,7 +391,21 @@ left join } public function expense($from=null,$to=null,$br=null){ - $sql = "SELECT ifnull(dbm.Date,'-') as date,ifnull(exp.TypeName,'-') as Expense_name,ifnull(sum(dbm.Amount),0) as Amount,b.BranchName as branch FROM (SELECT @s:= 0) AS s,T_Income_Outcome_Master exp + $sql = "SELECT ifnull(exp.TypeName,'-') as Expense_name,b.BranchName as branch, +ifnull(dbm.Date,'-') as date, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 1, dbm.Amount, 0)) AS January, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 2, dbm.Amount, 0)) AS February, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 3, dbm.Amount, 0)) AS March, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 4, dbm.Amount, 0)) AS April, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 5, dbm.Amount, 0)) AS May, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 6, dbm.Amount, 0)) AS June, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 7, dbm.Amount, 0)) AS July, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 8, dbm.Amount, 0)) AS August, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 9, dbm.Amount, 0)) AS September, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 10, dbm.Amount, 0)) AS October, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) = 11, dbm.Amount, 0)) AS November, +SUM(IF(month(STR_TO_DATE(dbm.Date,'%d-%m-%Y')) =12, dbm.Amount, 0)) AS December,ifnull(sum(dbm.Amount),0) as total +FROM T_Income_Outcome_Master exp join T_DayBookMaster dbm on dbm.Type=exp.ID left join T_BranchMaster b on b.BranchCode=exp.BranchCode where dbm.Name = 'I001' and exp.TypeName not like 'FEES' and dbm.Status = 'Approved' and exp.BranchCode = '".$br."' @@ -884,7 +914,7 @@ left join return $results; } - public function lead($from=null,$to=null,$br=null){ + public function lead($univ=null,$act=null,$sta=null,$ass=null,$from=null,$to=null,$br=null){ $sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as tid,ifnull(ltf.FollowupOn,'-') as fup,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobile,lt.University as univ,lt.Course as course,lt.Course as prvStatus,list.ListName as prsStatus,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo from T_Lead_Tracking_Followup as ltf @@ -897,7 +927,22 @@ from T_Lead_Tracking_Followup as ltf where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID) and lt.CreatedBranch = '".$br."' "; - + if ($univ != ''){ + $sql.=" and lt.University = '".$univ."' + "; + } + if ($act != ''){ + $sql.=" and am.ActivityID = '".$act."' + "; + } + if ($sta != ''){ + $sql.=" and list.ListCode = '".$sta."' + "; + } + if ($ass != ''){ + $sql.=" and sd.StaffID >= '".$ass."' + "; + } if ($from != ''){ $fromd= date("Y-m-d",strtotime($from)); @@ -1145,5 +1190,97 @@ if($feeDetails) return $result_array; } + public function getUniv($br=null) + { + $this->db->select('UniversityID,UniversityName'); + $this->db->where('IsActive','1'); + $this->db->where('BranchCode',$br); + $this->db->order_by('CreatedOn','DESC'); + $university = $this->db->get(UNIVERSITY); + + if($university->result()){ + $result = array(); + $result['univlist'] = true; + foreach ($university->result() as $row) + { + + $university_array['universityID'] = $row->UniversityID; + $university_array['universityName'] = $row->UniversityName; + $result_array[]=$university_array; + } + $result['university']= $result_array; + } + else { + $result['univlist'] = false; + $result['message'] = "No records found!"; + $result['universityID'] = ""; + $result['universityName'] = ""; + $result['batchDetails']= ""; + } + + + return $result; + + } + public function getActivity($branchID = null) + { + $this->db->select('ActivityID,ActivityName'); + $this->db->where('IsActive','1'); + $this->db->where('BranchCode',$branchID); + $this->db->order_by('ActivityID','ASC'); + $activity = $this->db->get(ACTIVITY); + if($activity->result()){ + $result_activity = array(); + foreach ($activity->result() as $row) + { + $activity_array['activityStatus'] = true; + $activity_array['activityID'] = $row->ActivityID; + $activity_array['activityName'] = $row->ActivityName; + $activity_array['activityStatus']= $this->getStatus($row->ActivityID); + $result_activity[]=$activity_array; + } + + } + else{ + $activity_array['activityStatus'] = false; + $activity_array['activityID'] = ""; + $activity_array['activityName'] = "No activity"; + $activity_array['activityStatus']= ""; + $result_activity[]=$activity_array; + + } + + return $result_activity; + } + + public function getStatus($activityID=null) + { + $this->db->select('AVS.StatusID,PLD.ListCode,PLD.ListName'); + $this->db->from(ACTIVITY_STATUS .' as AVS'); + $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AVS.StatusName'); + $this->db->where('AVS.ActivityID',$activityID); + $this->db->where('AVS.IsActive','1'); + $this->db->where('PLD.IsActive','1'); + $status = $this->db->get(); + return $status->result(); + } + public function getStaff($br){ + + + //staff Name + $sql_staf = "select StaffID,concat(Firstname,Lastname) as staff_name from T_StaffDetails where IsActive = 1 and BranchCode = '".$br."'"; + $staff=$this->db->query($sql_staf); + $staff_list = $staff->result(); + + + if (count($staff_list) > 0) { + $results['staff'] = $staff_list; + + } else { + $results['message'] = 'No record found'; + } + return $results; + + } } \ No newline at end of file diff --git a/Apollo/assets/js/controllers/report_certificateCtrl.js b/Apollo/assets/js/controllers/report_certificateCtrl.js index 6c38123b..2dd0fad5 100755 --- a/Apollo/assets/js/controllers/report_certificateCtrl.js +++ b/Apollo/assets/js/controllers/report_certificateCtrl.js @@ -165,7 +165,7 @@ app.controller('report_certificateCtrl', ["$scope", "$filter","$rootScope","$mod $scope.exportData = function () { - alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,initialPaid as DocumentFeePaidDate,Enrollment_id as EnrollmentID,Student_name as StudentName,Father_name as FatherName,Course_name as CourseName,University as University,CAST(balance AS NUMBER) as Balance,certname as CertificateName,status as CertificateStatus,adate as Date INTO XLS("Certificate_status.xls",?) FROM ?',[mystyle,$scope.cert_data]); + alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,initialPaid as CertificateFeePaidDate,Enrollment_id as EnrollmentID,Student_name as StudentName,Father_name as FatherName,Course_name as CourseName,University as University,CAST(balance AS NUMBER) as Balance,certname as CertificateName,status as CertificateStatus,adate as Date INTO XLS("Certificate_status.xls",?) FROM ?',[mystyle,$scope.cert_data]); }; /** diff --git a/Apollo/assets/js/controllers/report_expenseCtrl.js b/Apollo/assets/js/controllers/report_expenseCtrl.js index c46f53f4..95cbace2 100755 --- a/Apollo/assets/js/controllers/report_expenseCtrl.js +++ b/Apollo/assets/js/controllers/report_expenseCtrl.js @@ -11,8 +11,9 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle "from_date": "", "to_date": "", - }; + }; + $scope.date = new Date(); var localDetail = JSON.parse(localStorage.getItem('localObj')); const LOCALTYPE = localDetail.localType; @@ -112,9 +113,16 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle } }); - + $scope.getTotal = function(){ + var total = 0; + for(var i = 0; i < $scope.expense_data.length; i++){ + var item = $scope.expense_data[i]; + total += parseFloat(item.total); + } + return total; } } - } + + }; var mystyle = { sheetid: 'EXPENSE REPORT', @@ -131,10 +139,12 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle }; + //pdf + //end of pdf $scope.exportData = function () { - alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Expense_name as ExpenseName,CAST(Amount as NUMBER) as Amount INTO XLS("Expense_report.xls",?) FROM ?',[mystyle,$scope.expense_data]); + alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Expense_name as ExpenseName,CAST(January as NUMBER) as January,CAST(February as NUMBER) as February,CAST(March as NUMBER) as March,CAST(April as NUMBER) as April,CAST(May as NUMBER) as May,CAST(June as NUMBER) as June,CAST(July as NUMBER) as July,CAST(August as NUMBER) as August,CAST(September as NUMBER) as September,CAST(October as NUMBER) as October,CAST(November as NUMBER) as November,CAST(December as NUMBER) as December,CAST(total as NUMBER) as Amount INTO XLS("Expense_report.xls",?) FROM ?',[mystyle,$scope.expense_data]); }; }]); diff --git a/Apollo/assets/js/controllers/report_leadCtrl.js b/Apollo/assets/js/controllers/report_leadCtrl.js index 252b7891..9a747096 100644 --- a/Apollo/assets/js/controllers/report_leadCtrl.js +++ b/Apollo/assets/js/controllers/report_leadCtrl.js @@ -58,13 +58,16 @@ app.controller('report_leadCtrl', ["$scope", "$filter","$rootScope","$modal", "A // DataTables configurable options - $scope.filters = { - "branch": "", + $scope.filtersList = { + "univ": "", + "activity": "", + "status": "", + "assigned": "", "from_date": "", "to_date": "", }; - + console.log($scope.filters); $scope.filters = function () { var filterlist = { method: 'POST', @@ -81,46 +84,57 @@ app.controller('report_leadCtrl', ["$scope", "$filter","$rootScope","$modal", "A $http(filterlist).then(function (response) { if (response.data) { $scope.batch=[]; - $scope.batchlist = response.data.batch; - $scope.university = response.data.university; - //Desc order Batchlist - angular.forEach($scope.batchlist,function (values,key) { - var parts = values.BatchDate.split("-"); - $scope.batch.push({ - "batchcode":values.batchcode, - "batch":values.batch + '('+ values.batchcode + ')', - "BatchDate":values.BatchDate, - "givenDateObject":new Date(parts[2], parts[1] - 1, parts[0]) - }) - }); - // call service for make a list in desc order based on date - $scope.batch=dateListDescService.getOrderByList($scope.batch); - //console.log($scope.branch); + $scope.activity = response.data.Activity; + $scope.university = response.data.Univ.university; + $scope.staff = response.data.Staff.staff; + // console.log($scope.activity); + console.log($scope.university); + // console.log($scope.staff); + // console.log(response.data); } else { } }); } + /* watch university model for bind batch objects*/ + + $scope.$watch('filtersList.activity', function (newValue,oldValue) { + if(newValue==undefined || newValue==''){ + $scope.statusDetails=""; + } + else{ + if(angular.isString(newValue)){ + $scope.statusDetails=angular.fromJson(newValue); + // console.log($scope.statusDetails); + } + } + }); + // if($scope.filtersList.activity) + // { + + // } + //Button disable if no fields selected + $scope.disableSubmit=true; + $scope.click = function(){ + + $scope.disableSubmit=false; + console.log('hi'); + } + + $scope.show = false; $scope.onSubmit = function (form) { - var firstError = null; - if (form.$invalid) { - var field = null, firstError = null; - $scope.show = true; - for (field in form) { - if (field[0] != '$') { - if (firstError === null && !form[field].$valid) { - firstError = form[field].$addDate; - firstError = form[field].$toDate; - } - if (form[field].$pristine) { - form[field].$dirty = true; - } - } - } - angular.element('.ng-invalid[toDate=' + firstError + ']').focus(); - }else { - //alert($scope.batch.name); + console.log($scope.filtersList); + + + if($scope.filtersList.activity) { + $scope.filterActivity = angular.fromJson($scope.filtersList.activity); + } + else{ + $scope.filterActivity=''; + } + + //$scope.filterActivity = angular.fromJson($scope.filtersList.activity); $scope.lead_data = ''; $scope.message = ''; var response_data = { @@ -131,12 +145,19 @@ app.controller('report_leadCtrl', ["$scope", "$filter","$rootScope","$modal", "A }, data: { branch: JSON.parse(localStorage.getItem('localObj')).localBranchID, + university : $scope.filtersList.univ, + activity : $scope.filterActivity.activityID, + status : $scope.filtersList.status, + assigned : $scope.filtersList.assigned, from : $scope.filters.from_date, to : $scope.filters.to_date } }; - + console.log($scope.filtersList.univ); + console.log($scope.filterActivity.activityID); + console.log($scope.filtersList.status); + console.log($scope.filtersList.assigned); $http(response_data).then(function (response) { if (response.data.leadList == true) { $scope.lead_data = response.data.lead_data; @@ -149,7 +170,7 @@ app.controller('report_leadCtrl', ["$scope", "$filter","$rootScope","$modal", "A }); - } + } var mystyle = { sheetid: 'Lead REPORT', diff --git a/Apollo/assets/js/controllers/report_markcard_statusCtrl.js b/Apollo/assets/js/controllers/report_markcard_statusCtrl.js index e95b45e0..340a573e 100755 --- a/Apollo/assets/js/controllers/report_markcard_statusCtrl.js +++ b/Apollo/assets/js/controllers/report_markcard_statusCtrl.js @@ -163,7 +163,7 @@ app.controller('report_markcard_statusCtrl', ["$scope", "$filter","$rootScope", $scope.exportData = function () { - alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Initial_paid_date as InitialPaidDate,Enrollment_id as EnrollmentID,Student_name as StudentName,Roll_NO as RollNO,Father_name as FatherName,Course_name as CourseName,Sem_year as SemYear,University as University,CAST(Balance_Fee AS NUMBER) as BalanceFee,appdate as ApplicationSentDate,ansdate as AnswerBookletSentDate,Status as MarkCardStatus,Date as Date INTO XLS("Markcard_status.xls",?) FROM ?',[mystyle,$scope.markcard_data]); + alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Initial_paid_date as InitialPaidDate,Enrollment_id as EnrollmentID,Roll_NO as RollNO,Student_name as StudentName,Father_name as FatherName,Course_name as CourseName,Sem_year as SemYear,University as University,CAST(Balance_Fee AS NUMBER) as BalanceFee,appdate as ApplicationSentDate,ansdate as AnswerBookletSentDate,Status as MarkCardStatus,Date as Date INTO XLS("Markcard_status.xls",?) FROM ?',[mystyle,$scope.markcard_data]); }; /** * Auto Call Tracking Sriram diff --git a/Apollo/assets/views/report_expense.html b/Apollo/assets/views/report_expense.html index 501259e9..8ebba350 100755 --- a/Apollo/assets/views/report_expense.html +++ b/Apollo/assets/views/report_expense.html @@ -10,9 +10,9 @@ .table>tbody>tr>td { padding: 2px; } .table-responsive { - width:80%; + /* width:80%; margin-left: 101px; - + */ }