Customer Photo

This commit is contained in:
iBNu Maksum 2024-10-31 13:49:51 +07:00
parent 6e446192d8
commit 3dfb12d830
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
6 changed files with 104 additions and 34 deletions

View File

@ -95,19 +95,72 @@ switch ($action) {
$msg .= 'Phone Number must be a number' . '<br>';
}
$user->fullname = $fullname;
$user->address = $address;
if ($_c['allow_phone_otp'] != 'yes') {
$user->phonenumber = $phonenumber;
}
if ($_c['allow_email_otp'] != 'yes') {
$user->email = $email;
}
if (empty($msg)) {
if (!empty($_FILES['photo']['name'])) {
if (function_exists('imagecreatetruecolor')) {
$hash = md5_file($_FILES['photo']['tmp_name']);
$subfolder = substr($hash, 0, 2);
$folder = $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR;
if (!file_exists($folder)) {
mkdir($folder);
}
$folder = $UPLOAD_PATH . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR . $subfolder . DIRECTORY_SEPARATOR;
if (!file_exists($folder)) {
mkdir($folder);
}
$imgPath = $folder . $hash . '.jpg';
if (!file_exists($imgPath)) {
File::resizeCropImage($_FILES['photo']['tmp_name'], $imgPath, 1600, 1600, 100);
}
if (!file_exists($imgPath . '.thumb.jpg')) {
if (_post('faceDetect') == 'yes') {
try {
$detector = new svay\FaceDetector();
$detector->setTimeout(5000);
$detector->faceDetect($imgPath);
$detector->cropFaceToJpeg($imgPath . '.thumb.jpg', false);
} catch (Exception $e) {
File::makeThumb($imgPath, $imgPath . '.thumb.jpg', 200);
} catch (Throwable $e) {
File::makeThumb($imgPath, $imgPath . '.thumb.jpg', 200);
}
} else {
File::makeThumb($imgPath, $imgPath . '.thumb.jpg', 200);
}
}
if (file_exists($imgPath)) {
if ($user['photo'] != '') {
if (file_exists($UPLOAD_PATH . $d['photo'])) {
unlink($UPLOAD_PATH . $d['photo']);
if (file_exists($UPLOAD_PATH . $d['photo'] . '.thumb.jpg')) {
unlink($UPLOAD_PATH . $d['photo'] . '.thumb.jpg');
}
}
}
$user->photo = '/photos/' . $subfolder . '/' . $hash . '.jpg';
}
if (file_exists($_FILES['photo']['tmp_name'])) unlink($_FILES['photo']['tmp_name']);
} else {
r2(U . 'settings/app', 'e', 'PHP GD is not installed');
}
}
$user->save();
$user->fullname = $fullname;
$user->address = $address;
if ($_c['allow_phone_otp'] != 'yes') {
$user->phonenumber = $phonenumber;
}
if ($_c['allow_email_otp'] != 'yes') {
$user->email = $email;
}
_log('[' . $user['username'] . ']: ' . Lang::T('User Updated Successfully'), 'User', $user['id']);
r2(U . 'accounts/profile', 's', Lang::T('User Updated Successfully'));
$user->save();
_log('[' . $user['username'] . ']: ' . Lang::T('User Updated Successfully'), 'User', $user['id']);
r2(U . 'accounts/profile', 's', Lang::T('User Updated Successfully'));
}else{
r2(U . 'accounts/profile', 'e', $msg);
}
break;

View File

@ -776,5 +776,7 @@
"When_Expired__customer_will_be_move_to_selected_internet_package": "Jika masa berlaku habis, pelanggan akan dipindahkan ke paket internet yang dipilih",
"Data_Change": "Perubahan Data",
"Home_Address": "Alamat Rumah",
"Email_Address": "Alamat Email"
"Email_Address": "Alamat Email",
"Custom_Balance": "Saldo Kustom",
"Input_Desired_Amount": "Masukkan Jumlah yang Diinginkan"
}

View File

@ -19,7 +19,7 @@
<div class="form-group">
<label class="col-md-3 col-xs-12 control-label">{Lang::T('Photo')}</label>
<div class="col-md-6 col-xs-8">
<input type="file" class="form-control" name="photo">
<input type="file" class="form-control" name="photo" accept="image/*">
</div>
<div class="form-group col-md-3 col-xs-4">
<label class=""><input type="checkbox" checked name="faceDetect" value="yes"> Facedetect</label>

