public function testGetCorporateDirectoryEmployeeDetailsAsArrayWithImage64BaseString() { $base64TestString = 'R0lGODlhCgAKALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////ywAAAAACgAKAAAEClDJSau9OOvNe44AOw=='; $decodedBase64String = base64_decode($base64TestString); $empPicture = new EmpPicture(); $empPicture->setPicture($decodedBase64String); $empPicture->setFileType('png'); $employee = new Employee(); $employee->setEmpNumber(1); $employee->setFirstName('testEmpFirstName'); $employee->setLastName('testEmpLastName'); $count = 1; $employees = array($employee); $employeeDirectoryServiceMock = $this->getMock('EmployeeDirectoryService'); $employeeDirectoryServiceMock->expects($this->once())->method('searchEmployees')->will($this->returnValue($employees)); $employeeDirectoryServiceMock->expects($this->once())->method('getSearchEmployeeCount')->will($this->returnValue($count)); $employeeServiceMock = $this->getMock('EmployeeService'); $employeeServiceMock->expects($this->once())->method('getEmployeePicture')->will($this->returnValue($empPicture)); $this->corporateDirectoryWebServiceHelper->setEmployeeDirectoryService($employeeDirectoryServiceMock); $this->corporateDirectoryWebServiceHelper->setEmployeeService($employeeServiceMock); $employeeDetails = $this->corporateDirectoryWebServiceHelper->getCorporateDirectoryEmployeeDetailsAsArray(); $employeeProfilePicture = $employeeDetails[0]['profile_picture']; $this->assertNotNull($employeeProfilePicture); $this->assertEquals($base64TestString, $employeeProfilePicture['image_string']); }
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; }
/** * 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 }
/** * Testing Adding Employee Picture */ public function testAddEmployeePictureException() { $empNumber = 102; $pic = new EmpPicture(); $pic->setEmpNumber($empNumber); $pic->setFilename("pic_" . rand(0, 1000)); $mockDao = $this->getMock('EmployeeDao'); $mockDao->expects($this->once())->method('saveEmployeePicture')->with($pic)->will($this->throwException(new DaoException())); $this->employeeService->setEmployeeDao($mockDao); try { $result = $this->employeeService->saveEmployeePicture($pic); $this->fail("Exception expected"); } catch (Exception $e) { $this->assertTrue($e instanceof PIMServiceException); } }
$object = $extractor->parseData(); if ($object != null) { $object->setEmpId($_GET['id']); $result = $object->updateEmpPic(); } else { $message = "FAILURE"; } break; } } } $parsedObject = $extractor->parseData($_POST); $view_controller->assignData($_GET['reqcode'], $parsedObject, $_POST['STAT']); } elseif (isset($_POST['STAT']) && $_POST['STAT'] == 'DEL' && $locRights['delete']) { if (isset($_POST['imageChange']) && $_POST['imageChange'] == '1') { $object = new EmpPicture(); $result = $object->delEmpPic(array(array($_GET['id']))); } $view_controller->delAssignData($_GET['reqcode'], $_POST, $_GET); } if (isset($_POST['educationSTAT']) && ($_POST['educationSTAT'] == 'ADD' || $_POST['educationSTAT'] == 'EDIT')) { $parsedObject = $extractorForm->parseData($_POST); $view_controller->assignEmpFormData($_POST, $parsedObject, $_POST['educationSTAT']); } elseif (isset($_POST['educationSTAT']) && $_POST['educationSTAT'] == 'DEL') { $view_controller->delEmpFormData($_GET, $_POST); } if (isset($_POST['wrkexpSTAT']) && ($_POST['wrkexpSTAT'] == 'ADD' && $locRights['add'] || $_POST['wrkexpSTAT'] == 'EDIT' && $locRights['edit'])) { $parsedObject = $extractorForm->parseData($_POST); $view_controller->assignEmpFormData($_POST, $parsedObject, $_POST['wrkexpSTAT']); } elseif (isset($_POST['wrkexpSTAT']) && $_POST['wrkexpSTAT'] == 'DEL' && $locRights['delete']) { $view_controller->delEmpFormData($_GET, $_POST);
@session_start(); if (!isset($_SESSION['fname'])) { header("Location: ../../login.php"); exit; } if (!defined('ROOT_PATH')) { define("ROOT_PATH", $_SESSION['path']); } require_once ROOT_PATH . '/lib/models/hrfunct/EmpPhoto.php'; require_once ROOT_PATH . '/lib/extractor/hrfunct/EXTRACTOR_EmpPhoto.php'; require_once ROOT_PATH . '/lib/common/Language.php'; require_once ROOT_PATH . '/lib/common/CommonFunctions.php'; require_once ROOT_PATH . '/language/default/lang_default_full.php'; $lan = new Language(); require_once $lan->getLangPath("full.php"); $photo = new EmpPicture(); $employeeId = $_GET['id']; $edit = $photo->filterEmpPic($employeeId); $styleSheet = CommonFunctions::getTheme(); if (isset($_GET['action']) && $_GET['action'] == 'VIEW') { if ($edit) { header("Content-length: " . $edit[0][4]); header("Content-type: " . $edit[0][3]); echo $edit[0][1]; exit; } else { // TODO: Use the current theme instead of hard-coded 'beyondT'; Use the $styleSheet variable $tmpName = ROOT_PATH . '/themes/beyondT/pictures/default_employee_image.gif'; $fp = fopen($tmpName, 'r'); $contents = fread($fp, filesize($tmpName)); fclose($fp);
/** * Saving/Updating Employee Picture * @param EmpPicture $empPicture */ public function setEmployeePicture(EmpPicture $empPicture) { if ($this->getEmpNumber() != "") { $service = new EmployeeService(); $currentEmpPicture = $service->readEmployeePicture($this->getEmpNumber()); if ($currentEmpPicture instanceof EmpPicture) { $currentEmpPicture->setPicture($empPicture->getPicture()); $currentEmpPicture->setFilename($empPicture->getFilename()); $currentEmpPicture->setFileType($empPicture->getFileType()); $currentEmpPicture->setSize($empPicture->getSize()); } else { $currentEmpPicture = $empPicture; } $service->saveEmployeePicture($currentEmpPicture); } }
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(); }
/** * Testing Adding Employee Picture */ public function testAddEmployeePictureException() { $empNumber = 102; $pic = new EmpPicture(); $pic->setEmpNumber($empNumber); $pic->setFilename("pic_" . rand(0, 1000)); }
/** * 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()); } }