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
d68b3251
authored
May 16, 2018
by
Zen-PC\Zen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZEN : Update Province and Country
parent
daa6d701
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
28 deletions
+52
-28
www/src/Controller/ProfilesController.php
+30
-3
www/src/Template/Profiles/index.ctp
+22
-25
No files found.
www/src/Controller/ProfilesController.php
View file @
d68b3251
...
...
@@ -24,7 +24,8 @@ class ProfilesController extends AppController
$this
->
loadModel
(
'MasterCountries'
);
$Country
=
$this
->
MasterCountries
->
find
(
'list'
,
[
'conditions'
=>
[
'is_used'
=>
true
],
'is_used'
=>
true
,
'MasterCountries.id'
=>
1
],
'keyField'
=>
'id'
,
'valueField'
=>
'country_name_th'
]);
...
...
@@ -34,7 +35,8 @@ class ProfilesController extends AppController
$this
->
loadModel
(
'MasterProvinces'
);
$Province
=
$this
->
MasterProvinces
->
find
(
'list'
,
[
'conditions'
=>
[
'is_used'
=>
true
],
'is_used'
=>
true
,
'master_country_id'
=>
1
],
'keyField'
=>
'id'
,
'valueField'
=>
'province_name_th'
]);
...
...
@@ -565,5 +567,30 @@ if (!empty($SubjectEnrolls)) {
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
// public function getProvince() {
// $this->autoRender = false;
// $this->loadModel('MasterProvinces');
// $states = array();
// // pr($this->request->data);die;
// // echo 'jjjj';
// $states = $this->MasterProvinces->find('list', array(
// 'keyField' => 'id',
// 'valueField' => 'province_name_th',
// 'conditions' => array(
// 'master_country_id' => 2
// )
// ))->toArray();
// $arr = array();
// foreach($states as $key => $val){
// $arr[$key] = $val;
// }
// //pr($states);die;
// // $arr['1'] = "ไทยยยย";
// // $arr['2'] = "ไทยยยยยยยยยย";
// echo json_encode($arr);
// // $data = jQuery.parseJSON($f);
// // pr($data);die;
// }
}
www/src/Template/Profiles/index.ctp
View file @
d68b3251
...
...
@@ -200,29 +200,25 @@
//==================================================
// 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"));
});
}
});
}
});
});
// $(document).ready(function() {
// $("#loding1").hide();
// $("#loding2").hide();
// $("#master_country_id").on('change',function() {
// var id = $(this).val();
// // alert('dddd');
// $("#loding1").show();
// $("#master_province_id").find('option').remove();
// if (id) {
// var dataString = 'id='+ id;
// alert(dataString);
// $.post("/Profiles/getProvince", {id: id}, function(data) {
// console.log(data);
// data = jQuery.parseJSON(data);
// console.log(data);
// });
// // $('<option>').val('').text('---Select---');
// // $('<option>').val(key).text(value).appendTo($("#master_province_id"));
// }
// });
// });
</script>
\ 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