Commit d4bc76e6 by Zen-PC\Zen

Merge branch 'integration' into kraikrit

parents 53deb96f ea0117b1
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ebc259e4faf59f493adbde15e8aa5e34", "content-hash": "ebc259e4faf59f493adbde15e8aa5e34",
......
...@@ -8,13 +8,13 @@ use Cake\Http\Client; ...@@ -8,13 +8,13 @@ use Cake\Http\Client;
class ProfilesController extends AppController class ProfilesController extends AppController
{ {
public function index($id = 13112){ public function index(){
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
/*******************************/ /*******************************/
$id = $this->Auth->user('id'); $id = $this->Auth->user('id');
$this->loadModel('Users'); $this->loadModel('Users');
$responseUserProfile = $this->Users->get($id, [ $responseUserProfile = $this->Users->get($id, [
...@@ -47,8 +47,8 @@ class ProfilesController extends AppController ...@@ -47,8 +47,8 @@ class ProfilesController extends AppController
'keyField' => 'id', 'keyField' => 'id',
'valueField' => 'province_name_th' 'valueField' => 'province_name_th'
]) ])
->where(['master_country_id =' => $responseUserPersonal['master_country_id']]) ->where(['master_country_id =' => $responseUserPersonal['master_country_id']])
->order(['province_name_th']); ->order(['province_name_th']);
// pr($Province);die; // pr($Province);die;
if(!empty($Province)) $Province = $Province->toArray(); if(!empty($Province)) $Province = $Province->toArray();
...@@ -56,6 +56,8 @@ class ProfilesController extends AppController ...@@ -56,6 +56,8 @@ class ProfilesController extends AppController
$dateNow = $res->i18nFormat('dd/MM/yyyy'); $dateNow = $res->i18nFormat('dd/MM/yyyy');
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
// pr($this->request->data());die;
$data = $this->request->data; $data = $this->request->data;
// pr($this->request->data);die; // pr($this->request->data);die;
...@@ -103,13 +105,13 @@ class ProfilesController extends AppController ...@@ -103,13 +105,13 @@ class ProfilesController extends AppController
$userPersonals['master_province_id'] = $this->request->data['master_province_id']; $userPersonals['master_province_id'] = $this->request->data['master_province_id'];
$userPersonals['modified_by'] = $id; $userPersonals['modified_by'] = $id;
if ($this->UserPersonals->save($userPersonals)) { if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('Update Complete.')); $this->Flash->success(__('Update Complete.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
}
}else{
$this->Flash->error(__('Email Address already used by others.'));
} }
}else{
$this->Flash->error(__('Email Address already used by others.'));
}
$this->Flash->error(__('Not update. Please, try again.')); $this->Flash->error(__('Not update. Please, try again.'));
} }
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal')); $this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal'));
......
...@@ -211,7 +211,7 @@ class UserCardsController extends AppController ...@@ -211,7 +211,7 @@ class UserCardsController extends AppController
'user_id', 'user_id',
'organize_id' 'organize_id'
], 'conditions' => [ ], 'conditions' => [
'user_id' => 2, 'user_id' => $this->Auth->user('id'),
'organize_id' => $MasterOrganizations[0]['id'] 'organize_id' => $MasterOrganizations[0]['id']
] ]
])->toArray(); ])->toArray();
...@@ -231,7 +231,7 @@ class UserCardsController extends AppController ...@@ -231,7 +231,7 @@ class UserCardsController extends AppController
} }
public function viewCard($user_id = null){ public function viewCard($user_id = null){
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
// $user = $this->Auth(); $user_id = $this->Auth->user('id');
$this->loadModel('UserCards'); $this->loadModel('UserCards');
$UserCards = $this->UserCards->find('all') $UserCards = $this->UserCards->find('all')
->select($this->UserCards) ->select($this->UserCards)
...@@ -262,6 +262,7 @@ class UserCardsController extends AppController ...@@ -262,6 +262,7 @@ class UserCardsController extends AppController
$this->loadModel('MasterOrganizations'); $this->loadModel('MasterOrganizations');
if ($this->request->is('post')) { if ($this->request->is('post')) {
// pr($this->request->data());die; // pr($this->request->data());die;
// pr($this->Auth->user('id'));die;
$birthdate = explode("/", $this->request->data['UserCards']['birthdate']); $birthdate = explode("/", $this->request->data['UserCards']['birthdate']);
$birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0']; $birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0'];
$TempUserCards = $this->TempUserCards->find('all', [ $TempUserCards = $this->TempUserCards->find('all', [
...@@ -301,12 +302,31 @@ class UserCardsController extends AppController ...@@ -301,12 +302,31 @@ class UserCardsController extends AppController
$userCard['date_expiry'] = $TempUserCards['date_expiry']; $userCard['date_expiry'] = $TempUserCards['date_expiry'];
$userCard['signature'] = $TempUserCards['signature']; $userCard['signature'] = $TempUserCards['signature'];
$userCard['is_used'] = $TempUserCards['is_used']; $userCard['is_used'] = $TempUserCards['is_used'];
$userCard['created_by'] = 1; $userCard['created_by'] = $this->Auth->user('id');
$userCard['user_id'] = 1; $userCard['user_id'] = $this->Auth->user('id');
// pr($userCard);die; // pr($userCard);die;
if ($this->UserCards->save($userCard)) { if ($this->UserCards->save($userCard)) {
// pr('sdsd');die;
$TempUserCards['is_used'] = 0; $TempUserCards['is_used'] = 0;
$this->TempUserCards->save($TempUserCards); $this->TempUserCards->save($TempUserCards);
$this->loadModel('UserEntities');
$UserEntities = $this->UserEntities->find('all', [
'conditions' => [
'user_id' => $this->Auth->user('id'),
'entity_code' => $TempUserCards['organize_id']
]
])->first();
if(empty($UserEntities)){
// pr('sdsd');die;
$UserEntities = $this->UserEntities->newEntity();
$UserEntities['entity_code'] = $TempUserCards['organize_id'];
$UserEntities['user_id'] = $this->Auth->user('id');
$UserEntities['created_by'] = $this->Auth->user('id');
$UserEntities['modified_by'] = $this->Auth->user('id');
$this->UserEntities->save($UserEntities);
}
$this->Flash->success(__('บันทึกสำเร็จ')); $this->Flash->success(__('บันทึกสำเร็จ'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']); return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
} }
......
...@@ -117,13 +117,12 @@ class UsersController extends AppController { ...@@ -117,13 +117,12 @@ class UsersController extends AppController {
'keyField' => 'id', 'keyField' => 'id',
'valueField' => 'province_name_th' 'valueField' => 'province_name_th'
] ]
); );
if(!empty($provinces)) $provinces = $provinces->toArray(); if(!empty($provinces)) $provinces = $provinces->toArray();
$this->set(compact('provinces','countries')); $this->set(compact('provinces','countries'));
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
} }
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
#Signup #Signup
......
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* Building Entity
*/
class UserEntity extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
class UserEntitiesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('core.user_entities');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
// return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'core';
}
}
...@@ -156,18 +156,18 @@ use Cake\I18n\Time; ...@@ -156,18 +156,18 @@ use Cake\I18n\Time;
</div> </div>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12"> <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' => __('Ref 1'), 'placeholder' => 'รหัสพนักงาน / รหัสนักศึกษา', 'disabled', 'required']); ?> <?php echo $this->Form->input('UserCards.employee', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'employee', 'type' => 'text', 'label' => __('Ref 1'), 'placeholder' => 'Ref 1', 'disabled']); ?>
</div> </div>
</div> </div>
<div class="form-group has-feedback bootstrap-iso"> <div class="form-group has-feedback bootstrap-iso">
<div class="col-xs-12 col-sm-12 col-md-12"> <div class="col-xs-12 col-sm-12 col-md-12">
<label class="label-text-sub"><?php echo __('Ref 2');?></label> <label class="label-text-sub"><?php echo __('Ref 2');?></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" disabled> <input type="text" name="UserCards[birthdate]" id="date" placeholder="Ref 2" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from" disabled>
<span class="glyphicon glyphicon-calendar form-control-feedback"></span> <span class="glyphicon glyphicon-calendar form-control-feedback"></span>
</div> </div>
</div> </div>
<div> <div>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile">ตรวจสอบ</button> <button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile" id="checkbutton">ตรวจสอบ</button>
</div> </div>
<?php echo $this->Form->end(); ?> <?php echo $this->Form->end(); ?>
</div> </div>
...@@ -255,6 +255,113 @@ use Cake\I18n\Time; ...@@ -255,6 +255,113 @@ use Cake\I18n\Time;
</div> </div>
<style> <style>
#alertBox {
position:relative;
width:300px;
min-height:100px;
/*margin-top:50px;*/
border:1px solid #666;
background-color:#fff;
background-repeat:no-repeat;
background-position:20px 30px;
left: 0;
right: 0;
top: 100px;
z-index: 2;
}
#modalContainer > #alertBox {
position:fixed;
}
#alertBox h1 {
margin:0;
font:bold 0.9em verdana,arial;
background-color:#000;
color:#FFF;
border-bottom:1px solid #000;
padding:2px 0 2px 5px;
}
#alertBox p {
font-size: 14px;
height: 30px;
padding: 10px;
/* margin-left: 55px; */
text-align: center;
}
#alertBox #closeBtn {
display:block;
position:relative;
margin:5px auto;
padding:7px;
border:0 none;
width:70px;
font:0.7em verdana,arial;
text-transform:uppercase;
text-align:center;
color:#FFF;
background-color:#000;
border-radius: 3px;
text-decoration:none;
}
/* unrelated styles */
#mContainer {
position:relative;
width:600px;
margin:auto;
padding:5px;
border-top:2px solid #000;
border-bottom:2px solid #000;
font:0.7em verdana,arial;
}
h1,h2 {
margin:0;
padding:4px;
font:bold 1.5em verdana;
border-bottom:1px solid #000;
text-align: center;
}
code {
font-size:1.2em;
color:#069;
}
#credits {
position:relative;
margin:25px auto 0px auto;
width:350px;
font:0.7em verdana;
border-top:1px solid #000;
border-bottom:1px solid #000;
height:90px;
padding-top:4px;
}
#credits img {
float:left;
margin:5px 10px 5px 0px;
border:1px solid #000000;
width:80px;
height:79px;
}
.important {
background-color:#F5FCC8;
padding:2px;
}
code span {
color:green;
}
</style>
<style>
.box-card{ .box-card{
border: 1px solid #ccc; border: 1px solid #ccc;
height: 200px; height: 200px;
...@@ -327,34 +434,84 @@ use Cake\I18n\Time; ...@@ -327,34 +434,84 @@ use Cake\I18n\Time;
margin: 70% 0% 0% 25%; margin: 70% 0% 0% 25%;
} }
</style> </style>
<?php $this->append('scriptBottom'); ?> <?php $this->append('scriptBottom'); ?>
<script type="text/javascript"> <script>
var ALERT_TITLE = "";
var ALERT_BUTTON_TEXT = "Ok";
$('.owl-carousel').owlCarousel({ if (document.getElementById) {
loop:false, window.alert = function (txt) {
items:1, createCustomAlert(txt);
rewindNav : false, }
onTranslated:callBack }
}); function createCustomAlert(txt) {
owl = $('.owl-carousel').owlCarousel(); d = document;
$(".prev").click(function () { if (d.getElementById("modalContainer"))
owl.trigger('prev.owl.carousel'); return;
}); mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
mObj.id = "modalContainer";
mObj.style.height = d.documentElement.scrollHeight + "px";
alertObj = mObj.appendChild(d.createElement("div"));
alertObj.id = "alertBox";
if (d.all && !window.opera)
alertObj.style.top = document.documentElement.scrollTop + "px";
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth) / 2 + "px";
alertObj.style.visiblity = "visible";
$(".next").click(function () { h1 = alertObj.appendChild(d.createElement("h1"));
owl.trigger('next.owl.carousel'); h1.appendChild(d.createTextNode(ALERT_TITLE));
});
function callBack(){ msg = alertObj.appendChild(d.createElement("p"));
if($('.owl-carousel .owl-item').last().hasClass('active')){ //msg.appendChild(d.createTextNode(txt));
$('.next').hide(); msg.innerHTML = txt;
$('.prev').show();
btn = alertObj.appendChild(d.createElement("a"));
}else if($('.owl-carousel .owl-item').first().hasClass('active')){ btn.id = "closeBtn";
$('.prev').hide(); btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
$('.next').show(); btn.href = "#";
btn.focus();
btn.onclick = function () {
removeCustomAlert();
return false;
}
alertObj.style.display = "block";
} }
}
function removeCustomAlert() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
function ful() {
alert('Alert this pages');
}
</script>
<script type="text/javascript">
$('.owl-carousel').owlCarousel({
loop:false,
items:1,
rewindNav : false,
onTranslated:callBack
});
owl = $('.owl-carousel').owlCarousel();
$(".prev").click(function () {
owl.trigger('prev.owl.carousel');
});
$(".next").click(function () {
owl.trigger('next.owl.carousel');
});
function callBack(){
if($('.owl-carousel .owl-item').last().hasClass('active')){
$('.next').hide();
$('.prev').show();
}else if($('.owl-carousel .owl-item').first().hasClass('active')){
$('.prev').hide();
$('.next').show();
}
}
var organize_id = $("#organize_id"); var organize_id = $("#organize_id");
var employee = $("#employee"); var employee = $("#employee");
...@@ -362,6 +519,12 @@ function callBack(){ ...@@ -362,6 +519,12 @@ function callBack(){
$(document).ready(function() { $(document).ready(function() {
$("#organize_code").on('change',function(){ $("#organize_code").on('change',function(){
var organize_code = $("#organize_code").val(); var organize_code = $("#organize_code").val();
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
$('#checkbutton').attr("disabled",true);
organize_id.val('');
employee.val('');
date.val('');
$.post("/UserCards/checkOrg", {organize_code: organize_code}, function(data) { $.post("/UserCards/checkOrg", {organize_code: organize_code}, function(data) {
if(data!='false'){ if(data!='false'){
data = jQuery.parseJSON(data); data = jQuery.parseJSON(data);
...@@ -377,6 +540,7 @@ function callBack(){ ...@@ -377,6 +540,7 @@ function callBack(){
}else if(data['chkuser'] == false){ }else if(data['chkuser'] == false){
$("#nameorg_th").text(data[0]['org_name_th']); $("#nameorg_th").text(data[0]['org_name_th']);
$("#noorg_th").text(''); $("#noorg_th").text('');
$("#checkbutton").removeAttr("disabled");
$("#employee").removeAttr("disabled"); $("#employee").removeAttr("disabled");
$("#date").removeAttr("disabled"); $("#date").removeAttr("disabled");
organize_id.val(data[0]['id']); organize_id.val(data[0]['id']);
...@@ -395,12 +559,14 @@ function callBack(){ ...@@ -395,12 +559,14 @@ function callBack(){
}); });
function check() { function check() {
if (employee.val() == '') { if (employee.val() == '') {
alert('กรุณากรอก Ref1');
employee.focus(); employee.focus();
return false; return false;
} }
if (date.val() == '') { if (date.val() == '') {
return false; alert('กรุณากรอก Ref2');
date.focus(); date.focus();
return false;
} }
} }
$(document).ready(function(){ $(document).ready(function(){
...@@ -415,4 +581,4 @@ function callBack(){ ...@@ -415,4 +581,4 @@ function callBack(){
date_input.datepicker(options); date_input.datepicker(options);
}) })
</script> </script>
<?php $this->end();?> <?php $this->end();?>
\ No newline at end of file
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