Commit df89422c by Teeradone-PIM

Merge branch 'integration' into teeradone

parents 5e93d833 d68b3251
......@@ -362,6 +362,25 @@ return [
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
'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,79 @@ use Cake\Http\Client;
class ProfilesController extends AppController
{
public function index()
{
public function index($id = 13112){
$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');
$http = new Client();
$response = $http->post($api_core_profile,$data,$options)->body();
$response = json_decode($response,'_full');#prr($response);
$Profiles = $response['result']['Data'];
$Profiles['UserProfiles']['organize_id'] = 10;
$Profiles['UserProfiles']['dept_id'] = 10;
#debug($Profiles);
$this->set(compact('Profiles'));
#$this->set('_serialize', ['Profiles']);
#---------------------------------------------------------------------------------------------------------------
$this->loadModel('MasterOrganizations');
@$MasterDepartmentEducations = $this->MasterOrganizations->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['organize_id']],
$this->loadModel('Users');
$responseUserProfile = $this->Users->get($id, [
'contain' => []
]);
$username = $responseUserProfile['username'];
//********DropdownCountry********
$this->loadModel('MasterCountries');
$Country = $this->MasterCountries->find('list', [
'conditions' => [
'is_used' => true,
'MasterCountries.id' => 1],
'keyField' => 'id',
'valueField' => 'org_name_th',
'order' => 'org_name_th asc'
]
);
if(!empty($MasterDepartmentEducations)) $MasterDepartmentEducations = $MasterDepartmentEducations->toArray();
$this->set(compact('MasterDepartmentEducations'));
//debug($MasterDepartmentEducations[0]['org_name_th']);
$this->loadModel('MasterDepartments');
@$MasterDepartments_v = $this->MasterDepartments->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['dept_id']],
'valueField' => 'country_name_th'
]);
if(!empty($Country)) $Country = $Country->toArray();
//********DropdownProvince********
$this->loadModel('MasterProvinces');
$Province = $this->MasterProvinces->find('list', [
'conditions' => [
'is_used' => true,
'master_country_id' => 1],
'keyField' => 'id',
'valueField' => 'dept_name_th',
'order' => 'dept_name_th asc'
]
);
if(!empty($MasterDepartments_v)) $MasterDepartments_v = $MasterDepartments_v->toArray();
$this->set(compact('MasterDepartments_v'));
//debug($MasterDepartments_v);
$this->loadModel('MasterSections');
@$MasterSections_v = $this->MasterSections->find('all',
'valueField' => 'province_name_th'
]);
if(!empty($Province)) $Province = $Province->toArray();
$this->loadModel('UserPersonals');
$responseUserProfile = $this->UserPersonals->get($id, [
'contain' => []
]);
$res = $responseUserProfile['birthdate'];
$dateNow = $res->i18nFormat('dd/MM/yyyy');
if ($this->request->is(['patch', 'post', 'put'])) {
$data = $this->request->data;
// pr($this->request->data);die;
$this->loadModel('UserPersonals');
$userPersonals = $this->UserPersonals->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['section_id']],
'keyField' => 'id',
'valueField' => 'section_name_th',
'order' => 'section_name_th asc'
'limit' => 1,
'conditions' => [
'user_id' => $data['Users']['user_id']
]
);
if(!empty($MasterSections_v)) $MasterSections_v = $MasterSections_v->toArray();
$this->set(compact('MasterSections_v'));
//debug($MasterSections_v);
]
)->toArray();
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
$userPersonals = $this->UserPersonals->patchEntity($userPersonals[0], $data['UserPersonals']);
$userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th'];
$userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th'];
$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(__('The article has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The article could not be saved. Please, try again.'));
}
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']);
}
/*****************************************************************************/
......@@ -562,4 +568,29 @@ if (!empty($SubjectEnrolls)) {
}
// 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());die;
$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
]
])->toArray();
$TempUserCards = $this->TempUserCards->get($TempUserCards[0]['id']);
// pr($TempUserCards);die;
// pr($this->TempUserCards->get($TempUserCards[0]['id']));die;
$userCard = $this->UserCards->newEntity();
//pr($userCard);die;
// $userCard = $this->UserCards->patchEntity($userCard, $TempUserCards);
$userCard = $TempUserCards;
$userCard['user_id'] = 1;
$userCard['id'] = null;
// pr($userCard->toArray());die;
if ($this->UserCards->save($userCard)) {
$this->Flash->success(__('The user card has been saved.'));
die;
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The user card could not be saved. Please, try again.'));
// pr($TempUserCards);die;
}
}
public function checkOrg()
{
$this->autoRender = false;
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)){
$data = json_encode($MasterOrganizations);
echo $data;
}else{
echo 'false';
}
}
}
}
<?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;
}
}
<?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 style="text-align: center;">
<input type="file" id="uploadProfile" class="profile-img form-control form-input Profile-input-file" name="data[UserProfiles][img_path]" >
</div>
<div class="bg-profile"></div>
<!--<div class="col-xs-12 col-sm-12 col-md-12" style="padding-top: 20px;">-->
<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">
<!-- <?php echo $this->Form->input('UserCards.birthdate', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'birthdate', 'type' => 'daet', 'label' => __('วันเกิด'), 'placeholder' => '01/01/2000', 'disabled', 'required']); ?> -->
<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