Commit 68b33d4e by Prasong Putichanchai

Merge branch 'integration' into prasong

# Conflicts:
#	.gitignore
parents f3e159f1 fa4192db
<?php
namespace App\Controller;
use App\Controller\AppController;
class CheckemailsController extends AppController {
public function initialize() {
parent::initialize();
$this->Auth->allow('checkemail');
}
public function checkemail(){
// die('jjjjj');
$this->autoRender = false;
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']!='-'){
if(!empty($this->request->data['userId'])){
if($this->request->data['userId'] == $emails['user_id']){
$emails['chk'] = 'true';
$data = json_encode($emails);
echo $data;
}
$emails['chk'] = 'false';
$data = json_encode($emails);
echo $data;
}
$emails['chk'] = 'false';
$data = json_encode($emails);
echo $data;
}else{
$emails['chk'] = 'true';
$data = json_encode($emails);
echo $data;
}
}
}
}
\ No newline at end of file
...@@ -8,13 +8,13 @@ use Cake\Http\Client; ...@@ -8,13 +8,13 @@ use Cake\Http\Client;
class ProfilesController extends AppController class ProfilesController extends AppController
{ {
public function index($id = 13112){ public function index(){
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
/*******************************/ /*******************************/
$id = $this->Auth->user('id'); $id = $this->Auth->user('id');
$this->loadModel('Users'); $this->loadModel('Users');
$responseUserProfile = $this->Users->get($id, [ $responseUserProfile = $this->Users->get($id, [
...@@ -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', [
...@@ -47,8 +46,8 @@ class ProfilesController extends AppController ...@@ -47,8 +46,8 @@ class ProfilesController extends AppController
'keyField' => 'id', 'keyField' => 'id',
'valueField' => 'province_name_th' 'valueField' => 'province_name_th'
]) ])
->where(['master_country_id =' => $responseUserPersonal['master_country_id']]) ->where(['master_country_id =' => $responseUserPersonal['master_country_id']])
->order(['province_name_th']); ->order(['province_name_th']);
// pr($Province);die; // pr($Province);die;
if(!empty($Province)) $Province = $Province->toArray(); if(!empty($Province)) $Province = $Province->toArray();
...@@ -56,6 +55,8 @@ class ProfilesController extends AppController ...@@ -56,6 +55,8 @@ 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;
...@@ -68,23 +69,27 @@ class ProfilesController extends AppController ...@@ -68,23 +69,27 @@ 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{
$chkemail = false; // pr('false');die;
$chkemail = false;
} }
} }
...@@ -92,17 +97,20 @@ class ProfilesController extends AppController ...@@ -92,17 +97,20 @@ 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.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -113,7 +121,7 @@ class ProfilesController extends AppController ...@@ -113,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']);
} }
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -262,6 +262,7 @@ class UserCardsController extends AppController ...@@ -262,6 +262,7 @@ class UserCardsController extends AppController
$this->loadModel('MasterOrganizations'); $this->loadModel('MasterOrganizations');
if ($this->request->is('post')) { if ($this->request->is('post')) {
// pr($this->request->data());die; // pr($this->request->data());die;
// pr($this->Auth->user('id'));die;
$birthdate = explode("/", $this->request->data['UserCards']['birthdate']); $birthdate = explode("/", $this->request->data['UserCards']['birthdate']);
$birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0']; $birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0'];
$TempUserCards = $this->TempUserCards->find('all', [ $TempUserCards = $this->TempUserCards->find('all', [
...@@ -305,8 +306,27 @@ class UserCardsController extends AppController ...@@ -305,8 +306,27 @@ 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');
$UserEntities = $this->UserEntities->find('all', [
'conditions' => [
'user_id' => $this->Auth->user('id'),
'entity_code' => $TempUserCards['organize_id']
]
])->first();
if(empty($UserEntities)){
// pr('sdsd');die;
$UserEntities = $this->UserEntities->newEntity();
$UserEntities['entity_code'] = $TempUserCards['organize_id'];
$UserEntities['user_id'] = $this->Auth->user('id');
$UserEntities['created_by'] = $this->Auth->user('id');
$UserEntities['modified_by'] = $this->Auth->user('id');
$this->UserEntities->save($UserEntities);
}
$this->Flash->success(__('บันทึกสำเร็จ')); $this->Flash->success(__('บันทึกสำเร็จ'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']); return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
} }
......
...@@ -117,13 +117,12 @@ class UsersController extends AppController { ...@@ -117,13 +117,12 @@ class UsersController extends AppController {
'keyField' => 'id', 'keyField' => 'id',
'valueField' => 'province_name_th' 'valueField' => 'province_name_th'
] ]
); );
if(!empty($provinces)) $provinces = $provinces->toArray(); if(!empty($provinces)) $provinces = $provinces->toArray();
$this->set(compact('provinces','countries')); $this->set(compact('provinces','countries'));
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
} }
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
#Signup #Signup
......
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* Building Entity
*/
class UserEntity extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
class UserEntitiesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('core.user_entities');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
// return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'core';
}
}
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