| Current Path : /var/www/html/ekursusv2/frontend/runtime/frontendpage/ |
| Current File : /var/www/html/ekursusv2/frontend/runtime/frontendpage/182_1761214351065787900-content-443.php |
<?php
/*** CONTENT_ID-443***/
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use backend\modules\refdynawebv2\models\Ref;
use frontend\models\FrontendUser;
use kartik\file\FileInput;
use yii\web\UploadedFile;
use frontend\models\OwnerHistory;
use frontend\models\Staff;
if (($model = FrontendUser::findOne(Yii::$app->user->identity->id)) !== null) {
$original_fullname = $model->fullname;
$original_ic_no = $model->ic_no;
$original_gender = $model->gender;
$original_race = $model->race;
$original_mobile_no = $model->mobile_no;
$original_email = $model->email;
$model->fullname = NULL;
$model->ic_no = NULL;
$model->gender = NULL;
$model->race = NULL;
$model->mobile_no = NULL;
$model->email = NULL;
if ($model->load(Yii::$app->request->post())) {
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
$model->update_status = 1;
if ($model->save()) {
$modelHistory = new OwnerHistory();
$modelHistory->company_id = Yii::$app->user->identity->id;
$modelHistory->fullname = $original_fullname;
$modelHistory->ic_no = $original_ic_no;
$modelHistory->gender = $original_gender;
$modelHistory->race = $original_race;
$modelHistory->mobile_no = $original_mobile_no;
$modelHistory->email = $original_email;
$modelHistory->created_date = date("Y-m-d H:i:s");
$modelHistory->save();
//insert into staff
$modelStaff = new Staff();
$modelStaff->staff_name = $model->fullname;
$modelStaff->staff_ic_no = $model->ic_no;
$modelStaff->staff_gender = $model->gender;
$modelStaff->staff_race = $model->race;
$modelStaff->staff_tel = $model->mobile_no;
$modelStaff->staff_email = $model->email;
$modelStaff->staff_position = 'PEMILIK SYARIKAT';
$modelStaff->created_at = date("Y-m-d H:i:s");
$modelStaff->created_by = Yii::$app->user->identity->id;
$modelStaff->created_user_type = 'frontend_user';
$modelStaff->staff_company_id = Yii::$app->user->identity->id;
$modelStaff->uuid = (new \yii\db\Query)->select(new \yii\db\Expression('UUID()'))->scalar();
$modelStaff->save(false);
echo "<script>
Swal.fire({
icon: 'success',
title: 'Berjaya',
text: 'Maklumat pemilik telah dikemaskini',
}).then((result) => {
window.location.href = '".$baseUrl."/portal-main/view-profile';
});
</script>";
}
}
$form = ActiveForm::begin();
//echo $form->errorSummary($model);
echo '<style>.form-group{margin-bottom:1em;}</style>
<div class="page-title-box d-flex align-items-center justify-content-between">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="/portal-main/dashboard">Utama</a></li>
<li class="breadcrumb-item active">Tukar Pemilik</li>
</ol>
</div>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-sm-6">'.$form->field($model, 'fullname')->textInput(['class'=>'form-control']).'</div>
<div class="col-sm-6">
'.$form->field($model, 'ic_no')->textInput(['class'=>'form-control','placeholder'=>'Contoh : 880101-01-1234']).'
<p class="text-muted">Masukkan No. Kad Pengenalan dengan " - " Contoh : 880101-01-1234</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">'.$form->field($model, 'gender')->dropdownList(
ArrayHelper::map(\backend\modules\refdynawebv2\models\Ref::find()
->where(['cat' => 'GENDER'])
->orderBy(['descr' => SORT_ASC])->all(), 'code', 'descr'), [
'class' => 'select2','prompt'=>'-- Sila pilih --']).'</div>
<div class="col-sm-6">'.$form->field($model, 'race')->dropdownList(
ArrayHelper::map(\backend\modules\refdynawebv2\models\Ref::find()
->where(['cat' => 'RACE'])
->orderBy(['sort' => SORT_ASC])->all(), 'code', 'descr'), [
'class' => 'select2','prompt'=>'-- Sila pilih --']).'</div>
</div>
<div class="row">
<div class="col-sm-6">'.$form->field($model, 'mobile_no')->textInput(['class'=>'form-control']).'</div>
<div class="col-sm-6">'.$form->field($model, 'email')->textInput(['class'=>'form-control']).'</div>
</div>
</div>
</div>';
echo Html::a(Yii::t('app', 'Batal'), ['portal-main/view-profile'], ['class' => 'btn btn-outline-primary waves-effect waves-light']);
echo ' ';
echo Html::submitButton(Yii::t('app', 'Simpan'), ['class' => 'btn btn-primary waves-effect waves-light']).'<br><br>';
ActiveForm::end();
}
?>