Commit 3fe2815c by Prasong Putichanchai

update profile

parent 947fa85b
......@@ -59,7 +59,7 @@ class ProfilesController extends AppController
$dateNow = "";
}
//------- save update ----
if ($this->request->is(['patch', 'post', 'put'])) {
$data = $this->request->data;
......@@ -89,10 +89,7 @@ class ProfilesController extends AppController
if(empty($useremails)){
$chkemail = true;
// pr('true');die;
}else{
// pr('false');die;
$chkemail = false;
}
}
......@@ -124,490 +121,12 @@ class ProfilesController extends AppController
}
$this->Flash->error(__('Not update. Please, try again.'));
}
//-------end save update ----
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province', 'responseUserPersonal']);
}
/*****************************************************************************/
public function settingProfile()
{
//prr($this->request->getHeaderLine('Accept-Language'));
$this->viewBuilder()->layout('blank');
$http = new Client();
$data = [];
$options = ['headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => $this->request->getHeaderLine('Authorization')
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI0OSwidXNlcm5hbWUiOiJ0ZXN0dGVzdCIsImlwIjoiMTE2LjU4LjIyNS4yNDgiLCIkdG9waWMiOiJ0ZXN0dGVzdDMzM2Y5MWI5ZjVlMTQzMjlmMWQ2ZTc2MzgwYjhiOWVhIn0.7KwfmevJ--tz0ta5f1O_eDxKSPAjWuAzLSRCNSeWg-g'
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4OCwidXNlcm5hbWUiOiJOYW5hMyIsImlwIjoiMTI3LjAuMC4xIiwiJHRvcGljIjoiTmFuYTNiODAwMjVlNWYyZTUxZDVkMmY0ZTM1Y2E4YWFkNmI1MSJ9.Up1oxsqxWASpOmj9UsAuHISlKArT2EE5NRM0bB2NLIE'
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI5NCwidXNlcm5hbWUiOiJOYW5hOCIsImlwIjoiMTI3LjAuMC4xIiwiJHRvcGljIjoiTmFuYThhMzQzYmRiNjNiNzYxZWFjMTFmYzBlOGU2ZDQ2NjE5YyJ9.B2vi2ftThzO8bfv7xDx3lgpo_3-us-S10OzBpFmRn2Q'
]
];
//debug($options);
$api_core_profile = Configure::read('Config.apiCore.profile');
$http = new Client();
$response = $http->post($api_core_profile,$data,$options)->body();
$response = json_decode($response,'_full');#prr($response);
$Profiles = $response['result']['Data'];
$this->set(compact('Profiles'));
#$Profiles['UserProfiles'][0]['organize_id'] = 10;
#$Profiles['UserProfiles'][0]['dept_id'] = 10;
#debug($Profiles);
$count_user_profile = count($Profiles['UserProfiles']);
//$Profiles['UserProfiles'] = $Profiles['UserProfiles'][0];
$Profiles['UserProfiles']['education'] = @$Profiles['UserProfiles'][0];
unset($Profiles['UserProfiles'][0]);
if(count($Profiles['UserProfiles']) > 1){ $Profiles['UserProfiles']['work'] = $Profiles['UserProfiles'][1];unset($Profiles['UserProfiles'][1]);}
//$master_language_id = $Profiles['UserDefaultLanguages']['master_language_id'];
$master_language_id = $this->request->getHeaderLine('Accept-Language');
$this->loadModel('MasterLanguages');
$MasterLanguages = $this->MasterLanguages->find('list',
[
'conditions' => ['id' => $master_language_id],
'keyField' => 'id',
'valueField' => 'language_abbr'
]
);
if(!empty($MasterLanguages)) $MasterLanguages = $MasterLanguages->toArray();
#prd($MasterLanguages);
//$language = strtolower($MasterLanguages[$master_language_id]);
#Education
#---------------------------------------------------------------------------------------------------------------
$this->loadModel('MasterOrganizations');
$MasterOrganizationEducations = $this->MasterOrganizations->find('list',
[
'conditions' => ['master_organization_type_id' => 1],
'keyField' => 'id',
'valueField' => 'org_name_th',
'order' => 'org_name_th asc'
]
);
if(!empty($MasterOrganizationEducations)) $MasterOrganizationEducations = $MasterOrganizationEducations->toArray();
$this->set(compact('MasterOrganizations'));
//debug($MasterOrganizationEducations);
$this->loadModel('MasterDepartments');
$MasterDepartments = $this->MasterDepartments->find('list',
[
//'conditions' => ['master_organization_id' => $Profiles['UserProfiles']['education']['organize_id']],
//'conditions' => ['master_organization_id' => $Profiles['UserProfiles'][0]['organize_id']],
'conditions' => ['master_organization_id' => 7],
'keyField' => 'id',
'valueField' => 'dept_name_th',
'order' => 'dept_name_th asc'
]
);
if(!empty($MasterDepartments)) $MasterDepartments = $MasterDepartments->toArray();
$this->set(compact('MasterDepartments'));
//debug($MasterDepartments);
$this->loadModel('MasterSections');
$MasterSections = $this->MasterSections->find('list',
[
//'conditions' => ['master_department_id' => $Profiles['UserProfiles']['education']['dept_id']],
//'conditions' => ['master_department_id' => $Profiles['UserProfiles'][0]['dept_id']],
'conditions' => ['master_department_id' => 49],
'keyField' => 'id',
'valueField' => 'section_name_th',
'order' => 'section_name_th asc'
]
);
if(!empty($MasterSections)) $MasterSections = $MasterSections->toArray();
$this->set(compact('MasterSections'));
//debug($MasterSections);
#Work
#---------------------------------------------------------------------------------------------------------------
$MasterOrganizationPositions = [];
if(!empty($Profiles['UserProfiles']['work']['organize_id'])){
$this->loadModel('MasterOrganizationPositions');
$MasterOrganizationPositions = $this->MasterOrganizationPositions->find('list',
[
'conditions' => ['master_organization_id' => $Profiles['UserProfiles']['work']['organize_id']],
'keyField' => 'id',
'valueField' => 'organization_position_name',
'order' => 'organization_position_name asc'
]
);
if(!empty($MasterOrganizationPositions)) $MasterOrganizationPositions = $MasterOrganizationPositions->toArray();
#prd($MasterOrganizationPositions);
}
$this->loadModel('MasterBusinessTypes');
$MasterBusinessTypes = $this->MasterBusinessTypes->find('list',
[
'conditions' => ['master_language_id' => $master_language_id],
'keyField' => 'id',
'valueField' => 'business_type_name',
'order' => 'business_type_name asc',
]
);
if(!empty($MasterBusinessTypes)) $MasterBusinessTypes = $MasterBusinessTypes->toArray();
#prd($MasterBusinessTypes);
$this->loadModel('MasterOrganizations');
$MasterOrganizationWorks = $this->MasterOrganizations->find('list',
[
'conditions' => ['master_organization_type_id' => 2],
'keyField' => 'id',
'valueField' => 'org_name_th',
'order' => 'org_name_th asc'
]
);
if(!empty($MasterOrganizationWorks)) $MasterOrganizationWorks = $MasterOrganizationWorks->toArray();
#prd($MasterOrganizationWorks);
$MasterSectionWorks = [];
if(!empty($Profiles['UserProfiles']['work']['dept_id'])){
$this->loadModel('MasterSections');
$MasterSectionWorks = $this->MasterSections->find('list',
[
'conditions' => ['master_department_id' => $Profiles['UserProfiles']['work']['dept_id']],
'keyField' => 'id',
'valueField' => 'section_name_th',
'order' => 'section_name_th asc'
]
);
if(!empty($MasterSectionWorks)) $MasterSectionWorks = $MasterSectionWorks->toArray();
#prd($MasterSectionWorks);
}
#debug($Profiles);
$this->set(compact(
'Profiles',
'MasterOrganizationEducations', 'MasterDepartmentEducations', 'MasterSectionEducations',
'MasterOrganizationPositions', 'MasterBusinessTypes', 'MasterOrganizationWorks', 'MasterSectionWorks'
));
}
public function updateProfile()
{
$this->viewBuilder()->layout('blank');
$data = $this->request->data;#debug($data);
#$api_update_profile = 'http://connect06.pakgon.com/api/Connects/Profile/updateProfile';
#$api_update_profile = Configure::read('Config.apiCore.profile').'/updateProfile';
$http = new Client();
$data = [];
$options = ['headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => $this->request->getHeaderLine('Authorization')
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI0OSwidXNlcm5hbWUiOiJ0ZXN0dGVzdCIsImlwIjoiMTE2LjU4LjIyNS4yNDgiLCIkdG9waWMiOiJ0ZXN0dGVzdDMzM2Y5MWI5ZjVlMTQzMjlmMWQ2ZTc2MzgwYjhiOWVhIn0.7KwfmevJ--tz0ta5f1O_eDxKSPAjWuAzLSRCNSeWg-g'
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI4OCwidXNlcm5hbWUiOiJOYW5hMyIsImlwIjoiMTI3LjAuMC4xIiwiJHRvcGljIjoiTmFuYTNiODAwMjVlNWYyZTUxZDVkMmY0ZTM1Y2E4YWFkNmI1MSJ9.Up1oxsqxWASpOmj9UsAuHISlKArT2EE5NRM0bB2NLIE'
//'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1OTI5NCwidXNlcm5hbWUiOiJOYW5hOCIsImlwIjoiMTI3LjAuMC4xIiwiJHRvcGljIjoiTmFuYThhMzQzYmRiNjNiNzYxZWFjMTFmYzBlOGU2ZDQ2NjE5YyJ9.B2vi2ftThzO8bfv7xDx3lgpo_3-us-S10OzBpFmRn2Q'
]
];
//debug($options);exit();
$api_update_profile = Configure::read('Config.apiCore.profile');
$http = new Client();
$response = $http->post($api_update_profile,$data,$options)->body();
//debug($response);
$response = json_decode($response,'_full');#debug($response);
$Profiles = $response['result']['Data'];
$this->set(compact('Profiles'));
$this->loadModel('UserPersonLists');
$this->loadModel('UserProfiles');
$this->loadModel('AppAccess');
$this->loadModel('SubjectEnrolls');
//debug($this->request->data);
if ($this->request->is('post')) {
#59294
//if (!empty($this->request->data)) {
$UserPersonLists_V = $this->UserPersonLists->find('all',
[
#'conditions' => ['is_used' => true,'username' => $data['username']],
'conditions' => ['user_id' => $this->request->data['data']['Users']['id']],
'fields' => ['id', 'user_id'],
'limit' => 1
]
)->toArray();
//debug($UserPersonLists[0]['id']);exit();
//if (empty($UserPersonLists[0]['id'] == null)) {
if (!empty($UserPersonLists_V)) {
foreach($this->request->data as $UserPersonLists) {
//$UserPersonLists=$this->UserPersonLists->newEntity();
//debug($UserPersonLists['id'] = $this->request->data['data']['Users']['id']);exit();
//debug($UserPersonLists['data']['Users']['id']);exit();
//debug($UserPersonLists=$this->UserPersonLists->get($UserPersonLists['Users']['id']));exit();
//debug($UserPersonLists_V);exit();
$UserPersonLists=$this->UserPersonLists->get($UserPersonLists_V[0]['id']);
$UserPersonLists['master_organization_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
$UserPersonLists['master_department_id'] = $this->request->data['data']['UserProfiles']['education']['dept_id'];
$UserPersonLists['master_section_id'] = $this->request->data['data']['UserProfiles']['education']['section_id'];
$UserPersonLists['card_code'] = $this->request->data['data']['UserProfiles']['education']['card_code'];
$UserPersonLists['first_name'] = $this->request->data['data']['UserPersonals']['name'];
$UserPersonLists['last_name'] = $this->request->data['data']['UserPersonals']['name'];
$UserPersonLists['master_user_type_id'] = '1';
$UserPersonLists['user_id'] = $this->request->data['data']['Users']['id'];
$UserPersonLists['is_used'] = '1';
$UserPersonLists['created'] = date('Y-m-d H:i:s');
$UserPersonLists['create_uid'] = '0';
$UserPersonLists['modified'] = date('Y-m-d H:i:s');
$UserPersonLists['update_uid'] = '0';
$UserPersonLists['master_prefix_id'] = '1';
//debug($UserPersonLists);exit();
if (empty($UserPersonLists['card_code'] == null || $UserPersonLists['master_organization_id'] == null || $UserPersonLists['master_department_id'] == null || $UserPersonLists['master_section_id'] == null)) {
if ($this->UserPersonLists->save($UserPersonLists)) {
}
} else{
$this->Flash->error(__('ไม่สามารถปรับปรุงข้อมูลการศึกษาได้ โปรดติด่อเจ้าหน้าที่'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
//debug($this->UserPersonLists->save($UserPersonLists));exit();
}
}else {
foreach($this->request->data as $UserPersonLists) {
$UserPersonLists=$this->UserPersonLists->newEntity();
//debug($UserPersonLists['id'] = $this->request->data['data']['Users']['id']);exit();
//debug($UserPersonLists['data']['Users']['id']);exit();
//debug($UserPersonLists=$this->UserPersonLists->get($UserPersonLists['Users']['id']));exit();
//debug($UserPersonLists_V);exit();
//$UserPersonLists=$this->UserPersonLists->get($UserPersonLists_V[0]['id']);
$UserPersonLists['master_organization_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
$UserPersonLists['master_department_id'] = $this->request->data['data']['UserProfiles']['education']['dept_id'];
$UserPersonLists['master_section_id'] = $this->request->data['data']['UserProfiles']['education']['section_id'];
$UserPersonLists['card_code'] = $this->request->data['data']['UserProfiles']['education']['card_code'];
$UserPersonLists['first_name'] = $this->request->data['data']['UserPersonals']['name'];
$UserPersonLists['last_name'] = $this->request->data['data']['UserPersonals']['name'];
$UserPersonLists['master_user_type_id'] = '1';
$UserPersonLists['user_id'] = $this->request->data['data']['Users']['id'];
$UserPersonLists['is_used'] = '1';
$UserPersonLists['created'] = date('Y-m-d H:i:s');
$UserPersonLists['create_uid'] = '0';
$UserPersonLists['modified'] = date('Y-m-d H:i:s');
$UserPersonLists['update_uid'] = '0';
$UserPersonLists['master_prefix_id'] = '1';
//debug($UserPersonLists);exit();
if (empty($UserPersonLists['card_code'] == null || $UserPersonLists['master_organization_id'] == null || $UserPersonLists['master_department_id'] == null || $UserPersonLists['master_section_id'] == null)) {
if ($this->UserPersonLists->save($UserPersonLists)) {
}
} else{
$this->Flash->error(__('ไม่สามารถปรับปรุงข้อมูลการศึกษาได้ โปรดติด่อเจ้าหน้าที่'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
//debug($this->UserPersonLists->save($UserPersonLists));exit();
}
}
$UserProfiles = $this->UserProfiles->find('all',
[
'conditions' => ['user_id' => $this->request->data['data']['Users']['id']],
'fields' => ['user_id'],
'limit' => 1
]
)->toArray();
//debug($this->request->data['data']['Users']['id']);exit();
if (!empty($this->request->data['data']['Users']['id'])) {
foreach($UserProfiles as $user_profiles) {
$user_profiles=$this->UserProfiles->get($this->request->data['data']['UserProfiles']['education']['id']);
//$date = date_create('2000-01-01');
//$user_profiles['id'] = $this->request->data['data']['Users']['id'];
//$user_profiles['user_id'] = $this->request->data['data']['Users']['id'];
$user_profiles['organize_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
$user_profiles['dept_id'] = $this->request->data['data']['UserProfiles']['education']['dept_id'];
$user_profiles['section_id'] = $this->request->data['data']['UserProfiles']['education']['section_id'];
$user_profiles['card_code'] = $this->request->data['data']['UserProfiles']['education']['card_code'];
$user_profiles['user_type_id'] = '1';
$user_profiles['img_path'] = '';
//$user_profiles['is_used'] = '1';
//$user_profiles['created_by'] = '0';
$user_profiles['created'] = date('Y-m-d H:i:s');
$user_profiles['modified_by'] = '0';
$user_profiles['modified'] = date('Y-m-d H:i:s');
//$user_profiles['position_org'] = '195';
//$user_profiles['position_edu'] = '89';
$user_profiles['enter_date'] = date('Y-m-d');
$user_profiles['address'] = $this->request->data['data']['UserProfiles']['education']['address'];
$user_profiles['master_business_type_id'] = '0';
$user_profiles['phone_no'] = $this->request->data['data']['UserProfiles']['education']['phone_no'];
$user_profiles['master_organization_position_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
//debug($this->request->data)
//debug($this->UserProfiles->save($user_profiles));exit;
//debug($user_profiles);exit();
if($this->UserProfiles->save($user_profiles)){
}
//return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
}else {
foreach($this->request->data as $UserPersonLists) {
$UserPersonLists=$this->UserPersonLists->newEntity();
//debug($UserPersonLists['id'] = $this->request->data['data']['Users']['id']);exit();
//debug($UserPersonLists['data']['Users']['id']);exit();
//debug($UserPersonLists=$this->UserPersonLists->get($UserPersonLists['Users']['id']));exit();
//debug($UserPersonLists_V);exit();
//$UserPersonLists=$this->UserPersonLists->get($UserPersonLists_V[0]['id']);
$user_profiles['organize_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
$user_profiles['dept_id'] = $this->request->data['data']['UserProfiles']['education']['dept_id'];
$user_profiles['section_id'] = $this->request->data['data']['UserProfiles']['education']['section_id'];
$user_profiles['card_code'] = $this->request->data['data']['UserProfiles']['education']['card_code'];
$user_profiles['user_type_id'] = '1';
$user_profiles['img_path'] = '';
//$user_profiles['is_used'] = '1';
//$user_profiles['created_by'] = '0';
$user_profiles['created'] = date('Y-m-d H:i:s');
$user_profiles['modified_by'] = '0';
$user_profiles['modified'] = date('Y-m-d H:i:s');
//$user_profiles['position_org'] = '195';
//$user_profiles['position_edu'] = '89';
$user_profiles['enter_date'] = date('Y-m-d');
$user_profiles['address'] = $this->request->data['data']['UserProfiles']['education']['address'];
$user_profiles['master_business_type_id'] = '0';
$user_profiles['phone_no'] = $this->request->data['data']['UserProfiles']['education']['phone_no'];
$user_profiles['master_organization_position_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
//debug($UserPersonLists);exit();
if ($this->UserPersonLists->save($UserPersonLists)) {
}
//debug($this->UserPersonLists->save($UserPersonLists));exit();
}
}
$AppAccess = $this->AppAccess->find('all',
[
'conditions' => ['user_id' => $this->request->data['data']['Users']['id']],
//'fields' => ['user_id'],
'limit' => 1
]
)->toArray();
//debug($AppAccess);//exit();
//debug($AppAccess);exit();
if (!empty($AppAccess)) {
//debug($AppAccess);exit();
foreach($AppAccess as $app_access) {
//debug($app_access);exit();
//debug($this->request->data['data']['Users']['id']);exit();
$app_access=$this->AppAccess->get($app_access['id']);
//$user_profiles=$this->UserProfiles->get($this->request->data['data']['UserProfiles']['education']['id']);
//$app_access=$this->AppAccess->newEntity();
//debug($AppAccess);exit();
$AppAccess['user_id'] = $this->request->data['data']['Users']['id'];
$app_access['master_app_id'] = '3';
$app_access['is_used'] = '1';
$app_access['create_uid'] = '0';
$app_access['created'] = date('Y-m-d H:i:s');
$app_access['update_uid'] = '0';
$app_access['modified'] = date('Y-m-d H:i:s');
//debug($app_access);exit();
if($this->AppAccess->save($app_access)){
}
}
}else{
//debug($this->request->data['data']['Users']['id']);exit();
foreach($this->request->data as $app_access) {
//debug($this->request->data);exit();
//debug($this->request->data['data']['Users']['id']);exit();
//$app_access=$this->AppAccess->get($app_access['id']);
//$user_profiles=$this->UserProfiles->get($this->request->data['data']['UserProfiles']['education']['id']);
$app_access=$this->AppAccess->newEntity();
//debug($this->request->data['data']['Users']['id']);exit();
$app_access['user_id'] = $this->request->data['data']['Users']['id'];
$app_access['master_app_id'] = '3';
$app_access['is_used'] = '1';
$app_access['create_uid'] = '0';
$app_access['created'] = date('Y-m-d H:i:s');
$app_access['update_uid'] = '0';
$app_access['modified'] = date('Y-m-d H:i:s');
//debug($app_access);exit();
if($this->AppAccess->save($app_access)){
}
}
}
$SubjectEnrolls = $this->SubjectEnrolls->find('all',
[
'conditions' => ['user_id' => $this->request->data['data']['Users']['id']],
//'fields' => ['user_id'],
'limit' => 1
]
)->toArray();
//$SubjectEnrolls = $this->SubjectEnrolls->find('all')->toArray();
//debug($SubjectEnrolls);exit();
if (!empty($SubjectEnrolls)) {
foreach($this->request->data as $subject_enrolls) {
//debug($subject_enrolls);exit();
$subject_enrolls=$this->SubjectEnrolls->get($SubjectEnrolls[0]['id']);
//$subject_enrolls=$this->SubjectEnrolls->newEntity();
$subject_enrolls['subject_id'] = '';
$subject_enrolls['user_id'] = $this->request->data['data']['Users']['id'];
$subject_enrolls['master_organization_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
$subject_enrolls['card_code'] = $this->request->data['data']['UserProfiles']['education']['card_code'];
$subject_enrolls['is_used'] = '1';
$subject_enrolls['create_uid'] = '0';
$subject_enrolls['created'] = date('Y-m-d H:i:s');
$subject_enrolls['update_uid'] = '0';
$subject_enrolls['modified'] = date('Y-m-d H:i:s');
//debug($subject_enrolls);exit();
if($this->SubjectEnrolls->save($subject_enrolls)){
if (empty($subject_enrolls)) {
$this->Session->setFlash(__("ไม่ถูกต้อง"));
return false;
}
}
}
}else{
foreach($this->request->data as $subject_enrolls) {
//debug($subject_enrolls);exit();
//$subject_enrolls=$this->SubjectEnrolls->get($SubjectEnrolls[0]['id']);
$subject_enrolls=$this->SubjectEnrolls->newEntity();
$subject_enrolls['subject_id'] = '';
$subject_enrolls['user_id'] = $this->request->data['data']['Users']['id'];
$subject_enrolls['master_organization_id'] = $this->request->data['data']['UserProfiles']['education']['organize_id'];
$subject_enrolls['card_code'] = $this->request->data['data']['UserProfiles']['education']['card_code'];
$subject_enrolls['is_used'] = '1';
$subject_enrolls['create_uid'] = '0';
$subject_enrolls['created'] = date('Y-m-d H:i:s');
$subject_enrolls['update_uid'] = '0';
$subject_enrolls['modified'] = date('Y-m-d H:i:s');
//debug($subject_enrolls);exit();
if($this->SubjectEnrolls->save($subject_enrolls)){
if (empty($subject_enrolls)) {
$this->Session->setFlash(__("ไม่ถูกต้อง"));
return false;
}
}
}
}
//}
// $this->Flash->error(__('ไม่สามารถปรับปรุงข้อมูลการศึกษาได้ โปรดติด่อเจ้าหน้าที่'));
// return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
//debug($UserPersonLists);exit();
$this->Flash->success(__('ปรับปรุงข้อมูลสำเร็จ'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
public function profileCard()
{
$this->viewBuilder()->layout('blank');
}
}
......@@ -76,4 +76,6 @@ use Cake\I18n\Time;
</div>
<!--/.defaultModal -->
</div>
<!--/.col-xs-12 -->
</div>
<!--/row modal card-->
\ No newline at end of file
......@@ -27,8 +27,10 @@
}
}
?>
<div class="row">
<div class="owl-carousel owl-theme" data-plugin-options="{'items': 1}">
<div class="row">
<div class="col-xs-1 col-sm-1 col-md-1 box-arrow" ></div>
<div class="col-xs-10 col-sm-10 col-md-10">
<div data-toggle="modal" data-target="#defaultModal" style="text-align: center; cursor: pointer;">
......@@ -44,16 +46,19 @@
</a>
</div>
<div style="clear: both"></div>
</div><!--/row-->
<br><br>
<!-- </div>
/.row card img-->
<br><br>
<div class="row">
<!-- <div class="row">-->
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->create('UserProfiles', ['id' => 'frmSignIn', 'type' => 'file','name' => 'frmSignIn','role' => 'form', 'onsubmit' => 'return validateForm()']); ?>
<?php echo $this->Flash->render() ?>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<h3> <?php echo __('user profile');?></h3>
<h3>
<?php echo __('user profile');?>
</h3>
</div>
</div>
<div class="form-group has-feedback">
......@@ -65,21 +70,24 @@
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('firstname');?><em>* </em>
<?php echo __('firstname');?>
<em>* </em>
<?php echo $this->Form->input('UserPersonals.firstname_th', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $responseUserPersonal['firstname_th'], 'id' => 'firstname_th', 'type' => 'text', 'label' => false, 'placeholder' => 'firstname']); ?>
<?php // echo $this->Form->input('fullname', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->firstname_th . ' ' . $userProfiles->lastname_th, 'id' => 'fullName', 'type' => 'text', 'label' => __('ชื่อ - นามสกุล'), 'placeholder' => 'ชื่อ - นามสกุล']); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('lastname');?><em>* </em>
<?php echo __('lastname');?>
<em>* </em>
<?php echo $this->Form->input('UserPersonals.lastname_th', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $responseUserPersonal['lastname_th'], 'id' => 'lastname_th', 'type' => 'text', 'label' => false, 'placeholder' => 'lastname']); ?>
<?php // echo $this->Form->input('fullname', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->firstname_th . ' ' . $userProfiles->lastname_th, 'id' => 'fullName', 'type' => 'text', 'label' => __('ชื่อ - นามสกุล'), 'placeholder' => 'ชื่อ - นามสกุล']); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('birthdate');?><em>* </em>
<?php echo __('birthdate');?>
<em>* </em>
<?php echo $this->Form->input('UserPersonals.birthdate', ['class' => 'form-control-reg border-bottom-from', 'value' => $dateNow, 'id' => 'datepicker', 'type' => 'text', 'label' => false, 'placeholder' => 'DD-MM-YYYY']); ?>
<span class="glyphicon glyphicon-calendar form-control-feedback datepicker"></span>
</div>
......@@ -90,10 +98,14 @@
<?php echo __('gender'); ?>
<div class="radio-group">
<label class="radio-inline">
<input type="radio" name="UserPersonals[gender]" id="male" value="M" <?php echo ($responseUserPersonal['gender'] == 'M') ? 'checked="checked"' : null; ?>> <?php echo __('male'); ?>
<input type="radio" name="UserPersonals[gender]" id="male" value="M" <?php echo ($responseUserPersonal[ 'gender']=='M' )
? 'checked="checked"' : null; ?>>
<?php echo __('male'); ?>
</label>
<label class="radio-inline">
<input type="radio" name="UserPersonals[gender]" id="female" value="F" <?php echo ($responseUserPersonal['gender'] == 'F') ? 'checked="checked"' : null; ?>> <?php echo __('female'); ?>
<input type="radio" name="UserPersonals[gender]" id="female" value="F" <?php echo ($responseUserPersonal[ 'gender']=='F'
) ? 'checked="checked"' : null; ?>>
<?php echo __('female'); ?>
</label>
</div>
</div>
......@@ -103,33 +115,44 @@
<?php echo __('blood group'); ?>
<div class="radio-group">
<label class="radio-inline">
<input type="radio" name="UserPersonals[blood_group]" id="blood-A" value="A" <?php echo ($responseUserPersonal['blood_group'] == 'A') ? 'checked="checked"' : null; ?>> <?php echo __('A'); ?>
<input type="radio" name="UserPersonals[blood_group]" id="blood-A" value="A" <?php echo ($responseUserPersonal[
'blood_group']=='A' ) ? 'checked="checked"' : null; ?>>
<?php echo __('A'); ?>
</label>
<label class="radio-inline">
<input type="radio" name="UserPersonals[blood_group]" id="blood-B" value="B" <?php echo ($responseUserPersonal['blood_group'] == 'B') ? 'checked="checked"' : null; ?>> <?php echo __('B'); ?>
<input type="radio" name="UserPersonals[blood_group]" id="blood-B" value="B" <?php echo ($responseUserPersonal[
'blood_group']=='B' ) ? 'checked="checked"' : null; ?>>
<?php echo __('B'); ?>
</label>
<label class="radio-inline">
<input type="radio" name="UserPersonals[blood_group]" id="blood-AB" value="AB" <?php echo ($responseUserPersonal['blood_group'] == 'AB') ? 'checked="checked"' : null; ?>> <?php echo __('AB'); ?>
<input type="radio" name="UserPersonals[blood_group]" id="blood-AB" value="AB" <?php echo ($responseUserPersonal[
'blood_group']=='AB' ) ? 'checked="checked"' : null; ?>>
<?php echo __('AB'); ?>
</label>
<label class="radio-inline">
<input type="radio" name="UserPersonals[blood_group]" id="blood-O" value="O" <?php echo ($responseUserPersonal['blood_group'] == 'O') ? 'checked="checked"' : null; ?>> <?php echo __('O'); ?>
<input type="radio" name="UserPersonals[blood_group]" id="blood-O" value="O" <?php echo ($responseUserPersonal[
'blood_group']=='O' ) ? 'checked="checked"' : null; ?>>
<?php echo __('O'); ?>
</label>
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('mobile');?><em>* </em>
<?php echo __('mobile');?>
<em>* </em>
<?php echo $this->Form->input('UserPersonals.moblie_no', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $responseUserPersonal['moblie_no'], 'id' => 'moblieNo', 'type' => 'text', 'label' => false, 'maxlength' => '10', 'placeholder' => 'mobile']); ?>
<?php // echo $this->Form->input('moblie_no', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->moblie_no, 'id' => 'moblieNo', 'type' => 'text', 'label' => __('เบอร์โทรศัพท์'), 'placeholder' => '000-000-0000']); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('email');?><em>* </em>
<?php echo __('email');?>
<em>* </em>
<!-- <?php echo $this->Form->input('UserPersonals.email', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $responseUserPersonal['email'], 'id' => 'email', 'label' => false, 'placeholder' => 'mail@xxx.com']); ?> -->
<?php // echo $this->Form->input('email', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->email, 'id' => 'email', 'type' => 'email', 'label' => __('Email'), 'placeholder' => 'mail@xxx.com']); ?>
<input type="text" name="email" id="email" value="<?php echo $responseUserPersonal['email'] ?>" placeholder="mail@xxx.com" class="form-control-reg border-bottom-from">
<input type="text" name="email" id="email" value="<?php echo $responseUserPersonal['email'] ?>" placeholder="mail@xxx.com"
class="form-control-reg border-bottom-from">
</div>
</div>
<div class="form-group has-feedback">
......@@ -140,7 +163,8 @@
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('country'); ?><em>* </em>
<?php echo __('country'); ?>
<em>* </em>
<?php
echo $this->Form->input( 'master_country_id', array(
'id' => 'master_country_id',
......@@ -159,7 +183,8 @@
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('province'); ?><em>* </em>
<?php echo __('province'); ?>
<em>* </em>
<?php
echo $this->Form->input( 'master_province_id', array(
'id' => 'master_province_id',
......@@ -178,13 +203,21 @@
</div>
<div>
<?php // echo $this->Form->submit(__('SAVE')) ?>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile">SAVE</button>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile">
<?php echo __('SAVE');?>
</button>
</div>
<?php echo $this->Form->end(); ?>
</div>
</div>
</div>
<!--/.row profile-->
<div class="row">
</div>
<!--/.owl-carousel -->
<!--- *************** model list ******************* -->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true">
<div class="modal-dialog box-ads">
......@@ -212,8 +245,20 @@
</div>
</div>
</div>
</div>
</div>
<!--/.row modal card-->
<?php
if(!empty($UserCards)){
$i=0;
foreach ($UserCards as $value) {
echo $this->element('card_from/from_0',array('value' => $value,'i'=> $i));
$i++;
}
}
?>
</div>
<!--/.row top-->
<script>
$(document).ready(function() {
$("#email").on('change',function(){
......@@ -223,7 +268,7 @@
// console.log(data);
data = jQuery.parseJSON(data);
if(data['chk'] == 'false'){
alert(<?php echo __('This email is already in the system.') ?>);
alert(<?php echo __('This email is already in the system.'); ?>);
return false;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment