Commit 31aafaee by Wittaya-PIM

Merge branch 'integration' into wittaya

parents dece6e4b 0ae6c106
......@@ -51,6 +51,7 @@ class ProfilesController extends AppController
if ($this->request->is(['patch', 'post', 'put'])) {
$data = $this->request->data;
// pr($this->request->data);die;
$this->loadModel('UserPersonals');
$userPersonals = $this->UserPersonals->find('all',
......@@ -60,13 +61,35 @@ class ProfilesController extends AppController
'user_id' => $data['Users']['user_id']
]
]
)->first();
// pr($userPersonals);die;
if($userPersonals['email'] == $this->request->data['UserPersonals']['email']){
$chkemail = true;
}else{
$userPersonals = $this->UserPersonals->find('all',
[
'limit' => 1,
'conditions' => [
'email' => $data['UserPersonals']['email']
]
]
)->toArray();
if(empty($userPersonals)){
$chkemail = true;
}else{
$chkemail = false;
}
}
if($chkemail == true){
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
$userPersonals = $this->UserPersonals->patchEntity($userPersonals[0], $data['UserPersonals']);
$userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
$userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th'];
$userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th'];
$userPersonals['email'] = $this->request->data['UserPersonals']['email'];
$userPersonals['birthdate'] = $birthdate;
$userPersonals['user_id'] = $data['Users']['user_id'];
$userPersonals['master_country_id'] = $this->request->data['master_country_id'];
......@@ -74,10 +97,13 @@ class ProfilesController extends AppController
$userPersonals['modified_by'] = '';
if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('The article has been saved.'));
$this->Flash->success(__('Update Complete.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The article could not be saved. Please, try again.'));
}else{
$this->Flash->error(__('Email Address already used by others.'));
}
$this->Flash->error(__('Not update. Please, try again.'));
}
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']);
......
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->create('UserProfiles', ['id' => 'frmSignIn', 'type' => 'file']); ?>
<div style="position: absolute;z-index: 2;">
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
</div>
......@@ -17,6 +17,12 @@
</div>
<div class="bg-profile"></div>
<!--<div class="col-xs-12 col-sm-12 col-md-12" style="padding-top: 20px;">-->
</div><!--/col-xs-12-->
</div><!--/row-->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->create('UserProfiles', ['id' => 'frmSignIn', 'type' => 'file']); ?>
<?php echo $this->Flash->render() ?>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->hidden('Users.user_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['id'], 'id' => 'userId', 'type' => 'text', 'label' => __('ชื่อผู้ใช้งาน'), 'placeholder' => 'USERNAME']); ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment