Example #1
0
 public function tasksAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $projectTasksData = $projectData = array();
     $projectId = $this->getRequest()->getParam('projectid', null);
     if ($this->getRequest()->getPost()) {
         $taskprojectIds = $this->getRequest()->getParam('hid_taskprojid');
         $projectId = $this->getRequest()->getParam('project_id');
         $taskIds = $this->getRequest()->getParam('hid_taskid');
         $projectTaskData = array();
         $projectTasksModel = new Timemanagement_Model_Projecttasks();
         if (count($taskprojectIds) > 0) {
             foreach ($taskprojectIds as $key => $taskProjectId) {
                 $projectTaskData = array('project_id' => trim($projectId), 'task_id' => trim($taskIds[$key]), 'is_active' => 1, 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
                 $where = array('id=?' => $taskProjectId);
                 $projectTasksModel->SaveorUpdateProjectTaskData($projectTaskData, $where);
             }
         }
         $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Task(s) updated successfully."));
         $this->_redirect('timemanagement/projects/tasks/projectid/' . $projectId);
     }
     $projectResourcesModel = new Timemanagement_Model_Projectresources();
     $checkResourceExistsforProject = $projectResourcesModel->checkProjectResource($projectId, $loginUserId);
     if ($loginUserId == 1 || $checkResourceExistsforProject > 0) {
         try {
             if (is_numeric($projectId) && $projectId > 0) {
                 $projectTasksModel = new Timemanagement_Model_Projecttasks();
                 $projectTasksData = $projectTasksModel->getProjectTasksData($projectId);
                 $projectModel = new Timemanagement_Model_Projects();
                 $projectData = $projectModel->getSingleProjectData($projectId);
                 if ($projectTasksData == 'norows') {
                     $this->view->projectData = $projectData;
                     $this->view->rowexist = "norows";
                     $this->view->messages = $this->_helper->flashMessenger->getMessages();
                 } else {
                     if (!empty($projectTasksData)) {
                         $this->view->rowexist = "rows";
                         $this->view->projectData = $projectData;
                         $this->view->projectTasksData = $projectTasksData;
                         $this->view->messages = $this->_helper->flashMessenger->getMessages();
                     }
                 }
             } else {
                 $this->view->projectData = 'norows';
                 $this->view->projectTasksData = 'norows';
                 $this->view->messages = $this->_helper->flashMessenger->getMessages();
             }
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $this->view->projectData = 'norows';
         $this->view->projectTasksData = 'norows';
         $this->view->messages = $this->_helper->flashMessenger->getMessages();
     }
 }
 public function resourcetaskassigndeleteAction()
 {
     $dresource_model = new Timemanagement_Model_Projectresources();
     $task_resource_model = new Timemanagement_Model_Projecttaskresources();
     $projectId = $this->_getParam('projectId');
     $employeeId = $this->_getParam('employeeId');
     $checkedTasks = $this->_getParam('chekedtaskids');
     $uncheckedTasks = $this->_getParam('uncheckedtaskids');
     $checkedTaskIds = json_decode($checkedTasks);
     $uncheckedTasksIds = json_decode($uncheckedTasks);
     $allTaskIdsArray = array();
     $project_task_id = array();
     $inserted_count = 0;
     $updated_count = 0;
     $getAllTasks = $dresource_model->getAllTasks($projectId);
     //get all tasks for perticuler project
     foreach ($getAllTasks as $task_id) {
         $allTaskIdsArray[] = $task_id['task_id'];
         $project_task_id[$task_id['task_id']] = $task_id['id'];
     }
     $assignedTasks = $dresource_model->getassignedTasks($projectId, $employeeId);
     $assignedTaskIds = array();
     $resourceProjectTaskPrimaryId = array();
     if (count($assignedTasks) > 0) {
         foreach ($assignedTasks as $id) {
             $assignedTaskIds[] = $id['task_id'];
             $resourceProjectTaskPrimaryId[$id['task_id']] = $id['id'];
         }
     }
     $unAssignedTasks = array();
     foreach ($allTaskIdsArray as $tId) {
         if (!in_array($tId, $assignedTaskIds)) {
             $unAssignedTasks[] = $tId;
         }
     }
     //user selected to delete tasks from resources
     //compare previoues assigned tasks and selected to delete tasks
     if (count($uncheckedTasksIds) > 0) {
         foreach ($uncheckedTasksIds as $ckedId) {
             if (in_array($ckedId, $assignedTaskIds)) {
                 $is_updated = $task_resource_model->assignTasks($ckedId, $projectId, $employeeId, $resourceProjectTaskPrimaryId[$ckedId], $for_update = 1);
                 if ($is_updated == 'update') {
                     $updated_count++;
                 }
             }
         }
     }
     if (count($checkedTaskIds) > 0) {
         foreach ($checkedTaskIds as $taskId) {
             if (in_array($taskId, $unAssignedTasks)) {
                 //insert tasks in employee_tasks table
                 $isTaskAssigned = $task_resource_model->isTaskAssigned($projectId, $taskId, $employeeId);
                 if ($isTaskAssigned == 0) {
                     $is_inserted = $task_resource_model->assignTasks($taskId, $projectId, $employeeId, $project_task_id[$taskId]);
                     if ($is_inserted > 0) {
                         $inserted_count++;
                     }
                 }
             }
         }
     }
     //$this->_helper->json(array('message'=>'success','status'=>$updated_count.' Tasks deleted successfully,'.$inserted_count.' Tasks assigned successfully.'));
     $this->_helper->json(array('message' => 'success', 'status' => 'Tasks list updated successfully.'));
 }
 public function viewAction()
 {
     $auth = Zend_Auth::getInstance();
     $loginUserId = 0;
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'employeeprojects';
     $projectModel = new Timemanagement_Model_Projects();
     $projectTaskModel = new Timemanagement_Model_Projecttasks();
     $projectResourcesModel = new Timemanagement_Model_Projectresources();
     try {
         if (is_numeric($id) && $id > 0) {
             $data = $projectModel->getSingleProjectData($id);
             if (!empty($data) && $data != "norows") {
                 $data_arr = array();
                 $call = $this->_getParam('call');
                 if ($call == 'ajaxcall') {
                     $this->_helper->layout->disableLayout();
                 }
                 $view = Zend_Layout::getMvcInstance()->getView();
                 $objname = $this->_getParam('objname');
                 $refresh = $this->_getParam('refresh');
                 $dashboardcall = $this->_getParam('dashboardcall');
                 //$data = array();
                 $searchQuery = '';
                 $searchArray = array();
                 $tablecontent = '';
                 if ($refresh == 'refresh') {
                     $sort = 'DESC';
                     $by = 'modified';
                     $perPage = DASHBOARD_PERPAGE;
                     $pageNo = 1;
                     $searchData = '';
                 } else {
                     $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                     $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'tpe.modified';
                     $perPage = $this->_getParam('per_page', DASHBOARD_PERPAGE);
                     $pageNo = $this->_getParam('page', 1);
                     $searchData = $this->_getParam('searchData');
                 }
                 $role = Zend_Registry::get('tm_role');
                 $dataTmp = $projectTaskModel->getEmpTaskGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $id, $loginUserId, $role);
                 $dataTmp['emptyRoles'] = '';
                 $dataTmp['objectname'] = 'leadprojects';
                 $dataTmp['dataemptyFlag'] = '';
                 $dataTmp['menuName'] = 'Tasks';
                 $dataTmp['dashboardcall'] = 'Yes';
                 $dataTmp['projectId'] = $id;
                 array_push($data_arr, $dataTmp);
                 $by = 'modified';
                 $projectResourcesModel = new Timemanagement_Model_Projectresources();
                 $dataResourceTmp = $projectResourcesModel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $id, $loginUserId, $role);
                 $dataResourceTmp['emptyRoles'] = '';
                 $dataResourceTmp['objectname'] = 'projectresources';
                 $dataResourceTmp['dataemptyFlag'] = '';
                 $dataResourceTmp['menuName'] = 'Resources';
                 $dataResourceTmp['dashboardcall'] = 'Yes';
                 $dataResourceTmp['projectId'] = $id;
                 array_push($data_arr, $dataResourceTmp);
                 $this->view->data_arr = $data_arr;
                 $this->view->controllername = $objName;
                 $this->view->data = $data;
                 $this->view->id = $id;
                 $this->view->ermsg = '';
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'nodata';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
 }