/**
  * Retrieve the JSON representing all the supervisors for an employee.
  */
 public function jsonAction()
 {
     // Retrieve the employee id.
     $id = $this->getInt('id');
     // Wrap the whole thing in a try/catch.
     try {
         // Make sure the id is valid.
         if (isset($id) && is_numeric($id)) {
             // Get all the supervisors.
             $employeeDao = new EmployeeDao();
             $supervisors = $employeeDao->getSupervisorEmployees($id);
             // Create the JSON object to return.
             $json = new stdClass();
             $json->success = true;
             $json->supervisors = $supervisors;
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             $json->msg = 'A valid employee id must be provided.';
             $json->supervisors = array();
         }
     } catch (Zend_Exception $ex) {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = $ex->getMessage();
         $json->supervisors = array();
     }
     // Return all the employees as JSON.
     $this->_helper->json($json);
 }
 protected function execute($arguments = array(), $options = array())
 {
     $con = $this->crearConexion();
     try {
         $record = Doctrine::getTable('EmailConfiguration')->findAll()->getFirst();
         $config_mail = array('charset' => 'UTF-8', 'encryption' => $record->getSmtpSecurityType(), 'host' => $record->getSmtpHost(), 'port' => $record->getSmtpPort(), 'username' => $record->getSmtpUsername(), 'password' => $record->getSmtpPassword(), 'authentication' => $record->getSmtpAuthType());
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->CharSet = $config_mail['charset'];
         if ($config_mail['authentication'] == "login") {
             $mail->SMTPAuth = true;
         }
         if ($config_mail['encryption'] == "tls") {
             $mail->SMTPSecure = "tls";
         }
         if ($config_mail['encryption'] == "ssl") {
             $mail->SMTPSecure = "ssl";
         }
         $mail->Host = $config_mail['host'];
         $mail->Port = $config_mail['port'];
         $mail->Username = $config_mail['username'];
         $mail->Password = $config_mail['password'];
         $mail->FromName = 'Mi company';
         $mail->From = $config_mail['username'];
         //email de remitente desde donde se env?a el correo
         $mail->AddAddress($config_mail['username'], 'Destinatario');
         //destinatario que va a recibir el correo
         $mail->Subject = "confeccion de gafete";
         /*Recojemos los datos del oficial*/
         $dao = new EmployeeDao();
         $employeeList = $dao->getEmployeeList();
         foreach ($employeeList as $employee) {
             if ($employee->getJoinedDate() != "") {
                 $datetime1 = new DateTime($employee->getJoinedDate());
                 $datetime2 = new DateTime(date('y-m-d', time()));
                 $formato = $datetime2->format('y-m-d');
                 $intervalo = $datetime1->diff($datetime2, true);
                 if ($intervalo->m == 2 && $intervalo->d == 0) {
                     $html = "Identificador: " . $employee->getEmployeeId() . "<br/>";
                     $html .= "ID: " . $employee->getOtherId() . "<br/>";
                     $html .= "Nombre      : " . utf8_encode($employee->getFullName()) . "<br/>";
                     $html .= "Fecha Nac   : " . $employee->getEmpBirthday() . "<br/>";
                     $sexo = $employee->getEmpGender() == 1 ? "Masculino" : "Femenino";
                     $html .= "G&eacute;nero      : " . $sexo . "<br/>";
                     $html .= "Nacionalidad: " . $employee->getNationality() . "<br/>";
                     $html .= "M&oacute;vil: " . $employee->getEmpMobile() . "<br/>";
                     $mail->MsgHTML($html);
                     if (!$mail->Send()) {
                         $this->escribirYML('log_tareas', false, $mail->ErrorInfo . " Error al enviar el correo  con los datos del empleado " . $employee->getFullName());
                     } else {
                         $this->escribirYML('log_tareas', true, "correo enviado  con los datos del empleado " . $employee->getFullName());
                     }
                 }
             }
         }
         Doctrine_Manager::getInstance()->closeConnection($con);
     } catch (Exception $e) {
         $this->escribirYML('log_tareas', false, $e->getMessage());
     }
 }
 /**
  * Update the employee's profile information.
  */
 public function updateAction()
 {
     // 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 {
         // Create an array of the fields that represent the employee.
         $data = array('first_name' => $this->getStr('first_name'), 'last_name' => $this->getStr('last_name'), 'suffix' => $this->getStr('suffix'), 'login' => $this->getStr('login'), 'email' => $this->getStr('email'));
         // Set the hashed password value if necessary.
         $password = $this->getStr('password');
         if (isset($password)) {
             $data['hashed_pass'] = hash('SHA512', $password);
         }
         // Make sure the id is set.
         if (isset($me) && isset($me->id) && is_numeric($me->id)) {
             // Get the DAO.
             $employeeDao = new EmployeeDao();
             // Save the new values.
             $employeeDao->save($me->id, $data);
             // Retrieve the updated employee.
             $employee = $employeeDao->get($me->id);
             // Make sure the employee was returned.
             if (isset($employee)) {
                 // Create the JSON object to return.
                 $json = new stdClass();
                 $json->success = true;
                 $json->msg = 'Your profile was updated successfully.';
                 $json->employee = $employee;
             } else {
                 // Create the error JSON object to return.
                 $json = new stdClass();
                 $json->success = false;
                 $json->msg = 'Failed to update your profile.';
             }
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             $json->msg = 'Unable to find your profile.';
         }
     } 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);
 }