View File

@ -2,16 +2,30 @@
<!-- user-profile -->
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{Lang::T('Data Change')}</div>
<div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}accounts/edit-profile-post">
<form class="form-horizontal" enctype="multipart/form-data" method="post" role="form" action="{$_url}accounts/edit-profile-post">
<input type="hidden" name="csrf_token" value="{$csrf_token}">
<input type="hidden" name="id" value="{$_user['id']}">
<center>
<img src="{$UPLOAD_PATH}{$_user['photo']}.thumb.jpg" width="200"
onerror="this.src='{$UPLOAD_PATH}/user.default.jpg'" class="img-circle img-responsive"
alt="Foto" onclick="return deletePhoto({$d['id']})">
</center><br>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Username')}</label>
<div class="col-md-6">
<label class="col-md-3 col-xs-12 control-label">{Lang::T('Photo')}</label>
<div class="col-md-6 col-xs-8">
<input type="file" class="form-control" name="photo" accept="image/*">
</div>
<div class="form-group col-md-3 col-xs-4">
<label class=""><input type="checkbox" checked name="faceDetect" value="yes"> Facedetect</label>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
<div class="col-md-9">
<div class="input-group">
{if $_c['registration_username'] == 'phone'}
<span class="input-group-addon" id="basic-addon1"><i
@ -30,23 +44,23 @@
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Full Name')}</label>
<div class="col-md-6">
<label class="col-md-3 control-label">{Lang::T('Full Name')}</label>
<div class="col-md-9">
<input type="text" class="form-control" id="fullname" name="fullname"
value="{$_user['fullname']}">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Home Address')}</label>
<div class="col-md-6">
<label class="col-md-3 control-label">{Lang::T('Home Address')}</label>
<div class="col-md-9">
<textarea name="address" id="address" class="form-control">{$_user['address']}</textarea>
</div>
</div>
{if $_c['allow_phone_otp'] != 'yes'}
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Phone Number')}</label>
<div class="col-md-6">
<label class="col-md-3 control-label">{Lang::T('Phone Number')}</label>
<div class="col-md-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-phone-alt"></i></span>
<input type="text" class="form-control" name="phonenumber" id="phonenumber"
@ -57,8 +71,8 @@
</div>
{else}
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Phone Number')}</label>
<div class="col-md-6">
<label class="col-md-3 control-label">{Lang::T('Phone Number')}</label>
<div class="col-md-9">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i class="glyphicon glyphicon-phone-alt"></i></span>
<input type="text" class="form-control" name="phonenumber" id="phonenumber"
@ -74,15 +88,15 @@
{/if}
{if $_c['allow_email_otp'] != 'yes'}
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Email Address')}</label>
<div class="col-md-6">
<label class="col-md-3 control-label">{Lang::T('Email Address')}</label>
<div class="col-md-9">
<input type="text" class="form-control" id="email" name="email" value="{$_user['email']}">
</div>
</div>
{else}
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Email Address')}</label>
<div class="col-md-6">
<label class="col-md-3 control-label">{Lang::T('Email Address')}</label>
<div class="col-md-9">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input type="text" class="form-control" name="email" id="email"
@ -96,10 +110,11 @@
</div>
{/if}
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-success" type="submit">
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-success btn-block" type="submit">
{Lang::T('Save Changes')}</button>
Or <a href="{$_url}home">{Lang::T('Cancel')}</a>
<br>
<a href="{$_url}home" class="btn btn-link btn-block">{Lang::T('Cancel')}</a>
</div>
</div>
</form>

View File

@ -17,7 +17,7 @@
<div class="form-group">
<label class="col-md-3 col-xs-12 control-label">{Lang::T('Photo')}</label>
<div class="col-md-6 col-xs-8">
<input type="file" class="form-control" name="photo">
<input type="file" class="form-control" name="photo" accept="image/*">
</div>
<div class="form-group col-md-3 col-xs-4">
<label class=""><input type="checkbox" checked name="faceDetect" value="yes"> Facedetect</label>

View File

@ -1,3 +1,3 @@
{
"version": "2024.10.23"
"version": "2024.10.31"
}