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
658fa6f9
authored
May 21, 2018
by
Wittaya-PIM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Aof : ย้าย funtion ceateCards ไปรวมกับ funtion viewCards และอัฟเดทข้อมูลใน Temp
parent
17699c43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
1 deletions
+66
-1
www/src/Controller/UserCardsController.php
+66
-1
No files found.
www/src/Controller/UserCardsController.php
View file @
658fa6f9
...
@@ -116,7 +116,7 @@ class UserCardsController extends AppController
...
@@ -116,7 +116,7 @@ class UserCardsController extends AppController
return
$this
->
redirect
([
'action'
=>
'index'
]);
return
$this
->
redirect
([
'action'
=>
'index'
]);
}
}
public
function
createCards
()
public
function
createCards
()
// ----------------- เอาไปรวมกับ viweCards แล้ว ------------------
{
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
loadModel
(
'TempUserCards'
);
$this
->
loadModel
(
'TempUserCards'
);
...
@@ -255,5 +255,69 @@ class UserCardsController extends AppController
...
@@ -255,5 +255,69 @@ class UserCardsController extends AppController
// pr($UserCards);die;
// pr($UserCards);die;
$this
->
set
(
compact
(
'UserCards'
));
$this
->
set
(
compact
(
'UserCards'
));
// -----------------------------ในส่วนของการ add-------------------------
$this
->
loadModel
(
'TempUserCards'
);
$this
->
loadModel
(
'MasterOrganizations'
);
if
(
$this
->
request
->
is
(
'post'
))
{
// pr($this->request->data());die;
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'UserCards'
][
'birthdate'
]);
$birthdate
=
$birthdate
[
'2'
]
.
'-'
.
$birthdate
[
'1'
]
.
'-'
.
$birthdate
[
'0'
];
$TempUserCards
=
$this
->
TempUserCards
->
find
(
'all'
,
[
'conditions'
=>
[
'organize_id'
=>
$this
->
request
->
data
[
'UserCards'
][
'organize_id'
],
'card_code'
=>
$this
->
request
->
data
[
'UserCards'
][
'employee'
],
'birthdate'
=>
$birthdate
]
])
->
first
();
// pr($TempUserCards);die;
if
(
!
empty
(
$TempUserCards
)){
$UserCards
=
$this
->
UserCards
->
find
(
'all'
,
[
'conditions'
=>
[
'organize_id'
=>
$TempUserCards
[
'organize_id'
],
'card_code'
=>
$TempUserCards
[
'card_code'
]
]
])
->
first
();
// pr($UserCards);die;
if
(
empty
(
$UserCards
)){
$userCard
=
$this
->
UserCards
->
newEntity
();
$userCard
[
'organize_id'
]
=
$TempUserCards
[
'organize_id'
];
$userCard
[
'card_code'
]
=
$TempUserCards
[
'card_code'
];
$userCard
[
'img_path'
]
=
$TempUserCards
[
'img_path'
];
$userCard
[
'prefix_name_th'
]
=
$TempUserCards
[
'prefix_name_th'
];
$userCard
[
'firstname_th'
]
=
$TempUserCards
[
'firstname_th'
];
$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
))
{
$TempUserCards
[
'is_used'
]
=
0
;
$this
->
TempUserCards
->
save
(
$TempUserCards
);
$this
->
Flash
->
success
(
__
(
'บันทึกสำเร็จ'
));
return
$this
->
redirect
([
'controller'
=>
'Profiles'
,
'action'
=>
'index'
]);
}
}
else
{
$this
->
Flash
->
success
(
__
(
'ลงทะเบียนไว้อยู่แล้ว'
));
return
$this
->
redirect
([
'controller'
=>
'UserCards'
,
'action'
=>
'viewCard'
]);
}
}
else
{
$this
->
Flash
->
success
(
__
(
'ไม่พบข้อมูล'
));
return
$this
->
redirect
([
'controller'
=>
'UserCards'
,
'action'
=>
'viewCard'
]);
}
}
}
}
}
}
\ No newline at end of file
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