Commit fe787816 by Teeradone-PIM

Merge branch 'teeradone' into integration

parents f0730d60 7a1d7643
......@@ -18,7 +18,7 @@ class UsersController extends AppController {
*/
public function initialize() {
parent::initialize();
$this->Auth->allow(['signin', 'signout', 'signup', 'verify','forgotPassword','createAccount','pinCode','pinCodepassword','changeForgotpassword']);
$this->Auth->allow(['signin', 'signout', 'signup', 'verify','forgotPassword','createAccount','pinCode','pinCodepassword','registersendpin','forgotsendpin','changeForgotpassword']);
}
public function index() {
......@@ -440,6 +440,65 @@ class UsersController extends AppController {
return $this->redirect($this->Auth->logout());
}
public function forgotsendpin($token=null) {
$this->loadModel('UserPersonals');
$users = $this->Users->find('all',[
'conditions'=>[
'Users.token'=>$token
]
])->first();
$digits = 4;
$users['pin_pass'] = str_pad(rand(0, pow(10, $digits)-1), $digits, '0', STR_PAD_LEFT);
$user_personals = $this->UserPersonals->find('all',[
'conditions'=>[
'UserPersonals.user_id'=>$users['id']
]
])->first();
//--------------------ตัวส่ง Email ---------------------------------------------------------
//pr($user_personals);die;
$data_notification = [];
$data_notification['email'] = $user_personals['email'];
$data_notification['pin_code'] = $users['pin_pass'].'<br>'." Username: ".$users['username'];
$this->notification($data_notification);
//----------------------------------------------------------------------------------------
if($this->Users->save($users)){
$this->Flash->success(__('send pin success.'));
return $this->redirect(['action' => 'pin_codepassword/'.$token]);
}
$this->Flash->success(__('send pin false.'));
return $this->redirect(['action' => 'pin_codepassword/'.$token]);
}
public function registersendpin($token=null) {
$this->loadModel('UserPersonals');
$users = $this->Users->find('all',[
'conditions'=>[
'Users.token'=>$token
]
])->first();
$digits = 4;
$users['pin_pass'] = str_pad(rand(0, pow(10, $digits)-1), $digits, '0', STR_PAD_LEFT);
$user_personals = $this->UserPersonals->find('all',[
'conditions'=>[
'UserPersonals.user_id'=>$users['id']
]
])->first();
//--------------------ตัวส่ง Email ---------------------------------------------------------
//pr($user_personals);die;
$data_notification = [];
$data_notification['email'] = $user_personals['email'];
$data_notification['pin_code'] = $users['pin_pass'].'<br>'." Username: ".$users['username'];
$this->notification($data_notification);
//----------------------------------------------------------------------------------------
if($this->Users->save($users)){
$this->Flash->success(__('send pin success.'));
return $this->redirect(['action' => 'pin_code/'.$token]);
}
$this->Flash->success(__('send pin false.'));
return $this->redirect(['action' => 'pin_code/'.$token]);
}
......
......@@ -31,6 +31,18 @@
</div>
</div>
</div>
<div class="row">
<div class="form-group has-feedback">
<div class="col-md-12">
<div class=" row center">
<?php
echo $this->Html->link('ส่ง pin ใหม่อีกครั้ง', ['controller' => 'Users', 'action' => 'registersendpin/'.$token]);
?>
</div>
</div>
</div>
</div>
<?php echo $this->Form->end(); ?>
</div>
</div>
......
......@@ -8,7 +8,9 @@
<?php echo $this->Form->create(null, ['url' => ['controller' => 'Users', 'action' => 'pinCodepassword/'.$token],
'id' => 'PinCode', 'name' => 'PinCode', 'role' => 'form']);
?>
<div style="padding: 5px;">
<?php echo $this->Flash->render(); ?>
</div>
<div class="row">
<div class="form-group has-feedback">
<div class="col-md-12">
......@@ -30,6 +32,17 @@
</div>
</div>
</div>
<div class="row">
<div class="form-group has-feedback">
<div class="col-md-12">
<div class=" row center">
<?php
echo $this->Html->link('ส่ง pin ใหม่อีกครั้ง', ['controller' => 'Users', 'action' => 'forgotsendpin/'.$token]);
?>
</div>
</div>
</div>
</div>
<?php echo $this->Form->end(); ?>
</div>
</div>
......
......@@ -91,8 +91,8 @@
<div>
<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="phone_no" id="phone_no" onkeypress="check_phone();" value="" maxlength="12" placeholder="000-000-0000" class="mask form-control-reg border-bottom-from">
<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">
</div>
</div>
</div>
......@@ -164,17 +164,6 @@
</div>
</div>
<!-- ------------------------------- popup ----------------------------------- -->
<script type="text/javascript">
$(function () {
$('#phone_no').inputmask('999-999-9999');
//==================================================
// CHANGE Date Times
//==================================================
$('#datepicker').datepicker({
format: 'dd/mm/yyyy'
});
});
</script>
<script>
$(document).ready(function() {
......@@ -316,7 +305,7 @@ function check_notnum() {
alert("กรุณากรอก เบอร์โทรศัพท์ของท่าน");
return false;
}
if(document.getElementById("phone_no").value.length != 12)
if(document.getElementById("phone_no").value.length != 10)
{
alert('กรุณากรอกเบอร์โทรศัพท์ ให้ครบ 10 หลัก');
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