SHOW:
|
|
- or go back to the newest paste.
1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | |
2 | ||
3 | class Roadmap extends CI_Controller { | |
4 | ||
5 | function __construct() { | |
6 | parent::__construct(); | |
7 | $this->load->library('googlemaps'); | |
8 | $this->load->model('roadmap/M_map'); | |
9 | $this->load->model('roadmap/D_map'); | |
10 | } | |
11 | ||
12 | public function index() { | |
13 | // Initialize the map, passing through any parameters | |
14 | $config['center'] = '106.7018137,-6.1358678'; | |
15 | $config['zoom'] = "auto"; | |
16 | $this->googlemaps->initialize($config); | |
17 | // Get the co-ordinates from the database using our model | |
18 | $coords = $this->M_map->get_coordinates(); | |
19 | // Loop through the coordinates we obtained above and add them to the map | |
20 | foreach ($coords as $coordinate) { | |
21 | $marker = array(); | |
22 | $marker['position'] = $coordinate->LAT.','.$coordinate->LNG; | |
23 | $marker['title'] = $coordinate->NMRS; | |
24 | $marker['icon'] = "http://93.188.161.251/ids/assets/img/mark.png"; | |
25 | //$marker['icon'] = "https://www.shareicon.net/data/48x48/2017/07/08/888189_flag_512x512.png"; | |
26 | $marker['infowindow_content'] = $coordinate->WINDOW; | |
27 | $this->googlemaps->add_marker($marker); | |
28 | } | |
29 | $polyline = array(); | |
30 | $polyline['points'] = array('-6.15018053, 106.897536', | |
31 | '-6.12989141, 106.9010896', | |
32 | '-6.12953328, 106.8906516', | |
33 | '-6.12325847, 106.8891642', | |
34 | '-6.13952669, 106.8443176'); | |
35 | $this->googlemaps->add_polyline($polyline); | |
36 | // Create the map | |
37 | $data = array(); | |
38 | $data = array('title' => 'ROAD MAP', 'menu_title' => 'ROAD MAP','sub_menu_title' => 'ROADMAP'); | |
39 | $data['map'] = $this->googlemaps->create_map(); | |
40 | $this->template->display('map/roadmap', $data); | |
41 | } | |
42 | ||
43 | public function rutemap() | |
44 | { | |
45 | // Initialize the map, passing through any parameters | |
46 | $config['center'] = '106.7018137,-6.1358678'; | |
47 | $config['zoom'] = "auto"; | |
48 | $this->googlemaps->initialize($config); | |
49 | // Get the co-ordinates from the database using our model | |
50 | $coords = $this->M_map->get_coordinates(); | |
51 | // Loop through the coordinates we obtained above and add them to the map | |
52 | foreach ($coords as $coordinate) { | |
53 | $marker = array(); | |
54 | $marker['position'] = $coordinate->LAT.','.$coordinate->LNG; | |
55 | $marker['title'] = $coordinate->NMRS; | |
56 | $marker['icon'] = "http://93.188.161.251/ids/assets/img/mark.png"; | |
57 | //$marker['icon'] = "https://www.shareicon.net/data/48x48/2017/07/08/888189_flag_512x512.png"; | |
58 | $marker['infowindow_content'] = $coordinate->WINDOW; | |
59 | $this->googlemaps->add_marker($marker); | |
60 | } | |
61 | $salesmans = $this->D_map->get_list_salesmans(); | |
62 | $opt2 = array('' => 'Show All'); | |
63 | foreach ($salesmans as $salesman) { | |
64 | $opt2[$salesman] = $salesman; | |
65 | } | |
66 | $polyline = array(); | |
67 | $polyline['points'] = array('-6.15018053, 106.897536', | |
68 | '-6.12989141, 106.9010896', | |
69 | '-6.12953328, 106.8906516', | |
70 | '-6.12325847, 106.8891642', | |
71 | '-6.13952669, 106.8443176'); | |
72 | $this->googlemaps->add_polyline($polyline); | |
73 | // Create the map | |
74 | $data = array(); | |
75 | $data = array('title' => 'ROAD MAP', 'menu_title' => 'ROAD MAP','sub_menu_title' => 'ROADMAP'); | |
76 | $data['form_salesmans'] = form_dropdown('',$opt2,'','id="salesman" class="form-control js-example-basic-single"'); | |
77 | $data['map'] = $this->googlemaps->create_map(); | |
78 | $data['x'] = $this->D_map->get_hari(); | |
79 | $this->template->display('map/rutemap', $data); | |
80 | } | |
81 | ||
82 | public function dataRutemap() | |
83 | { | |
84 | $data = array(); | |
85 | $data = array('title' => 'ROAD MAP', 'menu_title' => 'ROAD MAP','sub_menu_title' => 'ROADMAP'); | |
86 | $data['rute'] = $this->D_map->get_rutedata(); | |
87 | $this->template->display('map/data_rute',$data); | |
88 | } | |
89 | ||
90 | public function formRute(){ | |
91 | $salesmans = $this->D_map->get_list_salesmans(); | |
92 | $opt2 = array('' => 'Show All'); | |
93 | foreach ($salesmans as $salesman) { | |
94 | $opt2[$salesman] = $salesman; | |
95 | } | |
96 | $data = array(); | |
97 | $data = array('title' => 'ROAD MAP', 'menu_title' => 'ROAD MAP','sub_menu_title' => 'ROADMAP'); | |
98 | $data['form_salesmans'] = form_dropdown('',$opt2,'','id="salesman" class="form-control js-example-basic-single" onchange="getForm(this.value)"'); | |
99 | $this->template->display('map/edit_rute',$data); | |
100 | } | |
101 | ||
102 | public function get_Form() | |
103 | { | |
104 | /* bukan 'id_jurusan' tetapi 'row'. | |
105 | * Lihat fungsi getProdi di views/mahasiswa/add.php. | |
106 | */ | |
107 | $NMSAL = $this->input->post('row'); | |
108 | $nohp = $this->D_map->getNohp($NMSAL); | |
109 | $opt1 = array(); | |
110 | foreach ($nohp as $row) { | |
111 | $opt1[$row] = $row; | |
112 | } | |
113 | $nmrs = $this->D_map->getNmrs($NMSAL); | |
114 | $opt2 = array(); | |
115 | foreach ($nmrs as $row) { | |
116 | $opt2[$row] = $row; | |
117 | } | |
118 | $nors = $this->D_map->getNors($NMSAL); | |
119 | $opt3 = array(); | |
120 | foreach ($nors as $row) { | |
121 | $opt3[$row] = $row; | |
122 | } | |
123 | $lng = $this->D_map->getLang($NMSAL); | |
124 | $opt4 = array(); | |
125 | foreach ($lng as $row) { | |
126 | $opt4[$row] = $row; | |
127 | } | |
128 | $opt5 = Array( "Senin" => "Senin", "Selasa" => "Selasa","Rabu" => "Rabu","Kamis" => "Kamis","Jum'at" => "Jum'at","Sabtu" => "Sabtu", "Minggu" => "Minggu"); | |
129 | - | $formOpt = array("nohp" => form_dropdown('',$opt1,'','id="NOHP" class="form-control js-example-basic-single"'), "nmrs" => form_dropdown('',$opt2,'','id="NMRS" class="form-control js-example-basic-single"'), "nors" => form_dropdown('',$opt3,'','id="NORS" class="form-control js-example-basic-single"'), "lng" => form_dropdown('',$opt4,'','id="LNG" class="form-control js-example-basic-single"'),"hari" => form_dropdown('',$opt5,'','id="HARI" class="form-control js-example-basic-single"')); |
129 | + | /* |
130 | $formOpt = array("nohp" => form_dropdown('',$opt1,'','id="NOHP" class="form-control js-example-basic-single"'), | |
131 | "nmrs" => form_dropdown('',$opt2,'','id="NMRS" class="form-control js-example-basic-single"'), | |
132 | "nors" => form_dropdown('',$opt3,'','id="NORS" class="form-control js-example-basic-single"'), | |
133 | "lng" => form_dropdown('',$opt4,'','id="LNG" class="form-control js-example-basic-single"'), | |
134 | "hari" => form_dropdown('',$opt5,'','id="HARI" class="form-control js-example-basic-single"')); | |
135 | */ | |
136 | $formOpt = array( | |
137 | 'nohp'=>$this->form_options($opt1), | |
138 | "nmrs" => $this->form_options($opt2 ), | |
139 | "nors" => $this->form_options($opt3 ), | |
140 | "lng" => $this->form_options($opt4 ), | |
141 | "hari" => $this->form_options($opt5 ) | |
142 | ||
143 | ); | |
144 | //now it is converted to object and you can access it. | |
145 | echo json_encode($formOpt); | |
146 | } | |
147 | ||
148 | private function form_options($ar=array()){ | |
149 | $txt=''; | |
150 | foreach($ar as $key=>$value){ | |
151 | $str.='<option value="'.addslashes( $key ).'">'; | |
152 | $str.=htmlentities( $value ); | |
153 | $str.="</option>"; | |
154 | } | |
155 | return $txt; | |
156 | } | |
157 | ||
158 | } |