mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'bug/profile' into 'main'
Arreglado el bug, habia parametros de mas en el metodo store( See merge request jjimenez/safekat!195
This commit is contained in:
@ -30,165 +30,120 @@ class Profile extends BaseController
|
|||||||
|
|
||||||
$data['title'] = [
|
$data['title'] = [
|
||||||
'module' => lang("App.profile_title"),
|
'module' => lang("App.profile_title"),
|
||||||
'page' => lang("App.profile_subtitle"),
|
'page' => lang("App.profile_subtitle"),
|
||||||
'icon' => 'fas fa-user'
|
'icon' => 'fas fa-user'
|
||||||
];
|
];
|
||||||
|
|
||||||
$data['breadcrumb'] = [
|
$data['breadcrumb'] = [
|
||||||
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
['title' => lang("App.menu_dashboard"), 'route' => "/home", 'active' => false],
|
||||||
['title' => lang("App.profile_title"), 'route' => "", 'active' => true]
|
['title' => lang("App.profile_title"), 'route' => "", 'active' => true]
|
||||||
];
|
];
|
||||||
|
|
||||||
$data['btn_return'] = [
|
$data['btn_return'] = [
|
||||||
'title' => lang("App.global_come_back"),
|
'title' => lang("App.global_come_back"),
|
||||||
'route' => '/',
|
'route' => '/',
|
||||||
'class' => 'btn btn-dark mr-1',
|
'class' => 'btn btn-dark mr-1',
|
||||||
'icon' => 'fas fa-angle-left'
|
'icon' => 'fas fa-angle-left'
|
||||||
];
|
];
|
||||||
|
|
||||||
$data['btn_submit'] = [
|
$data['btn_submit'] = [
|
||||||
'title' => lang("App.global_save"),
|
'title' => lang("App.global_save"),
|
||||||
'route' => '',
|
'route' => '',
|
||||||
'class' => 'btn btn-primary mr-1',
|
'class' => 'btn btn-primary mr-1',
|
||||||
'icon' => 'fas fa-save'
|
'icon' => 'fas fa-save'
|
||||||
];
|
];
|
||||||
|
|
||||||
$session = session();
|
$session = session();
|
||||||
|
|
||||||
$data['obj'] = $this->user_model->where('id_user',$this->id_user)->first();
|
$data['obj'] = $this->user_model->where('id_user', $this->id_user)->first();
|
||||||
|
|
||||||
if(!empty($data['obj']->date_birth)){
|
if (!empty($data['obj']->date_birth)) {
|
||||||
$data['obj']->date_birth = dateFormatWeb($data['obj']->date_birth);
|
$data['obj']->date_birth = dateFormatWeb($data['obj']->date_birth);
|
||||||
}
|
}
|
||||||
$data['country'] = $this->countries_model->select('code,name')->where('data_lang',session()->get('lang')??'en')->findAll();
|
$data['country'] = $this->countries_model->select('code,name')->where('data_lang', session()->get('lang') ?? 'en')->findAll();
|
||||||
|
|
||||||
$file = $this->request->getFile('file');
|
$file = $this->request->getFile('file');
|
||||||
if(!empty($file)){
|
if (!empty($file)) {
|
||||||
$integration = new Integration();
|
$integration = new Integration();
|
||||||
$allow = ['jpeg','jpg','gif','bmp','png'];
|
$allow = ['jpeg', 'jpg', 'gif', 'bmp', 'png'];
|
||||||
$path = 'assets/img/';
|
$path = 'assets/img/';
|
||||||
$pathRet = '/'.$integration->saveStorage($file,$path,$allow);
|
$pathRet = '/' . $integration->saveStorage($file, $path, $allow);
|
||||||
if(!empty($pathRet)){
|
if (!empty($pathRet)) {
|
||||||
$this->user_model->save([
|
$this->user_model->save([
|
||||||
'id_user' => $this->id_user,
|
'id_user' => $this->id_user,
|
||||||
'picture' => $pathRet
|
'picture' => $pathRet
|
||||||
]);
|
]);
|
||||||
$data['obj']['picture'] = $pathRet;
|
$data['obj']['picture'] = $pathRet;
|
||||||
$session->set('picture',$pathRet);
|
$session->set('picture', $pathRet);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if(!empty($this->request->getPost())){
|
if (!empty($this->request->getPost())) {
|
||||||
$post = $this->request->getPost();
|
$post = $this->request->getPost();
|
||||||
$image = '';
|
$image = '';
|
||||||
foreach ($post as $key=>$value){
|
foreach ($post as $key => $value) {
|
||||||
if(strpos($key, 'image') !== false){
|
if (strpos($key, 'image') !== false) {
|
||||||
$image = $value;
|
$image = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!empty($image)){
|
if (!empty($image)) {
|
||||||
$this->user_model->save([
|
$this->user_model->save([
|
||||||
'id_user' => $this->id_user,
|
'id_user' => $this->id_user,
|
||||||
'picture' => $image
|
'picture' => $image
|
||||||
]);
|
]);
|
||||||
$data['obj']['picture'] = $image;
|
$data['obj']['picture'] = $image;
|
||||||
$session->set('picture',$image);
|
$session->set('picture', $image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo view(getenv('theme.path').'form/profile/index', $data);
|
echo view(getenv('theme.path') . 'form/profile/index', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
|
|
||||||
//Demo Mode
|
|
||||||
if(env('demo.mode')??false){
|
|
||||||
session()->setFlashdata('sweet', ['warning',lang("App.general_demo_mode")]);
|
|
||||||
return redirect()->to('/profile');
|
|
||||||
}
|
|
||||||
|
|
||||||
$session = session();
|
$session = session();
|
||||||
helper('form');
|
helper('form');
|
||||||
|
|
||||||
$password = 'max_length[35]';
|
|
||||||
$confirm_password = 'max_length[35]';
|
|
||||||
|
|
||||||
if(!empty($this->request->getPost('password'))){
|
|
||||||
$password = 'required|min_length[8]';
|
|
||||||
$confirm_password = 'matches[password]';
|
|
||||||
}
|
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
'last_name' => 'required',
|
'last_name' => 'required',
|
||||||
'password' => $password,
|
|
||||||
'confirm_password' => $confirm_password
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$rules_error = [
|
$rules_error = [
|
||||||
'first_name' => ['required' => lang("App.profile_rules_first_name_r")],
|
'first_name' => ['required' => lang("App.profile_rules_first_name_r")],
|
||||||
'last_name' => ['required' => lang("App.profile_rules_last_name_r")],
|
'last_name' => ['required' => lang("App.profile_rules_last_name_r")],
|
||||||
'password' => [
|
|
||||||
'required' => lang("App.profile_rules_password_r"),
|
|
||||||
'min_length' => lang("App.profile_rules_password_m")
|
|
||||||
],
|
|
||||||
'confirm_password' => ['matches' => lang("App.profile_rules_password_confirm_m")]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if(empty($this->request->getPost('tfa_secret'))){
|
|
||||||
if ($this->validate($rules??[],$rules_error??[])){
|
|
||||||
if(!empty($this->id_user)){
|
|
||||||
$date_birth = !empty($this->request->getPost('date_birth')??'') ? dateFormatMysql($this->request->getPost('date_birth')):null;
|
|
||||||
$this->user_model->save([
|
|
||||||
'id_user' => $this->id_user,
|
|
||||||
'first_name' => $this->request->getPost('first_name'),
|
|
||||||
'last_name' => $this->request->getPost('last_name'),
|
|
||||||
'date_birth' => $date_birth,
|
|
||||||
'address' => $this->request->getPost('address'),
|
|
||||||
'city' => $this->request->getPost('city'),
|
|
||||||
'state' => $this->request->getPost('state'),
|
|
||||||
'country' => $this->request->getPost('country'),
|
|
||||||
'zip_code' => $this->request->getPost('zip_code'),
|
|
||||||
'mobile' => $this->request->getPost('mobile'),
|
|
||||||
'language' => $this->request->getPost('language')
|
|
||||||
]);
|
|
||||||
$session->set('lang', $this->request->getPost('language') ?? 'en');
|
|
||||||
if(!empty($this->request->getPost('password'))){
|
|
||||||
$phpass = new PasswordHash(8, true);
|
|
||||||
$this->user_model->save([
|
|
||||||
'id_user' => $this->id_user,
|
|
||||||
'password' => $phpass->HashPassword($this->request->getPost('password')),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$session->setFlashdata('sweet', ['success',lang("App.global_alert_save_success")]);
|
|
||||||
}else{
|
|
||||||
$session->setFlashdata('sweet', ['error',lang("App.global_alert_save_error")]);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
|
|
||||||
$session->setFlashdata('error','error');
|
if ($this->validate($rules ?? [], $rules_error ?? [])) {
|
||||||
return $this->index();
|
if (!empty($this->id_user)) {
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if($this->request->getPost('tfa') == 'on'){
|
|
||||||
$this->user_model->save([
|
$this->user_model->save([
|
||||||
'id_user' => $this->id_user,
|
'id_user' => $this->id_user,
|
||||||
'tfa' => true,
|
'first_name' => $this->request->getPost('first_name'),
|
||||||
'tfa_secret' => $this->request->getPost('tfa_secret'),
|
'last_name' => $this->request->getPost('last_name'),
|
||||||
'tfa_code' => $this->request->getPost('tfa_code')
|
'address' => $this->request->getPost('address'),
|
||||||
]);
|
'city' => $this->request->getPost('city'),
|
||||||
}else{
|
'state' => $this->request->getPost('state'),
|
||||||
$this->user_model->save([
|
'country' => $this->request->getPost('country'),
|
||||||
'id_user' => $this->id_user,
|
'mobile' => $this->request->getPost('mobile'),
|
||||||
'tfa' => false,
|
'language' => $this->request->getPost('language')
|
||||||
'tfa_secret' => '',
|
|
||||||
'tfa_code' => ''
|
|
||||||
]);
|
]);
|
||||||
|
$session->set('lang', $this->request->getPost('language') ?? 'en');
|
||||||
|
$session->setFlashdata('sweet', ['success', lang("App.global_alert_save_success")]);
|
||||||
|
} else {
|
||||||
|
$session->setFlashdata('sweet', ['error', lang("App.global_alert_save_error")]);
|
||||||
}
|
}
|
||||||
$session->setFlashdata('sweet', ['success',lang("App.global_alert_save_success")]);
|
} else {
|
||||||
|
|
||||||
|
$session->setFlashdata('error', 'error');
|
||||||
|
return $this->index();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return redirect()->to('/profile');
|
return redirect()->to('/profile');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,20 +88,9 @@
|
|||||||
value="<?= (isset($obj)) ? $obj->email : set_value('email'); ?>"
|
value="<?= (isset($obj)) ? $obj->email : set_value('email'); ?>"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 col-md-6">
|
|
||||||
<label for="organization" class="form-label">Organization</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="form-control"
|
|
||||||
id="organization"
|
|
||||||
name="organization"
|
|
||||||
value="Pixinvent"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3 col-md-6">
|
<div class="mb-3 col-md-6">
|
||||||
<label class="form-label" for="mobile"><?= lang("App.profile_mobile") ?></label>
|
<label class="form-label" for="mobile"><?= lang("App.profile_mobile") ?></label>
|
||||||
<div class="input-group input-group-merge">
|
<div class="input-group input-group-merge">
|
||||||
<span class="input-group-text">US (+1)</span>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="mobile"
|
id="mobile"
|
||||||
@ -162,7 +151,6 @@
|
|||||||
<option value=""><?= lang("App.global_select") ?></option>
|
<option value=""><?= lang("App.global_select") ?></option>
|
||||||
<option value="en" <?= $id_select == "en" ? 'selected' : '' ?>><?= lang("App.lang_en") ?></option>
|
<option value="en" <?= $id_select == "en" ? 'selected' : '' ?>><?= lang("App.lang_en") ?></option>
|
||||||
<option value="es" <?= $id_select == "es" ? 'selected' : '' ?>><?= lang("App.lang_es") ?></option>
|
<option value="es" <?= $id_select == "es" ? 'selected' : '' ?>><?= lang("App.lang_es") ?></option>
|
||||||
<option value="pt" <?= $id_select == "pt" ? 'selected' : '' ?>><?= lang("App.lang_pt") ?></option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -175,7 +163,7 @@
|
|||||||
<!-- /Account -->
|
<!-- /Account -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<!-- <div class="card">
|
||||||
<h5 class="card-header">Delete Account</h5>
|
<h5 class="card-header">Delete Account</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="mb-3 col-12 mb-0">
|
<div class="mb-3 col-12 mb-0">
|
||||||
@ -199,7 +187,7 @@
|
|||||||
<button type="submit" class="btn btn-danger deactivate-account">Deactivate Account</button>
|
<button type="submit" class="btn btn-danger deactivate-account">Deactivate Account</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -295,10 +283,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#first_name').focus();
|
$('#first_name').focus();
|
||||||
$('#date_birth').bootstrapMaterialDatePicker({
|
|
||||||
format: '<?=momentDateJS()?>',
|
|
||||||
time: false
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
$('.file-upload').on('click', function (e) {
|
$('.file-upload').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user