Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
smart_core_connect
/
core-connect
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9b7a9912
authored
May 22, 2018
by
Wittaya-PIM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Aof : Add UserEntity หลัง Add UserCards สำเร็จ
parent
9dba9ad1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
2 deletions
+109
-2
www/src/Controller/UserCardsController.php
+21
-1
www/src/Model/Entity/UserEntity.php
+23
-0
www/src/Model/Table/UserEntitiesTable.php
+57
-0
www/src/Template/UserCards/view_card.ctp
+8
-1
No files found.
www/src/Controller/UserCardsController.php
View file @
9b7a9912
...
...
@@ -211,7 +211,7 @@ class UserCardsController extends AppController
'user_id'
,
'organize_id'
],
'conditions'
=>
[
'user_id'
=>
2
,
'user_id'
=>
$this
->
Auth
->
user
(
'id'
)
,
'organize_id'
=>
$MasterOrganizations
[
0
][
'id'
]
]
])
->
toArray
();
...
...
@@ -262,6 +262,7 @@ class UserCardsController extends AppController
$this
->
loadModel
(
'MasterOrganizations'
);
if
(
$this
->
request
->
is
(
'post'
))
{
// pr($this->request->data());die;
// pr($this->Auth->user('id'));die;
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserCards'
][
'birthdate'
]);
$birthdate
=
$birthdate
[
'2'
]
.
'-'
.
$birthdate
[
'1'
]
.
'-'
.
$birthdate
[
'0'
];
$TempUserCards
=
$this
->
TempUserCards
->
find
(
'all'
,
[
...
...
@@ -305,8 +306,27 @@ class UserCardsController extends AppController
$userCard
[
'user_id'
]
=
$this
->
Auth
->
user
(
'id'
);
// pr($userCard);die;
if
(
$this
->
UserCards
->
save
(
$userCard
))
{
// pr('sdsd');die;
$TempUserCards
[
'is_used'
]
=
0
;
$this
->
TempUserCards
->
save
(
$TempUserCards
);
$this
->
loadModel
(
'UserEntities'
);
$UserEntities
=
$this
->
UserEntities
->
find
(
'all'
,
[
'conditions'
=>
[
'user_id'
=>
$this
->
Auth
->
user
(
'id'
),
'entity_code'
=>
$TempUserCards
[
'organize_id'
]
]
])
->
first
();
if
(
empty
(
$UserEntities
)){
// pr('sdsd');die;
$UserEntities
=
$this
->
UserEntities
->
newEntity
();
$UserEntities
[
'entity_code'
]
=
$TempUserCards
[
'organize_id'
];
$UserEntities
[
'user_id'
]
=
$this
->
Auth
->
user
(
'id'
);
$UserEntities
[
'created_by'
]
=
$this
->
Auth
->
user
(
'id'
);
$UserEntities
[
'modified_by'
]
=
$this
->
Auth
->
user
(
'id'
);
$this
->
UserEntities
->
save
(
$UserEntities
);
}
$this
->
Flash
->
success
(
__
(
'บันทึกสำเร็จ'
));
return
$this
->
redirect
([
'controller'
=>
'Profiles'
,
'action'
=>
'index'
]);
}
...
...
www/src/Model/Entity/UserEntity.php
0 → 100644
View file @
9b7a9912
<?php
namespace
App\Model\Entity
;
use
Cake\ORM\Entity
;
/**
* Building Entity
*/
class
UserEntity
extends
Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
}
www/src/Model/Table/UserEntitiesTable.php
0 → 100644
View file @
9b7a9912
<?php
namespace
App\Model\Table
;
use
Cake\ORM\Query
;
use
Cake\ORM\RulesChecker
;
use
Cake\ORM\Table
;
use
Cake\Validation\Validator
;
class
UserEntitiesTable
extends
Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public
function
initialize
(
array
$config
)
{
parent
::
initialize
(
$config
);
$this
->
setTable
(
'core.user_entities'
);
$this
->
setDisplayField
(
'id'
);
$this
->
setPrimaryKey
(
'id'
);
$this
->
addBehavior
(
'Timestamp'
);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public
function
validationDefault
(
Validator
$validator
)
{
// return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public
static
function
defaultConnectionName
()
{
return
'core'
;
}
}
www/src/Template/UserCards/view_card.ctp
View file @
9b7a9912
...
...
@@ -164,7 +164,7 @@ use Cake\I18n\Time;
</div>
</div>
<div>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile">ตรวจสอบ</button>
<button type="submit" class="btn btn-quaternary mr-xs mb-sm button-text-profile"
id="checkbutton"
>ตรวจสอบ</button>
</div>
<?php echo $this->Form->end(); ?>
</div>
...
...
@@ -485,6 +485,12 @@ use Cake\I18n\Time;
$(document).ready(function() {
$("#organize_code").on('change',function(){
var organize_code = $("#organize_code").val();
$('#employee').attr("disabled",true);
$('#date').attr("disabled",true);
$('#checkbutton').attr("disabled",true);
organize_id.val('');
employee.val('');
date.val('');
$.post("/UserCards/checkOrg", {organize_code: organize_code}, function(data) {
if(data!='false'){
data = jQuery.parseJSON(data);
...
...
@@ -500,6 +506,7 @@ use Cake\I18n\Time;
}else if(data['chkuser'] == false){
$("#nameorg_th").text(data[0]['org_name_th']);
$("#noorg_th").text('');
$("#checkbutton").removeAttr("disabled");
$("#employee").removeAttr("disabled");
$("#date").removeAttr("disabled");
organize_id.val(data[0]['id']);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment