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
2905751c
authored
May 14, 2018
by
Teeradone-PIM
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration' into teeradone
parents
b4f18915
7b36c6e8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
107 deletions
+139
-107
www/src/Controller/UserprofilesController.php
+57
-25
www/src/Model/Table/UserPersonalsTable.php
+47
-47
www/src/Model/Table/UserProfilesTable.php
+35
-35
No files found.
www/src/Controller/UserprofilesController.php
View file @
2905751c
...
@@ -102,38 +102,70 @@ class UserProfilesController extends AppController {
...
@@ -102,38 +102,70 @@ class UserProfilesController extends AppController {
//// debug($userProfiles);
//// debug($userProfiles);
// }
// }
// exit;
// exit;
// $data = $this->request->data;
// $UserPersonal = $this->UserProfiles->UserPersonals->find('first', [
// 'conditions' => [
// 'UserPersonals.user_id' => $data['Users']['user_id']
// ]
// ]);
// pr($UserPersonal);die;
if
(
$this
->
request
->
is
([
'patch'
,
'post'
,
'put'
]))
{
if
(
$this
->
request
->
is
([
'patch'
,
'post'
,
'put'
]))
{
$data
=
$this
->
request
->
data
;
// debug($this->request->data);
// debug($this->request->data);
// exit;
// exit;
$data
=
$this
->
request
->
data
;
//pr($data);
// pr($data);
list
(
$data
[
'UserPersonals'
][
'firstname_th'
],
$data
[
'UserPersonals'
][
'lastname_th'
])
=
explode
(
' '
,
$data
[
'UserPersonals'
][
'fullname'
]);
unset
(
$data
[
'UserPersonals'
][
'fullname'
]);
$this
->
loadModel
(
'UserPersonals'
);
$data
[
'UserPersonals'
][
'birthdate'
]
=
''
;
$data
[
'UserPersonals'
][
'user_id'
]
=
$data
[
'Users'
][
'user_id'
];
$userPersonals
=
$this
->
UserPersonals
->
find
(
'all'
,
$data
[
'UserPersonals'
][
'modified_by'
]
=
''
;
[
$data
[
'UserProfiles'
][
0
][
'user_id'
]
=
$data
[
'Users'
][
'user_id'
];
'limit'
=>
1
,
$data
[
'UserProfiles'
][
0
][
'user_type_id'
]
=
1
;
'conditions'
=>
[
$data
[
'UserProfiles'
][
0
][
'modified_by'
]
=
''
;
'user_id'
=>
$data
[
'Users'
][
'user_id'
]
$data
[
'UserProfiles'
][
1
][
'user_id'
]
=
$data
[
'Users'
][
'user_id'
];
]
$data
[
'UserProfiles'
][
1
][
'user_type_id'
]
=
2
;
]
$data
[
'UserProfiles'
][
1
][
'modified_by'
]
=
''
;
)
->
toArray
();
// pr($userPersonals);
// pr($data['UserPersonals']);
// $userPersonals = $this->UserPersonals->newEntity();
$userPersonals
=
$this
->
UserPersonals
->
patchEntity
(
$userPersonals
[
0
],
$data
[
'UserPersonals'
]);
#prr($userPersonals);
list
(
$userPersonals
[
'firstname_th'
],
$userPersonals
[
'lastname_th'
])
=
explode
(
' '
,
$data
[
'UserPersonals'
][
'fullname'
]);
unset
(
$userPersonals
[
'fullname'
]);
$userPersonals
[
'birthdate'
]
=
'2000-01-01'
;
$userPersonals
[
'user_id'
]
=
$data
[
'Users'
][
'user_id'
];
$userPersonals
[
'modified_by'
]
=
''
;
// $userPersonals['modified'] = '2018-01-01 00:00:00';
// pr($userPersonals->toArray());die;
// debug($this->UserPersonals->save($userPersonals));die;
if
(
$this
->
UserPersonals
->
save
(
$userPersonals
))
{
//pr($userPersonals->toArray());die;
}
// $data['UserProfiles'][0]['user_id'] = $data['Users']['user_id'];
// $data['UserProfiles'][0]['user_type_id'] = 1;
// $data['UserProfiles'][0]['modified_by'] = '';
// $data['UserProfiles'][1]['user_id'] = $data['Users']['user_id'];
// $data['UserProfiles'][1]['user_type_id'] = 2;
// $data['UserProfiles'][1]['modified_by'] = '';
// debug($data);
// debug($data);
// exit;
// exit;
#$api_update_profile = 'http://connect06.pakgon.com/api/Connects/Profile/updateProfile';
#$api_update_profile = 'http://connect06.pakgon.com/api/Connects/Profile/updateProfile';
$api_update_profile
=
Configure
::
read
(
'Config.apiCore.profile'
)
.
'/updateProfile'
;
//
$api_update_profile = Configure::read('Config.apiCore.profile') . '/updateProfile';
$http
=
new
Client
();
//
$http = new Client();
// $data = [];
// $data = [];
$options
=
[
'headers'
=>
[
//
$options = ['headers' => [
'Content-Type'
=>
'application/x-www-form-urlencoded'
,
//
'Content-Type' => 'application/x-www-form-urlencoded',
#'Authorization' => $this->request->getHeaderLine('Authorization')
//
#'Authorization' => $this->request->getHeaderLine('Authorization')
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTIzMCwidXNlcm5hbWUiOiJ0ZXN0dG9uZyIsImlwIjoiMTI3LjAuMC4xIn0.37hXRDEhiwjsgqR8mcgbhxnKtAof3tIDahL2P6DnQ4I'
//
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTIzMCwidXNlcm5hbWUiOiJ0ZXN0dG9uZyIsImlwIjoiMTI3LjAuMC4xIn0.37hXRDEhiwjsgqR8mcgbhxnKtAof3tIDahL2P6DnQ4I'
'Authorization'
=>
'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4NywidXNlcm5hbWUiOiJOYW5hMiIsImlwIjoiOjoxIiwidG9waWMiOiJOYW5hMmI5OTQxMWE2NDExYTRhOTlhZmI5MWRhMjM3MTJjNDQ2In0.u3OdN5QzI_dvI9KfKYojjVXfcnvTcmHz9LM0XHXvwU8'
//
'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4NywidXNlcm5hbWUiOiJOYW5hMiIsImlwIjoiOjoxIiwidG9waWMiOiJOYW5hMmI5OTQxMWE2NDExYTRhOTlhZmI5MWRhMjM3MTJjNDQ2In0.u3OdN5QzI_dvI9KfKYojjVXfcnvTcmHz9LM0XHXvwU8'
]
//
]
];
//
];
#
prr($options);
//
prr($options);
$response
=
$http
->
post
(
$api_update_profile
,
$data
,
$options
)
->
body
();
//
$response = $http->post($api_update_profile, $data, $options)->body();
//
pr($response);
//
pr($response);
$response
=
json_decode
(
$response
,
'_full'
);
//
$response = json_decode($response, '_full');
// pr($response);
// pr($response);
// die;
// die;
}
}
...
...
www/src/Model/Table/UserPersonalsTable.php
View file @
2905751c
...
@@ -40,9 +40,9 @@ class UserPersonalsTable extends Table {
...
@@ -40,9 +40,9 @@ class UserPersonalsTable extends Table {
$this
->
addBehavior
(
'Timestamp'
);
$this
->
addBehavior
(
'Timestamp'
);
$this
->
belongsTo
(
'MasterPrefixes'
,
[
//
$this->belongsTo('MasterPrefixes', [
'foreignKey'
=>
'master_prefix_id'
//
'foreignKey' => 'master_prefix_id'
]);
//
]);
$this
->
belongsTo
(
'Users'
,
[
$this
->
belongsTo
(
'Users'
,
[
'foreignKey'
=>
'user_id'
'foreignKey'
=>
'user_id'
]);
]);
...
@@ -55,63 +55,63 @@ class UserPersonalsTable extends Table {
...
@@ -55,63 +55,63 @@ class UserPersonalsTable extends Table {
* @return \Cake\Validation\Validator
* @return \Cake\Validation\Validator
*/
*/
public
function
validationDefault
(
Validator
$validator
)
{
public
function
validationDefault
(
Validator
$validator
)
{
$validator
//
$validator
->
allowEmpty
(
'id'
,
'create'
);
//
->allowEmpty('id', 'create');
$validator
//
$validator
->
scalar
(
'person_card_no'
)
//
->scalar('person_card_no')
->
requirePresence
(
'person_card_no'
,
'create'
)
//
->requirePresence('person_card_no', 'create')
->
notEmpty
(
'person_card_no'
);
//
->notEmpty('person_card_no');
$validator
//
$validator
->
scalar
(
'firstname_th'
)
//
->scalar('firstname_th')
->
allowEmpty
(
'firstname_th'
);
//
->allowEmpty('firstname_th');
$validator
//
$validator
->
scalar
(
'lastname_th'
)
//
->scalar('lastname_th')
->
allowEmpty
(
'lastname_th'
);
//
->allowEmpty('lastname_th');
$validator
//
$validator
->
scalar
(
'firstname_en'
)
//
->scalar('firstname_en')
->
allowEmpty
(
'firstname_en'
);
//
->allowEmpty('firstname_en');
$validator
//
$validator
->
scalar
(
'lastname_en'
)
//
->scalar('lastname_en')
->
allowEmpty
(
'lastname_en'
);
//
->allowEmpty('lastname_en');
$validator
//
$validator
->
scalar
(
'gender'
)
//
->scalar('gender')
->
allowEmpty
(
'gender'
);
//
->allowEmpty('gender');
$validator
//
$validator
->
date
(
'birthdate'
)
//
->date('birthdate')
->
allowEmpty
(
'birthdate'
);
//
->allowEmpty('birthdate');
$validator
//
$validator
->
scalar
(
'moblie_no'
)
//
->scalar('moblie_no')
->
allowEmpty
(
'moblie_no'
);
//
->allowEmpty('moblie_no');
$validator
//
$validator
->
scalar
(
'phone_no'
)
//
->scalar('phone_no')
->
allowEmpty
(
'phone_no'
);
//
->allowEmpty('phone_no');
$validator
//
$validator
->
email
(
'email'
)
//
->email('email')
->
allowEmpty
(
'email'
);
//
->allowEmpty('email');
$validator
//
$validator
->
allowEmpty
(
'created_by'
);
//
->allowEmpty('created_by');
$validator
//
$validator
->
allowEmpty
(
'modified_by'
);
//
->allowEmpty('modified_by');
$validator
//
$validator
->
scalar
(
'blood_group'
)
//
->scalar('blood_group')
->
allowEmpty
(
'blood_group'
);
//
->allowEmpty('blood_group');
$validator
//
$validator
->
scalar
(
'address'
)
//
->scalar('address')
->
allowEmpty
(
'address'
);
//
->allowEmpty('address');
return
$validator
;
return
$validator
;
}
}
...
@@ -125,7 +125,7 @@ class UserPersonalsTable extends Table {
...
@@ -125,7 +125,7 @@ class UserPersonalsTable extends Table {
*/
*/
public
function
buildRules
(
RulesChecker
$rules
)
{
public
function
buildRules
(
RulesChecker
$rules
)
{
$rules
->
add
(
$rules
->
isUnique
([
'email'
]));
$rules
->
add
(
$rules
->
isUnique
([
'email'
]));
$rules
->
add
(
$rules
->
existsIn
([
'master_prefix_id'
],
'MasterPrefixes'
));
//
$rules->add($rules->existsIn(['master_prefix_id'], 'MasterPrefixes'));
$rules
->
add
(
$rules
->
existsIn
([
'user_id'
],
'Users'
));
$rules
->
add
(
$rules
->
existsIn
([
'user_id'
],
'Users'
));
return
$rules
;
return
$rules
;
...
...
www/src/Model/Table/UserProfilesTable.php
View file @
2905751c
...
@@ -79,52 +79,52 @@ class UserProfilesTable extends Table
...
@@ -79,52 +79,52 @@ class UserProfilesTable extends Table
*/
*/
public
function
validationDefault
(
Validator
$validator
)
public
function
validationDefault
(
Validator
$validator
)
{
{
$validator
//
$validator
->
allowEmpty
(
'id'
,
'create'
);
//
->allowEmpty('id', 'create');
$validator
//
$validator
->
scalar
(
'card_code'
)
//
->scalar('card_code')
->
maxLength
(
'card_code'
,
20
)
//
->maxLength('card_code', 20)
->
allowEmpty
(
'card_code'
);
//
->allowEmpty('card_code');
$validator
//
$validator
->
scalar
(
'img_path'
)
//
->scalar('img_path')
->
maxLength
(
'img_path'
,
255
)
//
->maxLength('img_path', 255)
->
allowEmpty
(
'img_path'
);
//
->allowEmpty('img_path');
$validator
//
$validator
->
boolean
(
'is_used'
)
//
->boolean('is_used')
->
requirePresence
(
'is_used'
,
'create'
)
//
->requirePresence('is_used', 'create')
->
notEmpty
(
'is_used'
);
//
->notEmpty('is_used');
$validator
//
$validator
->
requirePresence
(
'created_by'
,
'create'
)
//
->requirePresence('created_by', 'create')
->
notEmpty
(
'created_by'
);
//
->notEmpty('created_by');
$validator
//
$validator
->
allowEmpty
(
'modified_by'
);
//
->allowEmpty('modified_by');
$validator
//
$validator
->
allowEmpty
(
'position_org'
);
//
->allowEmpty('position_org');
$validator
//
$validator
->
allowEmpty
(
'position_edu'
);
//
->allowEmpty('position_edu');
$validator
//
$validator
->
date
(
'enter_date'
)
//
->date('enter_date')
->
allowEmpty
(
'enter_date'
);
//
->allowEmpty('enter_date');
$validator
//
$validator
->
scalar
(
'address'
)
//
->scalar('address')
->
maxLength
(
'address'
,
255
)
//
->maxLength('address', 255)
->
allowEmpty
(
'address'
);
//
->allowEmpty('address');
$validator
//
$validator
->
scalar
(
'phone_no'
)
//
->scalar('phone_no')
->
maxLength
(
'phone_no'
,
30
)
//
->maxLength('phone_no', 30)
->
allowEmpty
(
'phone_no'
);
//
->allowEmpty('phone_no');
return
$validator
;
//
return $validator;
}
}
/**
/**
...
...
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