public function getdatafromajaxcallAction() { $taskallocation_model = new Default_Model_Tasksallocation(); $methodKey = $this->_getParam('methodKey', null); if ($methodKey == "1") { //Get Project Tasks $projectid = $this->_getParam('projectid', null); $options_data = ""; $options_data .= sapp_Global::selectOptionBuilder('0', 'Select Task'); if ($projectid != '') { $dept_data = $taskallocation_model->getProjectTasks($projectid); foreach ($dept_data as $dept) { $options_data .= sapp_Global::selectOptionBuilder($dept['id'], $dept['name']); } } $this->_helper->json(array('options' => $options_data)); } else { if ($methodKey == "2") { //Get Tasks Planned Activities $taskid = $this->_getParam('taskid', null); $this->_helper->json(array('options' => sapp_Global::_convertArrayToHTMLTable("leavecardtablegrid", "Task Details", $taskallocation_model->getTaskDetails($taskid)))); } else { if ($methodKey == "3") { //Get Tasks Planned Activities $taskid = $this->_getParam('taskid', null); $taskActivityDetails = $taskallocation_model->getTaskActivityDetails($taskid); $this->_helper->json(array('options' => $this->getActivitesEditableGrid($taskActivityDetails))); //$this->_helper->json(array('options' => sapp_Global::_convertArrayToHTMLTable("leavecardtablegrid", "Task Activity Details", $taskActivityDetails))); } else { if ($methodKey == "4") { //Get Project resources $projectid = $this->_getParam('projectid', null); $options_data = ""; //$options_data .= sapp_Global::selectOptionBuilder('0', 'Select Task'); if ($projectid != '') { $dept_data = $taskallocation_model->getEmployeesByProject($projectid); foreach ($dept_data as $dept) { $options_data .= sapp_Global::selectOptionBuilder($dept['id'], $dept['name']); } } $this->_helper->json(array('options' => $options_data)); } } } } }
public function editAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $sess_vals = $auth->getStorage()->read(); $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $messages['message'] = ''; $id = $this->getRequest()->getParam('id', null); $taskAllocationModel = new Default_Model_Tasksallocation(); $activityModel = new Default_Model_Createactivities(); $requi_model = new Default_Model_Requisition(); $usersModel = new Default_Model_Users(); $currentUserSummary = $usersModel->getEmployeeSummaryByID($loginUserId); $where = ""; $actionflag = 1; $form = new Default_Form_createprojects(); $form->setAttrib('action', DOMAIN . 'tasksallocation/edit/id/' . $id); //$this->view->activeprojects = $taskAllocationModel->getActiveProjects(); $this->view->activeprojects = $taskAllocationModel->getActiveProjectsForUser($currentUserSummary['businessunit_id'], $loginUserId, $loginuserGroup); $this->view->projectCategories = $taskAllocationModel->getProjectCategories(); $this->view->business_units_list = $requi_model->getBusinessUnits(); $this->view->allusers = array(); //$this->view->allusers = $usersModel->getAllActiveUsers(); $form->submit->setLabel('Allocate Task Activities'); $this->view->loginuserGroup = $loginuserGroup; $this->view->form = $form; if ($this->getRequest()->getPost()) { $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); $tprojectSelected = $this->_getParam('projectSelected', null); $ttaskSelected = $this->_getParam('taskSelected', null); $ActivitiesForTasks = $taskAllocationModel->getTaskActivityDetails($ttaskSelected); $ttaskallocationdelete = $this->_getParam('taskallocationdelete', null); $ttaskallocationactivitys = $this->_getParam('taskallocationactivity', null); $ttaskallocationresource = $this->_getParam('taskallocationresource', null); $ttaskallocationstartdate = $this->_getParam('taskallocationstartdate', null); $ttaskallocationenddate = $this->_getParam('taskallocationenddate', null); $ttaskallocationeffort = $this->_getParam('taskallocationeffort', null); $ttaskallocationrowid = $this->_getParam('taskallocationrowid', null); $resCurPos = 0; foreach ($ttaskallocationactivitys as $ttaskallocationactivity) { $varCurrAction = "0"; $currRowID = $ttaskallocationrowid[$resCurPos]; $allocID = $this->getIDbyActivity($ActivitiesForTasks, $ttaskallocationactivity); if (is_numeric($currRowID)) { if ($currRowID > 0) { //for Update $mpolicydata = array('taskactivityid' => trim($allocID), 'resourceid' => trim($ttaskallocationresource[$resCurPos]), 'effort' => trim($ttaskallocationeffort[$resCurPos]), 'startdate' => sapp_Global::change_date(trim($ttaskallocationstartdate[$resCurPos]), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskallocationenddate[$resCurPos]), 'database'), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $currRowID); $varCurrAction = $taskAllocationModel->SaveorUpdateData($mpolicydata, $where); } } if ($varCurrAction == "0") { //for Insert $mpolicydata = array('taskactivityid' => trim($allocID), 'resourceid' => trim($ttaskallocationresource[$resCurPos]), 'status' => trim('5'), 'effort' => trim($ttaskallocationeffort[$resCurPos]), 'startdate' => sapp_Global::change_date(trim($ttaskallocationstartdate[$resCurPos]), 'database'), 'enddate' => sapp_Global::change_date(trim($ttaskallocationenddate[$resCurPos]), 'database'), 'createdby' => trim($loginUserId), 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = ""; $Id = $taskAllocationModel->SaveorUpdateData($mpolicydata, $where); } $resCurPos = $resCurPos + 1; } //for Soft Delete foreach ($ttaskallocationdelete as $ttaskallocationdelete1) { $isRecordForDelete = $ttaskallocationdelete[$resCurPos]; if (is_numeric($ttaskallocationdelete1)) { if ($ttaskallocationdelete1 > 0) { $mpolicydata = array('isactive' => '0', 'modifiedby' => trim($loginUserId), 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $ttaskallocationdelete1); $varCurrAction = $taskAllocationModel->SaveorUpdateData($mpolicydata, $where); } } } $menuID = -999; sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Task successfully allocated.")); $trDb->commit(); $this->_redirect('/tasksallocation'); } }