Commit 1cf54a6a by Teeradone-PIM

teeradone 23/5/2561

parent 7e963e6a
...@@ -28,7 +28,6 @@ class ProfilesController extends AppController ...@@ -28,7 +28,6 @@ class ProfilesController extends AppController
'user_id' => $id ] 'user_id' => $id ]
])->first(); ])->first();
//********DropdownCountry******** //********DropdownCountry********
$this->loadModel('MasterCountries'); $this->loadModel('MasterCountries');
$Country = $this->MasterCountries->find('list', [ $Country = $this->MasterCountries->find('list', [
...@@ -56,7 +55,7 @@ class ProfilesController extends AppController ...@@ -56,7 +55,7 @@ class ProfilesController extends AppController
$dateNow = $res->i18nFormat('dd/MM/yyyy'); $dateNow = $res->i18nFormat('dd/MM/yyyy');
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
// pr($this->request->data());die; // pr($this->request->data['email']);die;
$data = $this->request->data; $data = $this->request->data;
...@@ -70,22 +69,26 @@ class ProfilesController extends AppController ...@@ -70,22 +69,26 @@ class ProfilesController extends AppController
] ]
] ]
)->first(); )->first();
// pr($this->request->data['email']);die;
if($userPersonals['email'] == $this->request->data['UserPersonals']['email']){ if($userPersonals['email'] == $this->request->data['email']){
$chkemail = true; $chkemail = true;
}else{ }else{
$userPersonals = $this->UserPersonals->find('all', $useremails = $this->UserPersonals->find('all',
[ [
'limit' => 1, 'limit' => 1,
'conditions' => [ 'conditions' => [
'email' => $data['UserPersonals']['email'] 'email' => $data['email']
] ]
] ]
)->toArray(); )->first();
if(empty($userPersonals)){ if(empty($useremails)){
$chkemail = true; $chkemail = true;
// pr('true');die;
}else{ }else{
// pr('false');die;
$chkemail = false; $chkemail = false;
} }
} }
...@@ -94,16 +97,19 @@ class ProfilesController extends AppController ...@@ -94,16 +97,19 @@ class ProfilesController extends AppController
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']); $birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0]; $birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
// pr($userPersonals);die;
$userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']); // $userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
$userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th']; $userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th'];
$userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th']; $userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th'];
$userPersonals['email'] = $this->request->data['UserPersonals']['email']; $userPersonals['email'] = $this->request->data['email'];
$userPersonals['birthdate'] = $birthdate; $userPersonals['birthdate'] = $birthdate;
$userPersonals['user_id'] = $data['Users']['user_id']; $userPersonals['user_id'] = $data['Users']['user_id'];
$userPersonals['master_country_id'] = $this->request->data['master_country_id']; $userPersonals['master_country_id'] = $this->request->data['master_country_id'];
$userPersonals['master_province_id'] = $this->request->data['master_province_id']; $userPersonals['master_province_id'] = $this->request->data['master_province_id'];
$userPersonals['modified_by'] = $id; $userPersonals['modified_by'] = $id;
// $userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
$userPersonals = $this->Users->patchEntity($userPersonals, $this->request->getData());
// pr($userPersonals);die;
if ($this->UserPersonals->save($userPersonals)) { if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('Update Complete.')); $this->Flash->success(__('Update Complete.'));
...@@ -115,7 +121,7 @@ class ProfilesController extends AppController ...@@ -115,7 +121,7 @@ class ProfilesController extends AppController
$this->Flash->error(__('Not update. Please, try again.')); $this->Flash->error(__('Not update. Please, try again.'));
} }
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal')); $this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']); $this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal']);
} }
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -120,8 +120,10 @@ ...@@ -120,8 +120,10 @@
</div> </div>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12"> <div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserPersonals.email', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $responseUserPersonal['email'], 'id' => 'email', 'label' => __('Email'), 'placeholder' => 'mail@xxx.com']); ?> <!-- <?php echo $this->Form->input('UserPersonals.email', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $responseUserPersonal['email'], 'id' => 'email', 'label' => __('Email'), 'placeholder' => 'mail@xxx.com']); ?> -->
<?php // echo $this->Form->input('email', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->email, 'id' => 'email', 'type' => 'email', 'label' => __('Email'), 'placeholder' => 'mail@xxx.com']); ?> <?php // echo $this->Form->input('email', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->email, 'id' => 'email', 'type' => 'email', 'label' => __('Email'), 'placeholder' => 'mail@xxx.com']); ?>
<label class="label-text-sub" style="font-size: 14px"><?php echo __('อีเมลล์');?></label>
<input type="text" name="email" id="email" value="<?php echo $responseUserPersonal['email'] ?>" placeholder="mail@xxx.com" class="form-control-reg border-bottom-from">
</div> </div>
</div> </div>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
...@@ -440,7 +442,7 @@ ...@@ -440,7 +442,7 @@
<!-- <?php $this->append('scriptBottom'); ?> <?php $this->append('scriptBottom'); ?>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#moblieNo').inputmask('999-999-9999'); $('#moblieNo').inputmask('999-999-9999');
...@@ -509,4 +511,4 @@ ...@@ -509,4 +511,4 @@
.box-ads .close-modal:hover{ .box-ads .close-modal:hover{
text-decoration: none; text-decoration: none;
} }
</style> --> </style>
\ No newline at end of file \ No newline at end of file
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<div class="col-md-12"> <div class="col-md-12">
<label class="label-text-sub"><?php echo __('เบอร์โทรศัพท์');?><em>* </em></label> <label class="label-text-sub"><?php echo __('เบอร์โทรศัพท์');?><em>* </em></label>
<input type="text" name="phone_no" id="phone_no" onkeypress="check_phone();" value="" maxlength="10" placeholder="000-000-0000" class="mask form-control-reg border-bottom-from"> <input type="text" name="phone_no" id="phone_no" onkeypress="check_phone();" value="" maxlength="12" placeholder="000-000-0000" class="mask form-control-reg border-bottom-from">
</div> </div>
</div> </div>
</div> </div>
...@@ -164,6 +164,17 @@ ...@@ -164,6 +164,17 @@
</div> </div>
</div> </div>
<!-- ------------------------------- popup ----------------------------------- --> <!-- ------------------------------- popup ----------------------------------- -->
<script type="text/javascript">
$(function () {
$('#phone_no').inputmask('999-999-9999');
//==================================================
// CHANGE Date Times
//==================================================
$('#datepicker').datepicker({
format: 'dd/mm/yyyy'
});
});
</script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
...@@ -224,7 +235,7 @@ ...@@ -224,7 +235,7 @@
alert("กรุณากรอก เบอร์โทรศัพท์ของท่าน"); alert("กรุณากรอก เบอร์โทรศัพท์ของท่าน");
return false; return false;
} }
if(document.getElementById("phone_no").value.length < 10 || document.getElementById("phone_no").value.length > 10) if(document.getElementById("phone_no").value.length != 12)
{ {
alert('กรุณากรอกเบอร์โทรศัพท์ ให้ครบ 10 หลัก'); alert('กรุณากรอกเบอร์โทรศัพท์ ให้ครบ 10 หลัก');
return false; return false;
......
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