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
13ceb58c
authored
May 24, 2018
by
Teeradone-PIM
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration' into teeradone
# Conflicts: # www/src/Controller/UsersController.php
parents
f31c1fb2
507e8354
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
93 deletions
+112
-93
www/src/Controller/ProfilesController.php
+6
-1
www/src/Controller/UserCardsController.php
+50
-73
www/src/Controller/UsersController.php
+27
-13
www/src/Template/UserCards/view_card.ctp
+29
-6
No files found.
www/src/Controller/ProfilesController.php
View file @
13ceb58c
...
@@ -53,7 +53,12 @@ class ProfilesController extends AppController
...
@@ -53,7 +53,12 @@ class ProfilesController extends AppController
if
(
!
empty
(
$Province
))
$Province
=
$Province
->
toArray
();
if
(
!
empty
(
$Province
))
$Province
=
$Province
->
toArray
();
$res
=
$responseUserPersonal
[
'birthdate'
];
$res
=
$responseUserPersonal
[
'birthdate'
];
$dateNow
=
$res
->
i18nFormat
(
'dd/MM/yyyy'
);
if
(
$res
){
$dateNow
=
@
$res
->
i18nFormat
(
'dd/MM/yyyy'
);
}
else
{
$dateNow
=
""
;
}
if
(
$this
->
request
->
is
([
'patch'
,
'post'
,
'put'
]))
{
if
(
$this
->
request
->
is
([
'patch'
,
'post'
,
'put'
]))
{
$data
=
$this
->
request
->
data
;
$data
=
$this
->
request
->
data
;
...
...
www/src/Controller/UserCardsController.php
View file @
13ceb58c
...
@@ -115,85 +115,50 @@ class UserCardsController extends AppController
...
@@ -115,85 +115,50 @@ class UserCardsController extends AppController
return
$this
->
redirect
([
'action'
=>
'index'
]);
return
$this
->
redirect
([
'action'
=>
'index'
]);
}
}
public
function
checkOrg
()
public
function
createCards
()
// ----------------- เอาไปรวมกับ viweCards แล้ว ------------------
{
{
$this
->
viewBuilder
()
->
layout
(
'blank'
)
;
$this
->
autoRender
=
false
;
$this
->
loadModel
(
'TempUserCards'
);
if
(
$this
->
request
->
is
(
'post'
))
{
$this
->
loadModel
(
'MasterOrganizations'
);
$this
->
loadModel
(
'MasterOrganizations'
);
if
(
$this
->
request
->
is
(
'post'
))
{
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
// pr($this->Auth);die;
'fields'
=>
[
// pr($this->request->data());
'id'
,
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserCards'
][
'birthdate'
]);
'org_code'
,
$birthdate
=
$birthdate
[
'2'
]
.
'-'
.
$birthdate
[
'1'
]
.
'-'
.
$birthdate
[
'0'
];
'org_name_th'
$TempUserCards
=
$this
->
TempUserCards
->
find
(
'all'
,
[
],
'conditions'
=>
[
'conditions'
=>
[
'org_code'
=>
$this
->
request
->
data
[
'organize_code'
]
'organize_id'
=>
$this
->
request
->
data
[
'UserCards'
][
'organize_id'
],
'card_code'
=>
$this
->
request
->
data
[
'UserCards'
][
'employee'
],
'birthdate'
=>
$birthdate
]
]
])
->
first
();
])
->
toArray
();
if
(
!
empty
(
$
TempUserCard
s
)){
if
(
!
empty
(
$
MasterOrganization
s
)){
$UserCards
=
$this
->
UserCards
->
find
(
'all'
,
[
$UserCards
=
$this
->
UserCards
->
find
(
'all'
,
[
'conditions'
=>
[
'fields'
=>
[
'organize_id'
=>
$TempUserCards
[
'organize_id'
],
'id'
,
'card_code'
=>
$TempUserCards
[
'card_code'
]
'user_id'
,
'organize_id'
],
'conditions'
=>
[
'user_id'
=>
$this
->
Auth
->
user
(
'id'
),
'organize_id'
=>
$MasterOrganizations
[
0
][
'id'
]
]
]
])
->
first
();
])
->
toArray
();
// pr($UserCards);die;
if
(
empty
(
$UserCards
)){
if
(
empty
(
$UserCards
)){
$userCard
=
$this
->
UserCards
->
newEntity
();
$MasterOrganizations
[
'chkuser'
]
=
false
;
$userCard
[
'organize_id'
]
=
$TempUserCards
[
'organize_id'
];
$data
=
json_encode
(
$MasterOrganizations
);
$userCard
[
'card_code'
]
=
$TempUserCards
[
'card_code'
];
echo
$data
;
$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
{
}
else
{
$this
->
Flash
->
success
(
__
(
'ลงทะเบียนไว้อยู่แล้ว'
));
$MasterOrganizations
[
'chkuser'
]
=
true
;
return
$this
->
redirect
([
'controller'
=>
'UserCards'
,
'action'
=>
'createCards'
]);
$data
=
json_encode
(
$MasterOrganizations
);
echo
$data
;
}
}
}
else
{
}
else
{
$this
->
Flash
->
success
(
__
(
'ไม่พบข้อมูล'
));
echo
'false'
;
return
$this
->
redirect
([
'controller'
=>
'UserCards'
,
'action'
=>
'createCards'
]);
}
}
}
}
}
}
public
function
check
Org
()
public
function
check
Emp
()
{
{
$this
->
autoRender
=
false
;
$this
->
autoRender
=
false
;
// $this->loadModel('MasterOrganizations');
if
(
$this
->
request
->
is
(
'post'
))
{
// $MasterOrganizations = $this->MasterOrganizations->find('all', [
// pr($this->request->data);die;
// 'fields' => [
// 'id',
// 'org_code',
// 'org_name_th'
// ], 'conditions' => [
// 'org_code' => 'PAGO0010'
// ]
// ])->toArray();
// pr($MasterOrganizations);die;
if
(
$this
->
request
->
is
(
'post'
))
{
$this
->
loadModel
(
'MasterOrganizations'
);
$this
->
loadModel
(
'MasterOrganizations'
);
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
'fields'
=>
[
'fields'
=>
[
...
@@ -203,8 +168,17 @@ class UserCardsController extends AppController
...
@@ -203,8 +168,17 @@ class UserCardsController extends AppController
],
'conditions'
=>
[
],
'conditions'
=>
[
'org_code'
=>
$this
->
request
->
data
[
'organize_code'
]
'org_code'
=>
$this
->
request
->
data
[
'organize_code'
]
]
]
])
->
toArray
();
])
->
first
();
// pr($MasterOrganizations);die;
if
(
!
empty
(
$MasterOrganizations
)){
if
(
!
empty
(
$MasterOrganizations
)){
$this
->
loadModel
(
'TempUserCards'
);
$TempUserCards
=
$this
->
TempUserCards
->
find
(
'all'
,
[
'conditions'
=>
[
'organize_id'
=>
$MasterOrganizations
[
'id'
],
'card_code'
=>
$this
->
request
->
data
[
'employee_val'
]
]
])
->
first
();
if
(
!
empty
(
$TempUserCards
)){
$UserCards
=
$this
->
UserCards
->
find
(
'all'
,
[
$UserCards
=
$this
->
UserCards
->
find
(
'all'
,
[
'fields'
=>
[
'fields'
=>
[
'id'
,
'id'
,
...
@@ -212,21 +186,24 @@ class UserCardsController extends AppController
...
@@ -212,21 +186,24 @@ class UserCardsController extends AppController
'organize_id'
'organize_id'
],
'conditions'
=>
[
],
'conditions'
=>
[
'user_id'
=>
$this
->
Auth
->
user
(
'id'
),
'user_id'
=>
$this
->
Auth
->
user
(
'id'
),
'organize_id'
=>
$MasterOrganizations
[
0
]
[
'id'
]
'organize_id'
=>
$MasterOrganizations
[
'id'
]
]
]
])
->
toArray
();
])
->
first
();
if
(
empty
(
$UserCards
)){
if
(
empty
(
$UserCards
)){
$MasterOrganization
s
[
'chkuser'
]
=
false
;
$TempUserCard
s
[
'chkuser'
]
=
false
;
$data
=
json_encode
(
$MasterOrganization
s
);
$data
=
json_encode
(
$TempUserCard
s
);
echo
$data
;
echo
$data
;
}
else
{
}
else
{
$MasterOrganization
s
[
'chkuser'
]
=
true
;
$TempUserCard
s
[
'chkuser'
]
=
true
;
$data
=
json_encode
(
$MasterOrganization
s
);
$data
=
json_encode
(
$TempUserCard
s
);
echo
$data
;
echo
$data
;
}
}
}
else
{
}
else
{
echo
'false'
;
echo
'false'
;
}
}
}
else
{
echo
'false'
;
}
}
}
}
}
public
function
viewCard
(
$user_id
=
null
){
public
function
viewCard
(
$user_id
=
null
){
...
@@ -260,7 +237,7 @@ class UserCardsController extends AppController
...
@@ -260,7 +237,7 @@ class UserCardsController extends AppController
$this
->
loadModel
(
'TempUserCards'
);
$this
->
loadModel
(
'TempUserCards'
);
$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;
// pr($this->Auth->user('id'));die;
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserCards'
][
'birthdate'
]);
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserCards'
][
'birthdate'
]);
...
...
www/src/Controller/UsersController.php
View file @
13ceb58c
...
@@ -123,6 +123,7 @@ class UsersController extends AppController {
...
@@ -123,6 +123,7 @@ class UsersController extends AppController {
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
}
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#Signup
#Signup
...
@@ -373,28 +374,31 @@ class UsersController extends AppController {
...
@@ -373,28 +374,31 @@ class UsersController extends AppController {
public
function
changePassword
(
$token
=
null
)
public
function
changePassword
(
$token
=
null
)
{
{
$id
=
$this
->
Auth
->
user
(
'id'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
$users
=
$this
->
Users
->
get
(
$id
);
'conditions'
=>
[
'Users.id'
=>
$this
->
Auth
->
user
(
'id'
)
]
])
->
first
();
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$oldpassword
=
$this
->
request
->
data
[
'oldpassword'
];
// pr($this->request->data['oldpassword']);die;
$hasher
=
new
DefaultPasswordHasher
();
$hasher
=
new
DefaultPasswordHasher
();
$password
=
$this
->
request
->
data
[
'password'
];
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$oldpassword
=
$this
->
request
->
data
[
'oldpassword'
];
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if
(
password_verify
(
$oldpassword
,
$users
[
'password'
]))
{
if
(
password_verify
(
$oldpassword
,
$users
[
'password'
]))
{
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$this
->
Users
->
save
(
$users
);
$this
->
Users
->
save
(
$users
);
$this
->
Flash
->
success
(
__
(
'change password success'
));
$this
->
Flash
->
success
(
__
(
'change password success'
));
$this
->
Flash
->
success
(
__
(
'You are now logged out.'
));
return
$this
->
redirect
([
'action'
=>
'signout'
]);
return
$this
->
redirect
([
'action'
=>
'signout'
]);
}
else
{
}
else
{
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
return
$this
->
redirect
([
'action'
=>
'change-password
/'
.
$token
]);
return
$this
->
redirect
([
'action'
=>
'change-password
'
]);
}
}
}
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
...
@@ -411,7 +415,7 @@ class UsersController extends AppController {
...
@@ -411,7 +415,7 @@ class UsersController extends AppController {
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$hasher
=
new
DefaultPasswordHasher
();
$hasher
=
new
DefaultPasswordHasher
();
$password
=
$this
->
request
->
data
[
'password'
];
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
//
$confirm_password = $this->request->data['confirm_password'];
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
...
@@ -428,13 +432,23 @@ class UsersController extends AppController {
...
@@ -428,13 +432,23 @@ class UsersController extends AppController {
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
public
function
signout
()
/**
{
*
$this
->
checkToken
();
* Function user logout / signout
* @author sarawutt.b
* @since 2018/05/22 16:44:20
* @license PAKGON
* @return void
*/
public
function
signout
()
{
$http
=
new
Client
();
$result
=
$http
->
delete
(
Configure
::
read
(
'OAUTH2_PROVIDER.TOKEN_DETETE'
)
.
'/'
.
$this
->
Auth
->
user
(
'id'
))
->
body
();
$this
->
Flash
->
success
(
__
(
'You are now logged out.'
));
return
$this
->
redirect
(
$this
->
Auth
->
logout
());
}
}
}
}
www/src/Template/UserCards/view_card.ctp
View file @
13ceb58c
...
@@ -156,12 +156,14 @@ use Cake\I18n\Time;
...
@@ -156,12 +156,14 @@ use Cake\I18n\Time;
<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' => 'Ref 1', 'disabled']); ?>
<?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']); ?>
<label id = "nameemp_th" style="color: green"></label>
<label id = "noepm_th" style="color: red"></label>
</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="Ref 2" 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=""
readonly
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>
...
@@ -527,6 +529,7 @@ use Cake\I18n\Time;
...
@@ -527,6 +529,7 @@ use Cake\I18n\Time;
var date = $("#date");
var date = $("#date");
$(document).ready(function() {
$(document).ready(function() {
$("#organize_code").on('change',function(){
$("#organize_code").on('change',function(){
// alert(moment("05/22/2012", 'MM/DD/YYYY',true).isValid()); //true
var organize_code = $("#organize_code").val();
var organize_code = $("#organize_code").val();
$('#employee').attr("disabled",true);
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
$('#date').attr("disabled",true);
...
@@ -537,30 +540,50 @@ use Cake\I18n\Time;
...
@@ -537,30 +540,50 @@ use Cake\I18n\Time;
$.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);
console.log(data);
if(data['chkuser'] == true){
if(data['chkuser'] == true){
$("#noorg_th").text('ลงทะเบียนกับ '+data[0]['org_name_th']+' แล้ว');
$("#noorg_th").text('ลงทะเบียนกับ '+data[0]['org_name_th']+' แล้ว');
$("#nameorg_th").text('');
$("#nameorg_th").text('');
$('#employee').attr("disabled",true);
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
organize_id.val('');
organize_id.val('');
employee.val('');
employee.val('');
date.val('');
}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");
$("#checkbutton").removeAttr("disabled");
$("#employee").removeAttr("disabled");
$("#employee").removeAttr("disabled");
$("#date").removeAttr("disabled");
organize_id.val(data[0]['id']);
organize_id.val(data[0]['id']);
}
}
}else{
}else{
$("#noorg_th").text('ไม่พบข้อมูล');
$("#noorg_th").text('ไม่พบข้อมูล');
$("#nameorg_th").text('');
$("#nameorg_th").text('');
$('#employee').attr("disabled",true);
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
organize_id.val('');
organize_id.val('');
employee.val('');
employee.val('');
}
});
});
$("#employee").on('change',function(){
var employee_val = employee.val();
var organize_code = $("#organize_code").val();
$('#date').attr("disabled",true);
date.val('');
$.post("/UserCards/checkEmp", {employee_val: employee_val,organize_code: organize_code}, function(data) {
if(data!='false'){
data = jQuery.parseJSON(data);
if(data['chkuser'] == true){
$("#noepm_th").text('ลงทะเบียนแล้ว');
$("#nameemp_th").text('');
$('#date').attr("disabled",true);
date.val('');
}else if(data['chkuser'] == false){
$("#nameemp_th").text(data['prefix_name_th']+data['firstname_th']+' '+data['lastname_th']);
$("#noepm_th").text('');
$("#date").removeAttr("disabled");
}
}else{
$("#noepm_th").text('"ไม่พบข้อมูลที่ต้องการ" กรุณากรอกรหัสข้อมูลที่ถูกต้องและกดตรวจสอบ');
$("#nameemp_th").text('');
$('#date').attr("disabled",true);
date.val('');
date.val('');
}
}
});
});
...
...
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