Commit 57aea8b6 by Wittaya-PIM

Merge branch 'integration' into wittaya

parents f8f3329a 32e0c1de
...@@ -28,6 +28,7 @@ class ProfilesController extends AppController ...@@ -28,6 +28,7 @@ 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', [
...@@ -55,8 +56,6 @@ class ProfilesController extends AppController ...@@ -55,8 +56,6 @@ 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['email']);die;
$data = $this->request->data; $data = $this->request->data;
// pr($this->request->data);die; // pr($this->request->data);die;
...@@ -98,7 +97,7 @@ class ProfilesController extends AppController ...@@ -98,7 +97,7 @@ 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; // 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['email']; $userPersonals['email'] = $this->request->data['email'];
...@@ -107,8 +106,6 @@ class ProfilesController extends AppController ...@@ -107,8 +106,6 @@ class ProfilesController extends AppController
$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; // pr($userPersonals);die;
if ($this->UserPersonals->save($userPersonals)) { if ($this->UserPersonals->save($userPersonals)) {
......
...@@ -306,7 +306,6 @@ class UserCardsController extends AppController ...@@ -306,7 +306,6 @@ class UserCardsController extends AppController
$userCard['user_id'] = $this->Auth->user('id'); $userCard['user_id'] = $this->Auth->user('id');
// pr($userCard);die; // pr($userCard);die;
if ($this->UserCards->save($userCard)) { if ($this->UserCards->save($userCard)) {
// pr('sdsd');die;
$TempUserCards['is_used'] = 0; $TempUserCards['is_used'] = 0;
$this->TempUserCards->save($TempUserCards); $this->TempUserCards->save($TempUserCards);
$this->loadModel('UserEntities'); $this->loadModel('UserEntities');
......
...@@ -123,6 +123,7 @@ class UsersController extends AppController { ...@@ -123,6 +123,7 @@ class UsersController extends AppController {
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
} }
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
#Signup #Signup
...@@ -399,35 +400,38 @@ class UsersController extends AppController { ...@@ -399,35 +400,38 @@ class UsersController extends AppController {
] ]
])->first(); ])->first();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$hasher = new DefaultPasswordHasher(); $hasher = new DefaultPasswordHasher();
$password = $this->request->data['password']; $password = $this->request->data['password'];
$confirm_password = $this->request->data['confirm_password']; $confirm_password = $this->request->data['confirm_password'];
$oldpassword = $this->request->data['oldpassword'];
$this->request->data['password'] = $hasher->hash($this->request->data['password']); $this->request->data['password'] = $hasher->hash($this->request->data['password']);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)--------------------------- //------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if (password_verify($oldpassword, $users['password'])) {
$users = $this->Users->patchEntity($users, $this->request->getData()); $users = $this->Users->patchEntity($users, $this->request->getData());
$this->Users->save($users); $this->Users->save($users);
$this->Flash->success(__('change password success')); $this->Flash->success(__('change password success'));
return $this->redirect(['action' => 'signin']); return $this->redirect(['action' => 'signin']);
} else {
$this->Flash->error(__('Invalid password.'));
return $this->redirect(['action' => 'change-password/'.$token]);
}
} }
$this->set(array('token' => $token, '_serialize' => array('token'))); $this->set(array('token' => $token, '_serialize' => array('token')));
} }
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
public function signout() /**
{ *
$this->checkToken(); * Function user logout / signout
* @author sarawutt.b
* @since 2018/05/22 16:44:20
* @license PAKGON
* @return void
*/
public function signout() {
$http = new Client();
$result = $http->delete(Configure::read('OAUTH2_PROVIDER.TOKEN_DETETE') . '/' . $this->Auth->user('id'))->body();
$this->Flash->success(__('You are now logged out.'));
return $this->redirect($this->Auth->logout());
} }
} }
...@@ -140,11 +140,12 @@ ...@@ -140,11 +140,12 @@
'id' => 'master_country_id', 'id' => 'master_country_id',
'label' => false, 'label' => false,
'type' => 'select', 'type' => 'select',
'require'=>'require',
'options' => $Country, 'options' => $Country,
'value' => $responseUserPersonal['master_country_id'], 'value' => $responseUserPersonal['master_country_id'],
'empty' => '---Select---', 'empty' => '---Select---',
'default' => !empty($responseUserPersonal['master_country_id'])? $responseUserPersonal['master_country_id']:'', 'default' => !empty($responseUserPersonal['master_country_id'])? $responseUserPersonal['master_country_id']:'',
'class' => 'form-control border-bottom-from label-text-sub', 'class' => 'form-control border-bottom-from label-text-sub require',
'style' => 'width:100%' 'style' => 'width:100%'
)); ));
?> ?>
...@@ -158,11 +159,12 @@ ...@@ -158,11 +159,12 @@
'id' => 'master_province_id', 'id' => 'master_province_id',
'label' => false, 'label' => false,
'type' => 'select', 'type' => 'select',
'require'=>'require',
'options' => $Province, 'options' => $Province,
'value' => $responseUserPersonal['master_province_id'], 'value' => $responseUserPersonal['master_province_id'],
'empty' => '---Select---', 'empty' => '---Select---',
'default' => !empty($responseUserPersonal['master_province_id'])? $responseUserPersonal['master_province_id']:'', 'default' => !empty($responseUserPersonal['master_province_id'])? $responseUserPersonal['master_province_id']:'',
'class' => 'form-control border-bottom-from label-text-sub', 'class' => 'form-control border-bottom-from label-text-sub require',
'style' => 'width:100%' 'style' => 'width:100%'
)); ));
?> ?>
...@@ -270,6 +272,16 @@ ...@@ -270,6 +272,16 @@
// return false; // return false;
// } // }
// }); // });
var master_country_id = document.getElementById("master_country_id").value;
if (master_country_id == null || master_country_id == "") {
alert("กรุณาระบุประเทศ");
return false;
}
var master_province_id = document.getElementById("master_province_id").value;
if (master_province_id == null || master_province_id == "") {
alert("กรุณาระบุจังหวัด");
return false;
}
$("body").delegate(".is_active", "click", function () { $("body").delegate(".is_active", "click", function () {
$('.is_active').not(this).prop('checked', false); $('.is_active').not(this).prop('checked', false);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,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="firstname" id="firstname" value="" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from"> <input type="text" name="firstname" id="firstname" value="" onkeypress="check_notnum();" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from">
</div> </div>
</div> </div>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,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="lastname" id="lastname" value="" placeholder="LASTNAME" class="form-control-reg border-bottom-from"> <input type="text" name="lastname" id="lastname" value="" onkeypress="check_notnum();" placeholder="LASTNAME" class="form-control-reg border-bottom-from">
</div> </div>
</div> </div>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,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="username" id="username" value="" placeholder="USERNAME" class="form-control-reg border-bottom-from"> <input type="text" name="username" id="username" value="" onkeypress="check_notnum();" placeholder="USERNAME" class="form-control-reg border-bottom-from">
</div> </div>
</div> </div>
...@@ -190,6 +190,21 @@ ...@@ -190,6 +190,21 @@
}); });
}); });
}); });
function check_phone() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
}
}
function check_notnum() {
e_k=event.keyCode
if ((e_k== 13 || e_k== 110) && (e_k > 48) || (e_k< 57)) {
event.returnValue = false;
alert("ข้อมูลผิดพลาด กรุณาใส่ข้อมูลที่เป็นตัวอักษรภาษาไทย [ก-ฮ] หรือภาษาอังกฤษให้ถูกต้อง");
}
}
function validateForm() { function validateForm() {
var firstname = document.getElementById("firstname").value; var firstname = document.getElementById("firstname").value;
...@@ -489,14 +504,14 @@ ...@@ -489,14 +504,14 @@
<script> <script>
function check_phone() { // function check_phone() {
e_k=event.keyCode // e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) { // //if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 10 && (e_k < 48) || (e_k > 57)) { // if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false; // event.returnValue = false;
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น"); // alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
} // }
} // }
/*var check = function() { /*var check = function() {
if (document.getElementById('password').value == if (document.getElementById('password').value ==
document.getElementById('confirm_password').value) { document.getElementById('confirm_password').value) {
......
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