Esempio n. 1
0
 public function getMostTasks()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $qry = "select task_id,count(*) cnt from tm_project_tasks where is_active=1 and task_id\n                  not in (select id from tm_tasks where is_active=1 and is_default=1) group by task_id \n                  order by cnt desc limit 500";
     $res = $db->query($qry);
     $most_arr = array();
     $task_model = new Timemanagement_Model_Tasks();
     while ($row = $res->fetch()) {
         $most_arr[$row['task_id']] = $task_model->getTaskById($row['task_id']);
     }
     return $most_arr;
 }
 public function edittasknameAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         if ($this->getRequest()->getPost()) {
             $projectTaskModel = new Timemanagement_Model_Projecttasks();
             $projectId = $this->_getParam('projectId');
             $taskId = $this->_getParam('taskId');
             $taskName = $this->_getParam('taskName');
             $checkTaskNameExistAlready = $projectTaskModel->getProjTaskNameExists($projectId, $taskId, $taskName);
             if ($checkTaskNameExistAlready[0]['taskNameExistsCount'] > 0) {
                 $this->_helper->json(array('status' => 'error', 'message' => 'Task name already exists in default task or in project task.'));
             } else {
                 $data = array('task' => trim($taskName), 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
                 if ($taskId != '') {
                     $taskModel = new Timemanagement_Model_Tasks();
                     $where = array('id=?' => trim($taskId));
                     $Id = $taskModel->SaveorUpdateTaskData($data, $where);
                     if ($Id == 'update') {
                         $this->_helper->json(array('status' => 'success', 'message' => 'Task name updated successfully.'));
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
 public function addtasksAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $taskModel = new Timemanagement_Model_Tasks();
         $projectTasksModel = new Timemanagement_Model_Projecttasks();
         $projectModel = new Timemanagement_Model_Projects();
         if ($this->getRequest()->getPost()) {
             $type = $this->_getParam('type');
             if ($type == 'new') {
                 $projectId = $this->_getParam('projectId');
                 $task_name = $this->_getParam('task_name');
                 $def_check = $this->_getParam('def_check');
                 $projectData = $projectModel->getSingleProjectData($projectId);
                 $newTaskData = array('task' => trim($task_name), 'is_default' => $def_check == 'true' ? '1' : '0', 'created_by' => $loginUserId, 'created' => gmdate("Y-m-d H:i:s"), 'is_active' => 1, 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
                 $insertedTaskId = $taskModel->SaveorUpdateTaskData($newTaskData, '');
                 if (is_numeric($insertedTaskId) && $insertedTaskId > 0) {
                     $projectTaskData = array('project_id' => trim($projectId), 'task_id' => trim($insertedTaskId), 'created_by' => $loginUserId, 'created' => gmdate("Y-m-d H:i:s"), 'is_active' => 1, 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
                     $result = $projectTasksModel->SaveorUpdateProjectTaskData($projectTaskData, '');
                 }
             } else {
                 if ($type == 'default') {
                     $projectId = $this->_getParam('projectId');
                     $taskids = $this->_getParam('taskids');
                     $defaultTaskIds = json_decode($taskids);
                     $projectData = $projectModel->getSingleProjectData($projectId);
                     if (count($defaultTaskIds) > 0) {
                         $projectTaskData = array();
                         foreach ($defaultTaskIds as $defTaskId) {
                             $projectTaskData = array('project_id' => trim($projectId), 'task_id' => trim($defTaskId), 'created_by' => $loginUserId, 'created' => gmdate("Y-m-d H:i:s"), 'is_active' => 1, 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
                             $result = $projectTasksModel->SaveorUpdateProjectTaskData($projectTaskData, '');
                         }
                     }
                 } else {
                     if ($type == 'most') {
                         $projectId = $this->_getParam('projectId');
                         $taskids = $this->_getParam('taskids');
                         $mostTaskIds = json_decode($taskids);
                         $projectData = $projectModel->getSingleProjectData($projectId);
                         if (count($mostTaskIds) > 0) {
                             $projectTaskData = array();
                             foreach ($mostTaskIds as $mostTaskId) {
                                 $projectTaskData = array('project_id' => trim($projectId), 'task_id' => trim($mostTaskId), 'created_by' => $loginUserId, 'created' => gmdate("Y-m-d H:i:s"), 'is_active' => 1, 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
                                 $result = $projectTasksModel->SaveorUpdateProjectTaskData($projectTaskData, '');
                             }
                         }
                     }
                 }
             }
             $projectTasksData = array();
             $projectTasksData = $projectTasksModel->getProjectTasksData($projectId);
             if ($projectTasksData == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 if (!empty($projectTasksData)) {
                     $this->view->rowexist = "rows";
                 }
             }
             $this->view->projectTasksData = $projectTasksData;
             $this->view->projectId = $projectId;
         }
     }
 }
 public function checkduptaskAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('checkDupTask', 'json')->initContext();
     $taskname = $this->_getParam('taskname');
     $taskModel = new Timemanagement_Model_Tasks();
     $taskexists = $taskModel->getcheckDupTask($taskname);
     if (count($taskexists) > 0) {
         $this->_helper->json(array('result' => 'exists'));
     } else {
         $this->_helper->json(array('result' => 'notexists'));
     }
 }