public function execute($request)
 {
     $projectId = $request->getParameter("projectId");
     $timesheetDao = new TimesheetDao();
     $this->noProjectActivity = "no";
     if ($projectId == -1) {
         $this->activityList = "All";
     } else {
         $this->activityList = $timesheetDao->getProjectActivitiesByPorjectId($projectId);
         $this->allActivityList = $timesheetDao->getProjectActivitiesByPorjectId($projectId, true);
         if ($this->allActivityList == null) {
             $this->noProjectActivity = "yes";
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Retrieve the timesheet status information.
  */
 function jsonAction()
 {
     // Get the pay period start date.
     $ppstart = $this->getDate('ppStart');
     // Attempt to convert the pay period start time into a date.
     if (!strtotime($ppstart)) {
         // Throw an exception.
         throw new Exception("Invalid date: {$ppstart}");
     }
     // Get the requested pay period.
     $payPeriodDao = new PayPeriodDao();
     $payPeriod = $payPeriodDao->getContaining($ppstart);
     // Make sure a start date was provided.
     if (isset($ppstart)) {
         // Get the user's session.
         $session = new Zend_Session_Namespace('Web');
         // Get the current user.
         $me = $session->employee;
         // Get an instance of the TimesheetDao.
         $timesheetDao = new TimesheetDao();
         // Retrieve the status information for the specified pay period.
         $status = $timesheetDao->getStatusForSupervised($payPeriod, $me);
         // Check to see if the status was retrieved.
         if (isset($status)) {
             // Create the JSON object to return.
             $json = new stdClass();
             $json->status = $status;
             $json->success = true;
             $json->msg = 'The requested status information was ' . 'retrieved successfully.';
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             $json->msg = 'Failed to retrieve the status information.';
         }
     } else {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = 'You must specify the pay period start date.';
     }
     // Return the JSON.
     $this->_helper->json($json);
 }
Ejemplo n.º 3
0
 /**
  * Unexport the specified timesheets.
  */
 function unexportAction()
 {
     // Get the ids of the timesheets to unexport.
     $ids = $this->getInts('ids');
     // Determine if there are multiple timesheets to unexport.
     $multiple = count($ids) > 1 ? true : false;
     // Get the user's session.
     $session = new Zend_Session_Namespace('Web');
     // Get the current user.
     $me = $session->employee;
     // Wrap the whole thing in a try/catch.
     try {
         // Get the DAO.
         $timesheetDao = new TimesheetDao();
         // Unexport all the timesheets.
         $count = $timesheetDao->unexport($ids, $me);
         // Make sure some timesheets were unexported.
         if (isset($count) && $count > 0) {
             // Create the JSON object to return.
             $json = new stdClass();
             $json->success = true;
             if ($multiple) {
                 $json->msg = 'The timesheets were unexported successfully.';
             } else {
                 $json->msg = 'The timesheet was unexported successfully.';
             }
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             if ($multiple) {
                 $json->msg = 'Failed to unexport the timesheets.';
             } else {
                 $json->msg = 'Failed to unexport the timesheet.';
             }
         }
     } catch (Zend_Exception $ex) {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = $ex->getMessage();
     }
     // Return the JSON.
     $this->_helper->json($json);
 }
Ejemplo n.º 4
0
 // Make sure yesterday was not a weekend day.
 if ($dayName != "Sat" && $dayName != "Sun") {
     // Log what we are doing.
     print "Processing Yesterday ({$dayName}, {$day}).\n";
     // Get the pay period containing yesterday.
     $payPeriodDao = new PayPeriodDao();
     $payPeriod = $payPeriodDao->getContaining($day);
     // Make sure the pay period was found.
     if (isset($payPeriod)) {
         // Log what we are doing.
         print "Found associated pay period.\n";
         // Get all the active employees in the system.
         $employeeDao = new EmployeeDao();
         $employees = $employeeDao->getAll(true);
         // This is used to retrieve timesheets.
         $timesheetDao = new TimesheetDao();
         // This is used to log our timesheet reviews.
         $auditLogDao = new AuditLogDao();
         // Make sure some active employees were found.
         if (isset($employees) && count($employees) > 0) {
             // Iterate over the available employees.
             foreach ($employees as $employee) {
                 // Log what we are doing.
                 print "\nFound employee to check: " . $employee->full_name . "\n";
                 // Keep track of whether we need to send notification info.
                 $notify = false;
                 // Get the timesheet for this employee.
                 $timesheet = $timesheetDao->getForEmployee($employee->id, $payPeriod);
                 // Make sure the timesheet exists.
                 if (isset($timesheet)) {
                     // Log what we are doing.
Ejemplo n.º 5
0
 public function executeGetRelatedActiviesForAutoCompleteAjax(sfWebRequest $request)
 {
     $this->backAction = $this->getContext()->getUser()->getFlash('actionName');
     $this->getContext()->getUser()->setFlash('actionName', $this->backAction);
     $customerName = $request->getParameter('customerName');
     $projectName = $request->getParameter('projectName');
     //        $projectName = htmlspecialchars($projectName, ENT_QUOTES);
     //        $customerName = htmlspecialchars($customerName, ENT_QUOTES);
     $timesheetDao = new TimesheetDao();
     $customer = $timesheetDao->getCustomerByName($customerName);
     $customerId = $customer->getCustomerId();
     $project = $timesheetDao->getProjectByProjectNameAndCustomerId($projectName, $customerId);
     $projectId = $project->getProjectId();
     $this->activityList = $timesheetDao->getProjectActivitiesByPorjectId($projectId);
 }
Ejemplo n.º 6
0
 /**
  * Re-open a completed timesheet so that the hours can be modified.
  */
 function fixAction()
 {
     // Get the id of the active timesheet.
     $timesheetId = $this->getInt('id');
     // Get the employee's current timesheet.
     $timesheetDao = new TimesheetDao();
     $timesheet = $timesheetDao->get($timesheetId);
     // Re-open the timesheet.
     $timesheetDao->save($timesheet->id, array('completed' => false));
     // Add an audit log for this completion.
     $auditLogDao = new AuditLogDao();
     $auditLogDao->add(array('timesheet_id' => $timesheet->id, 'log' => "Timesheet re-opened."));
     // Create the JSON object to return.
     $json = new stdClass();
     $json->success = true;
     $json->payPeriod = $timesheet->pp_start;
     $json->msg = 'Your timesheet was re-opened successfully. Refreshing ' . 'the display...';
     // Return the JSON.
     $this->_helper->json($json);
 }
 /**
  * Gets all the names of available projects, including deleted projects.
  * @return array() $projectNameList
  */
 private function _getDataList()
 {
     $activityNameList = array();
     $projectService = new ProjectService();
     $projectList = $projectService->getActiveProjectList();
     $projectId = -1;
     foreach ($projectList as $project) {
         $projectId = $project->getProjectId();
         break;
     }
     $timesheetDao = new TimesheetDao();
     $activityList = $timesheetDao->getProjectActivitiesByPorjectId($projectId);
     if ($activityList != null) {
         $activityNameList[-1] = __("All");
     } else {
         $activityNameList[null] = "--" . __("No Project Activities") . "--";
     }
     return $activityNameList;
 }
Ejemplo n.º 8
0
 /**
  * Re-open a completed timesheet so that the hours can be modified.
  */
 function fixAction()
 {
     // Get the user's session.
     $session = new Zend_Session_Namespace('Web');
     // Get the current user.
     $me = $session->employee;
     // Get the id of the active timesheet.
     $timesheetId = $this->getInt('id');
     // Get the employee's current timesheet.
     $timesheetDao = new TimesheetDao();
     $timesheet = $timesheetDao->get($timesheetId);
     // Re-open the timesheet.
     $timesheetDao->save($timesheet->id, array('completed' => false));
     // Add an audit log for this completion.
     $auditLogDao = new AuditLogDao();
     $auditLogDao->add(array('timesheet_id' => $timesheet->id, 'log' => "Timesheet re-opened by supervisor {$me->full_name}."));
     // Create the JSON object to return.
     $json = new stdClass();
     $json->success = true;
     $json->payPeriod = $timesheet->pp_start;
     $json->msg = 'Your timesheet was re-opened successfully.';
     // Return the JSON.
     $this->_helper->json($json);
 }