Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
smart_core_connect
/
core-connect
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0ae6c106
authored
May 16, 2018
by
Zen-PC\Zen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration' into kraikrit
parents
f51bf3de
dd0993fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
25 deletions
+86
-25
www/src/Controller/UserCardsController.php
+72
-20
www/src/Template/UserCards/create_cards.ctp
+14
-5
No files found.
www/src/Controller/UserCardsController.php
View file @
0ae6c106
...
@@ -123,7 +123,7 @@ class UserCardsController extends AppController
...
@@ -123,7 +123,7 @@ class UserCardsController extends AppController
$this
->
loadModel
(
'MasterOrganizations'
);
$this
->
loadModel
(
'MasterOrganizations'
);
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
// pr($this->Auth);die;
// pr($this->Auth);die;
// pr($this->request->data());
die;
// pr($this->request->data());
$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'
,
[
...
@@ -132,47 +132,99 @@ class UserCardsController extends AppController
...
@@ -132,47 +132,99 @@ class UserCardsController extends AppController
'card_code'
=>
$this
->
request
->
data
[
'UserCards'
][
'employee'
],
'card_code'
=>
$this
->
request
->
data
[
'UserCards'
][
'employee'
],
'birthdate'
=>
$birthdate
'birthdate'
=>
$birthdate
]
]
])
->
toArray
();
])
->
first
();
$TempUserCards
=
$this
->
TempUserCards
->
get
(
$TempUserCards
[
0
][
'id'
]);
if
(
!
empty
(
$TempUserCards
)){
$UserCards
=
$this
->
UserCards
->
find
(
'all'
,
[
// pr($TempUserCards);die;
'conditions'
=>
[
// pr($this->TempUserCards->get($TempUserCards[0]['id']));die;
'organize_id'
=>
$TempUserCards
[
'organize_id'
],
'card_code'
=>
$TempUserCards
[
'card_code'
]
]
])
->
first
();
// pr($UserCards);die;
if
(
empty
(
$UserCards
)){
$userCard
=
$this
->
UserCards
->
newEntity
();
$userCard
=
$this
->
UserCards
->
newEntity
();
//pr($userCard);die;
$userCard
[
'organize_id'
]
=
$TempUserCards
[
'organize_id'
];
// $userCard = $this->UserCards->patchEntity($userCard, $TempUserCards);
$userCard
[
'card_code'
]
=
$TempUserCards
[
'card_code'
];
$userCard
=
$TempUserCards
;
$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
;
$userCard
[
'user_id'
]
=
1
;
$userCard
[
'id'
]
=
null
;
// pr($userCard);die;
// pr($userCard->toArray());die;
if
(
$this
->
UserCards
->
save
(
$userCard
))
{
if
(
$this
->
UserCards
->
save
(
$userCard
))
{
$this
->
Flash
->
success
(
__
(
'The user card has been saved.'
));
$this
->
Flash
->
success
(
__
(
'บันทึกสำเร็จ'
));
die
;
return
$this
->
redirect
([
'controller'
=>
'Profiles'
,
'action'
=>
'index'
]);
return
$this
->
redirect
([
'action'
=>
'index'
]);
}
}
else
{
$this
->
Flash
->
success
(
__
(
'ลงทะเบียนไว้อยู่แล้ว'
));
return
$this
->
redirect
([
'controller'
=>
'UserCards'
,
'action'
=>
'createCards'
]);
}
}
else
{
$this
->
Flash
->
success
(
__
(
'ไม่พบข้อมูล'
));
return
$this
->
redirect
([
'controller'
=>
'UserCards'
,
'action'
=>
'createCards'
]);
}
}
$this
->
Flash
->
error
(
__
(
'The user card could not be saved. Please, try again.'
));
// pr($TempUserCards);die;
}
}
}
}
public
function
checkOrg
()
public
function
checkOrg
()
{
{
$this
->
autoRender
=
false
;
$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'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$this
->
loadModel
(
'MasterOrganizations'
);
$this
->
loadModel
(
'MasterOrganizations'
);
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
'fields'
=>
[
'fields'
=>
[
'id'
,
'org_code'
,
'id'
,
'org_code'
,
'org_name_th'
'org_name_th'
],
'conditions'
=>
[
],
'conditions'
=>
[
'org_code'
=>
$this
->
request
->
data
[
'organize_code'
]
'org_code'
=>
$this
->
request
->
data
[
'organize_code'
]
]
]
])
->
toArray
();
])
->
toArray
();
if
(
!
empty
(
$MasterOrganizations
)){
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
);
$data
=
json_encode
(
$MasterOrganizations
);
echo
$data
;
echo
$data
;
}
else
{
}
else
{
$MasterOrganizations
[
'chkuser'
]
=
true
;
$data
=
json_encode
(
$MasterOrganizations
);
echo
$data
;
}
}
else
{
echo
'false'
;
echo
'false'
;
}
}
}
}
...
...
www/src/Template/UserCards/create_cards.ctp
View file @
0ae6c106
<div class="row">
<div class="row">
<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->create('UserC
ra
ds', ['id' => 'frmSignIn', 'type' => 'file', 'onsubmit' => 'return check();']); ?>
<?php echo $this->Form->create('UserC
ar
ds', ['id' => 'frmSignIn', 'type' => 'file', 'onsubmit' => 'return check();']); ?>
<div style="position: absolute;z-index: 2;">
<div style="position: absolute;z-index: 2;">
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
</div>
</div>
...
@@ -25,14 +25,13 @@
...
@@ -25,14 +25,13 @@
</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">
<!-- <?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>
<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">
<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
>
<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">
ตรวจสอบ
</button>
</div>
</div>
<?php echo $this->Form->end(); ?>
<?php echo $this->Form->end(); ?>
</div>
</div>
...
@@ -49,11 +48,21 @@
...
@@ -49,11 +48,21 @@
if(data!='false'){
if(data!='false'){
data = jQuery.parseJSON(data);
data = jQuery.parseJSON(data);
console.log(data);
console.log(data);
if(data['chkuser'] == true){
$("#noorg_th").text('ลงทะเบียนกับ '+data[0]['org_name_th']+' แล้ว');
$("#nameorg_th").text('');
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
organize_id.value = '';
employee.value = '';
date.value = '';
}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('');
$("#employee").removeAttr("disabled");
$("#employee").removeAttr("disabled");
$("#date").removeAttr("disabled");
$("#date").removeAttr("disabled");
organize_id.value = data[0]['id'];
organize_id.value = data[0]['id'];
}
}else{
}else{
$("#noorg_th").text('ไม่พบข้อมูล');
$("#noorg_th").text('ไม่พบข้อมูล');
$("#nameorg_th").text('');
$("#nameorg_th").text('');
...
@@ -74,8 +83,8 @@
...
@@ -74,8 +83,8 @@
}
}
if (date.value == '') {
if (date.value == '') {
alert("วันเกิด");
alert("วันเกิด");
date.focus();
return false;
return false;
date.focus();
}
}
}
}
</script>
</script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment