Commit fc557395 by Zen-PC\Zen

Zen : update

parent 7b36c6e8
<?php
namespace App\Controller;
use App\Controller\AppController;
use Cake\Core\Configure;
use Cake\Http\Client;
class ProfilesController extends AppController
{
public function index()
{
$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'
]
];
$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'];
$Profiles['UserProfiles']['organize_id'] = 10;
$Profiles['UserProfiles']['dept_id'] = 10;
#debug($Profiles);
$this->set(compact('Profiles'));
#$this->set('_serialize', ['Profiles']);
#---------------------------------------------------------------------------------------------------------------
$this->loadModel('MasterOrganizations');
@$MasterDepartmentEducations = $this->MasterOrganizations->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['organize_id']],
'keyField' => 'id',
'valueField' => 'org_name_th',
'order' => 'org_name_th asc'
]
);
if(!empty($MasterDepartmentEducations)) $MasterDepartmentEducations = $MasterDepartmentEducations->toArray();
$this->set(compact('MasterDepartmentEducations'));
//debug($MasterDepartmentEducations[0]['org_name_th']);
$this->loadModel('MasterDepartments');
@$MasterDepartments_v = $this->MasterDepartments->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['dept_id']],
'keyField' => 'id',
'valueField' => 'dept_name_th',
'order' => 'dept_name_th asc'
]
);
if(!empty($MasterDepartments_v)) $MasterDepartments_v = $MasterDepartments_v->toArray();
$this->set(compact('MasterDepartments_v'));
//debug($MasterDepartments_v);
$this->loadModel('MasterSections');
@$MasterSections_v = $this->MasterSections->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['section_id']],
'keyField' => 'id',
'valueField' => 'section_name_th',
'order' => 'section_name_th asc'
]
);
if(!empty($MasterSections_v)) $MasterSections_v = $MasterSections_v->toArray();
$this->set(compact('MasterSections_v'));
//debug($MasterSections_v);
}
/*****************************************************************************/
/*****************************************************************************/
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');
}
}
......@@ -8,73 +8,77 @@ use Cake\Http\Client;
class ProfilesController extends AppController
{
public function index()
{
public function index($id = 13112){
$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'
]
];
$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'];
$Profiles['UserProfiles']['organize_id'] = 10;
$Profiles['UserProfiles']['dept_id'] = 10;
#debug($Profiles);
$this->set(compact('Profiles'));
#$this->set('_serialize', ['Profiles']);
#---------------------------------------------------------------------------------------------------------------
$this->loadModel('MasterOrganizations');
@$MasterDepartmentEducations = $this->MasterOrganizations->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['organize_id']],
'keyField' => 'id',
'valueField' => 'org_name_th',
'order' => 'org_name_th asc'
]
);
if(!empty($MasterDepartmentEducations)) $MasterDepartmentEducations = $MasterDepartmentEducations->toArray();
$this->set(compact('MasterDepartmentEducations'));
//debug($MasterDepartmentEducations[0]['org_name_th']);
$this->loadModel('MasterDepartments');
@$MasterDepartments_v = $this->MasterDepartments->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['dept_id']],
'keyField' => 'id',
'valueField' => 'dept_name_th',
'order' => 'dept_name_th asc'
]
);
if(!empty($MasterDepartments_v)) $MasterDepartments_v = $MasterDepartments_v->toArray();
$this->set(compact('MasterDepartments_v'));
//debug($MasterDepartments_v);
$this->loadModel('MasterSections');
@$MasterSections_v = $this->MasterSections->find('all',
[
'conditions' => ['id' => $Profiles['UserProfiles'][0]['section_id']],
'keyField' => 'id',
'valueField' => 'section_name_th',
'order' => 'section_name_th asc'
]
);
if(!empty($MasterSections_v)) $MasterSections_v = $MasterSections_v->toArray();
$this->set(compact('MasterSections_v'));
//debug($MasterSections_v);
$this->loadModel('Users');
$responseUserProfile = $this->Users->get($id, [
'contain' => []
]);
$username = $responseUserProfile['username'];
//********DropdownCountry********
$this->loadModel('MasterCountries');
$Country = $this->MasterCountries->find('list', [
'conditions' => [
'is_used' => true],
'keyField' => 'id',
'valueField' => 'country_name_th'
]);
if(!empty($Country)) $Country = $Country->toArray();
//********DropdownProvince********
$this->loadModel('MasterProvinces');
$Province = $this->MasterProvinces->find('list', [
'conditions' => [
'is_used' => true],
'keyField' => 'id',
'valueField' => 'province_name_th'
]);
if(!empty($Province)) $Province = $Province->toArray();
$this->loadModel('UserPersonals');
$responseUserProfile = $this->UserPersonals->get($id, [
'contain' => []
]);
$res = $responseUserProfile['birthdate'];
$dateNow = $res->i18nFormat('dd/MM/yyyy');
if ($this->request->is(['patch', 'post', 'put'])) {
$data = $this->request->data;
// pr($this->request->data);die;
$this->loadModel('UserPersonals');
$userPersonals = $this->UserPersonals->find('all',
[
'limit' => 1,
'conditions' => [
'user_id' => $data['Users']['user_id']
]
]
)->toArray();
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
$userPersonals = $this->UserPersonals->patchEntity($userPersonals[0], $data['UserPersonals']);
$userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th'];
$userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th'];
$userPersonals['birthdate'] = $birthdate;
$userPersonals['user_id'] = $data['Users']['user_id'];
$userPersonals['master_country_id'] = $this->request->data['master_country_id'];
$userPersonals['master_province_id'] = $this->request->data['master_province_id'];
$userPersonals['modified_by'] = '';
if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('The article has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The article could not be saved. Please, try again.'));
}
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']);
}
/*****************************************************************************/
......
<div class="row">
<div style="position: absolute;z-index: 2;">
<a href="../core/Profiles/settingProfile">
<?php echo $this->Html->image('/img/core/img/setting-icon@3x.png', ['alt' => 'setting-icon']); ?>
</a>
</div>
<!------------------------------->
<?php
class QRGenerator {
protected $size;
protected $data;
protected $encoding;
protected $errorCorrectionLevel;
protected $marginInRows;
protected $debug;
public function __construct($data='1334554 5454 545',$size='300',$encoding='UTF-8',$errorCorrectionLevel='L',$marginInRows=4,$debug=false) {
$this->data=urlencode($data);
$this->size=($size>100 && $size<800)? $size : 300;
$this->encoding=($encoding == 'Shift_JIS' || $encoding == 'ISO-8859-1' || $encoding == 'UTF-8') ? $encoding : 'UTF-8';
$this->errorCorrectionLevel=($errorCorrectionLevel == 'L' || $errorCorrectionLevel == 'M' || $errorCorrectionLevel == 'Q' || $errorCorrectionLevel == 'H') ? $errorCorrectionLevel : 'L';
$this->marginInRows=($marginInRows>0 && $marginInRows<10) ? $marginInRows:4;
$this->debug = ($debug==true)? true:false;
}
public function generate(){
$QRLink = "https://chart.googleapis.com/chart?cht=qr&chs=".$this->size."x".$this->size. "&chl=" . $this->data .
"&choe=" . $this->encoding .
"&chld=" . $this->errorCorrectionLevel . "|" . $this->marginInRows;
if ($this->debug) echo $QRLink;
return $QRLink;
}
}
?>
<!------------------------------->
<div class="box">
<div class="absolute-right">
<?php echo $this->Html->image('/img/core/img/location-profile-icon@3x.png', ['alt' => 'location-profile-icon']); ?> สีลม ,บางรัก</div>
</div>
<div style="text-align: center;">
<?php if (empty($Profiles['UserProfiles'][0]['img_path'])) { ?>
<?php echo $this->Html->image('/img/core/img/user-profile@3x.png', array('div' => false, 'class' => 'profile-img','id'=>'output','style'=>'width: 169px;height: 169px;-webkit-border-radius: 85px;
-moz-border-radius: 85px;
border-radius: 85px;')); ?>
<?php }else{ ?>
<img src="<?php echo $Profiles['UserProfiles'][0]['img_path'];?>" class="profile-img" id="output" style="width: 169px;height: 169px;-webkit-border-radius: 85px;-moz-border-radius: 85px;border-radius: 85px;"/>
<?php }?>
</div>
<div data-toggle="modal" data-target="#defaultModal" style="text-align: center;">
<a href="#">
<?php echo $this->Html->image('/img/core/img/id-card-button@3x.png', array('div' => false, 'class' => 'id-card-button')); ?>
</a>
</div>
<div class="bg-profile"></div>
<div style="margin: 11% 0% -12% 0%;text-align: center;position: relative;"><?php echo $this->Flash->render() ?></div>
<div style="padding: 40px 20px 0px 20px;">
<ul class="list list-icons list-primary list-borders">
<li class="promotion-li">
<a href="#">
<div class="row">
<div class="col-xs-6 col-sm-7 color-profile">
<!--<img src="../img/core/img/eWallet-icon@3x.png" width="53" height="53" style="vertical-align: middle;"/> -->
My eWallet by Connect
</div>
<div class="col-xs-6 col-sm-5 right-icon-view">
$150 <?php echo $this->Html->image('/img/core/img/next-icon-profile@3x.png', array('div' => false, 'style' => 'vertical-align: middle;')); ?>
<!--<img src="../img/core/img/next-icon-profile@3x.png" style="vertical-align: middle;"/>-->
</div>
</div>
</a>
</li>
<li class="promotion-li">
<a href="#">
<div class="row">
<div class="col-xs-6 col-sm-7 color-profile">
<!--<img src="../img/core/img/point-icon@3x.png" width="53" height="53" style="vertical-align: middle;"/> -->
Point ของฉัน
</div>
<div class="col-xs-6 col-sm-5 right-icon-view">
P200 <?php echo $this->Html->image('/img/core/img/next-icon-profile@3x.png', array('div' => false, 'style' => 'vertical-align: middle;')); ?>
<!--<img src="../img/core/img/next-icon-profile@3x.png" style="vertical-align: middle;"/>-->
</div>
</div>
</a>
</li>
</ul>
</div>
</div>
<!--------------------------------------------------------->
<style type="text/css">
</style>
<!--------------------------------------------------------->
<style type="text/css">
</style>
<?php //debug($Profiles);?>
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="">
<div class="">
<div class="col-md-6">
<div class="owl-carousel owl-theme" data-plugin-options="{'items': 1, 'margin': 10}">
<div>
<div class="idcard-profile"><?php echo __('ID Card');?></div>
<?php echo $this->Html->image('/img/core/img/card-bg-front@3x.png', array('div' => false, 'class' => 'img-responsive img-rounded','style' => 'position: absolute;')); ?>
<?php if (empty($Profiles['UserProfiles'][0]['img_path'])) { ?>
<?php echo $this->Html->image('/img/core/img/user-profile@3x.png', array('div' => false, 'class' => '','style' => 'position: absolute;width: 150px; margin: 85% 0% 0% 20%; -webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg); -o-transform: rotate(270deg);')); ?>
<?php }else{ ?>
<img src="<?php echo $Profiles['UserProfiles'][0]['img_path'];?>" class="" id="" style="position: absolute;width: 150px; height: 150px; margin: 85% 0% 0% 20%; -webkit-border-radius: 85px;-moz-border-radius: 85px;border-radius: 85px; -webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg); -o-transform: rotate(270deg);"/>
<?php }?>
<div class="idcard-text"><?php echo __('เลขบัตรประจำตัว');?></div>
<div class="idcard-number"><?php echo $Profiles['UserProfiles'][0]['card_code'];?></div>
<div class="idcard-name-th"><?php echo $Profiles['UserPersonals']['firstname_th'];?> <?php echo $Profiles['UserPersonals']['lastname_th'];?></div>
<div class="idcard-name-en"><?php echo $Profiles['UserPersonals']['firstname_en'];?> <?php echo $Profiles['UserPersonals']['lastname_en'];?></div>
<?php if (!empty($Profiles['UserProfiles'][0]['dept_id'])) { ?>
<div class="idcard-faculty"><b><?php echo __('คณะ');?></b> <?php echo $MasterDepartments_v[0]['dept_name_th'];?></div>
<?php }else{?>
<div class="idcard-faculty"><b><?php echo __('คณะ');?></b> <?php echo __('-');?></div>
<?php }?>
<?php if (!empty($Profiles['UserProfiles'][0]['section_id'])) { ?>
<div class="idcard-branch"><b><?php echo __('สาขา');?></b> <?php echo $MasterSections_v[0]['section_name_th'];?></div>
<?php }else{?>
<div class="idcard-branch"><b><?php echo __('สาขา');?></b> <?php echo __('-');?></div>
<?php }?>
<!-- <div class="idcard-faculty"><b><?php //echo __('คณะ');?></b> <?php //echo __('วิทยาการจัดการ');?></div>
<div class="idcard-branch"><b><?php //echo __('สาขา');?></b> <?php //echo __('คอมพิวเตอร์ธุรกิจ');?></div>-->
<div class="idcard-tel"><b><?php echo __('เบอร์');?></b> <?php echo $Profiles['UserProfiles'][0]['phone_no'];?></div>
<div class="idcard-email"><b><?php echo __('email');?></b> <?php echo $Profiles['UserPersonals']['email'];?></div>
<?php echo $this->Html->image('/img/core/img/thumbs-id@3x.png', array('div' => false, 'class' => '','style' => 'width:78px;height:78px;position: absolute;margin: -4px 0px 0px 96px;')); ?>
</div>
<div>
<div class="qrcode-profile"><?php echo __('แสดง QR Code เพื่อรับสิทธิ์');?></div>
<?php echo $this->Html->image('/img/core/img/card-bg-back@3x.png', array('div' => false, 'class' => 'img-responsive img-rounded','style' => '3position: absolute;')); ?>
<div class="qrcode-name">
<?php
$ex1 = new QRGenerator();
echo "<img src=".$ex1->generate()." style='position: absolute;width: 150px;border: solid 1px #000;' class='qrcode-name'>";
?>
<?php //echo $this->Html->image('/img/core/img/qr-code.jpg', array('div' => false, 'class' => 'qrcode-name','style' => 'position: absolute;width: 120px;')); ?>
</div>
<div class="qrcode-faculty"><?php echo __('Date of Issue');?> <?php echo date("m/Y",strtotime($Profiles['Users']['created']));?></div>
<div class="qrcode-branch">| &nbsp;&nbsp;<?php echo __('Date of Expire');?> <?php echo date("m/Y",strtotime($Profiles['Users']['token_expiry'])); ?></div>
<?php echo $this->Html->image('/img/core/img/card-university-logo.png', array('div' => false, 'class' => '','style' => 'width: 25px;position: absolute;margin: -17% 0% 0% 86%;')); ?>
<?php if (!empty($Profiles['UserProfiles'][0]['organize_id'])) { ?>
<div class="qrcode-university"><?php echo $MasterDepartmentEducations[0]['org_name_th'];?></div>
<?php }else{?>
<div class="qrcode-university"><?php echo __('-');?></div>
<?php }?>
<?php //echo __('มหาวิทยาลัยราชภัฏจันทรเกษม');?>
<?php echo $this->Html->image('/img/core/img/card-logo-connect.png', array('div' => false, 'class' => '','style' => 'width: 26px;position: absolute;margin: -114% 0% 0% 86%;')); ?>
<div class="qrcode-connect"><?php echo __('connect');?></div>
<?php echo $this->Html->image('/img/core/img/thumbs-id2@3x.png', array('div' => false, 'class' => '','style' => 'width:78px;height:78px;position: absolute;margin: -152% 0% 0% 28%;')); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!------------------------------------------------------------------------------->
<div class="row">
<div style="position: absolute;z-index: 2;">
<a href="../core/Profiles/settingProfile">
<?php echo $this->Html->image('/img/core/img/setting-icon@3x.png', ['alt' => 'setting-icon']); ?>
</a>
</div>
<!------------------------------->
<?php
class QRGenerator {
protected $size;
protected $data;
protected $encoding;
protected $errorCorrectionLevel;
protected $marginInRows;
protected $debug;
public function __construct($data='1334554 5454 545',$size='300',$encoding='UTF-8',$errorCorrectionLevel='L',$marginInRows=4,$debug=false) {
$this->data=urlencode($data);
$this->size=($size>100 && $size<800)? $size : 300;
$this->encoding=($encoding == 'Shift_JIS' || $encoding == 'ISO-8859-1' || $encoding == 'UTF-8') ? $encoding : 'UTF-8';
$this->errorCorrectionLevel=($errorCorrectionLevel == 'L' || $errorCorrectionLevel == 'M' || $errorCorrectionLevel == 'Q' || $errorCorrectionLevel == 'H') ? $errorCorrectionLevel : 'L';
$this->marginInRows=($marginInRows>0 && $marginInRows<10) ? $marginInRows:4;
$this->debug = ($debug==true)? true:false;
}
public function generate(){
$QRLink = "https://chart.googleapis.com/chart?cht=qr&chs=".$this->size."x".$this->size. "&chl=" . $this->data .
"&choe=" . $this->encoding .
"&chld=" . $this->errorCorrectionLevel . "|" . $this->marginInRows;
if ($this->debug) echo $QRLink;
return $QRLink;
}
}
?>
<!------------------------------->
<div class="box">
<div class="absolute-right">
<?php echo $this->Html->image('/img/core/img/location-profile-icon@3x.png', ['alt' => 'location-profile-icon']); ?> สีลม ,บางรัก</div>
</div>
<div style="text-align: center;">
<?php if (empty($Profiles['UserProfiles'][0]['img_path'])) { ?>
<?php echo $this->Html->image('/img/core/img/user-profile@3x.png', array('div' => false, 'class' => 'profile-img','id'=>'output','style'=>'width: 169px;height: 169px;-webkit-border-radius: 85px;
-moz-border-radius: 85px;
border-radius: 85px;')); ?>
<?php }else{ ?>
<img src="<?php echo $Profiles['UserProfiles'][0]['img_path'];?>" class="profile-img" id="output" style="width: 169px;height: 169px;-webkit-border-radius: 85px;-moz-border-radius: 85px;border-radius: 85px;"/>
<?php }?>
</div>
<div data-toggle="modal" data-target="#defaultModal" style="text-align: center;">
<a href="#">
<?php echo $this->Html->image('/img/core/img/id-card-button@3x.png', array('div' => false, 'class' => 'id-card-button')); ?>
</a>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->create('UserProfiles', ['id' => 'frmSignIn', 'type' => 'file']); ?>
<div style="position: absolute;z-index: 2;">
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
</div>
<div class="box">
<div class="absolute-right"><img src="/img/core/img/location-profile-icon@3x.png"/> สีลม ,บางรัก</div>
</div>
<div style="text-align: center;">
<!--<div class="">-->
<?php //echo @$this->Html->image($responseUserProfile['UserProfiles']['img_path'], ['class' => 'imgCircle profile-img', 'id' => 'img-upload', 'alt' => 'Profile picture']); ?>
<!-- <img src="/porto/core/img/profile-img@3x.png" class="imgCircle profile-img" id="img-upload" alt="Profile picture"> -->
<img src="/img/core/img/profile-img@3x.png" class="imgCircle profile-img" id="img-upload" alt="Profile picture">
<!--</div>-->
<input type="file" id="uploadProfile" class="profile-img form-control form-input Profile-input-file" name="data[UserProfiles][img_path]" >
</div>
<div class="bg-profile"></div>
<!--<div class="col-xs-12 col-sm-12 col-md-12" style="padding-top: 20px;">-->
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->hidden('Users.user_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['id'], 'id' => 'userId', 'type' => 'text', 'label' => __('ชื่อผู้ใช้งาน'), 'placeholder' => 'USERNAME']); ?>
<?php echo $this->Form->input('Users.username', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $username, 'id' => 'username', 'type' => 'text', 'label' => __('ชื่อผู้ใช้งาน'), 'placeholder' => 'USERNAME', 'readonly']); ?>
<?php // echo $this->Form->input('user_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $userProfile->username, 'id' => 'userId', 'type' => 'text', 'label' => __('ชื่อผู้ใช้งาน'), 'placeholder' => 'USERNAME']); ?>
</div>
</div>
<?php // foreach ($userProfile->user['user_personals'] as $k => $userProfiles): ?>
<?php // debug($userProfiles); exit;?>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<!--<label class="label-text-sub">เพศ</label>-->
<?php echo __('เพศ'); ?>
<div class="radio-group">
<label class="radio-inline">
<input type="radio" name="UserPersonals[gender]" id="male" value="M" <?php echo ($responseUserProfile['gender'] == 'M') ? 'checked="checked"' : null; ?>> <?php echo __('ชาย'); ?>
</label>
<label class="radio-inline">
<input type="radio" name="UserPersonals[gender]" id="female" value="F" <?php echo ($responseUserProfile['gender'] == 'F') ? 'checked="checked"' : null; ?>> <?php echo __('หญิง'); ?>
</label>
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserPersonals.firstname_th', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['firstname_th'], 'id' => 'firstname_th', 'type' => 'text', 'label' => __('ชื่อ'), 'placeholder' => 'ชื่อ', 'required']); ?>
<?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' => 'ชื่อ - นามสกุล', 'required']); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserPersonals.lastname_th', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['lastname_th'], 'id' => 'lastname_th', 'type' => 'text', 'label' => __('นามสกุล'), 'placeholder' => 'นามสกุล', 'required']); ?>
<?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' => 'ชื่อ - นามสกุล', 'required']); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserPersonals.birthdate', ['class' => 'form-control-reg border-bottom-from required', 'value' => $dateNow, 'id' => 'datepicker', 'type' => 'text', 'label' => __('วันเดือนปีเกิด'), 'placeholder' => 'DD-MM-YYYY', 'required']); ?>
<span class="glyphicon glyphicon-calendar form-control-feedback datepicker"></span>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('กรุ๊ปเลือด'); ?>
<div class="radio-group">
<label class="radio-inline">
<input type="radio" name="UserPersonals[blood_group]" id="blood-A" value="A" <?php echo ($responseUserProfile['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 ($responseUserProfile['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 ($responseUserProfile['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 ($responseUserProfile['blood_group'] == 'O') ? 'checked="checked"' : null; ?>> <?php echo __('O'); ?>
</label>
</div>
<div class="bg-profile"></div>
<div style="margin: 11% 0% -12% 0%;text-align: center;position: relative;"><?php echo $this->Flash->render() ?></div>
<div style="padding: 40px 20px 0px 20px;">
<ul class="list list-icons list-primary list-borders">
<li class="promotion-li">
<a href="#">
<div class="row">
<div class="col-xs-6 col-sm-7 color-profile">
<!--<img src="../img/core/img/eWallet-icon@3x.png" width="53" height="53" style="vertical-align: middle;"/> -->
My eWallet by Connect
</div>
<div class="col-xs-6 col-sm-5 right-icon-view">
$150 <?php echo $this->Html->image('/img/core/img/next-icon-profile@3x.png', array('div' => false, 'style' => 'vertical-align: middle;')); ?>
<!--<img src="../img/core/img/next-icon-profile@3x.png" style="vertical-align: middle;"/>-->
</div>
</div>
</a>
</li>
<li class="promotion-li">
<a href="#">
<div class="row">
<div class="col-xs-6 col-sm-7 color-profile">
<!--<img src="../img/core/img/point-icon@3x.png" width="53" height="53" style="vertical-align: middle;"/> -->
Point ของฉัน
</div>
<div class="col-xs-6 col-sm-5 right-icon-view">
P200 <?php echo $this->Html->image('/img/core/img/next-icon-profile@3x.png', array('div' => false, 'style' => 'vertical-align: middle;')); ?>
<!--<img src="../img/core/img/next-icon-profile@3x.png" style="vertical-align: middle;"/>-->
</div>
</div>
</a>
</li>
</ul>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserPersonals.moblie_no', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['moblie_no'], 'id' => 'moblieNo', 'type' => 'text', 'label' => __('เบอร์โทรศัพท์'), 'placeholder' => '000-000-0000']); ?>
<?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 $this->Form->input('UserPersonals.email', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['email'], 'id' => 'email', 'type' => 'email', 'label' => __('Email'), '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']); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->input('UserPersonals.address', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'value' => $responseUserProfile['address'], 'id' => 'address', 'type' => 'text', 'label' => __('ที่อยู่อาศัย'), 'placeholder' => __('112/3 สุขุมวิท 22 ทองหล่อ กทม 10523')]); ?>
<?php // echo $this->Form->input('address', ['class' => 'form-control-reg border-bottom-from label-text-sub', 'value' => $userProfiles->address, 'id' => 'address', 'type' => 'text', 'label' => __('ที่อยู่อาศัย'), 'placeholder' => __('112/3 สุขุมวิท 22 ทองหล่อ กทม 10523')]); ?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('ประเทศ'); ?>
<?php
echo $this->Form->input( 'master_country_id', array(
'id' => 'master_country_id',
'label' => false,
'type' => 'select',
'options' => $Country,
'value' => $responseUserProfile['master_country_id'],
'empty' => '---Select---',
'default' => !empty($responseUserProfile['master_country_id'])? $responseUserProfile['master_country_id']:'',
'class' => 'form-control border-bottom-from label-text-sub required',
'style' => 'width:100%'
));
?>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12">
<?php echo __('จังหวัด'); ?>
<?php
echo $this->Form->input( 'master_province_id', array(
'id' => 'master_province_id',
'label' => false,
'type' => 'select',
'options' => $Province,
'value' => $responseUserProfile['master_province_id'],
'empty' => '---Select---',
'default' => !empty($responseUserProfile['master_province_id'])? $responseUserProfile['master_province_id']:'',
'class' => 'form-control border-bottom-from label-text-sub required',
'style' => 'width:100%'
));
?>
</div>
</div>
<?php // endforeach; ?>
<div>
<?php // echo $this->Form->submit(__('SAVE')) ?>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile">บันทึก</button>
</div>
<?php echo $this->Form->end(); ?>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#moblieNo').inputmask('999-999-9999');
$('#officePhone').inputmask('99-999-9999');
//==================================================
// CHANGE UNIVERSITY PROFILES
//==================================================
$("#OrganizetionId").change(function () {
getDepartment();
});
$("#DepartmentId").change(function () {
getSection();
});
$("#SectionId").change(function () {
updateChosen();
});
//==================================================
// CHANGE COMPAMY PROFILES
//==================================================
$("#companyName").change(function () {
getCompanyDepartment();
});
$("#department").change(function () {
getCompanySection();
});
$("#cottonId").change(function () {
getCompanyPosition();
});
$(".datepicker").change(function () {
updateChosen();
});
$('#datepicker').datepicker({
format: 'dd/mm/yyyy'
});
<!--------------------------------------------------------->
<style type="text/css">
//==================================================
// CHANGE PROFILES PICTURE
//==================================================
$("#uploadProfile").change(function () {
readURL(this);
});
});
</style>
<!--------------------------------------------------------->
<style type="text/css">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#img-upload')
.attr('src', e.target.result)
.width(150)
.height(150);
}
</style>
<?php //debug($Profiles);?>
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="">
<div class="">
<div class="col-md-6">
<div class="owl-carousel owl-theme" data-plugin-options="{'items': 1, 'margin': 10}">
<div>
<div class="idcard-profile"><?php echo __('ID Card');?></div>
<?php echo $this->Html->image('/img/core/img/card-bg-front@3x.png', array('div' => false, 'class' => 'img-responsive img-rounded','style' => 'position: absolute;')); ?>
<?php if (empty($Profiles['UserProfiles'][0]['img_path'])) { ?>
<?php echo $this->Html->image('/img/core/img/user-profile@3x.png', array('div' => false, 'class' => '','style' => 'position: absolute;width: 150px; margin: 85% 0% 0% 20%; -webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg); -o-transform: rotate(270deg);')); ?>
<?php }else{ ?>
<img src="<?php echo $Profiles['UserProfiles'][0]['img_path'];?>" class="" id="" style="position: absolute;width: 150px; height: 150px; margin: 85% 0% 0% 20%; -webkit-border-radius: 85px;-moz-border-radius: 85px;border-radius: 85px; -webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg); -o-transform: rotate(270deg);"/>
<?php }?>
<div class="idcard-text"><?php echo __('เลขบัตรประจำตัว');?></div>
<div class="idcard-number"><?php echo $Profiles['UserProfiles'][0]['card_code'];?></div>
<div class="idcard-name-th"><?php echo $Profiles['UserPersonals']['firstname_th'];?> <?php echo $Profiles['UserPersonals']['lastname_th'];?></div>
<div class="idcard-name-en"><?php echo $Profiles['UserPersonals']['firstname_en'];?> <?php echo $Profiles['UserPersonals']['lastname_en'];?></div>
<?php if (!empty($Profiles['UserProfiles'][0]['dept_id'])) { ?>
<div class="idcard-faculty"><b><?php echo __('คณะ');?></b> <?php echo $MasterDepartments_v[0]['dept_name_th'];?></div>
<?php }else{?>
<div class="idcard-faculty"><b><?php echo __('คณะ');?></b> <?php echo __('-');?></div>
<?php }?>
<?php if (!empty($Profiles['UserProfiles'][0]['section_id'])) { ?>
<div class="idcard-branch"><b><?php echo __('สาขา');?></b> <?php echo $MasterSections_v[0]['section_name_th'];?></div>
<?php }else{?>
<div class="idcard-branch"><b><?php echo __('สาขา');?></b> <?php echo __('-');?></div>
<?php }?>
<!-- <div class="idcard-faculty"><b><?php //echo __('คณะ');?></b> <?php //echo __('วิทยาการจัดการ');?></div>
<div class="idcard-branch"><b><?php //echo __('สาขา');?></b> <?php //echo __('คอมพิวเตอร์ธุรกิจ');?></div>-->
<div class="idcard-tel"><b><?php echo __('เบอร์');?></b> <?php echo $Profiles['UserProfiles'][0]['phone_no'];?></div>
<div class="idcard-email"><b><?php echo __('email');?></b> <?php echo $Profiles['UserPersonals']['email'];?></div>
<?php echo $this->Html->image('/img/core/img/thumbs-id@3x.png', array('div' => false, 'class' => '','style' => 'width:78px;height:78px;position: absolute;margin: -4px 0px 0px 96px;')); ?>
</div>
<div>
<div class="qrcode-profile"><?php echo __('แสดง QR Code เพื่อรับสิทธิ์');?></div>
<?php echo $this->Html->image('/img/core/img/card-bg-back@3x.png', array('div' => false, 'class' => 'img-responsive img-rounded','style' => '3position: absolute;')); ?>
<div class="qrcode-name">
<?php
$ex1 = new QRGenerator();
echo "<img src=".$ex1->generate()." style='position: absolute;width: 150px;border: solid 1px #000;' class='qrcode-name'>";
?>
<?php //echo $this->Html->image('/img/core/img/qr-code.jpg', array('div' => false, 'class' => 'qrcode-name','style' => 'position: absolute;width: 120px;')); ?>
</div>
<div class="qrcode-faculty"><?php echo __('Date of Issue');?> <?php echo date("m/Y",strtotime($Profiles['Users']['created']));?></div>
<div class="qrcode-branch">| &nbsp;&nbsp;<?php echo __('Date of Expire');?> <?php echo date("m/Y",strtotime($Profiles['Users']['token_expiry'])); ?></div>
<?php echo $this->Html->image('/img/core/img/card-university-logo.png', array('div' => false, 'class' => '','style' => 'width: 25px;position: absolute;margin: -17% 0% 0% 86%;')); ?>
<?php if (!empty($Profiles['UserProfiles'][0]['organize_id'])) { ?>
<div class="qrcode-university"><?php echo $MasterDepartmentEducations[0]['org_name_th'];?></div>
<?php }else{?>
<div class="qrcode-university"><?php echo __('-');?></div>
<?php }?>
<?php //echo __('มหาวิทยาลัยราชภัฏจันทรเกษม');?>
<?php echo $this->Html->image('/img/core/img/card-logo-connect.png', array('div' => false, 'class' => '','style' => 'width: 26px;position: absolute;margin: -114% 0% 0% 86%;')); ?>
<div class="qrcode-connect"><?php echo __('connect');?></div>
<?php echo $this->Html->image('/img/core/img/thumbs-id2@3x.png', array('div' => false, 'class' => '','style' => 'width:78px;height:78px;position: absolute;margin: -152% 0% 0% 28%;')); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!------------------------------------------------------------------------------->
reader.readAsDataURL(input.files[0]);
}
}
//==================================================
// CHANGE Province According Country
//==================================================
$(document).ready(function() {
$("#loding1").hide();
$("#loding2").hide();
$("#master_country_id").on('change',function() {
var id = $(this).val();
$("#loding1").show();
$("#master_province_id").find('option').remove();
if (id) {
var dataString = 'id='+ id;
$.ajax({
type: "POST",
url: '/Profiles/index',
data: dataString,
cache: false,
success: function(html) {
$("#loding1").hide();
$.each(html, function(key, value) {
$('<option>').val('').text('select');
$('<option>').val(key).text(value).appendTo($("#master_province_id"));
});
}
});
}
});
});
</script>
\ No newline at end of file
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