예제 #1
0
 public function save()
 {
     $posts = $this->getValues();
     $file = $posts['photofile'];
     //        print_r($file);die;
     //saving employee
     $employee = new Employee();
     $employee->firstName = $posts['firstName'];
     $employee->lastName = $posts['lastName'];
     $employee->middleName = $posts['middleName'];
     $employee->employeeId = $posts['employeeId'];
     $employeeService = $this->getEmployeeService();
     $employeeService->saveEmployee($employee);
     $empNumber = $employee->empNumber;
     //saving emp picture
     if ($file instanceof sfValidatedFile && $file->getOriginalName() != "") {
         $empPicture = new EmpPicture();
         $empPicture->emp_number = $empNumber;
         $tempName = $file->getTempName();
         $empPicture->picture = file_get_contents($tempName);
         $empPicture->filename = $file->getOriginalName();
         $empPicture->file_type = $file->getType();
         $empPicture->size = $file->getSize();
         list($width, $height) = getimagesize($file->getTempName());
         $sizeArray = $this->pictureSizeAdjust($height, $width);
         $empPicture->width = $sizeArray['width'];
         $empPicture->height = $sizeArray['height'];
         $empPicture->save();
     }
     if ($this->createUserAccount) {
         $this->saveUser($empNumber);
     }
     //merge location dropdown
     $formExtension = PluginFormMergeManager::instance();
     $formExtension->saveMergeForms($this, 'addEmployee', 'AddEmployeeForm');
     return $empNumber;
 }
 private function saveEmployeePicture($empNumber, $file)
 {
     $employeeService = $this->getEmployeeService();
     $empPicture = $employeeService->getEmployeePicture($empNumber);
     if (!$empPicture instanceof EmpPicture) {
         $empPicture = new EmpPicture();
         $empPicture->emp_number = $empNumber;
     }
     $empPicture->picture = file_get_contents($file['photofile']['tmp_name']);
     $empPicture->filename = $file['photofile']['name'];
     $empPicture->file_type = $file['photofile']['type'];
     $empPicture->size = $file['photofile']['size'];
     $empPicture->width = $this->newWidth;
     $empPicture->height = $this->newHeight;
     $empPicture->save();
 }
예제 #3
0
 /**
  * Save EmployeePicture
  * @param EmpPicture $empPicture
  * @return EmpPicture
  * @throws DaoException
  */
 public function saveEmployeePicture(EmpPicture $empPicture)
 {
     try {
         $empPicture->save();
         return $empPicture;
         // @codeCoverageIgnoreStart
     } catch (Exception $e) {
         throw new DaoException($e->getMessage(), $e->getCode(), $e);
     }
     // @codeCoverageIgnoreEnd
 }
예제 #4
0
 /**
  * Save EmployeePicture
  * @param EmpPicture $empPicture
  * @returns boolean
  * @throws DaoException
  */
 function saveEmployeePicture(EmpPicture $empPicture)
 {
     try {
         $empPicture->save();
         return true;
     } catch (Exception $e) {
         throw new DaoException($e->getMessage());
     }
 }