示例#4
0
 /**
  * Performs an authentication attempt for a user.
  *
  * @throws Zend_Auth_Adapter_Exception If authentication cannot
  *                                     be performed
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     // Get the DAO used to retrieve employee info.
     $employeeDao = new EmployeeDao();
     // Get the employee attempting to log in.
     $employee = $employeeDao->getAuthEmployee($this->login, $this->password);
     // Check to see if an employee was found.
     if ($employee != null) {
         // Log what we are doing.
         Logger::getLogger()->info("Authentication successful: " . $this->login);
         // Return the result.
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $employee);
     }
     // Log what we are doing.
     Logger::getLogger()->warn("Authentication failed: " . $this->login);
     // On failure, return a bad result.
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null, array('Invalid login or password.'));
 }
 /**
  * @group ReportingChain 
  */
 public function testGetSubordinateList_ReportingChain_4LevelHierarchy()
 {
     $subordinates = $this->dao->getSubordinateList(97, false, true);
     $this->assertTrue(is_array($subordinates));
     $this->assertEquals(16, count($subordinates));
     $this->assertTrue($subordinates[0] instanceof Employee);
     $this->assertEquals(61, $subordinates[0]->getEmpNumber());
     $this->assertEquals(25, $subordinates[1]->getEmpNumber());
     $this->assertEquals(36, $subordinates[2]->getEmpNumber());
     $this->assertEquals(41, $subordinates[3]->getEmpNumber());
     $this->assertEquals(68, $subordinates[4]->getEmpNumber());
     $this->assertEquals(87, $subordinates[5]->getEmpNumber());
     $this->assertEquals(6, $subordinates[6]->getEmpNumber());
     $this->assertEquals(7, $subordinates[7]->getEmpNumber());
     $this->assertEquals(20, $subordinates[8]->getEmpNumber());
     $this->assertEquals(23, $subordinates[9]->getEmpNumber());
     $this->assertEquals(31, $subordinates[10]->getEmpNumber());
     $this->assertEquals(71, $subordinates[11]->getEmpNumber());
     $this->assertEquals(92, $subordinates[12]->getEmpNumber());
     $this->assertEquals(94, $subordinates[13]->getEmpNumber());
     $this->assertEquals(24, $subordinates[14]->getEmpNumber());
     $this->assertEquals(53, $subordinates[15]->getEmpNumber());
 }
示例#6
0
 $day = gmdate('Y-m-d', strtotime(gmdate('Y-m-d') . " -0000") - 24 * 60 * 60);
 $dayTime = strtotime($day . " -0000");
 $dayName = gmdate('D', $dayTime);
 // 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);
