public static function SaveModel($model, $transaction_id, $ColumnNameFile) { self::saveFile($model, $ColumnNameFile); $mFile = new ProInventoryPhoto(); // $mFile->date_only = $model->date_only; $mFile->file_name = $model->file_name; $mFile->transaction_id = $transaction_id; $mFile->user_id = Yii::app()->user->id; if (isset($_GET['uid'])) { $mFile->user_id = $_GET['uid']; } $mFile->file_name_slug = $model->file_name_slug; $mFile->save(); $model->id = $mFile->id; self::resizeImage($model, $ColumnNameFile, ProInventoryPhoto::$aSize); return $mFile->id; }
/** * @Author: ANH DUNG Jul 25, 2014 * @Todo: remove inventory photo * @Param: $id * @note: cùng chức năng với actionAjaxRemoveFileAll ở EnquiryController ngoài cùng */ public function AjaxRemoveFileAll() { if (isset($_GET['InventoryPhotoId'])) { $model = ProInventoryPhoto::model()->findByPk($_GET['InventoryPhotoId']); if ($model) { if ($model->user_id == Yii::app()->user->id) { $model->delete(); } } die; } }
} if ($idModelFile) { $response['code'] = true; $response['message'] = $idModelFile; $response['file_name'] = $model->file_name; $response['li'] = $this->builLiPhoto($model); } } else { $response['code'] = false; $response['message'] = $model->getError($ColumnNameFile); }
<h3 class="uppercase">Inventory Photo</h3> <div class="box_inventory_photo" style=""> <!--<div class="form-type upload_inventory_photo" style="border-top: none;border-left: none;border-right: none;">--> <?php $form = $this->beginWidget('CActiveForm', array('method' => 'post', 'htmlOptions' => array('enctype' => 'multipart/form-data'))); $transaction_id = isset($_GET['transaction_id']) ? $_GET['transaction_id'] : 0; $mProInventoryPhoto = new ProInventoryPhoto(); $aModelPhoto = ProInventoryPhoto::GetByUidAndTransactionId(Yii::app()->user->id, $transaction_id); $countModelPhoto = count($aModelPhoto); ?> <div class="form-type inventory_photo_upload" > <div class="in-row clearfix"> <label class="lb">Upload Photo</label> <div class="group-upload f-left w-400"> <?php echo $form->fileField($mProInventoryPhoto, 'file_name', array('class' => 'file_name')); ?> <span>Only <?php echo ProInventoryPhoto::$AllowFile; ?> are allow</span> <input type="hidden" name="ClassName" value="ProInventoryPhoto"> <input type="hidden" name="Scenario" value="file_upload"> <input type="hidden" name="ColumnNameFile" value="file_name"> <input type="hidden" name="transaction_id" value="<?php echo $transaction_id; ?> "> </div> </div>
public function actionInventoryPhoto($transaction_id) { $this->pageTitle = "Inventory Photo - " . Yii::app()->params['title']; $this->layout = "application.views.layouts.layout_callslog"; try { $model = new ProInventoryPhoto(); $model->transaction_id = $transaction_id; $aModelPhoto = ProInventoryPhoto::GetByUidAndTransactionId(0, $transaction_id); $this->render('inventoryphoto/list', array('model' => $model, 'aModelPhoto' => $aModelPhoto, 'actions' => $this->listActionsCanAccess)); } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException("Exception " . print_r($e, true)); } }