Commit 56fe1379 by Teeradone-PIM

teeradone

parent b91a2679
...@@ -51,6 +51,7 @@ class ProfilesController extends AppController ...@@ -51,6 +51,7 @@ class ProfilesController extends AppController
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$data = $this->request->data; $data = $this->request->data;
// pr($this->request->data);die; // pr($this->request->data);die;
$this->loadModel('UserPersonals'); $this->loadModel('UserPersonals');
$userPersonals = $this->UserPersonals->find('all', $userPersonals = $this->UserPersonals->find('all',
...@@ -60,13 +61,35 @@ class ProfilesController extends AppController ...@@ -60,13 +61,35 @@ class ProfilesController extends AppController
'user_id' => $data['Users']['user_id'] 'user_id' => $data['Users']['user_id']
] ]
] ]
)->toArray(); )->first();
// pr($userPersonals);die;
if($userPersonals['email'] == $this->request->data['UserPersonals']['email']){
$chkemail = true;
}else{
$userPersonals = $this->UserPersonals->find('all',
[
'limit' => 1,
'conditions' => [
'email' => $data['UserPersonals']['email']
]
]
)->toArray();
if(empty($userPersonals)){
$chkemail = true;
}else{
$chkemail = false;
}
}
if($chkemail == true){
$birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']); $birthdate = explode("/", $this->request->data['UserPersonals']['birthdate']);
$birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0]; $birthdate = $birthdate[2].'-'.$birthdate[1].'-'.$birthdate[0];
$userPersonals = $this->UserPersonals->patchEntity($userPersonals[0], $data['UserPersonals']); $userPersonals = $this->UserPersonals->patchEntity($userPersonals, $data['UserPersonals']);
$userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th']; $userPersonals['firstname_th'] = $this->request->data['UserPersonals']['firstname_th'];
$userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th']; $userPersonals['lastname_th'] = $this->request->data['UserPersonals']['lastname_th'];
$userPersonals['email'] = $this->request->data['UserPersonals']['email'];
$userPersonals['birthdate'] = $birthdate; $userPersonals['birthdate'] = $birthdate;
$userPersonals['user_id'] = $data['Users']['user_id']; $userPersonals['user_id'] = $data['Users']['user_id'];
$userPersonals['master_country_id'] = $this->request->data['master_country_id']; $userPersonals['master_country_id'] = $this->request->data['master_country_id'];
...@@ -74,10 +97,13 @@ class ProfilesController extends AppController ...@@ -74,10 +97,13 @@ class ProfilesController extends AppController
$userPersonals['modified_by'] = ''; $userPersonals['modified_by'] = '';
if ($this->UserPersonals->save($userPersonals)) { if ($this->UserPersonals->save($userPersonals)) {
$this->Flash->success(__('The article has been saved.')); $this->Flash->success(__('Update Complete.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
} }
$this->Flash->error(__('The article could not be saved. Please, try again.')); }else{
$this->Flash->error(__('Email Address already used by others.'));
}
$this->Flash->error(__('Not update. Please, try again.'));
} }
$this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province')); $this->set(compact('userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province'));
$this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']); $this->set('_serialize', ['userPersonals', 'responseUserProfile', 'dateNow', 'username', 'Country', 'Province']);
......
...@@ -123,7 +123,7 @@ class UserCardsController extends AppController ...@@ -123,7 +123,7 @@ class UserCardsController extends AppController
$this->loadModel('MasterOrganizations'); $this->loadModel('MasterOrganizations');
if ($this->request->is('post')) { if ($this->request->is('post')) {
// pr($this->Auth);die; // pr($this->Auth);die;
// pr($this->request->data());die; // pr($this->request->data());
$birthdate = explode("/", $this->request->data['UserCards']['birthdate']); $birthdate = explode("/", $this->request->data['UserCards']['birthdate']);
$birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0']; $birthdate = $birthdate['2'].'-'.$birthdate['1'].'-'.$birthdate['0'];
$TempUserCards = $this->TempUserCards->find('all', [ $TempUserCards = $this->TempUserCards->find('all', [
...@@ -132,49 +132,101 @@ class UserCardsController extends AppController ...@@ -132,49 +132,101 @@ class UserCardsController extends AppController
'card_code' => $this->request->data['UserCards']['employee'], 'card_code' => $this->request->data['UserCards']['employee'],
'birthdate' => $birthdate 'birthdate' => $birthdate
] ]
])->toArray(); ])->first();
$TempUserCards = $this->TempUserCards->get($TempUserCards[0]['id']); if(!empty($TempUserCards)){
$UserCards = $this->UserCards->find('all', [
// pr($TempUserCards);die; 'conditions' => [
// pr($this->TempUserCards->get($TempUserCards[0]['id']));die; 'organize_id' => $TempUserCards['organize_id'],
$userCard = $this->UserCards->newEntity(); 'card_code' => $TempUserCards['card_code']
//pr($userCard);die; ]
// $userCard = $this->UserCards->patchEntity($userCard, $TempUserCards); ])->first();
$userCard = $TempUserCards; // pr($UserCards);die;
$userCard['user_id'] = 1; if(empty($UserCards)){
$userCard['id'] = null; $userCard = $this->UserCards->newEntity();
// pr($userCard->toArray());die; $userCard['organize_id'] = $TempUserCards['organize_id'];
$userCard['card_code'] = $TempUserCards['card_code'];
if ($this->UserCards->save($userCard)) { $userCard['img_path'] = $TempUserCards['img_path'];
$this->Flash->success(__('The user card has been saved.')); $userCard['prefix_name_th'] = $TempUserCards['prefix_name_th'];
die; $userCard['firstname_th'] = $TempUserCards['firstname_th'];
return $this->redirect(['action' => 'index']); $userCard['lastname_th'] = $TempUserCards['lastname_th'];
$userCard['prefix_name_en'] = $TempUserCards['prefix_name_en'];
$userCard['firstname_en'] = $TempUserCards['firstname_en'];
$userCard['lastname_en'] = $TempUserCards['lastname_en'];
$userCard['department_name'] = $TempUserCards['department_name'];
$userCard['section_name'] = $TempUserCards['section_name'];
$userCard['position_name'] = $TempUserCards['position_name'];
$userCard['gender'] = $TempUserCards['gender'];
$userCard['blood_group'] = $TempUserCards['blood_group'];
$userCard['birthdate'] = $TempUserCards['birthdate'];
$userCard['date_issued'] = $TempUserCards['date_issued'];
$userCard['date_expiry'] = $TempUserCards['date_expiry'];
$userCard['signature'] = $TempUserCards['signature'];
$userCard['is_used'] = $TempUserCards['is_used'];
$userCard['created_by'] = 1;
$userCard['user_id'] = 1;
// pr($userCard);die;
if ($this->UserCards->save($userCard)) {
$this->Flash->success(__('บันทึกสำเร็จ'));
return $this->redirect(['controller' => 'Profiles', 'action' => 'index']);
}
}else{
$this->Flash->success(__('ลงทะเบียนไว้อยู่แล้ว'));
return $this->redirect(['controller' => 'UserCards', 'action' => 'createCards']);
}
}else{
$this->Flash->success(__('ไม่พบข้อมูล'));
return $this->redirect(['controller' => 'UserCards', 'action' => 'createCards']);
} }
$this->Flash->error(__('The user card could not be saved. Please, try again.'));
// pr($TempUserCards);die;
} }
} }
public function checkOrg() public function checkOrg()
{ {
$this->autoRender = false; $this->autoRender = false;
// $this->loadModel('MasterOrganizations');
// $MasterOrganizations = $this->MasterOrganizations->find('all', [
// 'fields' => [
// 'id',
// 'org_code',
// 'org_name_th'
// ], 'conditions' => [
// 'org_code' => 'PAGO0010'
// ]
// ])->toArray();
// pr($MasterOrganizations);die;
if ($this->request->is('post')) { if ($this->request->is('post')) {
$this->loadModel('MasterOrganizations'); $this->loadModel('MasterOrganizations');
$MasterOrganizations = $this->MasterOrganizations->find('all', [ $MasterOrganizations = $this->MasterOrganizations->find('all', [
'fields' => [ 'fields' => [
'id','org_code', 'id',
'org_code',
'org_name_th' 'org_name_th'
], 'conditions' => [ ], 'conditions' => [
'org_code' => $this->request->data['organize_code'] 'org_code' => $this->request->data['organize_code']
] ]
])->toArray(); ])->toArray();
if(!empty($MasterOrganizations)){ if(!empty($MasterOrganizations)){
$data = json_encode($MasterOrganizations); $UserCards = $this->UserCards->find('all', [
echo $data; 'fields' => [
'id',
'user_id',
'organize_id'
], 'conditions' => [
'user_id' => 2,
'organize_id' => $MasterOrganizations[0]['id']
]
])->toArray();
if(empty($UserCards)){
$MasterOrganizations['chkuser'] = false;
$data = json_encode($MasterOrganizations);
echo $data;
}else{
$MasterOrganizations['chkuser'] = true;
$data = json_encode($MasterOrganizations);
echo $data;
}
}else{ }else{
echo 'false'; echo 'false';
} }
} }
} }
} }
\ No newline at end of file
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-12"> <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;"> <div style="position: absolute;z-index: 2;">
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a> <a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
</div> </div>
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
</div> </div>
<div class="bg-profile"></div> <div class="bg-profile"></div>
<!--<div class="col-xs-12 col-sm-12 col-md-12" style="padding-top: 20px;">--> <!--<div class="col-xs-12 col-sm-12 col-md-12" style="padding-top: 20px;">-->
</div><!--/col-xs-12-->
</div><!--/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']); ?>
<?php echo $this->Flash->render() ?>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12"> <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->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']); ?>
......
...@@ -4,11 +4,8 @@ ...@@ -4,11 +4,8 @@
<div style="position: absolute;z-index: 2;"> <div style="position: absolute;z-index: 2;">
<a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a> <a href="profile_setting"><img src="/img/core/img/setting-icon@3x.png"/></a>
</div> </div>
<div style="text-align: center;">
<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="bg-profile"></div>
<!--<div class="col-xs-12 col-sm-12 col-md-12" style="padding-top: 20px;">--> <?php echo $this->Flash->render() ?>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<div class="col-xs-12 col-sm-12 col-md-12"> <div class="col-xs-12 col-sm-12 col-md-12">
<?php echo $this->Form->hidden('UserCards.user_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'userId', 'type' => 'text', 'placeholder' => 'USERNAME']); ?> <?php echo $this->Form->hidden('UserCards.user_id', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'userId', 'type' => 'text', 'placeholder' => 'USERNAME']); ?>
...@@ -25,7 +22,6 @@ ...@@ -25,7 +22,6 @@
</div> </div>
<div class="form-group has-feedback bootstrap-iso"> <div class="form-group has-feedback bootstrap-iso">
<div class="col-xs-12 col-sm-12 col-md-12"> <div class="col-xs-12 col-sm-12 col-md-12">
<!-- <?php echo $this->Form->input('UserCards.birthdate', ['class' => 'form-control-reg border-bottom-from label-text-sub required', 'id' => 'birthdate', 'type' => 'daet', 'label' => __('วันเกิด'), 'placeholder' => '01/01/2000', 'disabled', 'required']); ?> -->
<label class="label-text-sub"><?php echo __('วันเกิด');?></label> <label class="label-text-sub"><?php echo __('วันเกิด');?></label>
<input type="text" name="UserCards[birthdate]" id="date" placeholder="กรุณาระบุวันเดือนปีเกิด" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from"> <input type="text" name="UserCards[birthdate]" id="date" placeholder="กรุณาระบุวันเดือนปีเกิด" value="" placeholder="DD-MM-YYYY" data-date-format="mm/dd/yyyy" class="form-control-reg border-bottom-from">
<span class="glyphicon glyphicon-calendar form-control-feedback"></span> <span class="glyphicon glyphicon-calendar form-control-feedback"></span>
......
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