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
302d0208
authored
May 24, 2018
by
Zen-PC\Zen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration' into kraikrit
parents
7bfa72d6
13ceb58c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
110 deletions
+130
-110
www/src/Controller/UserCardsController.php
+54
-77
www/src/Controller/UsersController.php
+5
-21
www/src/Template/UserCards/view_card.ctp
+30
-7
www/src/Template/Users/signup.ctp
+41
-5
No files found.
www/src/Controller/UserCardsController.php
View file @
302d0208
...
...
@@ -115,85 +115,10 @@ class UserCardsController extends AppController
return
$this
->
redirect
([
'action'
=>
'index'
]);
}
public
function
createCards
()
// ----------------- เอาไปรวมกับ viweCards แล้ว ------------------
{
$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'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$this
->
loadModel
(
'MasterOrganizations'
);
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
'fields'
=>
[
...
...
@@ -229,6 +154,58 @@ class UserCardsController extends AppController
}
}
}
public
function
checkEmp
()
{
$this
->
autoRender
=
false
;
if
(
$this
->
request
->
is
(
'post'
))
{
// pr($this->request->data);die;
$this
->
loadModel
(
'MasterOrganizations'
);
$MasterOrganizations
=
$this
->
MasterOrganizations
->
find
(
'all'
,
[
'fields'
=>
[
'id'
,
'org_code'
,
'org_name_th'
],
'conditions'
=>
[
'org_code'
=>
$this
->
request
->
data
[
'organize_code'
]
]
])
->
first
();
// pr($MasterOrganizations);die;
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'
,
[
'fields'
=>
[
'id'
,
'user_id'
,
'organize_id'
],
'conditions'
=>
[
'user_id'
=>
$this
->
Auth
->
user
(
'id'
),
'organize_id'
=>
$MasterOrganizations
[
'id'
]
]
])
->
first
();
if
(
empty
(
$UserCards
)){
$TempUserCards
[
'chkuser'
]
=
false
;
$data
=
json_encode
(
$TempUserCards
);
echo
$data
;
}
else
{
$TempUserCards
[
'chkuser'
]
=
true
;
$data
=
json_encode
(
$TempUserCards
);
echo
$data
;
}
}
else
{
echo
'false'
;
}
}
else
{
echo
'false'
;
}
}
}
public
function
viewCard
(
$user_id
=
null
){
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$user_id
=
$this
->
Auth
->
user
(
'id'
);
...
...
@@ -260,7 +237,7 @@ class UserCardsController extends AppController
$this
->
loadModel
(
'TempUserCards'
);
$this
->
loadModel
(
'MasterOrganizations'
);
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
// pr($this->request->data());die;
// pr($this->Auth->user('id'));die;
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserCards'
][
'birthdate'
]);
...
...
www/src/Controller/UsersController.php
View file @
302d0208
...
...
@@ -315,26 +315,7 @@ class UsersController extends AppController {
$this
->
loadModel
(
'UserPersonals'
);
if
(
$this
->
request
->
is
(
'post'
))
{
$hasher
=
new
DefaultPasswordHasher
();
$email
=
$this
->
request
->
data
[
'email'
];
//-------------------RandomPassword---------------------------------------------------------
// $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
// $pass = array();
// $alphaLength = strlen($alphabet) - 1;
// for ($i = 0; $i < 8; $i++) {
// $n = rand(0, $alphaLength);
// $pass[] = $alphabet[$n];
// }
// $password = implode($pass);
//--------------------ตัวส่ง Email --------------------------------------
//pr($user_personals);die;
// $data_notification = [];
// $data_notification['email'] = $this->request->data['email'];
// $data_notification['password'] = $password;
// $this->notification($data_notification);
//------------------------------------------------------------------------------------------
$email
=
$this
->
request
->
data
[
'email'
];
$user_personals
=
$this
->
UserPersonals
->
find
(
'all'
,[
'conditions'
=>
[
'UserPersonals.email'
=>
$email
...
...
@@ -438,9 +419,12 @@ class UsersController extends AppController {
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$this
->
Users
->
save
(
$users
);
if
(
$this
->
Users
->
save
(
$users
)){
$this
->
Flash
->
success
(
__
(
'change password success'
));
return
$this
->
redirect
([
'action'
=>
'signin'
]);
}
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
return
$this
->
redirect
([
'action'
=>
'change_forgotpassword'
]);
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
...
...
www/src/Template/UserCards/view_card.ctp
View file @
302d0208
...
...
@@ -156,12 +156,14 @@ use Cake\I18n\Time;
<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' => __('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 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 __('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>
</div>
</div>
...
...
@@ -527,6 +529,7 @@ use Cake\I18n\Time;
var date = $("#date");
$(document).ready(function() {
$("#organize_code").on('change',function(){
// alert(moment("05/22/2012", 'MM/DD/YYYY',true).isValid()); //true
var organize_code = $("#organize_code").val();
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
...
...
@@ -536,31 +539,51 @@ use Cake\I18n\Time;
date.val('');
$.post("/UserCards/checkOrg", {organize_code: organize_code}, function(data) {
if(data!='false'){
data = jQuery.parseJSON(data);
console.log(data);
data = jQuery.parseJSON(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.val('');
employee.val('');
date.val('');
}else if(data['chkuser'] == false){
$("#nameorg_th").text(data[0]['org_name_th']);
$("#noorg_th").text('');
$("#checkbutton").removeAttr("disabled");
$("#employee").removeAttr("disabled");
$("#date").removeAttr("disabled");
organize_id.val(data[0]['id']);
}
}else{
$("#noorg_th").text('ไม่พบข้อมูล');
$("#nameorg_th").text('');
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
organize_id.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('');
}
});
...
...
www/src/Template/Users/signup.ctp
View file @
302d0208
...
...
@@ -29,7 +29,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อผู้ใช้งาน');?><em>* </em></label>
<input type="text" name="username" id="username" value="" onkeypress="check
_notnum
();" placeholder="USERNAME" class="form-control-reg border-bottom-from">
<input type="text" name="username" id="username" value="" onkeypress="check
eng
();" placeholder="USERNAME" class="form-control-reg border-bottom-from">
</div>
</div>
...
...
@@ -109,7 +109,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('รหัสผ่าน');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="password" id="password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<input data-toggle="password" data-placement="before"
onkeypress="checkeng();"
type="password" name="password" id="password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<!--<input type="password" name="data[password]" id="password" value="" placeholder="********" class="form-control-reg border-bottom-from" onkeyup='check();'>-->
<!--<span class="glyphicon glyphicon-eye-close form-control-feedback"></span>-->
</div>
...
...
@@ -119,7 +119,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ยืนยันรหัสผ่าน');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="confirm_password" id="confirm_password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<input data-toggle="password" data-placement="before"
onkeypress="checkeng();"
type="password" name="confirm_password" id="confirm_password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<!--<input type="password" id="confirm_password" name="data[confirm_password]" value="" placeholder="********" class="form-control-reg border-bottom-from" onkeyup='check();'>-->
<!--<span class="glyphicon glyphicon-eye-close form-control-feedback" id='message'></span>-->
<span id='message'></span>
...
...
@@ -176,8 +176,34 @@
});
</script>
<script>
// function check_key() {
// e_k=event.keyCode
// alert( 'asdasd')
// if ((k>=65 && k<=90) || (k>=97 && k<=122)){
// return true;
// }else{
// alert("thai");
// return false;
// }
// }
$(document).ready(function() {
// $("#username").on('keyup',function(){
// var $this = $(this);
// if($this.val().length>=4){
// alert(check_key());
// }else{
// //alert("กรุณากรอกชื่อผู้ใช้งานของท่าน");
// // return false;
// }
// });
$("#fremail").on('change',function(){
var email = document.getElementById("fremail").value;
$.post("/Checkemails/checkemail", {email: email}, function(data) {
...
...
@@ -205,6 +231,16 @@
alert("ข้อมูลผิดพลาด กรุณาใส่ข้อมูลที่เป็นตัวอักษรภาษาไทย [ก-ฮ] หรือภาษาอังกฤษให้ถูกต้อง");
}
}
function checkeng()
{
e_k=event.keyCode
if ((e_k >= 48 && e_k<=57) || (e_k>=97 && e_k<=122) || ((e_k>=65 && e_k<=90))) {
e_k = true;
}else{
e_k = false;
alert("กรุณากรอกชือผู้ใช้เป็นเป็นตัวอักษรภาษาอังกฤษตัวเล็กหรือตัวใหญ่และมีหรือไม่มีตัวเลขผสมอยู่");
}
}
function validateForm() {
var firstname = document.getElementById("firstname").value;
...
...
@@ -222,9 +258,9 @@
alert("กรุณากรอกชื่อผู้ใช้งานของท่าน");
return false;
}
if(document.getElementById("username").value.length <
5
)
if(document.getElementById("username").value.length <
4 || document.getElementById("username").value.length > 10
)
{
alert('กรุณาระบุชื่อผู้ใช้งาน
อย่างน้อย 5
ตัวอักษร');
alert('กรุณาระบุชื่อผู้ใช้งาน
ความยาว 4-10
ตัวอักษร');
return false;
}
var master_country_id = document.getElementById("master_country_id").value;
...
...
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