示例#7
0
 /**
  * Used to retrieve timesheet status information for a supervisor's
  * employees for a specific pay period.
  *
  * @param pp The pay period for which the timesheet status information will
  * be retrieved.
  *
  * @param supervisor The supervisor for which timesheets status will be
  * retrieved.
  *
  * @return Returns the requested timesheet status information.
  */
 public function getStatusForSupervised($pp, $supervisor)
 {
     // Make sure the pay period is valid.
     if (!isset($pp) || !isset($pp->start) || !isset($supervisor) || !isset($supervisor->id)) {
         return null;
     }
     // Get the database adapter.
     $db = $this->getAdapter();
     // Set the fetch mode.
     $db->setFetchMode(Zend_Db::FETCH_OBJ);
     // Get the select object.
     $select = $db->select();
     // Get the DAOs we are joining across.
     $employeeDao = new EmployeeDao();
     $supervisorDao = new SupervisorDao();
     // Build the query.
     $select->from(array('e' => $employeeDao->_name), array('division', 'email', 'first_name', 'last_name', 'login', 'personnel_type', 'active'))->join(array('s' => $supervisorDao->_name), 'e.id = s.employee_id')->joinLeft(array('t' => $this->_name), 'e.id = t.employee_id')->where('(t.pp_start = ? OR t.pp_start IS NULL)', $pp->start)->where('s.supervisor_id = ?', $supervisor->id)->order('last_name')->order('first_name');
     // Add ordering.
     $this->setDefaultOrder($select);
     // Retrieve all the objects.
     $objs = $db->query($select)->fetchAll();
     // Perform post-processing on all the objects.
     if (isset($objs) && count($objs) > 0) {
         foreach ($objs as $obj) {
             // Post-process the timesheet.
             $this->postProcess($obj);
             // Post-process the employee.
             $employeeDao->postProcess($obj);
             // Add the timesheet summary information.
             $this->addSummary($obj, $pp);
         }
     }
     // Return the objects.
     return $objs;
 }
 /**
  * Forgot password.
  */
 function forgotAction()
 {
     // Wrap the whole thing in a try/catch.
     try {
         // Get the login name.
         $login = $this->getStr('login');
         // Make sure the login is valid.
         if (isset($login)) {
             // Get the DAO used to retrieve employee info.
             $employeeDao = new EmployeeDao();
             // Get the employee attempting to log in.
             $employee = $employeeDao->getEmployeeByLogin($login);
             // Make sure the employee was found.
             if (isset($employee)) {
                 // Make sure the employee has an email address.
                 if (isset($employee->email)) {
                     // The new password.
                     $password = $this->generatePassword();
                     // Log the password.
                     Logger::getLogger()->debug("Resetting password for {$login}: {$password}");
                     // Get the mail configuration.
                     $config = Bootstrap::$registry->config->mail;
                     // Create the login info.
                     $mailconfig = array('auth' => 'login', 'port' => $config->port, 'username' => $config->user, 'password' => $config->pass);
                     // Create the transport.
                     $transport = new Zend_Mail_Transport_Smtp($config->host, $mailconfig);
                     $mail = new Zend_Mail();
                     $mail->setBodyText("\nForgot Password Request:\n\n" . "Your company timesheet system web site received a request \n" . "indicating your account password was forgotten and should \n" . "be reset. If you did not make this request, please notify the\n" . "web site administrator.\n\n" . "Here is your new login information:\n" . "      Login:    {$login}\n" . "      Password: {$password}\n\n" . "Once you login, you can change your password by viewing\n" . "your profile information.\n")->setFrom($config->from, $config->name)->addTo($employee->email, $employee->full_name)->setSubject('Timesheet System - Password Reset')->send($transport);
                     // Create the JSON object to return.
                     $json = new stdClass();
                     $json->success = true;
                     $json->msg = 'An email with a new random password was sent ' . 'to the email address associated with your account. ' . 'Please check your email for your updated login info. ' . 'If you have any problems, please contact the web site ' . 'administrator.';
                     // Set a random password on the user account.
                     $employee->hashed_pass = hash('SHA512', $password);
                     // Turn the employee info into an array.
                     $data = array('id' => $employee->id, 'login' => $employee->login, 'hashed_pass' => $employee->hashed_pass, 'email' => $employee->email, 'first_name' => $employee->first_name, 'last_name' => $employee->last_name, 'suffix' => $employee->suffix, 'division' => $employee->division, 'personnel_type' => $employee->personnel_type, 'active' => $employee->active);
                     // Save the updated employee data.
                     $employeeDao->save($employee->id, $data);
                 } else {
                     // No email address on file.
                     $json = new stdClass();
                     $json->success = false;
                     $json->msg = 'No email address is specified within your ' . 'profile information, so your password was not reset. ' . 'Please contact the web site administrator for your new password.';
                 }
             } else {
                 // No user account found.
                 $json = new stdClass();
                 $json->success = false;
                 $json->msg = 'No user account was found with the specified ' . 'login or email address. Please specify the correct ' . 'user information before requesting a password reset.';
             }
         } else {
             // Create the JSON object to return.
             $json = new stdClass();
             $json->success = false;
             $json->msg = 'A login or email address must be provided ' . 'when requesting a password reset.';
         }
     } catch (Zend_Exception $ex) {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = $ex->getMessage();
     }
     // Return the JSON response.
     $this->_helper->json($json);
 }
 /**
  * Retrieve the JSON for all the employees assigned to a contract as of a
  * specific day.
  */
 public function contractAction()
 {
     // Get the id of the contract for which employees are to be retrieved.
     $id = $this->getInt('id');
     // Get the day for which employee data is to be retrieved.
     $day = $this->getDate('day');
     // Wrap the whole thing in a try/catch.
     try {
         // Check to see if the provided contract id is valid.
         if (isset($id) && is_numeric($id)) {
             // Used to retrieve the necessary pay period.
             $payPeriodDao = new PayPeriodDao();
             // Used to retrieve the employees.
             $employeeDao = new EmployeeDao();
             // Get the employees for the specified contract.
             $employees = $employeeDao->getContractEmployees($id, $day);
             // Create the JSON object to return.
             $json = new stdClass();
             $json->success = true;
             $json->msg = 'The assigned employees were ' . 'retrieved successfully.';
             $json->employees = $employees;
         } else {
             // Create the error JSON object to return.
             $json = new stdClass();
             $json->success = false;
             $json->msg = 'A valid contract id must be specified.';
         }
     } catch (Zend_Exception $ex) {
         // Create the error JSON object to return.
         $json = new stdClass();
         $json->success = false;
         $json->msg = $ex->getMessage();
         $json->employees = array();
     }
     // Return all the employees as JSON.
     $this->_helper->json($json);
 }
