Commit 10b14ed5 by Wittaya-PIM

Merge branch 'integration' into wittaya

parents 1fa2031a 68b33d4e
...@@ -4,4 +4,4 @@ www/tmp/ ...@@ -4,4 +4,4 @@ www/tmp/
www/webroot/img/img/demos/shop/products/shop8/product2.jpg www/webroot/img/img/demos/shop/products/shop8/product2.jpg
www/webroot/img/img/demos/ www/webroot/img/img/demos/
www/src/Controller/UsersController.php.bg20180515 www/src/Controller/UsersController.php.bg20180515
www/config/app.backup www/config/app - Copy.php
...@@ -3,29 +3,11 @@ namespace App\Controller; ...@@ -3,29 +3,11 @@ namespace App\Controller;
use App\Controller\AppController; use App\Controller\AppController;
class CheckemailsController extends AppController { class CheckemailsController extends AppController {
public function checkemailregister(){ public function initialize() {
// die('jjjjj'); parent::initialize();
$this->autoRender = false; $this->Auth->allow('checkemail');
if ($this->request->is('post')) {
$this->loadModel('UserPersonals');
$emails = $this->UserPersonals->find('all',[
'conditions' => [
'email' => $this->request->data['email']
]
])->first();
if(!empty($emails)&&$emails['email']!=''&&$emails['email']!='-'){
$emails['chk'] = 'false';
$data = json_encode($emails);
echo $data;
}else{
$emails['chk'] = 'true';
$data = json_encode($emails);
echo $data;
}
} }
} public function checkemail(){
public function checkemailedit(){
// die('jjjjj'); // die('jjjjj');
$this->autoRender = false; $this->autoRender = false;
if ($this->request->is('post')) { if ($this->request->is('post')) {
...@@ -36,15 +18,19 @@ class CheckemailsController extends AppController { ...@@ -36,15 +18,19 @@ class CheckemailsController extends AppController {
] ]
])->first(); ])->first();
if(!empty($emails)&&$emails['email']!=''&&$emails['email']!='-'){ if(!empty($emails)&&$emails['email']!=''&&$emails['email']!='-'){
if(!empty($this->request->data['userId'])){
if($this->request->data['userId'] == $emails['user_id']){ if($this->request->data['userId'] == $emails['user_id']){
$emails['chk'] = 'true'; $emails['chk'] = 'true';
$data = json_encode($emails); $data = json_encode($emails);
echo $data; echo $data;
} else { }
$emails['chk'] = 'false'; $emails['chk'] = 'false';
$data = json_encode($emails); $data = json_encode($emails);
echo $data; echo $data;
} }
$emails['chk'] = 'false';
$data = json_encode($emails);
echo $data;
}else{ }else{
$emails['chk'] = 'true'; $emails['chk'] = 'true';
$data = json_encode($emails); $data = json_encode($emails);
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
$("#email").on('change',function(){ $("#email").on('change',function(){
var userId = document.getElementById("userId").value; var userId = document.getElementById("userId").value;
var email = document.getElementById("email").value; var email = document.getElementById("email").value;
$.post("/Checkemails/checkemailedit", {email: email,userId: userId}, function(data) { $.post("/Checkemails/checkemail", {email: email,userId: userId}, function(data) {
// console.log(data); // console.log(data);
data = jQuery.parseJSON(data); data = jQuery.parseJSON(data);
if(data['chk'] == 'false'){ if(data['chk'] == 'false'){
......
...@@ -180,8 +180,8 @@ ...@@ -180,8 +180,8 @@
$(document).ready(function() { $(document).ready(function() {
$("#fremail").on('change',function(){ $("#fremail").on('change',function(){
var email = document.getElementById("fremail").value; var email = document.getElementById("fremail").value;
$.post("/Checkemails/checkemailregister", {email: email}, function(data) { $.post("/Checkemails/checkemail", {email: email}, function(data) {
// console.log(data); console.log(data);
data = jQuery.parseJSON(data); data = jQuery.parseJSON(data);
if(data['chk'] == 'false'){ if(data['chk'] == 'false'){
alert("อีเมลล์นี้มีในระบบแล้ว"); alert("อีเมลล์นี้มีในระบบแล้ว");
......
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