Commit 57aea8b6 by Wittaya-PIM

Merge branch 'integration' into wittaya

parents f8f3329a 32e0c1de
......@@ -14,7 +14,7 @@ class ProfilesController extends AppController
/*******************************/
$id = $this->Auth->user('id');
$id = $this->Auth->user('id');
$this->loadModel('Users');
$responseUserProfile = $this->Users->get($id, [
......@@ -28,6 +28,7 @@ class ProfilesController extends AppController
'user_id' => $id ]
])->first();
//********DropdownCountry********
$this->loadModel('MasterCountries');
$Country = $this->MasterCountries->find('list', [
......@@ -46,8 +47,8 @@ class ProfilesController extends AppController
'keyField' => 'id',
'valueField' => 'province_name_th'
])
->where(['master_country_id =' => $responseUserPersonal['master_country_id']])
->order(['province_name_th']);
->where(['master_country_id =' => $responseUserPersonal['master_country_id']])
->order(['province_name_th']);
// pr($Province);die;
if(!empty($Province)) $Province = $Province->toArray();
......@@ -55,8 +56,6 @@ class ProfilesController extends AppController
$dateNow = $res->i18nFormat('dd/MM/yyyy');
if ($this->request->is(['patch', 'post', 'put'])) {
// pr($this->request->data['email']);die;
$data = $this->request->data;
// pr($this->request->data);die;
......@@ -97,8 +96,8 @@ class ProfilesController extends AppController
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
// pr($userPersonals);die;
// $userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
// pr($userPersonals);die;
$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['email'];
......@@ -107,9 +106,7 @@ class ProfilesController extends AppController
$userPersonals['master_country_id'] = $this->request->data['master_country_id'];
$userPersonals['master_province_id'] = $this->request->data['master_province_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)) {
$this->Flash->success(__('Update Complete.'));
......
......@@ -306,7 +306,6 @@ class UserCardsController extends AppController
$userCard['user_id'] = $this->Auth->user('id');
// pr($userCard);die;
if ($this->UserCards->save($userCard)) {
// pr('sdsd');die;
$TempUserCards['is_used'] = 0;
$this->TempUserCards->save($TempUserCards);
$this->loadModel('UserEntities');
......
......@@ -117,12 +117,13 @@ class UsersController extends AppController {
'keyField' => 'id',
'valueField' => 'province_name_th'
]
);
);
if(!empty($provinces)) $provinces = $provinces->toArray();
$this->set(compact('provinces','countries'));
$this->viewBuilder()->layout('blank');
}
$this->viewBuilder()->layout('blank');
}
#---------------------------------------------------------------------------------------------------
#Signup
......@@ -399,33 +400,36 @@ class UsersController extends AppController {
]
])->first();
if ($this->request->is('post')) {
$hasher = new DefaultPasswordHasher();
$password = $this->request->data['password'];
$confirm_password = $this->request->data['confirm_password'];
$oldpassword = $this->request->data['oldpassword'];
$this->request->data['password'] = $hasher->hash($this->request->data['password']);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if (password_verify($oldpassword, $users['password'])) {
$users = $this->Users->patchEntity($users, $this->request->getData());
$this->Users->save($users);
$this->Flash->success(__('change password success'));
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')));
}
#---------------------------------------------------------------------------------------------------
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 @@
'id' => 'master_country_id',
'label' => false,
'type' => 'select',
'require'=>'require',
'options' => $Country,
'value' => $responseUserPersonal['master_country_id'],
'empty' => '---Select---',
'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%'
));
?>
......@@ -158,11 +159,12 @@
'id' => 'master_province_id',
'label' => false,
'type' => 'select',
'require'=>'require',
'options' => $Province,
'value' => $responseUserPersonal['master_province_id'],
'empty' => '---Select---',
'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%'
));
?>
......@@ -270,6 +272,16 @@
// 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 () {
$('.is_active').not(this).prop('checked', false);
......
......@@ -11,7 +11,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<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>
......@@ -20,7 +20,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<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>
......@@ -29,7 +29,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<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>
......@@ -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() {
var firstname = document.getElementById("firstname").value;
......@@ -489,14 +504,14 @@
<script>
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_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("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
// }
// }
/*var check = function() {
if (document.getElementById('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