update upload ảnh nhân viên
This commit is contained in:
parent
7204a46da7
commit
e97496a628
4102
access_control.sql
4102
access_control.sql
File diff suppressed because it is too large
Load Diff
|
@ -111,6 +111,7 @@ class StaffController extends Controller {
|
|||
$model->phone = $data["Phone"];
|
||||
$model->date_in = date_format(date_create_from_format('d/m/Y', $data["DateIn"]), 'U');
|
||||
$model->address = $data["Address"];
|
||||
$model->image = $data["Image"];
|
||||
$model->modified_at = time();
|
||||
if ($model->save()) {
|
||||
common::insertSystemLogs(["action" => "update", "description" => "Chỉnh sửa nhân viên: " . $data["Name"], "type" => Yii::$app->controller->id]);
|
||||
|
@ -294,4 +295,11 @@ class StaffController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionImage() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$model = new common();
|
||||
return $model->UploadFile("AnhNhanVien", ["PNG", "JPG", "JPEG", "GIF"], "staff");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ use Yii;
|
|||
* @property int $birthday
|
||||
* @property string $email
|
||||
* @property string $phone
|
||||
* @property string $image
|
||||
* @property int $date_in
|
||||
* @property string $address
|
||||
* @property int $created_at
|
||||
|
@ -41,7 +42,7 @@ class Staff extends \yii\db\ActiveRecord {
|
|||
return [
|
||||
[['code', 'name', 'gender'], 'required'],
|
||||
[['code', 'card_number', 'department_id', 'birthday', 'date_in', 'created_at', 'modified_at', 'card_register_time', 'schedule_id'], 'integer'],
|
||||
[['address', 'door_access', 'door_access_old'], 'string'],
|
||||
[['address', 'door_access', 'door_access_old', 'image'], 'string'],
|
||||
[['name', 'email'], 'string', 'max' => 100],
|
||||
[['gender'], 'string', 'max' => 10],
|
||||
[['phone'], 'string', 'max' => 20],
|
||||
|
@ -92,7 +93,8 @@ class Staff extends \yii\db\ActiveRecord {
|
|||
"address" => $data["Address"],
|
||||
"created_at" => time(),
|
||||
"modified_at" => time(),
|
||||
"card_register_time" => time()
|
||||
"card_register_time" => time(),
|
||||
"image" => $data['Image']
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
{$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist')}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group" id="code">
|
||||
|
@ -54,8 +55,28 @@
|
|||
</div>
|
||||
<span class="help-block hidden"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Địa chỉ</div>
|
||||
<textarea class="form-control" rows="6" name="Address">{$model->address}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<fieldset style="width: 50%;margin: auto !important;">
|
||||
<legend>Hình nhân viên</legend>
|
||||
{$img=$directoryAsset|cat:"/img/user2-160x160.jpg"}
|
||||
{if $model->image}
|
||||
{$img="/"|cat:$model->image}
|
||||
{/if}
|
||||
<img src="{$img}" id='staff-img' width="100%" class="img-thumbnail" style="cursor: pointer;">
|
||||
<div class="hidden">
|
||||
<input type="file" name="AnhNhanVien" id="AnhNhanVien">
|
||||
<input type="hidden" name="AnhNhanVienUrl" value="{$model->image}">
|
||||
<input type="hidden" name="url_upload_staff_image" value="{yii\helpers\Url::to(['image'])}">
|
||||
</div>
|
||||
</fieldset>
|
||||
<br>
|
||||
<div class="form-group" id="card_number">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Mã thẻ</div>
|
||||
|
@ -77,12 +98,6 @@
|
|||
<input type="text" class="form-control DatePicker" value="{$model->date_in|date_format:"%d/%m/%Y"}" name="DateIn">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Địa chỉ</div>
|
||||
<textarea class="form-control" rows="6" name="Address">{$model->address}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
|
|
|
@ -242,6 +242,10 @@ common.form = function (e, obj, bigSize) {
|
|||
if (obj === 'staff') {
|
||||
$('#Department').select2();
|
||||
common.dateTimePickerByClass("DatePicker", "DD/MM/YYYY");
|
||||
btnImage();
|
||||
$("#staff-img").on("click", function () {
|
||||
$("#AnhNhanVien").trigger("click");
|
||||
});
|
||||
}
|
||||
if (obj === 'card-register') {
|
||||
$('#Staff').select2();
|
||||
|
|
|
@ -61,7 +61,8 @@ function save(e) {
|
|||
CardNumber: $("input[name='CardNumber']").val(),
|
||||
Department: $("select[name='Department']").val(),
|
||||
DateIn: $("input[name='DateIn']").val(),
|
||||
Address: $("textarea[name='Address']").val()
|
||||
Address: $("textarea[name='Address']").val(),
|
||||
Image: $("input[name='AnhNhanVienUrl']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
|
@ -112,6 +113,10 @@ function _form(e) {
|
|||
common.modalOpen(data.form, true, data.title);
|
||||
$('#Department').select2();
|
||||
common.dateTimePickerByClass("DatePicker", "DD/MM/YYYY");
|
||||
btnImage();
|
||||
$("#staff-img").on("click", function () {
|
||||
$("#AnhNhanVien").trigger("click");
|
||||
});
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
|
@ -228,3 +233,28 @@ function _logs(e) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function btnImage() {
|
||||
var fData = {
|
||||
UploadImage: true
|
||||
};
|
||||
fData[common.csrfParam] = common.csrf;
|
||||
new afuButton({
|
||||
uploadURI: $("input[name='url_upload_staff_image']").val(),
|
||||
formData: fData,
|
||||
wrap: {
|
||||
tagName: 'div',
|
||||
classes: ''
|
||||
},
|
||||
fileExtension: '.png,.jpg,.jpeg,.gif',
|
||||
fileSizeLimit: 1,
|
||||
classes: 'btn btn-default',
|
||||
fakeInputContent: '<span class=\'fa fa-file-image-o\'></span> Chọn hình ảnh',
|
||||
onUploaded: function (data) {
|
||||
$("#staff-img").attr("src", "/" + data);
|
||||
$("input[name='AnhNhanVienUrl']").val(data);
|
||||
common.uploadBlock(false);
|
||||
}
|
||||
}).addInstance('AnhNhanVien');
|
||||
}
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue
Block a user