示例#10
0
 public function SendEmail()
 {
     $file = sfConfig::get('sf_app_config_dir') . '/app.yml';
     $result = sfYaml::load($file);
     $config_mail = $result['mailer'];
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->CharSet = $config_mail['param']['charset'];
     $mail->SMTPAuth = true;
     if ($config_mail['param']['tls'] == true) {
         $mail->SMTPSecure = "tls";
     }
     $mail->Host = $config_mail['param']['host'];
     $mail->Port = $config_mail['param']['port'];
     $mail->Username = $config_mail['param']['username'];
     $mail->Password = $config_mail['param']['password'];
     $mail->FromName = 'Mi company';
     $mail->From = $config_mail['param']['username'];
     //email de remitente desde donde se env�a el correo
     $mail->AddAddress($config_mail['param']['username'], 'Destinatario');
     //destinatario que va a recibir el correo
     $mail->Subject = "confección de título";
     //$mail->AltBody = 'cuerpo del mensaje en texto plano';//cuerpo con texto plano
     /*Recojemos los datos del oficial*/
     $dao = new EmployeeDao();
     $empleoyeeList = $dao->getEmployeeList();
     foreach ($empleoyeeList as $employee) {
         $fecha_union = new DateTime($employee->getJoinedDate());
         $fecha_actual = date('yyyy-mm-dd');
         $fecha_actual = new DateTime($fecha_actual);
         $diferencia = $fecha_actual->diff($fecha_union);
         print_r($diferencia);
         exit;
         if ($employee->getJoinedDate()) {
         }
         $html = "Identificador: " . $employee->getEmployeeId() . "<br/>";
         $html .= "ID: " . $employee->getOtherId() . "<br/>";
         $html .= "Nombre      : " . $employee->getFullName() . "<br/>";
         $html .= "Fecha Nac   : " . $employee->getEmpBirthday() . "<br/>";
         $sexo = $employee->getEmpGender() == 1 ? "Masculino" : "Femenino";
         $html .= "Genero      : " . $sexo . "<br/>";
         $html .= "Nacionalidad: " . $employee->getNationality() . "<br/>";
         $html .= "Movil: " . $employee->getEmpMobile() . "<br/>";
     }
     //print_r($mail->);exit;
     $mail->MsgHTML($html);
     //cuerpo con html
     if (!$mail->Send()) {
         return false;
         //print_r($mail->ErrorInfo);
     } else {
         return true;
     }
 }