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,7 +8,7 @@ use Cake\Http\Client;
class ProfilesController extends AppController
{
public function index($id = 13112){
public function index(){
$this->viewBuilder()->layout('blank');
......@@ -28,7 +28,6 @@ class ProfilesController extends AppController
'user_id' => $id ]
])->first();
//********DropdownCountry********
$this->loadModel('MasterCountries');
$Country = $this->MasterCountries->find('list', [
......@@ -56,6 +55,8 @@ 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;
......@@ -68,22 +69,26 @@ class ProfilesController extends AppController
]
]
)->first();
// pr($this->request->data['email']);die;
if($userPersonals['email'] == $this->request->data['UserPersonals']['email']){
if($userPersonals['email'] == $this->request->data['email']){
$chkemail = true;
}else{
$userPersonals = $this->UserPersonals->find('all',
$useremails = $this->UserPersonals->find('all',
[
'limit' => 1,
'conditions' => [
'email' => $data['UserPersonals']['email']
'email' => $data['email']
]
]
)->toArray();
)->first();
if(empty($userPersonals)){
if(empty($useremails)){
$chkemail = true;
// pr('true');die;
}else{
// pr('false');die;
$chkemail = false;
}
}
......@@ -92,16 +97,19 @@ class ProfilesController extends AppController
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
$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['UserPersonals']['email'];
$userPersonals['email'] = $this->request->data['email'];
$userPersonals['birthdate'] = $birthdate;
$userPersonals['user_id'] = $data['Users']['user_id'];
$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;
if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('Update Complete.'));
......@@ -113,7 +121,7 @@ class ProfilesController extends AppController
$this->Flash->error(__('Not update. Please, try again.'));
}
$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
$this->loadModel('MasterOrganizations');
if ($this->request->is('post')) {
// pr($this->request->data());die;
// pr($this->Auth->user('id'));die;
$birthdate = explode("/", $this->request->data['UserCards']['birthdate']);
$birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0'];
$TempUserCards = $this->TempUserCards->find('all', [
......@@ -305,8 +306,27 @@ 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');
$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(__('บันทึกสำเร็จ'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
......
......@@ -123,7 +123,6 @@ class UsersController extends AppController {
$this->viewBuilder()->layout('blank');
}
#---------------------------------------------------------------------------------------------------
#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