Commit c50dfddf by Prasong Putichanchai

Merge branch 'integration' into prasong

parents 8c61459c b713d9fa
...@@ -362,6 +362,25 @@ return [ ...@@ -362,6 +362,25 @@ return [
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'], //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
'url' => env('DATABASE_TEST_URL', null), 'url' => env('DATABASE_TEST_URL', null),
], ],
'db_temp' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Postgres',
'persistent' => false,
'host' => '122.155.223.38',
'port' => '5432',
//'port' => 'non_standard_port_number',
'username' => 'connect06',
'password' => 'c0nn@6',
'database' => 'connect06',
'encoding' => 'utf8',
'schema' => 'temp',
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
'log' => false,
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
'url' => env('DATABASE_TEST_URL', null),
],
], ],
/** /**
......
...@@ -8,73 +8,105 @@ use Cake\Http\Client; ...@@ -8,73 +8,105 @@ use Cake\Http\Client;
class ProfilesController extends AppController class ProfilesController extends AppController
{ {
public function index() public function index($id = 13112){
{
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
/*******************************/
/*******************************/ /*******************************/
$http = new Client();
$data = [];
$options = ['headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => $this->request->getHeaderLine('Authorization')
#'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI0OSwidXNlcm5hbWUiOiJ0ZXN0dGVzdCIsImlwIjoiMTE2LjU4LjIyNS4yNDgiLCIkdG9waWMiOiJ0ZXN0dGVzdDMzM2Y5MWI5ZjVlMTQzMjlmMWQ2ZTc2MzgwYjhiOWVhIn0.7KwfmevJ--tz0ta5f1O_eDxKSPAjWuAzLSRCNSeWg-g'
#'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4OCwidXNlcm5hbWUiOiJOYW5hMyIsImlwIjoiMTI3LjAuMC4xIiwiJHRvcGljIjoiTmFuYTNiODAwMjVlNWYyZTUxZDVkMmY0ZTM1Y2E4YWFkNmI1MSJ9.Up1oxsqxWASpOmj9UsAuHISlKArT2EE5NRM0bB2NLIE'
]
];
$api_core_profile = Configure::read('Config.apiCore.profile'); $this->loadModel('Users');
$http = new Client(); $responseUserProfile = $this->Users->get($id, [
$response = $http->post($api_core_profile,$data,$options)->body(); 'contain' => []
$response = json_decode($response,'_full');#prr($response); ]);
$username = $responseUserProfile['username'];
$Profiles = $response['result']['Data'];
$Profiles['UserProfiles']['organize_id'] = 10; //********DropdownCountry********
$Profiles['UserProfiles']['dept_id'] = 10; $this->loadModel('MasterCountries');
#debug($Profiles); $Country = $this->MasterCountries->find('list', [
'conditions' => [
$this->set(compact('Profiles')); 'is_used' => true,
#$this->set('_serialize', ['Profiles']); 'MasterCountries.id' => 1],
#--------------------------------------------------------------------------------------------------------------- 'keyField' => 'id',
$this->loadModel('MasterOrganizations'); 'valueField' => 'country_name_th'
@$MasterDepartmentEducations = $this->MasterOrganizations->find('all', ]);
[ if(!empty($Country)) $Country = $Country->toArray();
'conditions' => ['id' => $Profiles['UserProfiles'][0]['organize_id']],
'keyField' => 'id', //********DropdownProvince********
'valueField' => 'org_name_th', $this->loadModel('MasterProvinces');
'order' => 'org_name_th asc' $Province = $this->MasterProvinces->find('list', [
] 'conditions' => [
); 'is_used' => true,
if(!empty($MasterDepartmentEducations)) $MasterDepartmentEducations = $MasterDepartmentEducations->toArray(); 'master_country_id' => 1],
$this->set(compact('MasterDepartmentEducations')); 'keyField' => 'id',
//debug($MasterDepartmentEducations[0]['org_name_th']); 'valueField' => 'province_name_th'
$this->loadModel('MasterDepartments'); ]);
@$MasterDepartments_v = $this->MasterDepartments->find('all', if(!empty($Province)) $Province = $Province->toArray();
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['dept_id']], $this->loadModel('UserPersonals');
'keyField' => 'id', $responseUserProfile = $this->UserPersonals->get($id, [
'valueField' => 'dept_name_th', 'contain' => []
'order' => 'dept_name_th asc' ]);
] $res = $responseUserProfile['birthdate'];
); $dateNow = $res->i18nFormat('dd/MM/yyyy');
if(!empty($MasterDepartments_v)) $MasterDepartments_v = $MasterDepartments_v->toArray();
$this->set(compact('MasterDepartments_v')); if ($this->request->is(['patch', 'post', 'put'])) {
//debug($MasterDepartments_v); $data = $this->request->data;
$this->loadModel('MasterSections'); // pr($this->request->data);die;
@$MasterSections_v = $this->MasterSections->find('all', $this->loadModel('UserPersonals');
[ $userPersonals = $this->UserPersonals->find('all',
'conditions' => ['id' => $Profiles['UserProfiles'][0]['section_id']], [
'keyField' => 'id', 'limit' => 1,
'valueField' => 'section_name_th', 'conditions' => [
'order' => 'section_name_th asc' 'user_id' => $data['Users']['user_id']
] ]
); ]
if(!empty($MasterSections_v)) $MasterSections_v = $MasterSections_v->toArray(); )->first();
$this->set(compact('MasterSections_v')); // pr($userPersonals);die;
//debug($MasterSections_v); if($userPersonals['email'] == $this->request->data['UserPersonals']['email']){
$chkemail = true;
}else{
$userPersonals = $this->UserPersonals->find('all',
[
'limit' => 1,
'conditions' => [
'email' => $data['UserPersonals']['email']
]
]
)->toArray();
if(empty($userPersonals)){
$chkemail = true;
}else{
$chkemail = false;
}
}
if($chkemail == true){
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
$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['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'] = '';
if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('Update Complete.'));
return $this->redirect(['action' => 'index']);
}
}else{
$this->Flash->error(__('Email Address already used by others.'));
}
$this->Flash->error(__('Not update. Please, try again.'));
}
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -561,5 +593,30 @@ if (!empty($SubjectEnrolls)) { ...@@ -561,5 +593,30 @@ if (!empty($SubjectEnrolls)) {
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
} }
// public function getProvince() {
// $this->autoRender = false;
// $this->loadModel('MasterProvinces');
// $states = array();
// // pr($this->request->data);die;
// // echo 'jjjj';
// $states = $this->MasterProvinces->find('list', array(
// 'keyField' => 'id',
// 'valueField' => 'province_name_th',
// 'conditions' => array(
// 'master_country_id' => 2
// )
// ))->toArray();
// $arr = array();
// foreach($states as $key => $val){
// $arr[$key] = $val;
// }
// //pr($states);die;
// // $arr['1'] = "ไทยยยย";
// // $arr['2'] = "ไทยยยยยยยยยย";
// echo json_encode($arr);
// // $data = jQuery.parseJSON($f);
// // pr($data);die;
// }
} }
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* UserCards Controller
*
* @property \App\Model\Table\UserCardsTable $UserCards
*
* @method \App\Model\Entity\UserCard[] paginate($object = null, array $settings = [])
*/
class UserCardsController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|void
*/
public function index()
{
$this->paginate = [
'contain' => ['Users', 'Organizes']
];
$userCards = $this->paginate($this->UserCards);
$this->set(compact('userCards'));
$this->set('_serialize', ['userCards']);
}
/**
* View method
*
* @param string|null $id User Card id.
* @return \Cake\Http\Response|void
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$userCard = $this->UserCards->get($id, [
'contain' => ['Users', 'Organizes']
]);
$this->set('userCard', $userCard);
$this->set('_serialize', ['userCard']);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$userCard = $this->UserCards->newEntity();
if ($this->request->is('post')) {
$userCard = $this->UserCards->patchEntity($userCard, $this->request->getData());
if ($this->UserCards->save($userCard)) {
$this->Flash->success(__('The user card has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The user card could not be saved. Please, try again.'));
}
$users = $this->UserCards->Users->find('list', ['limit' => 200]);
$organizes = $this->UserCards->Organizes->find('list', ['limit' => 200]);
$this->set(compact('userCard', 'users', 'organizes'));
$this->set('_serialize', ['userCard']);
}
/**
* Edit method
*
* @param string|null $id User Card id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function edit($id = null)
{
$userCard = $this->UserCards->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$userCard = $this->UserCards->patchEntity($userCard, $this->request->getData());
if ($this->UserCards->save($userCard)) {
$this->Flash->success(__('The user card has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The user card could not be saved. Please, try again.'));
}
$users = $this->UserCards->Users->find('list', ['limit' => 200]);
$organizes = $this->UserCards->Organizes->find('list', ['limit' => 200]);
$this->set(compact('userCard', 'users', 'organizes'));
$this->set('_serialize', ['userCard']);
}
/**
* Delete method
*
* @param string|null $id User Card id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$userCard = $this->UserCards->get($id);
if ($this->UserCards->delete($userCard)) {
$this->Flash->success(__('The user card has been deleted.'));
} else {
$this->Flash->error(__('The user card could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
public function createCards()
{
$this->viewBuilder()->layout('blank');
$this->loadModel('TempUserCards');
$this->loadModel('MasterOrganizations');
if ($this->request->is('post')) {
// pr($this->Auth);die;
// pr($this->request->data());
$birthdate = explode("/", $this->request->data['UserCards']['birthdate']);
$birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0'];
$TempUserCards = $this->TempUserCards->find('all', [
'conditions' => [
'organize_id' => $this->request->data['UserCards']['organize_id'],
'card_code' => $this->request->data['UserCards']['employee'],
'birthdate' => $birthdate
]
])->first();
if(!empty($TempUserCards)){
$UserCards = $this->UserCards->find('all', [
'conditions' => [
'organize_id' => $TempUserCards['organize_id'],
'card_code' => $TempUserCards['card_code']
]
])->first();
// pr($UserCards);die;
if(empty($UserCards)){
$userCard = $this->UserCards->newEntity();
$userCard['organize_id'] = $TempUserCards['organize_id'];
$userCard['card_code'] = $TempUserCards['card_code'];
$userCard['img_path'] = $TempUserCards['img_path'];
$userCard['prefix_name_th'] = $TempUserCards['prefix_name_th'];
$userCard['firstname_th'] = $TempUserCards['firstname_th'];
$userCard['lastname_th'] = $TempUserCards['lastname_th'];
$userCard['prefix_name_en'] = $TempUserCards['prefix_name_en'];
$userCard['firstname_en'] = $TempUserCards['firstname_en'];
$userCard['lastname_en'] = $TempUserCards['lastname_en'];
$userCard['department_name'] = $TempUserCards['department_name'];
$userCard['section_name'] = $TempUserCards['section_name'];
$userCard['position_name'] = $TempUserCards['position_name'];
$userCard['gender'] = $TempUserCards['gender'];
$userCard['blood_group'] = $TempUserCards['blood_group'];
$userCard['birthdate'] = $TempUserCards['birthdate'];
$userCard['date_issued'] = $TempUserCards['date_issued'];
$userCard['date_expiry'] = $TempUserCards['date_expiry'];
$userCard['signature'] = $TempUserCards['signature'];
$userCard['is_used'] = $TempUserCards['is_used'];
$userCard['created_by'] = 1;
$userCard['user_id'] = 1;
// pr($userCard);die;
if ($this->UserCards->save($userCard)) {
$this->Flash->success(__('บันทึกสำเร็จ'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
}else{
$this->Flash->success(__('ลงทะเบียนไว้อยู่แล้ว'));
return $this->redirect(['controller' => 'UserCards', 'action' => 'createCards']);
}
}else{
$this->Flash->success(__('ไม่พบข้อมูล'));
return $this->redirect(['controller' => 'UserCards', 'action' => 'createCards']);
}
}
}
public function checkOrg()
{
$this->autoRender = false;
// $this->loadModel('MasterOrganizations');
// $MasterOrganizations = $this->MasterOrganizations->find('all', [
// 'fields' => [
// 'id',
// 'org_code',
// 'org_name_th'
// ], 'conditions' => [
// 'org_code' => 'PAGO0010'
// ]
// ])->toArray();
// pr($MasterOrganizations);die;
if ($this->request->is('post')) {
$this->loadModel('MasterOrganizations');
$MasterOrganizations = $this->MasterOrganizations->find('all', [
'fields' => [
'id',
'org_code',
'org_name_th'
], 'conditions' => [
'org_code' => $this->request->data['organize_code']
]
])->toArray();
if(!empty($MasterOrganizations)){
$UserCards = $this->UserCards->find('all', [
'fields' => [
'id',
'user_id',
'organize_id'
], 'conditions' => [
'user_id' => 2,
'organize_id' => $MasterOrganizations[0]['id']
]
])->toArray();
if(empty($UserCards)){
$MasterOrganizations['chkuser'] = false;
$data = json_encode($MasterOrganizations);
echo $data;
}else{
$MasterOrganizations['chkuser'] = true;
$data = json_encode($MasterOrganizations);
echo $data;
}
}else{
echo 'false';
}
}
}
}
\ No newline at end of file
...@@ -102,40 +102,72 @@ class UserProfilesController extends AppController { ...@@ -102,40 +102,72 @@ class UserProfilesController extends AppController {
//// debug($userProfiles); //// debug($userProfiles);
// } // }
// exit; // exit;
// $data = $this->request->data;
// $UserPersonal = $this->UserProfiles->UserPersonals->find('first', [
// 'conditions' => [
// 'UserPersonals.user_id' => $data['Users']['user_id']
// ]
// ]);
// pr($UserPersonal);die;
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$data = $this->request->data;
// debug($this->request->data); // debug($this->request->data);
// exit; // exit;
$data = $this->request->data; #pr($data); // pr($data);
list($data['UserPersonals']['firstname_th'], $data['UserPersonals']['lastname_th']) = explode(' ', $data['UserPersonals']['fullname']);
unset($data['UserPersonals']['fullname']); $this->loadModel('UserPersonals');
$data['UserPersonals']['birthdate'] = '';
$data['UserPersonals']['user_id'] = $data['Users']['user_id']; $userPersonals = $this->UserPersonals->find('all',
$data['UserPersonals']['modified_by'] = ''; [
$data['UserProfiles'][0]['user_id'] = $data['Users']['user_id']; 'limit' => 1,
$data['UserProfiles'][0]['user_type_id'] = 1; 'conditions' => [
$data['UserProfiles'][0]['modified_by'] = ''; 'user_id' => $data['Users']['user_id']
$data['UserProfiles'][1]['user_id'] = $data['Users']['user_id']; ]
$data['UserProfiles'][1]['user_type_id'] = 2;
$data['UserProfiles'][1]['modified_by'] = '';
debug($data);
exit;
#$api_update_profile = 'http://connect06.pakgon.com/api/Connects/Profile/updateProfile';
$api_update_profile = Configure::read('Config.apiCore.profile') . '/updateProfile';
$http = new Client();
// $data = [];
$options = ['headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
#'Authorization' => $this->request->getHeaderLine('Authorization')
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTIzMCwidXNlcm5hbWUiOiJ0ZXN0dG9uZyIsImlwIjoiMTI3LjAuMC4xIn0.37hXRDEhiwjsgqR8mcgbhxnKtAof3tIDahL2P6DnQ4I'
'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4NywidXNlcm5hbWUiOiJOYW5hMiIsImlwIjoiOjoxIiwidG9waWMiOiJOYW5hMmI5OTQxMWE2NDExYTRhOTlhZmI5MWRhMjM3MTJjNDQ2In0.u3OdN5QzI_dvI9KfKYojjVXfcnvTcmHz9LM0XHXvwU8'
] ]
]; )->toArray();
#prr($options); // pr($userPersonals);
$response = $http->post($api_update_profile, $data, $options)->body(); // pr($data['UserPersonals']);
pr($response); // $userPersonals = $this->UserPersonals->newEntity();
$response = json_decode($response, '_full'); $userPersonals = $this->UserPersonals->patchEntity($userPersonals[0], $data['UserPersonals']);#prr($userPersonals);
pr($response);
die; list($userPersonals['firstname_th'], $userPersonals['lastname_th']) = explode(' ', $data['UserPersonals']['fullname']);
unset($userPersonals['fullname']);
$userPersonals['birthdate'] = '2000-01-01';
$userPersonals['user_id'] = $data['Users']['user_id'];
$userPersonals['modified_by'] = '';
// $userPersonals['modified'] = '2018-01-01 00:00:00';
// pr($userPersonals->toArray());die;
// debug($this->UserPersonals->save($userPersonals));die;
if ($this->UserPersonals->save($userPersonals)) {
//pr($userPersonals->toArray());die;
}
// $data['UserProfiles'][0]['user_id'] = $data['Users']['user_id'];
// $data['UserProfiles'][0]['user_type_id'] = 1;
// $data['UserProfiles'][0]['modified_by'] = '';
// $data['UserProfiles'][1]['user_id'] = $data['Users']['user_id'];
// $data['UserProfiles'][1]['user_type_id'] = 2;
// $data['UserProfiles'][1]['modified_by'] = '';
// debug($data);
// exit;
#$api_update_profile = 'http://connect06.pakgon.com/api/Connects/Profile/updateProfile';
// $api_update_profile = Configure::read('Config.apiCore.profile') . '/updateProfile';
// $http = new Client();
// $data = [];
// $options = ['headers' => [
// 'Content-Type' => 'application/x-www-form-urlencoded',
// #'Authorization' => $this->request->getHeaderLine('Authorization')
// //'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTIzMCwidXNlcm5hbWUiOiJ0ZXN0dG9uZyIsImlwIjoiMTI3LjAuMC4xIn0.37hXRDEhiwjsgqR8mcgbhxnKtAof3tIDahL2P6DnQ4I'
// 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4NywidXNlcm5hbWUiOiJOYW5hMiIsImlwIjoiOjoxIiwidG9waWMiOiJOYW5hMmI5OTQxMWE2NDExYTRhOTlhZmI5MWRhMjM3MTJjNDQ2In0.u3OdN5QzI_dvI9KfKYojjVXfcnvTcmHz9LM0XHXvwU8'
// ]
// ];
// prr($options);
// $response = $http->post($api_update_profile, $data, $options)->body();
// pr($response);
// $response = json_decode($response, '_full');
// pr($response);
// die;
} }
// $organization = $this->UserProfiles->MasterOrganizations->find('list')->select(['MasterOrganizations.id', 'MasterOrganizations.org_name_th'])->where(['master_organization_type_id' => 1]); // $organization = $this->UserProfiles->MasterOrganizations->find('list')->select(['MasterOrganizations.id', 'MasterOrganizations.org_name_th'])->where(['master_organization_type_id' => 1]);
......
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* Building Entity
*/
class TempUserCard 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\Entity;
use Cake\ORM\Entity;
/**
* UserCard Entity
*
* @property int $id
* @property int $user_id
* @property int $organize_id
* @property string $card_code
* @property string $img_path
* @property string $prefix_name_th
* @property string $firstname_th
* @property string $lastname_th
* @property string $prefix_name_en
* @property string $firstname_en
* @property string $lastname_en
* @property string $department_name
* @property string $section_name
* @property string $position_name
* @property string $gender
* @property string $blood_group
* @property \Cake\I18n\FrozenDate $birthdate
* @property \Cake\I18n\FrozenDate $date_issued
* @property \Cake\I18n\FrozenDate $date_expiry
* @property string $signature
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\User $user
* @property \App\Model\Entity\Organize $organize
*/
class UserCard 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
*/
protected $_accessible = [
'user_id' => true,
'organize_id' => true,
'card_code' => true,
'img_path' => true,
'prefix_name_th' => true,
'firstname_th' => true,
'lastname_th' => true,
'prefix_name_en' => true,
'firstname_en' => true,
'lastname_en' => true,
'department_name' => true,
'section_name' => true,
'position_name' => true,
'gender' => true,
'blood_group' => true,
'birthdate' => true,
'date_issued' => true,
'date_expiry' => true,
'signature' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'user' => true,
'organize' => true
];
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
class TempUserCardsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('temp.user_cards');
$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)
{
// $validator
// ->allowEmpty('id', 'create');
// $validator
// ->scalar('building_code')
// ->maxLength('building_code', 20)
// ->requirePresence('building_code', 'create')
// ->notEmpty('building_code');
// $validator
// ->scalar('building_name')
// ->maxLength('building_name', 100)
// ->allowEmpty('building_name');
// $validator
// ->boolean('is_used')
// ->requirePresence('is_used', 'create')
// ->notEmpty('is_used');
// $validator
// ->requirePresence('create_uid', 'create')
// ->notEmpty('create_uid');
// $validator
// ->allowEmpty('update_uid');
// 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 'db_temp';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* UserCards Model
*
* @property \App\Model\Table\UsersTable|\Cake\ORM\Association\BelongsTo $Users
* @property \App\Model\Table\OrganizesTable|\Cake\ORM\Association\BelongsTo $Organizes
*
* @method \App\Model\Entity\UserCard get($primaryKey, $options = [])
* @method \App\Model\Entity\UserCard newEntity($data = null, array $options = [])
* @method \App\Model\Entity\UserCard[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\UserCard|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\UserCard patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\UserCard[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\UserCard findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class UserCardsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('user_cards');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Organizes', [
'foreignKey' => 'organize_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
// $validator
// ->allowEmpty('id', 'create');
// $validator
// ->scalar('card_code')
// ->allowEmpty('card_code');
// $validator
// ->scalar('img_path')
// ->allowEmpty('img_path');
// $validator
// ->scalar('prefix_name_th')
// ->allowEmpty('prefix_name_th');
// $validator
// ->scalar('firstname_th')
// ->allowEmpty('firstname_th');
// $validator
// ->scalar('lastname_th')
// ->allowEmpty('lastname_th');
// $validator
// ->scalar('prefix_name_en')
// ->allowEmpty('prefix_name_en');
// $validator
// ->scalar('firstname_en')
// ->allowEmpty('firstname_en');
// $validator
// ->scalar('lastname_en')
// ->allowEmpty('lastname_en');
// $validator
// ->scalar('department_name')
// ->allowEmpty('department_name');
// $validator
// ->scalar('section_name')
// ->allowEmpty('section_name');
// $validator
// ->scalar('position_name')
// ->allowEmpty('position_name');
// $validator
// ->scalar('gender')
// ->allowEmpty('gender');
// $validator
// ->scalar('blood_group')
// ->allowEmpty('blood_group');
// $validator
// ->date('birthdate')
// ->allowEmpty('birthdate');
// $validator
// ->date('date_issued')
// ->allowEmpty('date_issued');
// $validator
// ->date('date_expiry')
// ->allowEmpty('date_expiry');
// $validator
// ->scalar('signature')
// ->allowEmpty('signature');
// $validator
// ->boolean('is_used')
// ->requirePresence('is_used', 'create')
// ->notEmpty('is_used');
// $validator
// ->requirePresence('created_by', 'create')
// ->notEmpty('created_by');
// $validator
// ->allowEmpty('modified_by');
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
*/
public function buildRules(RulesChecker $rules)
{
// $rules->add($rules->existsIn(['user_id'], 'Users'));
// $rules->add($rules->existsIn(['organize_id'], 'Organizes'));
return $rules;
}
}
...@@ -40,9 +40,9 @@ class UserPersonalsTable extends Table { ...@@ -40,9 +40,9 @@ class UserPersonalsTable extends Table {
$this->addBehavior('Timestamp'); $this->addBehavior('Timestamp');
$this->belongsTo('MasterPrefixes', [ // $this->belongsTo('MasterPrefixes', [
'foreignKey' => 'master_prefix_id' // 'foreignKey' => 'master_prefix_id'
]); // ]);
$this->belongsTo('Users', [ $this->belongsTo('Users', [
'foreignKey' => 'user_id' 'foreignKey' => 'user_id'
]); ]);
...@@ -55,63 +55,63 @@ class UserPersonalsTable extends Table { ...@@ -55,63 +55,63 @@ class UserPersonalsTable extends Table {
* @return \Cake\Validation\Validator * @return \Cake\Validation\Validator
*/ */
public function validationDefault(Validator $validator) { public function validationDefault(Validator $validator) {
$validator // $validator
->allowEmpty('id', 'create'); // ->allowEmpty('id', 'create');
$validator // $validator
->scalar('person_card_no') // ->scalar('person_card_no')
->requirePresence('person_card_no', 'create') // ->requirePresence('person_card_no', 'create')
->notEmpty('person_card_no'); // ->notEmpty('person_card_no');
$validator // $validator
->scalar('firstname_th') // ->scalar('firstname_th')
->allowEmpty('firstname_th'); // ->allowEmpty('firstname_th');
$validator // $validator
->scalar('lastname_th') // ->scalar('lastname_th')
->allowEmpty('lastname_th'); // ->allowEmpty('lastname_th');
$validator // $validator
->scalar('firstname_en') // ->scalar('firstname_en')
->allowEmpty('firstname_en'); // ->allowEmpty('firstname_en');
$validator // $validator
->scalar('lastname_en') // ->scalar('lastname_en')
->allowEmpty('lastname_en'); // ->allowEmpty('lastname_en');
$validator // $validator
->scalar('gender') // ->scalar('gender')
->allowEmpty('gender'); // ->allowEmpty('gender');
$validator // $validator
->date('birthdate') // ->date('birthdate')
->allowEmpty('birthdate'); // ->allowEmpty('birthdate');
$validator // $validator
->scalar('moblie_no') // ->scalar('moblie_no')
->allowEmpty('moblie_no'); // ->allowEmpty('moblie_no');
$validator // $validator
->scalar('phone_no') // ->scalar('phone_no')
->allowEmpty('phone_no'); // ->allowEmpty('phone_no');
$validator // $validator
->email('email') // ->email('email')
->allowEmpty('email'); // ->allowEmpty('email');
$validator // $validator
->allowEmpty('created_by'); // ->allowEmpty('created_by');
$validator // $validator
->allowEmpty('modified_by'); // ->allowEmpty('modified_by');
$validator // $validator
->scalar('blood_group') // ->scalar('blood_group')
->allowEmpty('blood_group'); // ->allowEmpty('blood_group');
$validator // $validator
->scalar('address') // ->scalar('address')
->allowEmpty('address'); // ->allowEmpty('address');
return $validator; return $validator;
} }
...@@ -125,7 +125,7 @@ class UserPersonalsTable extends Table { ...@@ -125,7 +125,7 @@ class UserPersonalsTable extends Table {
*/ */
public function buildRules(RulesChecker $rules) { public function buildRules(RulesChecker $rules) {
$rules->add($rules->isUnique(['email'])); $rules->add($rules->isUnique(['email']));
$rules->add($rules->existsIn(['master_prefix_id'], 'MasterPrefixes')); // $rules->add($rules->existsIn(['master_prefix_id'], 'MasterPrefixes'));
$rules->add($rules->existsIn(['user_id'], 'Users')); $rules->add($rules->existsIn(['user_id'], 'Users'));
return $rules; return $rules;
......
...@@ -79,52 +79,52 @@ class UserProfilesTable extends Table ...@@ -79,52 +79,52 @@ class UserProfilesTable extends Table
*/ */
public function validationDefault(Validator $validator) public function validationDefault(Validator $validator)
{ {
$validator // $validator
->allowEmpty('id', 'create'); // ->allowEmpty('id', 'create');
$validator // $validator
->scalar('card_code') // ->scalar('card_code')
->maxLength('card_code', 20) // ->maxLength('card_code', 20)
->allowEmpty('card_code'); // ->allowEmpty('card_code');
$validator // $validator
->scalar('img_path') // ->scalar('img_path')
->maxLength('img_path', 255) // ->maxLength('img_path', 255)
->allowEmpty('img_path'); // ->allowEmpty('img_path');
$validator // $validator
->boolean('is_used') // ->boolean('is_used')
->requirePresence('is_used', 'create') // ->requirePresence('is_used', 'create')
->notEmpty('is_used'); // ->notEmpty('is_used');
$validator // $validator
->requirePresence('created_by', 'create') // ->requirePresence('created_by', 'create')
->notEmpty('created_by'); // ->notEmpty('created_by');
$validator // $validator
->allowEmpty('modified_by'); // ->allowEmpty('modified_by');
$validator // $validator
->allowEmpty('position_org'); // ->allowEmpty('position_org');
$validator // $validator
->allowEmpty('position_edu'); // ->allowEmpty('position_edu');
$validator // $validator
->date('enter_date') // ->date('enter_date')
->allowEmpty('enter_date'); // ->allowEmpty('enter_date');
$validator // $validator
->scalar('address') // ->scalar('address')
->maxLength('address', 255) // ->maxLength('address', 255)
->allowEmpty('address'); // ->allowEmpty('address');
$validator // $validator
->scalar('phone_no') // ->scalar('phone_no')
->maxLength('phone_no', 30) // ->maxLength('phone_no', 30)
->allowEmpty('phone_no'); // ->allowEmpty('phone_no');
return $validator; // return $validator;
} }
/** /**
......
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\UserCard $userCard
*/
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('List User Cards'), ['action' => 'index']) ?></li>
<li><?= $this->Html->link(__('List Users'), ['controller' => 'Users', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New User'), ['controller' => 'Users', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="userCards form large-9 medium-8 columns content">
<?= $this->Form->create($userCard) ?>
<fieldset>
<legend><?= __('Add User Card') ?></legend>
<?php
echo $this->Form->control('user_id', ['options' => $users]);
echo $this->Form->control('organize_id');
echo $this->Form->control('card_code');
echo $this->Form->control('img_path');
echo $this->Form->control('prefix_name_th');
echo $this->Form->control('firstname_th');
echo $this->Form->control('lastname_th');
echo $this->Form->control('prefix_name_en');
echo $this->Form->control('firstname_en');
echo $this->Form->control('lastname_en');
echo $this->Form->control('department_name');
echo $this->Form->control('section_name');
echo $this->Form->control('position_name');
echo $this->Form->control('gender');
echo $this->Form->control('blood_group');
echo $this->Form->control('birthdate', ['empty' => true]);
echo $this->Form->control('date_issued', ['empty' => true]);
echo $this->Form->control('date_expiry', ['empty' => true]);
echo $this->Form->control('signature');
echo $this->Form->control('is_used');
echo $this->Form->control('created_by');
echo $this->Form->control('modified_by');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->create('UserCrads', ['id' => 'frmSignIn', 'type' => 'file', 'onsubmit' => 'return check();']); ?>
<div style="position: absolute;z-index: 2;">
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
</div>
<div class="bg-profile"></div>
<?php echo $this->Flash->render() ?>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->hidden('UserCards.user_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'userId', 'type' => 'text', 'placeholder' => 'USERNAME']); ?>
<?php echo $this->Form->hidden('UserCards.organize_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'organize_id', 'type' => 'text', 'label' => __('ไอดีใช้งาน'), 'placeholder' => 'USERNAME', 'required']); ?>
<?php echo $this->Form->input('UserCards.organize_code', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'organize_code', 'type' => 'text', 'label' => __('Company Code'), 'placeholder' => 'Company Code', 'required']); ?>
<label id = "nameorg_th" style="color: green"></label>
<label id = "noorg_th" style="color: red"></label>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserCards.employee', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'employee', 'type' => 'text', 'label' => __('รหัสพนักงาน / รหัสนักศึกษา'), 'placeholder' => 'รหัสพนักงาน / รหัสนักศึกษา', 'disabled', 'required']); ?>
</div>
</div>
<div class="form-group has-feedback bootstrap-iso">
<div class="col-xs-12 col-sm-12 col-md-12">
<label class="label-text-sub"><?php echo __('วันเกิด');?></label>
<input type="text" name="UserCards[birthdate]" id="date" placeholder="กรุณาระบุวันเดือนปีเกิด" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from">
<span class="glyphicon glyphicon-calendar form-control-feedback"></span>
</div>
</div>
<div>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile">บันทึก</button>
</div>
<?php echo $this->Form->end(); ?>
</div>
</div>
<script>
var organize_id = document.getElementById("organize_id");
var employee = document.getElementById("employee");
var date = document.getElementById("date");
$(document).ready(function() {
$("#organize_code").on('change',function(){
var organize_code = document.getElementById("organize_code").value
alert(organize_code);
$.post("/UserCards/checkOrg", {organize_code: organize_code}, function(data) {
if(data!='false'){
data = jQuery.parseJSON(data);
console.log(data);
$("#nameorg_th").text(data[0]['org_name_th']);
$("#noorg_th").text('');
$("#employee").removeAttr("disabled");
$("#date").removeAttr("disabled");
organize_id.value = data[0]['id'];
}else{
$("#noorg_th").text('ไม่พบข้อมูล');
$("#nameorg_th").text('');
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
organize_id.value = '';
employee.value = '';
date.value = '';
}
});
});
});
function check() {
if (employee.value == '') {
alert("รหัสพนักงาน / รหัสนักศึกษา");
employee.focus();
return false;
}
if (date.value == '') {
alert("วันเกิด");
date.focus();
return false;
}
}
</script>
<script>
$(document).ready(function(){
var date_input=$('input[id="date"]'); //our date input has the name "date"
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
var options={
format: 'dd/mm/yyyy',
container: container,
todayHighlight: true,
autoclose: true,
};
date_input.datepicker(options);
})
</script>
\ No newline at end of file
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\UserCard $userCard
*/
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $userCard->id],
['confirm' => __('Are you sure you want to delete # {0}?', $userCard->id)]
)
?></li>
<li><?= $this->Html->link(__('List User Cards'), ['action' => 'index']) ?></li>
<li><?= $this->Html->link(__('List Users'), ['controller' => 'Users', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New User'), ['controller' => 'Users', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="userCards form large-9 medium-8 columns content">
<?= $this->Form->create($userCard) ?>
<fieldset>
<legend><?= __('Edit User Card') ?></legend>
<?php
echo $this->Form->control('user_id', ['options' => $users]);
echo $this->Form->control('organize_id');
echo $this->Form->control('card_code');
echo $this->Form->control('img_path');
echo $this->Form->control('prefix_name_th');
echo $this->Form->control('firstname_th');
echo $this->Form->control('lastname_th');
echo $this->Form->control('prefix_name_en');
echo $this->Form->control('firstname_en');
echo $this->Form->control('lastname_en');
echo $this->Form->control('department_name');
echo $this->Form->control('section_name');
echo $this->Form->control('position_name');
echo $this->Form->control('gender');
echo $this->Form->control('blood_group');
echo $this->Form->control('birthdate', ['empty' => true]);
echo $this->Form->control('date_issued', ['empty' => true]);
echo $this->Form->control('date_expiry', ['empty' => true]);
echo $this->Form->control('signature');
echo $this->Form->control('is_used');
echo $this->Form->control('created_by');
echo $this->Form->control('modified_by');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\UserCard[]|\Cake\Collection\CollectionInterface $userCards
*/
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('New User Card'), ['action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Users'), ['controller' => 'Users', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New User'), ['controller' => 'Users', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="userCards index large-9 medium-8 columns content">
<h3><?= __('User Cards') ?></h3>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th scope="col"><?= $this->Paginator->sort('id') ?></th>
<th scope="col"><?= $this->Paginator->sort('user_id') ?></th>
<th scope="col"><?= $this->Paginator->sort('organize_id') ?></th>
<th scope="col"><?= $this->Paginator->sort('card_code') ?></th>
<th scope="col"><?= $this->Paginator->sort('img_path') ?></th>
<th scope="col"><?= $this->Paginator->sort('prefix_name_th') ?></th>
<th scope="col"><?= $this->Paginator->sort('firstname_th') ?></th>
<th scope="col"><?= $this->Paginator->sort('lastname_th') ?></th>
<th scope="col"><?= $this->Paginator->sort('prefix_name_en') ?></th>
<th scope="col"><?= $this->Paginator->sort('firstname_en') ?></th>
<th scope="col"><?= $this->Paginator->sort('lastname_en') ?></th>
<th scope="col"><?= $this->Paginator->sort('department_name') ?></th>
<th scope="col"><?= $this->Paginator->sort('section_name') ?></th>
<th scope="col"><?= $this->Paginator->sort('position_name') ?></th>
<th scope="col"><?= $this->Paginator->sort('gender') ?></th>
<th scope="col"><?= $this->Paginator->sort('blood_group') ?></th>
<th scope="col"><?= $this->Paginator->sort('birthdate') ?></th>
<th scope="col"><?= $this->Paginator->sort('date_issued') ?></th>
<th scope="col"><?= $this->Paginator->sort('date_expiry') ?></th>
<th scope="col"><?= $this->Paginator->sort('signature') ?></th>
<th scope="col"><?= $this->Paginator->sort('is_used') ?></th>
<th scope="col"><?= $this->Paginator->sort('created_by') ?></th>
<th scope="col"><?= $this->Paginator->sort('created') ?></th>
<th scope="col"><?= $this->Paginator->sort('modified_by') ?></th>
<th scope="col"><?= $this->Paginator->sort('modified') ?></th>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($userCards as $userCard): ?>
<tr>
<td><?= $this->Number->format($userCard->id) ?></td>
<td><?= $userCard->has('user') ? $this->Html->link($userCard->user->username, ['controller' => 'Users', 'action' => 'view', $userCard->user->id]) : '' ?></td>
<td><?= $this->Number->format($userCard->organize_id) ?></td>
<td><?= h($userCard->card_code) ?></td>
<td><?= h($userCard->img_path) ?></td>
<td><?= h($userCard->prefix_name_th) ?></td>
<td><?= h($userCard->firstname_th) ?></td>
<td><?= h($userCard->lastname_th) ?></td>
<td><?= h($userCard->prefix_name_en) ?></td>
<td><?= h($userCard->firstname_en) ?></td>
<td><?= h($userCard->lastname_en) ?></td>
<td><?= h($userCard->department_name) ?></td>
<td><?= h($userCard->section_name) ?></td>
<td><?= h($userCard->position_name) ?></td>
<td><?= h($userCard->gender) ?></td>
<td><?= h($userCard->blood_group) ?></td>
<td><?= h($userCard->birthdate) ?></td>
<td><?= h($userCard->date_issued) ?></td>
<td><?= h($userCard->date_expiry) ?></td>
<td><?= h($userCard->signature) ?></td>
<td><?= h($userCard->is_used) ?></td>
<td><?= $this->Number->format($userCard->created_by) ?></td>
<td><?= h($userCard->created) ?></td>
<td><?= $this->Number->format($userCard->modified_by) ?></td>
<td><?= h($userCard->modified) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $userCard->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $userCard->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $userCard->id], ['confirm' => __('Are you sure you want to delete # {0}?', $userCard->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?></p>
</div>
</div>
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\UserCard $userCard
*/
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('Edit User Card'), ['action' => 'edit', $userCard->id]) ?> </li>
<li><?= $this->Form->postLink(__('Delete User Card'), ['action' => 'delete', $userCard->id], ['confirm' => __('Are you sure you want to delete # {0}?', $userCard->id)]) ?> </li>
<li><?= $this->Html->link(__('List User Cards'), ['action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New User Card'), ['action' => 'add']) ?> </li>
<li><?= $this->Html->link(__('List Users'), ['controller' => 'Users', 'action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New User'), ['controller' => 'Users', 'action' => 'add']) ?> </li>
</ul>
</nav>
<div class="userCards view large-9 medium-8 columns content">
<h3><?= h($userCard->id) ?></h3>
<table class="vertical-table">
<tr>
<th scope="row"><?= __('User') ?></th>
<td><?= $userCard->has('user') ? $this->Html->link($userCard->user->username, ['controller' => 'Users', 'action' => 'view', $userCard->user->id]) : '' ?></td>
</tr>
<tr>
<th scope="row"><?= __('Card Code') ?></th>
<td><?= h($userCard->card_code) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Img Path') ?></th>
<td><?= h($userCard->img_path) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Prefix Name Th') ?></th>
<td><?= h($userCard->prefix_name_th) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Firstname Th') ?></th>
<td><?= h($userCard->firstname_th) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Lastname Th') ?></th>
<td><?= h($userCard->lastname_th) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Prefix Name En') ?></th>
<td><?= h($userCard->prefix_name_en) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Firstname En') ?></th>
<td><?= h($userCard->firstname_en) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Lastname En') ?></th>
<td><?= h($userCard->lastname_en) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Department Name') ?></th>
<td><?= h($userCard->department_name) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Section Name') ?></th>
<td><?= h($userCard->section_name) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Position Name') ?></th>
<td><?= h($userCard->position_name) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Gender') ?></th>
<td><?= h($userCard->gender) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Blood Group') ?></th>
<td><?= h($userCard->blood_group) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Signature') ?></th>
<td><?= h($userCard->signature) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Id') ?></th>
<td><?= $this->Number->format($userCard->id) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Organize Id') ?></th>
<td><?= $this->Number->format($userCard->organize_id) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Created By') ?></th>
<td><?= $this->Number->format($userCard->created_by) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Modified By') ?></th>
<td><?= $this->Number->format($userCard->modified_by) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Birthdate') ?></th>
<td><?= h($userCard->birthdate) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Date Issued') ?></th>
<td><?= h($userCard->date_issued) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Date Expiry') ?></th>
<td><?= h($userCard->date_expiry) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Created') ?></th>
<td><?= h($userCard->created) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Modified') ?></th>
<td><?= h($userCard->modified) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Is Used') ?></th>
<td><?= $userCard->is_used ? __('Yes') : __('No'); ?></td>
</tr>
</table>
</div>
<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* UserCardsFixture
*
*/
class UserCardsFixture extends TestFixture
{
/**
* Fields
*
* @var array
*/
// @codingStandardsIgnoreStart
public $fields = [
'id' => ['type' => 'biginteger', 'length' => 20, 'autoIncrement' => true, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'unsigned' => null],
'user_id' => ['type' => 'biginteger', 'length' => 20, 'default' => null, 'null' => false, 'comment' => 'รหัส user', 'precision' => null, 'unsigned' => null, 'autoIncrement' => null],
'organize_id' => ['type' => 'biginteger', 'length' => 20, 'default' => null, 'null' => true, 'comment' => 'รหัส บริษัท', 'precision' => null, 'unsigned' => null, 'autoIncrement' => null],
'card_code' => ['type' => 'string', 'length' => 20, 'default' => null, 'null' => true, 'collate' => null, 'comment' => 'หมายเลขบัตร', 'precision' => null, 'fixed' => null],
'img_path' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'prefix_name_th' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => 'ฝ่าย', 'precision' => null, 'fixed' => null],
'firstname_th' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'lastname_th' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'prefix_name_en' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'firstname_en' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'lastname_en' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'department_name' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'section_name' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => 'แผนก', 'precision' => null, 'fixed' => null],
'position_name' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => 'ตำแหน่ง', 'precision' => null, 'fixed' => null],
'gender' => ['type' => 'string', 'length' => 1, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'blood_group' => ['type' => 'string', 'length' => 1, 'default' => null, 'null' => true, 'collate' => null, 'comment' => null, 'precision' => null, 'fixed' => null],
'birthdate' => ['type' => 'date', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null],
'date_issued' => ['type' => 'date', 'length' => null, 'default' => null, 'null' => true, 'comment' => 'วันที่ ออกบัตร', 'precision' => null],
'date_expiry' => ['type' => 'date', 'length' => null, 'default' => null, 'null' => true, 'comment' => 'วันที่ หมดอายุ', 'precision' => null],
'signature' => ['type' => 'string', 'length' => 255, 'default' => null, 'null' => true, 'collate' => null, 'comment' => 'ลายเซ็น', 'precision' => null, 'fixed' => null],
'is_used' => ['type' => 'boolean', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
'created_by' => ['type' => 'biginteger', 'length' => 20, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'unsigned' => null, 'autoIncrement' => null],
'created' => ['type' => 'timestamp', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
'modified_by' => ['type' => 'biginteger', 'length' => 20, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'unsigned' => null, 'autoIncrement' => null],
'modified' => ['type' => 'timestamp', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
],
];
// @codingStandardsIgnoreEnd
/**
* Records
*
* @var array
*/
public $records = [
[
'id' => 1,
'user_id' => 1,
'organize_id' => 1,
'card_code' => 'Lorem ipsum dolor ',
'img_path' => 'Lorem ipsum dolor sit amet',
'prefix_name_th' => 'Lorem ipsum dolor sit amet',
'firstname_th' => 'Lorem ipsum dolor sit amet',
'lastname_th' => 'Lorem ipsum dolor sit amet',
'prefix_name_en' => 'Lorem ipsum dolor sit amet',
'firstname_en' => 'Lorem ipsum dolor sit amet',
'lastname_en' => 'Lorem ipsum dolor sit amet',
'department_name' => 'Lorem ipsum dolor sit amet',
'section_name' => 'Lorem ipsum dolor sit amet',
'position_name' => 'Lorem ipsum dolor sit amet',
'gender' => 'Lorem ipsum dolor sit ame',
'blood_group' => 'Lorem ipsum dolor sit ame',
'birthdate' => '2018-05-15',
'date_issued' => '2018-05-15',
'date_expiry' => '2018-05-15',
'signature' => 'Lorem ipsum dolor sit amet',
'is_used' => 1,
'created_by' => 1,
'created' => 1526366122,
'modified_by' => 1,
'modified' => 1526366122
],
];
}
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\UserCardsController;
use Cake\TestSuite\IntegrationTestCase;
/**
* App\Controller\UserCardsController Test Case
*/
class UserCardsControllerTest extends IntegrationTestCase
{
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.user_cards',
'app.users',
'app.article_likes',
'app.article_take_questions',
'app.user_default_languages',
'app.user_homeplaces',
'app.user_personals',
'app.user_profiles',
'app.organizes'
];
/**
* Test index method
*
* @return void
*/
public function testIndex()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test view method
*
* @return void
*/
public function testView()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test add method
*
* @return void
*/
public function testAdd()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test edit method
*
* @return void
*/
public function testEdit()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test delete method
*
* @return void
*/
public function testDelete()
{
$this->markTestIncomplete('Not implemented yet.');
}
}
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\UserCardsTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\UserCardsTable Test Case
*/
class UserCardsTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\UserCardsTable
*/
public $UserCards;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.user_cards',
'app.users',
'app.article_likes',
'app.article_take_questions',
'app.user_default_languages',
'app.user_homeplaces',
'app.user_personals',
'app.user_profiles',
'app.organizes'
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::exists('UserCards') ? [] : ['className' => UserCardsTable::class];
$this->UserCards = TableRegistry::get('UserCards', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->UserCards);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
}
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