Beispiel #1
0
 /**
  * 
  * @param type $fieldName
  * @param type $path 'upload/imageExample/123456789'
  * @param type $oldImage old image filename to delete after resize
  * @return string
  * @copyright (c) 2014, bb
  */
 public function saveImage($fieldName, $path)
 {
     if (array_key_exists($fieldName, $this->aAttributesBeforeSave)) {
         $oldImage = $this->aAttributesBeforeSave[$fieldName];
     }
     if (is_null($this->{$fieldName})) {
         if (!empty($oldImage)) {
             $this->{$fieldName} = $oldImage;
             $this->update(array($fieldName));
         }
         return false;
     }
     if (!empty($oldImage)) {
         $this->deleteImage($fieldName, $path, $oldImage);
     }
     $ext = $this->{$fieldName}->getExtensionName();
     $fileName = time() . '_' . $this->id . '_' . $fieldName . '.' . $ext;
     $imageHelper = new ImageHelper();
     $imageHelper->createDirectoryByPath($path);
     $this->{$fieldName}->saveAs($path . '/' . $fileName);
     $this->{$fieldName} = $fileName;
     $this->update(array($fieldName));
     if (array_key_exists($fieldName, $this->aImageSize) && is_array($this->aImageSize[$fieldName])) {
         $this->resizeImage($fieldName, $path);
     }
 }
Beispiel #2
0
 /**
  * @Author: ANH DUNG Mar 28, 2014
  * @Todo: save user form model ProTransactionsVendorPurchaserDetail
  * @Param: $model is model ProTransactionsVendorPurchaserDetail
  * @Return: model user
  */
 public static function saveUserVendorPurchaser($model, $role_id)
 {
     $mUser = new Users();
     $mUser->scenario = 'abcdef';
     $mUser->first_name = $model->name;
     $mUser->email_not_login = $model->email;
     $mUser->nric_passportno_roc = $model->nric_passportno_roc;
     $mUser->contact_no = $model->contact_no;
     $mUser->address = $model->address;
     $mUser->postal_code = $model->postal_code;