Пример #1
0
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     $emptyFlag = 0;
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $objName = 'expenses';
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $expensesForm = new Timemanagement_Form_Expenses();
     $expensesModel = new Timemanagement_Model_Expenses();
     //pre populate data
     $clientsModel = new Timemanagement_Model_Clients();
     $clientsData = $clientsModel->getActiveClientsData();
     $msgarray = array();
     if (sizeof($clientsData) > 0) {
         foreach ($clientsData as $client) {
             $expensesForm->client_id->addMultiOption($client['id'], $client['client_name']);
         }
     } else {
         $msgarray['client_id'] = 'Clients are not configured yet.';
         $emptyFlag++;
     }
     $expenseCategoriesModel = new Timemanagement_Model_Expensecategories();
     $expenseCategoriesData = $expenseCategoriesModel->getActiveExpenseCategoriesData();
     if (sizeof($expenseCategoriesData) > 0) {
         foreach ($expenseCategoriesData as $category) {
             $expensesForm->expense_cat_id->addMultiOption($category['id'], $category['expense_category']);
         }
     } else {
         $msgarray['expense_cat_id'] = 'Expense Categories are not configured yet.';
         $emptyFlag++;
     }
     //End pre populate
     try {
         if ($id) {
             //Edit Record...
             if (is_numeric($id) && $id > 0) {
                 $data = $expensesModel->getExpensesDataById($id);
                 $projectsModel = new Timemanagement_Model_Projects();
                 $projectsData = $projectsModel->getProjectListByClientID($data[0]['client_id']);
                 if (sizeof($projectsData) > 0) {
                     foreach ($projectsData as $project) {
                         $expensesForm->project_id->addMultiOption($project['id'], $project['project_name']);
                     }
                 } else {
                     $msgarray['project_id'] = 'Clients are not configured yet.';
                     $emptyFlag++;
                 }
                 if (!empty($data) && $data != "norows") {
                     $expensesForm->populate($data[0]);
                     $expensesForm->submit->setLabel('Update');
                     $this->view->form = $expensesForm;
                     $this->view->controllername = $objName;
                     $this->view->id = $id;
                     $this->view->ermsg = '';
                     $this->view->inpage = 'Edit';
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } else {
             //Add Record...
             $this->view->ermsg = '';
             $this->view->form = $expensesForm;
             $this->view->inpage = 'Add';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     if ($this->getRequest()->getPost()) {
         if ($expensesForm->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $clientID = $this->_request->getParam('client_id');
             $expenseAmount = $this->_request->getParam('expense_amount');
             $expenseCategoryID = $this->_request->getParam('expense_cat_id');
             $expenseDate = sapp_Global::change_date($this->_request->getParam('expense_date'), 'database');
             $isBillable = $this->_request->getParam('is_billable');
             $note = $this->_request->getParam('note');
             $projectID = $this->_request->getParam('project_id');
             $imagepath = $this->_request->getParam('expense_image_value');
             $date = new Zend_Date();
             $data = array('client_id' => $clientID, 'emp_id' => $loginUserId, 'expense_amount' => trim($expenseAmount), 'expense_cat_id' => trim($expenseCategoryID), 'expense_date' => trim($expenseDate), 'is_billable' => trim($isBillable), 'note' => trim($note), 'project_id' => trim($projectID), 'receipt_file' => trim($imagepath), 'expense_status' => 'saved', 'modified' => gmdate("Y-m-d H:i:s"));
             $path = EXPENSES_UPLOAD_PATH;
             $filecopy = 'success';
             if ($imagepath != '') {
                 $filecopy = 'error';
                 if (file_exists(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath)) {
                     try {
                         echo $srcPath . '<br/>';
                         if (copy(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath, $path . '//' . $imagepath)) {
                             $filecopy = 'success';
                         }
                         unlink(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath);
                     } catch (Exception $e) {
                         echo $msgarray['expense_image_value'] = $e->getMessage();
                         exit;
                     }
                 }
             }
             if ($imagepath == '') {
                 unset($data['receipt_file']);
             } else {
                 if ($filecopy == 'error') {
                     unset($data['receipt_file']);
                 }
             }
             if ($id != '') {
                 $where = array('id=?' => $id);
             } else {
                 //$data['created_by'] = $loginUserId;
                 $data['created'] = gmdate("Y-m-d H:i:s");
                 $data['is_active'] = 1;
                 $where = '';
             }
             $Id = $expensesModel->SaveorUpdateExpensesData($data, $where);
             if ($Id == 'update') {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Expenses updated successfully."));
             } else {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Expenses added successfully."));
             }
             $this->_redirect('timemanagement/expenses');
         } else {
             $messages = $expensesForm->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
 }
Пример #2
0
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $objName = 'projects';
     $emptyFlag = 0;
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $popConfigPermission = array();
     $projectsForm = new Timemanagement_Form_Projects();
     $projectModel = new Timemanagement_Model_Projects();
     $clientModel = new Timemanagement_Model_Clients();
     $clientData = $clientModel->getActiveClientsData();
     $msgarray = array();
     array_push($popConfigPermission, 'client');
     array_push($popConfigPermission, 'currency');
     $this->view->popConfigPermission = $popConfigPermission;
     if (sizeof($clientData) > 0) {
         foreach ($clientData as $client) {
             $projectsForm->client_id->addMultiOption($client['id'], $client['client_name']);
         }
     } else {
         $msgarray['client_id'] = 'Clients are not configured yet.';
         $emptyFlag++;
     }
     $base_projectData = $projectModel->getProjectList();
     if (sizeof($base_projectData) > 0) {
         foreach ($base_projectData as $base_project) {
             $projectsForm->base_project->addMultiOption($base_project['id'], $base_project['project_name']);
         }
     }
     $this->view->msgarray = $msgarray;
     $this->view->emptyFlag = $emptyFlag;
     try {
         if ($id) {
             //Edit Record...
             if (is_numeric($id) && $id > 0) {
                 $auth = Zend_Auth::getInstance();
                 if ($auth->hasIdentity()) {
                     $loginUserId = $auth->getStorage()->read()->id;
                     $loginuserRole = $auth->getStorage()->read()->emprole;
                     $loginuserGroup = $auth->getStorage()->read()->group_id;
                 }
                 $projectResourcesModel = new Timemanagement_Model_Projectresources();
                 $checkResourceExistsforProject = $projectResourcesModel->checkProjectResource($id, $loginUserId);
                 if ($loginUserId == 1 || $checkResourceExistsforProject > 0) {
                     $data = $projectModel->getSingleProjectData($id);
                     if (!empty($data) && $data != "norows") {
                         $projectsForm->populate($data[0]);
                         $projectsForm->submit->setLabel('Update');
                         $this->view->form = $projectsForm;
                         $this->view->controllername = $objName;
                         $this->view->data = $data;
                         $this->view->id = $id;
                         $this->view->ermsg = '';
                         $this->view->inpage = 'Edit';
                     } else {
                         $this->view->form = $projectsForm;
                         $this->view->controllername = $objName;
                         $this->view->data = $data;
                         $this->view->ermsg = 'norecord';
                         $this->view->inpage = 'Edit';
                     }
                 } else {
                     $this->view->form = $projectsForm;
                     $this->view->controllername = $objName;
                     $this->view->data = array();
                     $this->view->ermsg = 'norecord';
                     $this->view->inpage = 'Edit';
                 }
             } else {
                 $this->view->form = $projectsForm;
                 $this->view->controllername = $objName;
                 $this->view->data = 'norows';
                 $this->view->inpage = 'Edit';
             }
         } else {
             if ($this->getRequest()->getParam('cid')) {
                 $cid = $this->getRequest()->getParam('cid');
                 $projectsForm->client_id->setValue($cid);
             }
             $this->view->form = $projectsForm;
             $this->view->ermsg = '';
             $this->view->id = '';
             $this->view->inpage = 'Add';
         }
     } catch (Exception $ex) {
         $this->view->ermsg = 'nodata';
     }
     if ($this->getRequest()->getPost()) {
         if ($projectsForm->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $project_name = $this->_request->getParam('project_name');
             $project_status = $this->_request->getParam('project_status');
             $base_project = $this->_request->getParam('base_project');
             $client_id = $this->_request->getParam('client_id');
             $description = $this->_request->getParam('description');
             $date = new Zend_Date();
             $data = array('project_name' => ucfirst(trim($project_name)), 'project_status' => trim($project_status), 'base_project' => trim($base_project) != '' ? $base_project : NUll, 'description' => trim($description), 'client_id' => trim($client_id), 'modified_by' => $loginUserId, 'modified' => gmdate("Y-m-d H:i:s"));
             if ($id != '') {
                 $where = array('id=?' => $id);
             } else {
                 $data['created_by'] = $loginUserId;
                 $data['created'] = gmdate("Y-m-d H:i:s");
                 $data['is_active'] = 1;
                 $where = '';
             }
             $insertedId = $projectModel->SaveorUpdateProjectsData($data, $where);
             if ($insertedId == 'update') {
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Project updated successfully."));
             } else {
                 if (Zend_Registry::get('tm_role') == 'Manager') {
                     $projectResourcesModel = new Timemanagement_Model_Projectresources();
                     $projectResourceData = array('project_id' => trim($insertedId), 'emp_id' => $loginUserId, '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 = $projectResourcesModel->SaveorUpdateProjectResourceData($projectResourceData, '');
                 }
                 $id = $insertedId;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Project added successfully."));
             }
             $this->_redirect('timemanagement/projects/tasks/projectid/' . $id);
         } else {
             $messages = $projectsForm->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             if (sizeof($clientData) < 1) {
                 $msgarray['client_id'] = 'Clients not configured yet.';
             }
             $this->view->msgarray = $msgarray;
         }
     }
 }
Пример #3
0
 public function addpopupAction()
 {
     $msgarray = array();
     $emptyFlag = '';
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $controllername = 'clients';
     $clientsForm = new Timemanagement_Form_Clients();
     $clientsModel = new Timemanagement_Model_Clients();
     $clientsForm->setAction(BASE_URL . 'timemanagement/clients/addpopup');
     if ($this->getRequest()->getPost()) {
         if ($clientsForm->isValid($this->_request->getPost())) {
             $country_id = NULL;
             $state_id = NULL;
             $id = $this->_request->getParam('id');
             $address = $this->_request->getParam('address');
             $client_name = $this->_request->getParam('client_name');
             if ($this->_request->getParam('country_id')) {
                 $country_id = $this->_request->getParam('country_id');
             }
             $email = $this->_request->getParam('email');
             $phone_no = $this->_request->getParam('phone_no');
             $poc = $this->_request->getParam('poc');
             $fax = $this->_request->getParam('fax');
             if ($this->_request->getParam('state_id')) {
                 $state_id = $this->_request->getParam('state_id');
             }
             $date = gmdate("Y-m-d H:i:s");
             $data = array('address' => $address, 'client_name' => $client_name, 'country_id' => $country_id, 'email' => $email, 'phone_no' => $phone_no, 'poc' => $poc, 'fax' => $fax, 'state_id' => $state_id);
             $data['created_by'] = $loginUserId;
             $data['created'] = gmdate("Y-m-d H:i:s");
             $data['modified'] = gmdate("Y-m-d H:i:s");
             $data['is_active'] = 1;
             $where = '';
             $Id = $clientsModel->saveOrUpdateClientsData($data, $where);
             $clientsData = $clientsModel->fetchAll('is_active = 1', 'client_name')->toArray();
             $opt = '';
             foreach ($clientsData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['client_name']);
             }
             $this->view->clientsData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $clientsForm->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->controllername = $controllername;
     $this->view->form = $clientsForm;
     $this->view->ermsg = '';
 }
 public function editpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $userid = $this->getRequest()->getParam('unitId');
     if ($id == '') {
         $id = $loginUserId;
     }
     // For open the form in popup...
     $empjobhistoryform = new Default_Form_empjobhistory();
     $empjobhistoryModel = new Default_Model_Empjobhistory();
     $employeeModel = new Default_Model_Employee();
     $positionModel = new Default_Model_Positions();
     $departmentModel = new Default_Model_Departments();
     $jobtitleModel = new Default_Model_Jobtitles();
     $clientsModel = new Timemanagement_Model_Clients();
     if ($id) {
         $employeeArr = $employeeModel->getActiveEmployeeData($userid);
         if (!empty($employeeArr)) {
             if (isset($employeeArr[0]['businessunit_id']) && $employeeArr[0]['businessunit_id'] != '') {
                 $departmentArr = $departmentModel->getDepartmentList($employeeArr[0]['businessunit_id']);
                 if (!empty($departmentArr)) {
                     $empjobhistoryform->department->addMultiOption('', 'Select Department');
                     foreach ($departmentArr as $departmentres) {
                         $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']);
                     }
                 }
             } else {
                 $departmentArr = $departmentModel->getTotalDepartmentList();
                 if (!empty($departmentArr)) {
                     $empjobhistoryform->department->addMultiOption('', 'Select Department');
                     foreach ($departmentArr as $departmentres) {
                         $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']);
                     }
                 }
             }
         }
         $positionArr = $positionModel->getTotalPositionList();
         if (!empty($positionArr)) {
             $empjobhistoryform->positionheld->addMultiOption('', 'Select Position');
             foreach ($positionArr as $positionres) {
                 $empjobhistoryform->positionheld->addMultiOption($positionres['id'], $positionres['positionname']);
             }
         }
         $jobtitleArr = $jobtitleModel->getJobTitleList();
         if (!empty($jobtitleArr)) {
             $empjobhistoryform->jobtitleid->addMultiOption('', 'Select Job Title');
             foreach ($jobtitleArr as $jobtitleres) {
                 $empjobhistoryform->jobtitleid->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
             }
         }
         $clientsArr = $clientsModel->getActiveClientsData();
         if (!empty($clientsArr)) {
             $empjobhistoryform->client->addMultiOption('', 'Select a Client');
             foreach ($clientsArr as $clientsres) {
                 $empjobhistoryform->client->addMultiOption($clientsres['id'], $clientsres['client_name']);
             }
         }
         $data = $empjobhistoryModel->getsingleEmpJobHistoryData($id);
         if (!empty($data)) {
             $empjobhistoryform->populate($data[0]);
             $empjobhistoryform->setDefault('department', $data[0]['department']);
             $empjobhistoryform->setDefault('positionheld', $data[0]['positionheld']);
             $empjobhistoryform->setDefault('jobtitleid', $data[0]['jobtitleid']);
             $empjobhistoryform->setDefault('client', $data[0]['client_id']);
             if (isset($data[0]['start_date']) && $data[0]['start_date'] != '') {
                 $start_date = sapp_Global::change_date($data[0]['start_date'], 'view');
                 $empjobhistoryform->start_date->setValue($start_date);
             }
             if (isset($data[0]['end_date']) && $data[0]['end_date'] != '') {
                 $end_date = sapp_Global::change_date($data[0]['end_date'], 'view');
                 $empjobhistoryform->end_date->setValue($end_date);
             }
         }
     }
     $empjobhistoryform->setAttrib('action', BASE_URL . 'empjobhistory/editpopup/unitId/' . $userid);
     $this->view->form = $empjobhistoryform;
     $this->view->controllername = 'empjobhistory';
     if ($this->getRequest()->getPost()) {
         $result = $this->save($empjobhistoryform, $userid);
         $this->view->msgarray = $result;
     }
 }
Пример #5
0
 /**
  * This will fetch all the project details based on the search paramerters passed with pagination.
  *
  * @param string $sort
  * @param string $by
  * @param number $perPage
  * @param number $pageNo
  * @param JSON $searchData
  * @param string $call
  * @param string $dashboardcall
  *
  * @return array
  */
 public function getEmpGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $employee_id, $tm_role = '')
 {
     $searchQuery = '';
     $searchArray = array();
     $data = array();
     if ($searchData != '' && $searchData != 'undefined') {
         $searchValues = json_decode($searchData);
         foreach ($searchValues as $key => $val) {
             if ($key == 'client') {
                 $key = 'client_id';
             } else {
                 $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
             }
             $searchArray[$key] = $val;
         }
         $searchQuery = rtrim($searchQuery, " AND");
     }
     $objName = 'employeeprojects';
     if ($tm_role == 'Lead') {
         $objName = 'leadprojects';
     }
     $tableFields = array('action' => 'Action', 'project_name' => 'Project', 'client_name' => 'Client');
     $tablecontent = $this->getEmpProjectsData($sort, $by, $pageNo, $perPage, $searchQuery, $employee_id);
     $clientModel = new Timemanagement_Model_Clients();
     $clientData = $clientModel->getActiveClientsData();
     $clientArray = array('' => 'All');
     if (sizeof($clientData) > 0) {
         foreach ($clientData as $client) {
             $clientArray[$client['client_name']] = $client['client_name'];
         }
     }
     $base_projectData = $this->getProjectList();
     $base_projectArray = array('' => 'All');
     if (sizeof($base_projectData) > 0) {
         foreach ($base_projectData as $base_project) {
             $base_projectArray[$base_project['id']] = $base_project['project_name'];
         }
     }
     $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'menuName' => 'Projects', 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => array('client_name' => array('type' => 'select', 'filter_data' => $clientArray), 'base_project' => array('type' => 'select', 'filter_data' => $base_projectArray), 'project_status' => array('type' => 'select', 'filter_data' => array('' => 'All', 'initiated' => 'Initiated', 'draft' => 'Draft', 'in-progress' => 'In Progress', 'hold' => 'Hold', 'completed' => 'Completed'))));
     return $dataTmp;
 }