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
57aea8b6
authored
May 24, 2018
by
Wittaya-PIM
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration' into wittaya
parents
f8f3329a
32e0c1de
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
39 deletions
+66
-39
www/src/Controller/ProfilesController.php
+7
-10
www/src/Controller/UserCardsController.php
+0
-1
www/src/Controller/UsersController.php
+19
-15
www/src/Template/Profiles/index.ctp
+14
-2
www/src/Template/Users/signup.ctp
+26
-11
No files found.
www/src/Controller/ProfilesController.php
View file @
57aea8b6
...
@@ -14,7 +14,7 @@ class ProfilesController extends AppController
...
@@ -14,7 +14,7 @@ class ProfilesController extends AppController
/*******************************/
/*******************************/
$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
,
[
...
@@ -28,6 +28,7 @@ class ProfilesController extends AppController
...
@@ -28,6 +28,7 @@ class ProfilesController extends AppController
'user_id'
=>
$id
]
'user_id'
=>
$id
]
])
->
first
();
])
->
first
();
//********DropdownCountry********
//********DropdownCountry********
$this
->
loadModel
(
'MasterCountries'
);
$this
->
loadModel
(
'MasterCountries'
);
$Country
=
$this
->
MasterCountries
->
find
(
'list'
,
[
$Country
=
$this
->
MasterCountries
->
find
(
'list'
,
[
...
@@ -46,8 +47,8 @@ class ProfilesController extends AppController
...
@@ -46,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
();
...
@@ -55,8 +56,6 @@ class ProfilesController extends AppController
...
@@ -55,8 +56,6 @@ 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['email']);die;
$data
=
$this
->
request
->
data
;
$data
=
$this
->
request
->
data
;
// pr($this->request->data);die;
// pr($this->request->data);die;
...
@@ -97,8 +96,8 @@ class ProfilesController extends AppController
...
@@ -97,8 +96,8 @@ class ProfilesController extends AppController
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserPersonals'
][
'birthdate'
]);
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserPersonals'
][
'birthdate'
]);
$birthdate
=
$birthdate
[
2
]
.
'-'
.
$birthdate
[
1
]
.
'-'
.
$birthdate
[
0
];
$birthdate
=
$birthdate
[
2
]
.
'-'
.
$birthdate
[
1
]
.
'-'
.
$birthdate
[
0
];
// pr($userPersonals);die;
// pr($userPersonals);die;
//
$userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
$userPersonals
=
$this
->
UserPersonals
->
patchEntity
(
$userPersonals
,
$data
[
'UserPersonals'
]);
$userPersonals
[
'firstname_th'
]
=
$this
->
request
->
data
[
'UserPersonals'
][
'firstname_th'
];
$userPersonals
[
'firstname_th'
]
=
$this
->
request
->
data
[
'UserPersonals'
][
'firstname_th'
];
$userPersonals
[
'lastname_th'
]
=
$this
->
request
->
data
[
'UserPersonals'
][
'lastname_th'
];
$userPersonals
[
'lastname_th'
]
=
$this
->
request
->
data
[
'UserPersonals'
][
'lastname_th'
];
$userPersonals
[
'email'
]
=
$this
->
request
->
data
[
'email'
];
$userPersonals
[
'email'
]
=
$this
->
request
->
data
[
'email'
];
...
@@ -107,9 +106,7 @@ class ProfilesController extends AppController
...
@@ -107,9 +106,7 @@ class ProfilesController extends AppController
$userPersonals
[
'master_country_id'
]
=
$this
->
request
->
data
[
'master_country_id'
];
$userPersonals
[
'master_country_id'
]
=
$this
->
request
->
data
[
'master_country_id'
];
$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
;
// $userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
// pr($userPersonals);die;
$userPersonals
=
$this
->
Users
->
patchEntity
(
$userPersonals
,
$this
->
request
->
getData
());
// pr($userPersonals);die;
if
(
$this
->
UserPersonals
->
save
(
$userPersonals
))
{
if
(
$this
->
UserPersonals
->
save
(
$userPersonals
))
{
$this
->
Flash
->
success
(
__
(
'Update Complete.'
));
$this
->
Flash
->
success
(
__
(
'Update Complete.'
));
...
...
www/src/Controller/UserCardsController.php
View file @
57aea8b6
...
@@ -306,7 +306,6 @@ class UserCardsController extends AppController
...
@@ -306,7 +306,6 @@ class UserCardsController extends AppController
$userCard
[
'user_id'
]
=
$this
->
Auth
->
user
(
'id'
);
$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'
);
$this
->
loadModel
(
'UserEntities'
);
...
...
www/src/Controller/UsersController.php
View file @
57aea8b6
...
@@ -117,12 +117,13 @@ class UsersController extends AppController {
...
@@ -117,12 +117,13 @@ 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
...
@@ -399,33 +400,36 @@ class UsersController extends AppController {
...
@@ -399,33 +400,36 @@ class UsersController extends AppController {
]
]
])
->
first
();
])
->
first
();
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'
];
$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'
]))
{
$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'
));
return
$this
->
redirect
([
'action'
=>
'signin'
]);
return
$this
->
redirect
([
'action'
=>
'signin'
]);
}
else
{
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
return
$this
->
redirect
([
'action'
=>
'change-password/'
.
$token
]);
}
}
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
}
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
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/Profiles/index.ctp
View file @
57aea8b6
...
@@ -140,11 +140,12 @@
...
@@ -140,11 +140,12 @@
'id' => 'master_country_id',
'id' => 'master_country_id',
'label' => false,
'label' => false,
'type' => 'select',
'type' => 'select',
'require'=>'require',
'options' => $Country,
'options' => $Country,
'value' => $responseUserPersonal['master_country_id'],
'value' => $responseUserPersonal['master_country_id'],
'empty' => '---Select---',
'empty' => '---Select---',
'default' => !empty($responseUserPersonal['master_country_id'])? $responseUserPersonal['master_country_id']:'',
'default' => !empty($responseUserPersonal['master_country_id'])? $responseUserPersonal['master_country_id']:'',
'class' => 'form-control border-bottom-from label-text-sub',
'class' => 'form-control border-bottom-from label-text-sub
require
',
'style' => 'width:100%'
'style' => 'width:100%'
));
));
?>
?>
...
@@ -158,11 +159,12 @@
...
@@ -158,11 +159,12 @@
'id' => 'master_province_id',
'id' => 'master_province_id',
'label' => false,
'label' => false,
'type' => 'select',
'type' => 'select',
'require'=>'require',
'options' => $Province,
'options' => $Province,
'value' => $responseUserPersonal['master_province_id'],
'value' => $responseUserPersonal['master_province_id'],
'empty' => '---Select---',
'empty' => '---Select---',
'default' => !empty($responseUserPersonal['master_province_id'])? $responseUserPersonal['master_province_id']:'',
'default' => !empty($responseUserPersonal['master_province_id'])? $responseUserPersonal['master_province_id']:'',
'class' => 'form-control border-bottom-from label-text-sub',
'class' => 'form-control border-bottom-from label-text-sub
require
',
'style' => 'width:100%'
'style' => 'width:100%'
));
));
?>
?>
...
@@ -270,6 +272,16 @@
...
@@ -270,6 +272,16 @@
// return false;
// return false;
// }
// }
// });
// });
var master_country_id = document.getElementById("master_country_id").value;
if (master_country_id == null || master_country_id == "") {
alert("กรุณาระบุประเทศ");
return false;
}
var master_province_id = document.getElementById("master_province_id").value;
if (master_province_id == null || master_province_id == "") {
alert("กรุณาระบุจังหวัด");
return false;
}
$("body").delegate(".is_active", "click", function () {
$("body").delegate(".is_active", "click", function () {
$('.is_active').not(this).prop('checked', false);
$('.is_active').not(this).prop('checked', false);
...
...
www/src/Template/Users/signup.ctp
View file @
57aea8b6
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<div class="form-group has-feedback">
<div class="form-group has-feedback">
<div class="col-md-12">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อ');?><em>* </em></label>
<label class="label-text-sub"><?php echo __('ชื่อ');?><em>* </em></label>
<input type="text" name="firstname" id="firstname" value="" placeholder="FIRSTNAME" class="form-control-reg border-bottom-from">
<input type="text" name="firstname" id="firstname" value=""
onkeypress="check_notnum();"
placeholder="FIRSTNAME" class="form-control-reg border-bottom-from">
</div>
</div>
</div>
</div>
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<div class="form-group has-feedback">
<div class="form-group has-feedback">
<div class="col-md-12">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('นามสกุล');?><em>* </em></label>
<label class="label-text-sub"><?php echo __('นามสกุล');?><em>* </em></label>
<input type="text" name="lastname" id="lastname" value="" placeholder="LASTNAME" class="form-control-reg border-bottom-from">
<input type="text" name="lastname" id="lastname" value=""
onkeypress="check_notnum();"
placeholder="LASTNAME" class="form-control-reg border-bottom-from">
</div>
</div>
</div>
</div>
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
<div class="form-group has-feedback">
<div class="form-group has-feedback">
<div class="col-md-12">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อผู้ใช้งาน');?><em>* </em></label>
<label class="label-text-sub"><?php echo __('ชื่อผู้ใช้งาน');?><em>* </em></label>
<input type="text" name="username" id="username" value="" placeholder="USERNAME" class="form-control-reg border-bottom-from">
<input type="text" name="username" id="username" value=""
onkeypress="check_notnum();"
placeholder="USERNAME" class="form-control-reg border-bottom-from">
</div>
</div>
</div>
</div>
...
@@ -190,6 +190,21 @@
...
@@ -190,6 +190,21 @@
});
});
});
});
});
});
function check_phone() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
}
}
function check_notnum() {
e_k=event.keyCode
if ((e_k== 13 || e_k== 110) && (e_k > 48) || (e_k< 57)) {
event.returnValue = false;
alert("ข้อมูลผิดพลาด กรุณาใส่ข้อมูลที่เป็นตัวอักษรภาษาไทย [ก-ฮ] หรือภาษาอังกฤษให้ถูกต้อง");
}
}
function validateForm() {
function validateForm() {
var firstname = document.getElementById("firstname").value;
var firstname = document.getElementById("firstname").value;
...
@@ -489,14 +504,14 @@
...
@@ -489,14 +504,14 @@
<script>
<script>
function check_phone() {
//
function check_phone() {
e_k=event.keyCode
//
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
//
//
if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
//
if (e_k = 10 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
//
event.returnValue = false;
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
//
alert("ขออภัยหมายเลขโทรศัพท์ ต้องเป็นตัวเลขเท่านั้น");
}
//
}
}
//
}
/*var check = function() {
/*var check = function() {
if (document.getElementById('password').value ==
if (document.getElementById('password').value ==
document.getElementById('confirm_password').value) {
document.getElementById('confirm_password').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