diff --git a/app/Http/Controllers/TpsController.php b/app/Http/Controllers/TpsController.php index e2210695c33ef4382836c62c01afaf247ec3ec68..c972941789953922bf371df8a706dad3b7cfebc5 100644 --- a/app/Http/Controllers/TpsController.php +++ b/app/Http/Controllers/TpsController.php @@ -73,6 +73,10 @@ class TpsController extends Controller $tps->id_manager = Input::get('idPengelola', 0); $tps->created_by = Auth::user()->id; $tps->id = 0; + + $tps->latitude = Input::get('latitude', 0); + $tps->longitude = Input::get('longitude', 0); + $tps->save(); //$tps = Tps::create(Input::all()); return redirect('/tps'); @@ -110,6 +114,10 @@ class TpsController extends Controller $tps->nama = Input::get('name', ''); $tps->is_full = Input::get('is_full', 0); $tps->id_manager = Input::get('idPengelola', 0); + + $tps->latitude = Input::get('latitude', 0); + $tps->longitude = Input::get('longitude', 0); + $tps->save(); \Event::fire(new \App\Events\TableModified($tps)); return redirect('/tps'); diff --git a/app/Listeners/LastModifyUpdate.php b/app/Listeners/LastModifyUpdate.php index 02549ce02df63bb5c4379e1a0a00bc12a87fb721..3cc9d9810d031393b9a6b727684f2c4cdc8cfc66 100644 --- a/app/Listeners/LastModifyUpdate.php +++ b/app/Listeners/LastModifyUpdate.php @@ -27,9 +27,7 @@ class LastModifyUpdate */ public function handle(TableModified $event) { - foreach ($event->getModel() as $row) { - $row->updated_by = \Auth::user()->id; - $row->save(); - } + $event->getModel()->updated_by = \Auth::user()->id; + $event->getModel()->save(); } } diff --git a/public/.htaccess b/public/.htaccess index 1d677765410027ae5a9cd38080886f64a38f0385..cc2d6904a591339d0c327c06db674252b9940b24 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1 +1,8 @@ DirectoryIndex index.php + +Options +FollowSymLinks +RewriteEngine On + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [L] diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 9bf7adceb535279e1a9111d4c1f0f8aec0b78f6f..c8b42da34dcb8724cd29f95fb29462a86d653599 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -11,155 +11,16 @@ <i class="icon-bdg_expand2 text-active"></i> </a> </li> <li><a href>Home</a></li> - <li class="active"><i class="fa fa-angle-right"></i>Chart</li> + <li class="active"><i class="fa fa-angle-right"></i>Map</li> </ul> </div> <div class="wrapper-lg bg-light"> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> - <div class="panel-heading font-semibold"> - Responsive Table + <div class="panel-heading font-semibold" style="height: 400px; padding: 2px;"> + <div id="map" style="height: 100%;"></div> </div> - <div class="row wrapper-sm"> - <div class="col-sm-5"> - <select class="input-sm form-control w-sm inline v-middle"> - <option value="0">Bulk action</option> - <option value="1">Delete selected</option> - <option value="2">Bulk edit</option> - <option value="3">Export</option> - </select> - <button class="btn btn-sm btn-default">Apply</button> - </div> - <div class="col-sm-4"> - </div> - <div class="col-sm-3"> - <div class="input-group"> - <input type="text" class="input-sm form-control" placeholder="Search"> - <span class="input-group-btn"> - <button class="btn btn-sm btn-default" type="button">Go!</button> - </span> - </div> - </div> - </div> - <div class="table-responsive"> - <table class="table table-striped b-t b-light"> - <thead> - <tr> - <th style="width:20px;"> - <label class="checkbox-inline "> - <input type="checkbox"><i></i> - </label> - </th> - <th>Project</th> - <th>Task</th> - <th>Date</th> - <th style="width:30px;"></th> - </tr> - </thead> - <tbody> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Idrawfast</td> - <td>4c</td> - <td>Jul 25, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Formasa</td> - <td>8c</td> - <td>Jul 22, 2013</td> - <td> - <a href ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Avatar system</td> - <td>15c</td> - <td>Jul 15, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Throwdown</td> - <td>4c</td> - <td>Jul 11, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Idrawfast</td> - <td>4c</td> - <td>Jul 7, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Formasa</td> - <td>8c</td> - <td>Jul 3, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Avatar system</td> - <td>15c</td> - <td>Jul 2, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - <tr> - <td><label class="checkbox-inline "><input type="checkbox" name="post[]"><i></i></label></td> - <td>Videodown</td> - <td>4c</td> - <td>Jul 1, 2013</td> - <td> - <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> - </td> - </tr> - </tbody> - </table> - </div> - <footer class="panel-footer"> - <div class="row"> - <div class="col-sm-4 hidden-xs"> - <select class="input-sm form-control w-sm inline v-middle"> - <option value="0">Bulk action</option> - <option value="1">Delete selected</option> - <option value="2">Bulk edit</option> - <option value="3">Export</option> - </select> - <button class="btn btn-sm btn-default">Apply</button> - </div> - <div class="col-sm-4 text-center"> - <small class="text-muted inline m-t-sm m-b-sm">showing 20-30 of 50 items</small> - </div> - <div class="col-sm-4 text-right text-center-xs"> - <ul class="pagination pagination-sm m-t-none m-b-none"> - <li><a href><i class="icon-bdg_arrow4"></i></a></li> - <li><a href>1</a></li> - <li><a href>2</a></li> - <li><a href>3</a></li> - <li><a href>4</a></li> - <li><a href>5</a></li> - <li><a href><i class="icon-bdg_arrow3"></i></a></li> - </ul> - </div> - </div> - </footer> </div> </div> </div> @@ -167,4 +28,42 @@ </div> </div> </div> + + <script> + function initMap() { + var customMapType = new google.maps.StyledMapType([{"featureType":"road","stylers":[{"hue":"#5e00ff"},{"saturation":-79}]},{"featureType":"poi","stylers":[{"saturation":-78},{"hue":"#6600ff"},{"lightness":-47},{"visibility":"off"}]},{"featureType":"road.local","stylers":[{"lightness":22}]},{"featureType":"landscape","stylers":[{"hue":"#6600ff"},{"saturation":-11}]},{},{},{"featureType":"water","stylers":[{"saturation":-65},{"hue":"#1900ff"},{"lightness":8}]},{"featureType":"road.local","stylers":[{"weight":1.3},{"lightness":30}]},{"featureType":"transit","stylers":[{"visibility":"simplified"},{"hue":"#5e00ff"},{"saturation":-16}]},{"featureType":"transit.line","stylers":[{"saturation":-72}]},{}], { + name: 'Custom Style' + }); + var customMapTypeId = 'custom_style'; + + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 12, + center: {lat: -6.914744, lng: 107.609810}, + mapTypeControlOptions: { + mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId] + } + }); + + var trashCan = { + path: 'M585.82,235.876H209.179c-39.621,0-71.728,32.082-71.728,71.703l38.865,412.675c0,39.597,32.131,71.703,71.751,71.703 h304.89c39.62,0,71.751-32.106,71.751-71.703l32.888-412.675C657.547,267.958,625.441,235.876,585.82,235.876z M301.839,666.41 c0,19.786-16.053,35.814-35.864,35.814c-19.81,0-35.863-16.053-35.863-35.814V343.467c0-19.786,16.053-35.888,35.863-35.888 c19.811,0,35.864,16.102,35.864,35.888V666.41L301.839,666.41z M427.385,666.41c0,19.786-16.053,35.814-35.863,35.814 c-19.81,0-35.863-16.053-35.863-35.814V343.467c0-19.786,16.053-35.888,35.863-35.888c19.811,0,35.863,16.102,35.863,35.888 V666.41z M552.933,666.41c0,19.786-16.054,35.814-35.864,35.814s-35.863-16.053-35.863-35.814V343.467 c0-19.786,16.053-35.888,35.863-35.888s35.864,16.102,35.864,35.888V666.41z M190.027,200.013L624.27,88.299 c23.981-6.148,38.425-30.594,32.252-54.576c-6.172-23.982-30.618-38.425-54.6-32.326L468.446,35.748 c-12.369-18.347-35.205-27.983-57.845-22.177l-52.088,13.443c-22.641,5.831-37.986,25.275-39.987,47.306l-150.847,38.84 c-23.982,6.148-38.401,30.594-32.253,54.576C141.599,191.742,166.045,206.136,190.027,200.013z', + fillColor: 'black', + fillOpacity: 1, + scale: 0.02, + strokeColor: 'black', + strokeWeight: 0.1 + }; + + var marker = new google.maps.Marker({ + position: map.getCenter(), + icon: trashCan, + map: map + }); + + map.mapTypes.set(customMapTypeId, customMapType); + map.setMapTypeId(customMapTypeId); + } + </script> + <script async defer + src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAQhtIUXQLjOphZJncykzuYoH85EWJ9JMc&callback=initMap"> + </script> @endsection diff --git a/resources/views/menu/editTps.blade.php b/resources/views/menu/editTps.blade.php index da729a087889646859894587d87f42ee308966cb..4410a88137b32fd22e921cbc4196d70c98991b1e 100644 --- a/resources/views/menu/editTps.blade.php +++ b/resources/views/menu/editTps.blade.php @@ -41,18 +41,8 @@ <div class="form-group"> <label class="col-sm-2 control-label">Kapasitas Sekarang</label> <div class="col-sm-10"> - <input ondrag="sliderNowChanges()" id="capacity_now" name="capacity_now" value="<?php echo $data->capacity_now; ?>" ui-jq="slider" ui-options="{ - min: 0, - max: 500, - step: 1, - value: <?php echo $data->capacity_now; ?> - }" class="slider slider-horizontal form-control" type="text"> <span id="span_capacity_now"class="m-l-sm font-bold"> - <script type="text/javascript"> - function sliderNowChanges(){ - document.getElementById("span_capacity_now").innerHTML = - document.getElementById("capacity_now").value; - } - </script> + <input id="capacity_now" name="capacity_now" value="<?php echo $data->capacity_now; ?>" class="form-control" type="text"> <span id="span_capacity_now"class="m-l-sm font-bold"> + </span> </div> </div> @@ -60,21 +50,9 @@ <div class="form-group"> <label class="col-sm-2 control-label">Kapasitas Penuh</label> <div class="col-sm-10"> - <input onchange="sliderFullChanges()" id="capacity_full" name="capacity_full" value="<?php echo $data->capacity_full; ?>" ui-jq="slider" ui-options="{ - min: 0, - max: 500, - step: 1, - value: <?php echo $data->capacity_full; ?> - }" class="slider slider-horizontal form-control" type="text"> <span id="span_capacity_full" class="m-l-sm font-bold"> - </span> + <input id="capacity_full" name="capacity_full" value="<?php echo $data->capacity_full; ?>" type="text" class="form-control"> </div> </div> - <script type="text/javascript"> - function sliderFullChanges(){ - document.getElementById("span_capacity_full").innerHTML = - document.getElementById("capacity_full").value; - } - </script> <div class="line line-dashed b-b line-lg pull-in"></div> <div class="form-group"> @@ -113,6 +91,17 @@ </div> <div class="line line-dashed b-b line-lg pull-in"></div> + <div class="form-group"> + <label class="col-sm-12">Lokasi TPS</label> + <div class="col-sm-12" style="height: 400px; padding: 2px;"> + <input type="hidden" id='latitude' name='latitude' value='<?php echo $data->latitude; ?>'> + <input type="hidden" id='longitude' name='longitude' value='<?php echo $data->longitude; ?>'> + <div id="map" style="height: 100%;"></div> + </div> + </div> + + <div class="line line-dashed b-b line-lg pull-in"></div> + <div class="form-group"> <div class="col-sm-4 col-sm-offset-2"> <a href="{{ url('/tps') }}"><button type="button" class="btn btn-default m-r-sm">Cancel</button></a> @@ -126,4 +115,52 @@ </div> </div> + + +<script> + + var marker = null; + + function initMap() { + var customMapType = new google.maps.StyledMapType([{"featureType":"road","stylers":[{"hue":"#5e00ff"},{"saturation":-79}]},{"featureType":"poi","stylers":[{"saturation":-78},{"hue":"#6600ff"},{"lightness":-47},{"visibility":"off"}]},{"featureType":"road.local","stylers":[{"lightness":22}]},{"featureType":"landscape","stylers":[{"hue":"#6600ff"},{"saturation":-11}]},{},{},{"featureType":"water","stylers":[{"saturation":-65},{"hue":"#1900ff"},{"lightness":8}]},{"featureType":"road.local","stylers":[{"weight":1.3},{"lightness":30}]},{"featureType":"transit","stylers":[{"visibility":"simplified"},{"hue":"#5e00ff"},{"saturation":-16}]},{"featureType":"transit.line","stylers":[{"saturation":-72}]},{}], { + name: 'Custom Style' + }); + var customMapTypeId = 'custom_style'; + + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 12, + center: {lat: -6.914744, lng: 107.609810}, + mapTypeControlOptions: { + mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId] + } + }); + + marker = new google.maps.Marker({ + position: new google.maps.LatLng(<?=$data->latitude?>,<?=$data->longitude?>), + map: map + }); + + map.addListener('click', function(e) { + placeMarkerAndPanTo(e.latLng, map); + }); + + map.mapTypes.set(customMapTypeId, customMapType); + map.setMapTypeId(customMapTypeId); + } + + function placeMarkerAndPanTo(latLng, map) { + + marker.setPosition(latLng); + + //update + document.getElementById('latitude').value = latLng.lat(); + document.getElementById('longitude').value = latLng.lng(); + + //map.panTo(latLng); + } + +</script> +<script async defer +src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAQhtIUXQLjOphZJncykzuYoH85EWJ9JMc&callback=initMap"> +</script> @endsection \ No newline at end of file diff --git a/resources/views/menu/insertTps.blade.php b/resources/views/menu/insertTps.blade.php index 4fd0badb1eb4305ce6b8ae605b4e39447b588fd9..e24248e7d51da95413ecd4bb1ef9766b1d946145 100644 --- a/resources/views/menu/insertTps.blade.php +++ b/resources/views/menu/insertTps.blade.php @@ -40,24 +40,14 @@ <div class="form-group"> <label class="col-sm-2 control-label">Kapasitas Sekarang</label> <div class="col-sm-10"> - <input id="slider" name="capacity_now" value="50" ui-jq="slider" ui-options="{ - min: 0, - max: 500, - step: 1, - value: 50 - }" class="slider slider-horizontal form-control" type="text"> <span class="m-l-sm font-bold"></span> + <input id="slider" name="capacity_now" value="0" class="form-control" type="number"> </div> </div> <div class="line line-dashed b-b line-lg pull-in"></div> <div class="form-group"> <label class="col-sm-2 control-label">Kapasitas Penuh</label> <div class="col-sm-10"> - <input id="slider" name="capacity_full" value="50" ui-jq="slider" ui-options="{ - min: 0, - max: 500, - step: 1, - value: 50 - }" class="slider slider-horizontal form-control" type="text"> <span class="m-l-sm font-bold"></span> + <input id="slider" name="capacity_full" value="0" class="form-control" type="number"> </div> </div> @@ -90,6 +80,18 @@ </div> </div> + <div class="line line-dashed b-b line-lg pull-in"></div> + <div class="form-group"> + <label class="col-sm-12">Lokasi TPS</label> + <div class="col-sm-12" style="height: 400px; padding: 2px;"> + <input type="hidden" id='latitude' name='latitude' value='0'> + <input type="hidden" id='longitude' name='longitude' value='0'> + <div id="map" style="height: 100%;"></div> + </div> + </div> + + <div class="line line-dashed b-b line-lg pull-in"></div> + <div class="form-group"> <div class="col-sm-4 col-sm-offset-2"> <a href="{{ url('/tps') }}"><button type="button" class="btn btn-default m-r-sm">Cancel</button></a> @@ -104,4 +106,51 @@ </div> </div> + +<script> + var marker = null; + + function initMap() { + var customMapType = new google.maps.StyledMapType([{"featureType":"road","stylers":[{"hue":"#5e00ff"},{"saturation":-79}]},{"featureType":"poi","stylers":[{"saturation":-78},{"hue":"#6600ff"},{"lightness":-47},{"visibility":"off"}]},{"featureType":"road.local","stylers":[{"lightness":22}]},{"featureType":"landscape","stylers":[{"hue":"#6600ff"},{"saturation":-11}]},{},{},{"featureType":"water","stylers":[{"saturation":-65},{"hue":"#1900ff"},{"lightness":8}]},{"featureType":"road.local","stylers":[{"weight":1.3},{"lightness":30}]},{"featureType":"transit","stylers":[{"visibility":"simplified"},{"hue":"#5e00ff"},{"saturation":-16}]},{"featureType":"transit.line","stylers":[{"saturation":-72}]},{}], { + name: 'Custom Style' + }); + var customMapTypeId = 'custom_style'; + + var map = new google.maps.Map(document.getElementById('map'), { + zoom: 12, + center: {lat: -6.914744, lng: 107.609810}, + mapTypeControlOptions: { + mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId] + } + }); + + map.addListener('click', function(e) { + placeMarkerAndPanTo(e.latLng, map); + }); + + map.mapTypes.set(customMapTypeId, customMapType); + map.setMapTypeId(customMapTypeId); + } + + function placeMarkerAndPanTo(latLng, map) { + + if (marker == null) { + marker = new google.maps.Marker({ + position: latLng, + map: map + }); + } else { + marker.setPosition(latLng); + } + + //update + document.getElementById('latitude').value = latLng.lat(); + document.getElementById('longitude').value = latLng.lng(); + + //map.panTo(latLng); + } +</script> +<script async defer +src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAQhtIUXQLjOphZJncykzuYoH85EWJ9JMc&callback=initMap"> +</script> @endsection \ No newline at end of file