From 2970773a043c0c1440bcb460a0c33f5a08f567c1 Mon Sep 17 00:00:00 2001 From: go-faustino Date: Mon, 23 Apr 2018 23:36:02 +0100 Subject: [PATCH] consider project task billable rate billing report --- .../controllers/ReportsController.php | 347 ++++++++++-------- .../modules/timemanagement/models/Reports.php | 191 +++++----- 2 files changed, 283 insertions(+), 255 deletions(-) diff --git a/application/modules/timemanagement/controllers/ReportsController.php b/application/modules/timemanagement/controllers/ReportsController.php index 2650b9021..cd949d5a0 100644 --- a/application/modules/timemanagement/controllers/ReportsController.php +++ b/application/modules/timemanagement/controllers/ReportsController.php @@ -30,11 +30,11 @@ public function preDispatch() if(!$checkTmEnable){ $this->_redirect('error'); }*/ - + //check Time management module enable // if(!sapp_Helper::checkTmEnable()) // $this->_redirect('error'); - + $auth = Zend_Auth::getInstance(); $loginuserGroup=0; $loginuserRole=0; @@ -42,9 +42,9 @@ public function preDispatch() $loginuserGroup = $auth->getStorage()->read()->group_id; $loginuserRole = $auth->getStorage()->read()->emprole; } - if(!($loginuserGroup==3 || ($loginuserGroup=='' && $loginuserRole==1) || $loginuserGroup==1)) + if(!($loginuserGroup==3 || ($loginuserGroup=='' && $loginuserRole==1) || $loginuserGroup==1)) $this->_redirect('error'); - + $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('employeereports', 'html')->initContext(); $ajaxContext->addActionContext('projectsreports', 'html')->initContext(); @@ -72,15 +72,15 @@ public function tmreportAction() $month_last_day = date('Y-m-t'); $month_first_day = sapp_Global::change_date($month_first_day,'database'); $month_last_day = sapp_Global::change_date($month_last_day,'database'); - + $start_date = ($this->_getParam('start_date')!='')? $this->_getParam('start_date'):$month_first_day; $end_date = ($this->_getParam('end_date')!='')? $this->_getParam('end_date'):$month_last_day; $this->view->start_date = ($this->_getParam('start_date')!='')? $this->_getParam('start_date'):$month_first_day; $this->view->end_date = ($this->_getParam('end_date')!='')? $this->_getParam('end_date'):$month_last_day; $this->view->selected_period_hidden = ($this->_getParam('selected_period_hidden')!='')? $this->_getParam('selected_period_hidden'):''; - - + + } public function employeereportsAction(){ @@ -98,7 +98,7 @@ public function employeereportsAction(){ $end_date = sapp_Global::change_date($end_date,'database'); $org_start_date = $start_date; $org_end_date = $end_date; - //pdf and excel flags + //pdf and excel flags $is_pdf = ($this->_getParam('is_pdf')!='' && $this->_getParam('is_pdf')!='undefined')? $this->_getParam('is_pdf'):""; $is_excel = ($this->_getParam('is_excel')!='' && $this->_getParam('is_excel')!='undefined')? $this->_getParam('is_excel'):""; $call = $this->_getParam('call'); @@ -165,7 +165,7 @@ public function employeereportsAction(){ } $this->_helper->layout->disableLayout(); //getting the employee reports data - $result = $reportsmodel->getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQuery,$start_date, $end_date, $projid, $param,1); + $result = $reportsmodel->getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQuery,$start_date, $end_date, $projid, $param,1); //for pdf if(!empty($is_pdf)) { @@ -206,9 +206,9 @@ public function employeereportsAction(){ $this->view->by =$by; $this->view->selected_period_hidden = ($this->_getParam('selected_period_hidden')!='')? $this->_getParam('selected_period_hidden'):''; } - + } - + public function billingreportAction(){ $reportsmodel = new Timemanagement_Model_Reports(); @@ -225,8 +225,8 @@ public function billingreportAction(){ $end_date = sapp_Global::change_date($end_date,'database'); $org_start_date = $start_date; $org_end_date = $end_date; - - //pdf and excel flags + + //pdf and excel flags $is_pdf = ($this->_getParam('is_pdf')!='' && $this->_getParam('is_pdf')!='undefined')? $this->_getParam('is_pdf'):""; $is_excel = ($this->_getParam('is_excel')!='' && $this->_getParam('is_excel')!='undefined')? $this->_getParam('is_excel'):""; $call = $this->_getParam('call'); @@ -235,7 +235,7 @@ public function billingreportAction(){ $this->view->start_date = $start_date; $this->view->end_date = $end_date; - $this->view->selected_period_hidden = $selected_period_hidden; + $this->view->selected_period_hidden = $selected_period_hidden; $this->view->projecttype = $projecttype; $this->view->call = $call ; @@ -292,12 +292,12 @@ public function billingreportAction(){ $this->view->sort =$sort; $this->view->by =$by; - + //getting the employee reports data $result = array(); - - $emp_billing_data = $reportsmodel->getBillingReportEmployeesData($sort, $by, $searchQuery,$start_date, $end_date); - + + $emp_billing_data = $reportsmodel->getBillingReportEmployeesData($sort, $by, $searchQuery,$start_date, $end_date); + $index = 1; $total_time = 0; $total_billing_hours = 0; @@ -308,7 +308,7 @@ public function billingreportAction(){ $total_on_call_days = 0; $billable_total = 0; - foreach($emp_billing_data as $temp_emp_billing_data){ + foreach($emp_billing_data as $temp_emp_billing_data){ $empid = $temp_emp_billing_data['user_id']; $total_emp_time = 0; $total_emp_billing_hours = 0; @@ -323,55 +323,59 @@ public function billingreportAction(){ $project_name = ''; $current_project_type_id = ''; $current_project_type = ''; - + $proj_billing_data = $reportsmodel->getBillingProjData($empid, $start_date, $end_date, $projecttype); $leave_billing_data = $reportsmodel->getBillingLeaveData($empid, $start_date, $end_date); $on_call_billing_data = $reportsmodel->getBillingOnCallData($empid, $start_date, $end_date); $work_schedule_hours = $reportsmodel->getWorkScheduleHours($empid); - - foreach($proj_billing_data as $temp_hours_task_week){ + + foreach($proj_billing_data as $temp_hours_task_week){ $totalweektime = 0; $totalweekbillinghours = 0; - + if ($temp_hours_task_week['sun_date'] >= $start_date && $temp_hours_task_week['sun_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['sun_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; + } + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; } - + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['sun_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['sun_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['sun_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['sun_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['sun_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -379,47 +383,51 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['mon_date'] >= $start_date && $temp_hours_task_week['mon_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['mon_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; + } + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; } - + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['mon_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['mon_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['mon_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['mon_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['mon_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -427,47 +435,51 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['tue_date'] >= $start_date && $temp_hours_task_week['tue_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['tue_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; } - + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; + } + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['tue_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['tue_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['tue_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['tue_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['tue_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -475,47 +487,51 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['wed_date'] >= $start_date && $temp_hours_task_week['wed_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['wed_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; + } + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; } - + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['wed_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['wed_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['wed_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['wed_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['wed_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -523,47 +539,51 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['thu_date'] >= $start_date && $temp_hours_task_week['thu_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['thu_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; + } + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; } - + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['thu_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['thu_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['thu_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['thu_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['thu_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -571,47 +591,51 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['fri_date'] >= $start_date && $temp_hours_task_week['fri_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['fri_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; } - + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; + } + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['fri_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['fri_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['fri_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['fri_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['fri_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -619,47 +643,51 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['sat_date'] >= $start_date && $temp_hours_task_week['sat_date'] <= $end_date) { list($hours,$minutes) = explode(':', $temp_hours_task_week['sat_duration'], 2); - - if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { - if ($temp_hours_task_week['billable_rate'] != '' && $temp_hours_task_week['billable_rate'] != 0) { - $billable_rate = $temp_hours_task_week['billable_rate']; + + if ((is_numeric($hours) && $hours <> 0) || (is_numeric($minutes) && $minutes <> 0)) { + if ($temp_hours_task_week['billable_rate_task'] != '' && $temp_hours_task_week['billable_rate_task'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_task']; + } + + if ($temp_hours_task_week['billable_rate_emp'] != '' && $temp_hours_task_week['billable_rate_emp'] != 0) { + $billable_rate = $temp_hours_task_week['billable_rate_emp']; } - + if ($temp_hours_task_week['project_name'] != '') { $project_name = $temp_hours_task_week['project_name']; $current_project_type_id = $temp_hours_task_week['id']; $current_project_type = $temp_hours_task_week['project_type']; } - + $day_time = 0; - + if ($hours_status != 'rejected') { $hours_status = $temp_hours_task_week['sat_status']; } - + if (is_numeric($hours) && $hours <> 0) { $day_time = $day_time + $hours; } - + if (is_numeric($minutes) && $minutes <> 0) { $day_time = $day_time + ($minutes / 60); } - + $totalweektime = $totalweektime + $day_time; if ($temp_hours_task_week['task'] != 'Overtime' && $temp_hours_task_week['task'] != 'On call overtime') { $work_schedule_hours_day = 0; - - foreach($work_schedule_hours as $temp_work_schedule_hours){ + + foreach($work_schedule_hours as $temp_work_schedule_hours){ if ($temp_work_schedule_hours['startdate'] <= $temp_hours_task_week['sat_date'] && $temp_work_schedule_hours['enddate'] >= $temp_hours_task_week['sat_date']) - $work_schedule_hours_day = $temp_work_schedule_hours['sat_duration']; + $work_schedule_hours_day = $temp_work_schedule_hours['sat_duration']; } - + if ($hours != $work_schedule_hours_day || (is_numeric($minutes) && $minutes <> 0) || $temp_hours_task_week['hours_day'] == 0) { $totalweekbillinghours = $totalweekbillinghours + $day_time; } else { @@ -667,8 +695,8 @@ public function billingreportAction(){ } } } - } - + } + if ($temp_hours_task_week['task'] == 'Overtime') { $total_emp_overtime = $total_emp_overtime + $totalweektime; } @@ -679,27 +707,27 @@ public function billingreportAction(){ $total_emp_time = $total_emp_time + $totalweektime; $total_emp_billing_hours = $total_emp_billing_hours + $totalweekbillinghours; } - + $billable_emp_total = $billable_emp_total + ($totalweekbillinghours * $billable_rate); - } - + } + foreach ($leave_billing_data as $temp_leave) { if ($temp_leave['leaveday'] == '1') { $total_emp_leave_days = $total_emp_leave_days + $temp_leave['appliedleavescount']; } else { $partial_emp_leave_days = $partial_emp_leave_days + $temp_leave['appliedleavescount']; - } - } - + } + } + foreach ($on_call_billing_data as $temp_oncall) { $total_emp_on_call_days = $total_emp_on_call_days + $temp_oncall['appliedoncallscount']; - } + } if ($projecttype == "" || $projecttype == $current_project_type_id) { - $result[$index]['Full Name'] = iconv("UTF-8", "UTF-8//IGNORE", $temp_emp_billing_data['userfullname']); - $result[$index]['Enterprise ID'] = iconv("UTF-8", "UTF-8//IGNORE", $temp_emp_billing_data['office_faxnumber']); - $result[$index]['Business Unit'] = iconv("UTF-8", "UTF-8//IGNORE", $temp_emp_billing_data['businessunit_name']); + $result[$index]['Full Name'] = iconv("UTF-8", "UTF-8//IGNORE", $temp_emp_billing_data['userfullname']); + $result[$index]['Enterprise ID'] = iconv("UTF-8", "UTF-8//IGNORE", $temp_emp_billing_data['office_faxnumber']); + $result[$index]['Business Unit'] = iconv("UTF-8", "UTF-8//IGNORE", $temp_emp_billing_data['businessunit_name']); $result[$index]['Project Name'] = iconv("UTF-8", "UTF-8//IGNORE", $project_name); $result[$index]['Project Type'] = iconv("UTF-8", "UTF-8//IGNORE", $current_project_type); $result[$index]['Project Hours'] = round($total_emp_time, 2); @@ -711,11 +739,11 @@ public function billingreportAction(){ $result[$index]['Partial Day Leaves Total'] = round($partial_emp_leave_days, 2); $result[$index]['Billable Hours'] = round($total_emp_billing_hours, 2); $result[$index]['Billable Rate'] = $billable_rate; - + $billable_emp_total = round(($total_emp_billing_hours * $billable_rate), 2); - + $result[$index]['Billable Total'] = round($billable_emp_total, 2); - + $total_time = $total_time + $total_emp_time; $total_overtime = $total_overtime + $total_emp_overtime; $total_on_call_overtime = $total_on_call_overtime + $total_emp_on_call_overtime; @@ -723,12 +751,12 @@ public function billingreportAction(){ $total_leave_days = $total_leave_days + $total_emp_leave_days; $partial_leave_days = $partial_leave_days + $partial_emp_leave_days; $total_billing_hours = $total_billing_hours + $total_emp_billing_hours; - $billable_total = $billable_total + $billable_emp_total; + $billable_total = $billable_total + $billable_emp_total; } - + $index++; } - + $result[$index]['Full Name'] = 'Total'; $result[$index]['Enterprise ID'] = ''; $result[$index]['Business Unit'] = ''; @@ -744,7 +772,7 @@ public function billingreportAction(){ $result[$index]['Billable Hours'] = round($total_billing_hours, 2); $result[$index]['Billable Rate'] = ''; $result[$index]['Billable Total'] = number_format(round($billable_total, 2), 2, '.', ''); - + //for pdf if(!empty($is_pdf)) { @@ -787,7 +815,7 @@ public function billingreportAction(){ { $this->view->dataArray = $result; } - + } public function projectsreportsAction(){ @@ -805,7 +833,7 @@ public function projectsreportsAction(){ $end_date = sapp_Global::change_date($end_date,'database'); $org_start_date = $start_date; $org_end_date = $end_date; - //pdf and excel flags + //pdf and excel flags $is_pdf = ($this->_getParam('is_pdf')!='' && $this->_getParam('is_pdf')!='undefined')? $this->_getParam('is_pdf'):""; $is_excel = ($this->_getParam('is_excel')!='' && $this->_getParam('is_excel')!='undefined')? $this->_getParam('is_excel'):""; $call = $this->_getParam('call'); @@ -813,7 +841,7 @@ public function projectsreportsAction(){ if($call == 'ajaxcall'){ $this->_helper->layout->disableLayout(); } - + $view = Zend_Layout::getMvcInstance()->getView(); $objname = $this->_getParam('objname'); $refresh = $this->_getParam('refresh'); @@ -895,12 +923,12 @@ public function projectsreportsAction(){ elseif (!empty($is_excel)) //for excel { $cols_param_arr = array('project_name' => 'Project','project_type' => 'Project Type','duration'=>'Duration'); - sapp_Global::export_to_excel($result,$cols_param_arr,"ProjectsReport.xlsx"); + sapp_Global::export_to_excel($result,$cols_param_arr,"ProjectsReport.xlsx"); } exit; } else //for reports grid - { + { $employeedata = $reportsmodel->getProjectReportsbyEmployeeId($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $start_date, $end_date, $empid,$org_start_date,$org_end_date,$param); @@ -950,7 +978,7 @@ public function getempdurationAction() $get_emp_proj_duration = $reportsmodel->getEmpProjDuration($emp_id,$start_date,$end_date,$projectId,$params); $this->view->get_emp_proj_duration = $get_emp_proj_duration; } - + public function getprojecttaskdurationAction() { $month_first_day = date('Y-m-01'); @@ -959,7 +987,7 @@ public function getprojecttaskdurationAction() $start_date = ($this->_getParam('start_date')!='' && $this->_getParam('start_date')!='undefined')? $this->_getParam('start_date'):$month_first_day; $end_date = ($this->_getParam('end_date')!='' && $this->_getParam('end_date')!='undefined')? $this->_getParam('end_date'):date('Y-m-d'); $projectId = $this->_getParam('projectId'); - + $param = $this->_getParam('params'); $params = $param; if($param=="Last7days") @@ -989,4 +1017,3 @@ public function getprojecttaskdurationAction() } } - diff --git a/application/modules/timemanagement/models/Reports.php b/application/modules/timemanagement/models/Reports.php index e511bf838..24922fada 100644 --- a/application/modules/timemanagement/models/Reports.php +++ b/application/modules/timemanagement/models/Reports.php @@ -32,7 +32,7 @@ class Timemanagement_Model_Reports extends Zend_Db_Table_Abstract protected $_name = 'tm_projects'; /** * This method is used to fetch the project details based on the user Role. - * + * * Added by Manju for reports. */ public function getProjectsListByRole(){ @@ -58,9 +58,9 @@ public function getProjectsListByRole(){ $result = $this->fetchAll($select)->toArray(); } return $result; - + } - + public function getEmpList() { $select = $this->select() @@ -72,7 +72,7 @@ public function getEmpList() return $this->fetchAll($select)->toArray(); } - + public function getProjectTypeList() { $select = $this->select() @@ -84,10 +84,10 @@ public function getProjectTypeList() return $this->fetchAll($select)->toArray(); } - - public function getEmployeeReportsbyProjectId($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, + + public function getEmployeeReportsbyProjectId($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $start_date, $end_date, $projid,$org_start_date,$org_end_date,$param=''){ - + $searchQuery = ''; $searchArray = array(); $data = array(); @@ -102,7 +102,7 @@ public function getEmployeeReportsbyProjectId($sort, $by, $perPage, $pageNo, $se } $searchQuery = rtrim($searchQuery," AND"); } - + $objName = 'reports'; //email,phone_no,poc,address,country_id,state_id,created_by @@ -114,12 +114,12 @@ public function getEmployeeReportsbyProjectId($sort, $by, $perPage, $pageNo, $se ); $tablecontent = $this->getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $start_date, $end_date, $projid, $param); - + $dataTmp = array( 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, - 'perPage' => $perPage, + 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), @@ -162,11 +162,11 @@ public function getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQue $start_dates=strtotime($start_date); $sd_month=date("m",$start_dates); $sd_year=date("Y",$start_dates); - + $end_dates=strtotime($end_date); $ed_month=date("m",$end_dates); $ed_year=date("Y",$end_dates); - + $andwhere = " AND et.ts_year >= ".$sd_year." AND et.ts_year <=".$ed_year." AND et.ts_month >= ".$sd_month." AND et.ts_month <= ".$ed_month; $duration = ""; $duration_sort = ""; @@ -186,14 +186,14 @@ public function getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQue TIME_TO_SEC( IF(thu_date BETWEEN '".$start_date."' AND '".$end_date."',thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date BETWEEN '".$start_date."' AND '".$end_date."',fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date BETWEEN '".$start_date."' AND '".$end_date."',sat_duration,'00:00')))/60)%60,2,'0'))"; - + $duration_sort = "TIME_TO_SEC( IF(mon_date BETWEEN '".$start_date."' AND '".$end_date."',mon_duration,'00:00')) + TIME_TO_SEC( IF(tue_date BETWEEN '".$start_date."' AND '".$end_date."',tue_duration,'00:00')) + TIME_TO_SEC( IF(wed_date BETWEEN '".$start_date."' AND '".$end_date."',wed_duration,'00:00')) + TIME_TO_SEC( IF(thu_date BETWEEN '".$start_date."' AND '".$end_date."',thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date BETWEEN '".$start_date."' AND '".$end_date."',fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date BETWEEN '".$start_date."' AND '".$end_date."',sat_duration,'00:00'))"; - + $andwhere =" AND (sun_date BETWEEN '".$start_date."' AND '".$end_date."' OR mon_date BETWEEN '".$start_date."' AND '".$end_date."' OR tue_date BETWEEN '".$start_date."' AND '".$end_date."' OR wed_date BETWEEN '".$start_date."' AND '".$end_date."' OR thu_date BETWEEN '".$start_date."' AND '".$end_date."' OR fri_date BETWEEN '".$start_date."' AND '".$end_date."' @@ -215,14 +215,14 @@ public function getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQue TIME_TO_SEC( IF(thu_date = '".$start_date."' ,thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date = '".$start_date."' ,fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date = '".$start_date."' ,sat_duration,'00:00')))/60)%60,2,'0'))"; - + $duration_sort = "TIME_TO_SEC( IF(mon_date = '".$start_date."' ,mon_duration,'00:00')) + TIME_TO_SEC( IF(tue_date = '".$start_date."' ,tue_duration,'00:00')) + TIME_TO_SEC( IF(wed_date = '".$start_date."' ,wed_duration,'00:00')) + TIME_TO_SEC( IF(thu_date = '".$start_date."' ,thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date = '".$start_date."' ,fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date = '".$start_date."' ,sat_duration,'00:00'))"; - + $andwhere = " AND (sun_date = '".$start_date."' OR mon_date = '".$start_date."' OR tue_date = '".$start_date."' OR wed_date = '".$start_date."' OR thu_date = '".$start_date."' OR fri_date = '".$start_date."' OR sat_date = '".$start_date."')"; } else @@ -231,27 +231,27 @@ public function getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQue $andwhere = " AND et.ts_year >= ".$sd_year." AND et.ts_year <=".$ed_year." AND et.ts_month >= ".$sd_month." AND et.ts_month <= ".$ed_month; $duration_sort = "SUM(TIME_TO_SEC(et.week_duration))"; } - + // if($param!="" && $param!="undefined" && $param!="Today" && $param!="Last 7 days") // { // $andwhere = " AND et.ts_year = ".$sd_year." AND et.ts_month >= ".$sd_month." AND et.ts_month <= ".$sd_month; // } // $andwhere = " AND et.created BETWEEN STR_TO_DATE('".$start_date."','%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('".$end_date."','%Y-%m-%d %H:%i:%s')"; } - + if($searchQuery){ - $andwhere .= " AND ".$searchQuery; + $andwhere .= " AND ".$searchQuery; } - + if($projid != ''){ $andwhere .= " AND p.id = '".$projid."'"; } - + $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) ->from(array('et' => 'tm_emp_timesheets'),array('e.userfullname','p.project_type','userId'=>'et.emp_id', - 'duration'=>$duration,'duration_sort'=>$duration_sort)) + 'duration'=>$duration,'duration_sort'=>$duration_sort)) ->joinInner(array('pt'=>'tm_project_tasks'), 'pt.id = et.project_task_id',array()) ->joinInner(array('p'=>'tm_projects'), 'p.id = pt.project_id',array()) ->joinInner(array('e'=>'main_employees_summary'), 'e.user_id = et.emp_id',array()) @@ -262,11 +262,11 @@ public function getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQue //echo $select; if(!empty($flag)) { - return $this->fetchAll($select)->toArray(); + return $this->fetchAll($select)->toArray(); } return $select; } - + /** * This will fetch all the active client details. * @@ -279,11 +279,11 @@ public function getEmployeeReportsData($sort, $by, $pageNo, $perPage, $searchQue * @return array $BillingReportEmployeesData */ public function getBillingReportEmployeesData($sort, $by, $searchQuery,$start_date, $end_date) - { + { $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) - ->from(array('e' => 'main_employees_summary'),array('e.user_id','e.userfullname','e.businessunit_name','e.office_faxnumber')) + ->from(array('e' => 'main_employees_summary'),array('e.user_id','e.userfullname','e.businessunit_name','e.office_faxnumber')) ->where("(e.date_of_leaving IS NULL". " or e.date_of_leaving = ''". " or e.date_of_leaving >= '".$start_date. @@ -291,18 +291,18 @@ public function getBillingReportEmployeesData($sort, $by, $searchQuery,$start_da " and e.isactive IS NOT NULL". " and e.emp_status_name <> 'Deputation'") ->order("$by $sort"); - return $this->fetchAll($select)->toArray(); + return $this->fetchAll($select)->toArray(); } - + public function getBillingProjData($empid, $start_date, $end_date, $projecttype) - { - if ($projecttype == "") + { + if ($projecttype == "") { $projecttypecond = ""; } else { - $projecttypecond = " and mp.id = ".$projecttype; + $projecttypecond = " and mp.id = ".$projecttype; } - + $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) @@ -310,50 +310,51 @@ public function getBillingProjData($empid, $start_date, $end_date, $projecttype) array('tp.project_type', 'tp.project_name', 'tt.task', - 'tpe.billable_rate', - 'tpte.project_task_id', + 'tpe.billable_rate as billable_rate_emp', + 'tpt.billable_rate as billable_rate_task', + 'tpte.project_task_id', 'mp.hours_day', 'mp.id', 'tet.sun_date', 'tet.sun_duration', - 'tts.sun_status', + 'tts.sun_status', 'tet.mon_date', 'tet.mon_duration', - 'tts.mon_status', + 'tts.mon_status', 'tet.tue_date', 'tet.tue_duration', - 'tts.tue_status', + 'tts.tue_status', 'tet.wed_date', 'tet.wed_duration', - 'tts.wed_status', + 'tts.wed_status', 'tet.thu_date', 'tet.thu_duration', - 'tts.thu_status', + 'tts.thu_status', 'tet.fri_date', 'tet.fri_duration', - 'tts.fri_status', + 'tts.fri_status', 'tet.sat_date', 'tet.sat_duration', 'tts.sat_status')) - ->joinInner(array('tp'=>'tm_projects'), + ->joinInner(array('tp'=>'tm_projects'), 'tp.id = tpe.project_id', array()) - ->joinInner(array('tpt'=>'tm_project_tasks'), + ->joinInner(array('tpt'=>'tm_project_tasks'), 'tpt.project_id = tpe.project_id', array()) - ->joinInner(array('tt'=>'tm_tasks'), + ->joinInner(array('tt'=>'tm_tasks'), 'tt.id = tpt.task_id', array()) - ->joinInner(array('tpte'=>'tm_project_task_employees'), + ->joinInner(array('tpte'=>'tm_project_task_employees'), 'tpte.project_id = tpe.project_id'. ' and tpte.task_id = tpt.task_id'. ' and tpte.emp_id = tpe.emp_id', array()) - ->joinInner(array('tet'=>'tm_emp_timesheets'), + ->joinInner(array('tet'=>'tm_emp_timesheets'), 'tet.emp_id = tpe.emp_id'. ' and tet.project_task_id = tpte.project_task_id', array()) - ->joinInner(array('tts'=>'tm_ts_status'), + ->joinInner(array('tts'=>'tm_ts_status'), 'tts.emp_id = tpe.emp_id'. ' and tts.project_id = tpe.project_id'. ' and tts.ts_year = tet.ts_year'. @@ -361,7 +362,7 @@ public function getBillingProjData($empid, $start_date, $end_date, $projecttype) ' and tts.ts_week = tet.ts_week'. ' and tts.cal_week = tet.cal_week', array()) - ->joinInner(array('mp'=>'main_projecttype'), + ->joinInner(array('mp'=>'main_projecttype'), 'mp.projecttype = tp.project_type', array()) ->where("tpe.is_active = 1". @@ -385,9 +386,9 @@ public function getBillingProjData($empid, $start_date, $end_date, $projecttype) * @param string $end_date * * @return array $leave_billing_data - */ + */ public function getBillingLeaveData($empid,$start_date,$end_date) - { + { $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) @@ -397,8 +398,8 @@ public function getBillingLeaveData($empid,$start_date,$end_date) 'ml.to_date', 'ml.leaveday', 'ml.no_of_days', - 'ml.appliedleavescount')) - ->joinInner(array('me'=>'main_employeeleavetypes'), + 'ml.appliedleavescount')) + ->joinInner(array('me'=>'main_employeeleavetypes'), 'me.id = ml.Leavetypeid',array()) ->where("ml.Leavestatus in ('Pending for approval', 'Approved')". " and ml.isactive = 1". @@ -416,9 +417,9 @@ public function getBillingLeaveData($empid,$start_date,$end_date) * @param string $end_date * * @return array $on_call_billing_data - */ + */ public function getBillingOnCallData($empid,$start_date,$end_date) - { + { $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) @@ -428,8 +429,8 @@ public function getBillingOnCallData($empid,$start_date,$end_date) 'mo.to_date', 'mo.oncallday', 'mo.no_of_days', - 'mo.appliedoncallscount')) - ->joinInner(array('me'=>'main_employeeoncalltypes'), + 'mo.appliedoncallscount')) + ->joinInner(array('me'=>'main_employeeoncalltypes'), 'me.id = mo.oncalltypeid',array()) ->where("mo.oncallstatus in ('Pending for approval', 'Approved')". " and mo.isactive = 1". @@ -445,9 +446,9 @@ public function getBillingOnCallData($empid,$start_date,$end_date) * @param string $empid * * @return array $billing_hours - */ + */ public function getWorkScheduleHours($empid) - { + { $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) @@ -460,16 +461,16 @@ public function getWorkScheduleHours($empid) 'mws.wed_duration', 'mws.thu_duration', 'mws.fri_duration', - 'mws.sat_duration')) - ->joinInner(array('mes'=>'main_employees_summary'), + 'mws.sat_duration')) + ->joinInner(array('mes'=>'main_employees_summary'), 'mes.businessunit_id = mws.businessunit_id'. ' and mes.department_id = mws.department_id', array()) ->where("mes.user_id = ".$empid. " and mws.isactive = 1"); - return $this->fetchAll($select)->toArray(); + return $this->fetchAll($select)->toArray(); } - + function getProjectReportsbyEmployeeId($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $start_date, $end_date, $empid,$org_start_date,$org_end_date,$param=""){ @@ -504,7 +505,7 @@ function getProjectReportsbyEmployeeId($sort, $by, $perPage, $pageNo, $searchDat 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, - 'perPage' => $perPage, + 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), @@ -521,11 +522,11 @@ function getProjectReportsbyEmployeeId($sort, $by, $perPage, $pageNo, $searchDat 'end_date' => $org_end_date, ); return $dataTmp; - + } - + function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $start_date, $end_date, $empid, $param="",$flag=""){ - + $andwhere = " AND (1=1)"; if($start_date != "") { @@ -537,12 +538,12 @@ function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $sta $start_dates=strtotime($start_date); $sd_month=date("m",$start_dates); $sd_year=date("Y",$start_dates); - + $end_dates=strtotime($end_date); $ed_month=date("m",$end_dates); $ed_year=date("Y",$end_dates); $andwhere = " AND et.ts_year >= ".$sd_year." AND et.ts_year <=".$ed_year." AND et.ts_month >= ".$sd_month." AND et.ts_month <= ".$ed_month; - + $duration=""; $duration_sort =""; //$andwhere = " AND et.created BETWEEN STR_TO_DATE('".$start_date."','%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('".$end_date."','%Y-%m-%d %H:%i:%s')"; @@ -562,14 +563,14 @@ function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $sta TIME_TO_SEC( IF(thu_date BETWEEN '".$start_date."' AND '".$end_date."',thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date BETWEEN '".$start_date."' AND '".$end_date."',fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date BETWEEN '".$start_date."' AND '".$end_date."',sat_duration,'00:00')))/60)%60,2,'0'))"; - + $duration_sort = "TIME_TO_SEC( IF(mon_date BETWEEN '".$start_date."' AND '".$end_date."',mon_duration,'00:00')) + TIME_TO_SEC( IF(tue_date BETWEEN '".$start_date."' AND '".$end_date."',tue_duration,'00:00')) + TIME_TO_SEC( IF(wed_date BETWEEN '".$start_date."' AND '".$end_date."',wed_duration,'00:00')) + TIME_TO_SEC( IF(thu_date BETWEEN '".$start_date."' AND '".$end_date."',thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date BETWEEN '".$start_date."' AND '".$end_date."',fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date BETWEEN '".$start_date."' AND '".$end_date."',sat_duration,'00:00'))"; - + $andwhere =" AND (sun_date BETWEEN '".$start_date."' AND '".$end_date."' OR mon_date BETWEEN '".$start_date."' AND '".$end_date."' OR tue_date BETWEEN '".$start_date."' AND '".$end_date."' OR wed_date BETWEEN '".$start_date."' AND '".$end_date."' OR thu_date BETWEEN '".$start_date."' AND '".$end_date."' OR fri_date BETWEEN '".$start_date."' AND '".$end_date."' @@ -591,14 +592,14 @@ function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $sta TIME_TO_SEC( IF(thu_date = '".$start_date."' ,thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date = '".$start_date."' ,fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date = '".$start_date."' ,sat_duration,'00:00')))/60)%60,2,'0'))"; - + $duration_sort = "TIME_TO_SEC( IF(mon_date = '".$start_date."' ,mon_duration,'00:00')) + TIME_TO_SEC( IF(tue_date = '".$start_date."' ,tue_duration,'00:00')) + TIME_TO_SEC( IF(wed_date = '".$start_date."' ,wed_duration,'00:00')) + TIME_TO_SEC( IF(thu_date = '".$start_date."' ,thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date = '".$start_date."' ,fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date = '".$start_date."' ,sat_duration,'00:00'))"; - + $andwhere = " AND (sun_date = '".$start_date."' OR mon_date = '".$start_date."' OR tue_date = '".$start_date."' OR wed_date = '".$start_date."' OR thu_date = '".$start_date."' OR fri_date = '".$start_date."' OR sat_date = '".$start_date."')"; } else @@ -608,9 +609,9 @@ function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $sta $duration_sort = "SUM(TIME_TO_SEC(et.week_duration))"; } } - + if($searchQuery){ - $andwhere .= " AND ".$searchQuery; + $andwhere .= " AND ".$searchQuery; } if($empid != "") @@ -622,7 +623,7 @@ function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $sta $select = $this->select() ->setIntegrityCheck(false) ->from(array('et' => 'tm_emp_timesheets'),array('p.project_name','proj_category'=>'p.project_type','p.id','project_type'=>'p.project_type', - 'duration'=>$duration,'duration_sort'=>$duration_sort)) + 'duration'=>$duration,'duration_sort'=>$duration_sort)) ->joinInner(array('pt'=>'tm_project_tasks'), 'pt.id = et.project_task_id',array()) ->joinInner(array('p'=>'tm_projects'), 'p.id = pt.project_id and p.id = et.project_id',array()) ->joinInner(array('e'=>'main_employees_summary'), 'e.user_id = et.emp_id',array()) @@ -633,12 +634,12 @@ function getProjectReportsData($sort, $by, $pageNo, $perPage, $searchQuery, $sta ->limitPage($pageNo, $perPage); if(!empty($flag)) { - return $this->fetchAll($select)->toArray(); + return $this->fetchAll($select)->toArray(); } //echo $select;//exit; return $select; } - + public function getEmpProjDuration($empId,$start_date,$end_date,$project_id,$param) { $andwhere = ''; @@ -652,15 +653,15 @@ public function getEmpProjDuration($empId,$start_date,$end_date,$project_id,$par $start_dates=strtotime($start_date); $sd_month=date("m",$start_dates); $sd_year=date("Y",$start_dates); - + $end_dates=strtotime($end_date); $ed_month=date("m",$end_dates); $ed_year=date("Y",$end_dates); - + $duration=""; $andwhere = " AND et.ts_year >= ".$sd_year." AND et.ts_year <=".$ed_year." AND et.ts_month >= ".$sd_month." AND et.ts_month <= ".$ed_month; //$andwhere = " AND et.created BETWEEN STR_TO_DATE('".$start_date."','%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('".$end_date."','%Y-%m-%d %H:%i:%s')"; - + if($param=="" || $param=="undefined" || $param=="Last 7 days") { $duration = "CONCAT(FLOOR(SUM( TIME_TO_SEC( IF(sun_date BETWEEN '".$start_date."' AND '".$end_date."',sun_duration,'00:00')) + @@ -677,8 +678,8 @@ public function getEmpProjDuration($empId,$start_date,$end_date,$project_id,$par TIME_TO_SEC( IF(thu_date BETWEEN '".$start_date."' AND '".$end_date."',thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date BETWEEN '".$start_date."' AND '".$end_date."',fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date BETWEEN '".$start_date."' AND '".$end_date."',sat_duration,'00:00')))/60)%60,2,'0'))"; - - + + $andwhere =" AND (sun_date BETWEEN '".$start_date."' AND '".$end_date."' OR mon_date BETWEEN '".$start_date."' AND '".$end_date."' OR tue_date BETWEEN '".$start_date."' AND '".$end_date."' OR wed_date BETWEEN '".$start_date."' AND '".$end_date."' OR thu_date BETWEEN '".$start_date."' AND '".$end_date."' OR fri_date BETWEEN '".$start_date."' AND '".$end_date."' @@ -700,7 +701,7 @@ public function getEmpProjDuration($empId,$start_date,$end_date,$project_id,$par TIME_TO_SEC( IF(thu_date = '".$start_date."' ,thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date = '".$start_date."' ,fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date = '".$start_date."' ,sat_duration,'00:00')))/60)%60,2,'0'))"; - + $andwhere = " AND (sun_date = '".$start_date."' OR mon_date = '".$start_date."' OR tue_date = '".$start_date."' OR wed_date = '".$start_date."' OR thu_date = '".$start_date."' OR fri_date = '".$start_date."' OR sat_date = '".$start_date."')"; } else @@ -715,14 +716,14 @@ public function getEmpProjDuration($empId,$start_date,$end_date,$project_id,$par $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->select() ->setIntegrityCheck(false) - ->from(array('et' => 'tm_emp_timesheets'),array('p.project_name','et.project_id','userId'=>'et.emp_id','duration'=>$duration)) + ->from(array('et' => 'tm_emp_timesheets'),array('p.project_name','et.project_id','userId'=>'et.emp_id','duration'=>$duration)) ->joinInner(array('p'=>'tm_projects'), 'p.id = et.project_id',array()) ->where('et.is_active=1 and p.is_active = 1 '.$andwhere.' and et.emp_id = '.$empId) ->group('et.project_id'); // echo $select; return $this->fetchAll($select)->toArray(); } - + public function getProjTaskDuration($empId,$start_date,$end_date,$project_id,$param) { $andwhere = " AND (1=1)"; @@ -736,12 +737,12 @@ public function getProjTaskDuration($empId,$start_date,$end_date,$project_id,$pa $start_dates=strtotime($start_date); $sd_month=date("m",$start_dates); $sd_year=date("Y",$start_dates); - + $end_dates=strtotime($end_date); $ed_month=date("m",$end_dates); $ed_year=date("Y",$end_dates); - - + + $andwhere = " AND et.ts_year >= ".$sd_year." AND et.ts_year <=".$ed_year." AND et.ts_month >= ".$sd_month." AND et.ts_month <= ".$ed_month; //$andwhere = " AND et.created BETWEEN STR_TO_DATE('".$start_date."','%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('".$end_date."','%Y-%m-%d %H:%i:%s')"; $duration=""; @@ -761,8 +762,8 @@ public function getProjTaskDuration($empId,$start_date,$end_date,$project_id,$pa TIME_TO_SEC( IF(thu_date BETWEEN '".$start_date."' AND '".$end_date."',thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date BETWEEN '".$start_date."' AND '".$end_date."',fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date BETWEEN '".$start_date."' AND '".$end_date."',sat_duration,'00:00')))/60)%60,2,'0'))"; - - + + $andwhere =" AND (sun_date BETWEEN '".$start_date."' AND '".$end_date."' OR mon_date BETWEEN '".$start_date."' AND '".$end_date."' OR tue_date BETWEEN '".$start_date."' AND '".$end_date."' OR wed_date BETWEEN '".$start_date."' AND '".$end_date."' OR thu_date BETWEEN '".$start_date."' AND '".$end_date."' OR fri_date BETWEEN '".$start_date."' AND '".$end_date."' @@ -784,9 +785,9 @@ public function getProjTaskDuration($empId,$start_date,$end_date,$project_id,$pa TIME_TO_SEC( IF(thu_date = '".$start_date."' ,thu_duration,'00:00')) + TIME_TO_SEC( IF(fri_date = '".$start_date."' ,fri_duration,'00:00')) + TIME_TO_SEC( IF(sat_date = '".$start_date."' ,sat_duration,'00:00')))/60)%60,2,'0'))"; - - - + + + $andwhere = " AND (sun_date = '".$start_date."' OR mon_date = '".$start_date."' OR tue_date = '".$start_date."' OR wed_date = '".$start_date."' OR thu_date = '".$start_date."' OR fri_date = '".$start_date."' OR sat_date = '".$start_date."')"; } else @@ -800,11 +801,11 @@ public function getProjTaskDuration($empId,$start_date,$end_date,$project_id,$pa { $andwhere .= ' AND et.emp_id = '.$empId; } - + $select = $this->select() ->setIntegrityCheck(false) ->from(array('et' => 'tm_emp_timesheets'),array('p.project_name','t.task', - 'duration'=>$duration)) + 'duration'=>$duration)) ->joinInner(array('pt'=>'tm_project_tasks'), 'pt.id = et.project_task_id',array()) ->joinInner(array('t'=>'tm_tasks'), 't.id = pt.task_id',array()) ->joinInner(array('p'=>'tm_projects'), 'p.id = pt.project_id and p.id = et.project_id',array()) @@ -815,4 +816,4 @@ public function getProjTaskDuration($empId,$start_date,$end_date,$project_id,$pa //echo $select;//exit; return $this->fetchAll($select)->toArray(); } -} \ No newline at end of file +}