Commit 4a98833e authored by Oky Rahmanto's avatar Oky Rahmanto
Browse files

Merge branch 'feature/view_slot_by_plat' into 'development'

add feature view slot by plat

See merge request !34
parents dd520364 c7b0f567
Pipeline #24240 passed with stage
in 39 seconds
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Parking extends CI_Controller {
//API URL
//private $url = 'https://easyparking-api.azurewebsites.net/api/location/';
//private $url_zone = 'https://easyparking-api.azurewebsites.net/api/zona/';
//private $url_slot = 'https://easyparking-api.azurewebsites.net/api/slot/';
private $url = 'https://api.easy-parking.ourcode.site/api/location/';
private $url_zone = 'https://api.easy-parking.ourcode.site/api/zona/';
private $url_slot = 'https://api.easy-parking.ourcode.site/api/slot/';
private $url_parking = 'http://api.easy-parking.ourcode.site/api/parking/transaction/';
private $url_booking = 'http://api.easy-parking.ourcode.site/api/booking/';
private $url_search_park = 'http://api.easy-parking.ourcode.site/api/parking/transaction/active';
private $url_save_park = 'http://api.easy-parking.ourcode.site/api/parking/transaction/start/';
function __construct(){
parent::__construct();
}
function location(){
//create a new cURL resource
$ch = curl_init($this->url);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
$data = array(
'result' => json_decode($result),
);
return $data;
}
function zone(){
//create a new cURL resource
$ch = curl_init($this->url_zone);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
$data = array(
'result' => json_decode($result),
);
$data['lokasi']=$this->location();
return $data;
}
function get_data_area(){
//create a new cURL resource
$ch = curl_init($this->url_slot);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
$data = array(
'result' => json_decode($result),
);
$data['zona']=$this->zone();
$data['lokasi']=$this->location();
return $data;
}
function available_area(){
$data = $this->get_data_area();
$this->load->view('menu/header-menu.php');
$this->load->view('parking/available_area',$data);
}
function get_parking(){
//create a new cURL resource
$ch = curl_init($this->url_parking);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
$data = array(
'result' => json_decode($result),
);
return $data;
}
function get_booking(){
//create a new cURL resource
$ch = curl_init($this->url_booking);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
$data = array(
'result' => json_decode($result),
);
return $data;
}
function search(){
$data['parking']=$this->get_parking();
$data['booking']= $this->get_booking();
$this->load->view('menu/header-menu.php');
$this->load->view('parking/search_plat.php',$data);
}
function searchLicense(){
$licensePlat = $this->input->post('licensePlate');
//create a new cURL resource
$ch = curl_init($this->url_search_park."/".$licensePlat);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
$data_search = array(
'result' => json_decode($result),
);
$data['parking']=$this->get_parking();
$data['booking']= $this->get_booking();
$data['search']= $data_search;
$this->load->view('menu/header-menu.php');
$this->load->view('parking/search_plat.php',$data);
}
function park(){
$data['slot']= $this->get_data_area();
$data['parking'] = $this->get_parking();
$this->load->view('menu/header-menu.php');
$this->load->view('parking/park.php',$data);
}
function save(){
$licensePlate = $this->input->post('licensePlate');
$inputedById = $this->input->post('inputedById');
$slotId = $this->input->post('slotId');
//create a new cURL resource
$ch = curl_init($this->url_save_park);
// //setup request to send json via POST
$data = array(
'licensePlate' => $licensePlate,
'inputedById' => $inputedById,
'slotId' => $slotId,
);
$param = json_encode($data);
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
// //attach encoded JSON string to the POST fields
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json','Content-Length: '. strlen($param)));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
$responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
//close cURL resource
curl_close($ch);
$alert = 'alert-success';
$message = 'Data Berhasil Disimpan';
if ($responseCode != 200) {
$message = $result;
$alert = 'alert-danger';
}
$this->session->set_flashdata("notifikasi","<div class='alert $alert alert-dismissable'>
<i class='fa fa-info'></i>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
<b>$message !</b>
</div>");
redirect(base_url('parking/park'));
}
}
?>
\ No newline at end of file
......@@ -145,15 +145,20 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</a>
<ul class="treeview-menu">
<li>
<a href="#">
<i class='fa fa-circle'></i> <span>View Available Slot</span>
</a>
</li>
<li>
<a href="#">
<i class='fa fa-circle'></i> <span>Update Slot</span>
</a>
</li>
<a href="<?php echo base_url()?>parking/search">
<i class='fa fa-search'></i> <span>View Slot by Plat</span>
</a>
</li>
<li>
<a href="<?php echo base_url()?>parking/available_area">
<i class='fa fa-map'></i> <span>View Available Area</span>
</a>
</li>
<li>
<a href="<?php echo base_url()?>parking/park">
<i class='fa fa-car'></i> <span>Parking</span>
</a>
</li>
</ul>
</li>
<?php
......
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php $this->load->view('main/header.php')?>
<!-- Left side column. contains the logo and sidebar -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
SEARCH PARKING
<small>
<?php $this->view('main/viewdate.php')?>
</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-lg-12">
<!-- Default box -->
<div class="box">
<div class="box-header">
<!-- Flash Notifikasi -->
<?php
if (isset($search['result'])){
echo "
<div class='alert alert-info alert-dismissable'>
<i class='fa fa-info'></i>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
<b>Data Pencarian Ditemukan</b></br></br>
<table>
<tr>
<td>Slot</td>
<td> : ".$search['result']->slot->name."</td>
</tr>
<tr>
<td>License Plate</td>
<td> : ".$search['result']->licensePlate."</td>
</tr>
<tr>
<td>Start Time</td>
<td> : ".$search['result']->startTime."</td>
</tr>
<tr>
<td>Stop Time</td>
<td> : ".$search['result']->stopTime."</td>
</tr>
<tr>
<td>Name</td>
<td> : ".$search['result']->inputedBy->name."</td>
</tr>
<tr>
<td>Email</td>
<td> : ".$search['result']->inputedBy->email."</td>
</tr>
</table>
</div>";
}else{
echo "
<div class='alert alert-warning alert-dismissable'>
<i class='fa fa-warning'></i>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
<b>Data Pencarian Belum Ada</b>
</div>";
}
?>
<a class="btn btn-primary btn-sm" onclick="function_add()" href="#"><i class="fa fa-search"></i> Search</a>
<a class="btn btn-info btn-sm" href="<?php echo base_url()?>parking/search"><i class="fa fa-retweet"></i> Reset</a>
</div>
<div class="col-lg-6 box-body">
<h4>List Booking</h4>
<div style="max-width: auto; overflow-x: auto;">
<table id="example2" class="table table-bordered table-striped small">
<thead>
<tr>
<th>NO</th>
<th>SLOT</th>
<th>LICENSE PLATE</th>
<th>START TIME</th>
<th>STOP TIME</th>
</tr>
</thead>
<tbody>
<?php
if (count($booking['result'])>0){
$start = 0;
foreach ($booking['result'] as $value)
{ ?>
<tr>
<td><?php echo ++$start;?></td>
<td><?php echo $value->slot->name;?></td>
<td><?php echo $value->licensePlate;?></td>
<td><?php echo $value->startTime;?></td>
<td><?php echo $value->endTime;?></td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
<div class="col-lg-6 box-body">
<h4>List Transaction</h4>
<div style="max-width: auto; overflow-x: auto;">
<table id="example1" class="table table-bordered table-striped small">
<thead>
<tr>
<th>NO</th>
<th>SLOT</th>
<th>LICENSE PLATE</th>
<th>START TIME</th>
<th>STOP TIME</th>
</tr>
</thead>
<tbody>
<?php
if (count($parking['result'])>0){
$start = 0;
foreach ($parking['result'] as $value)
{ ?>
<tr>
<td><?php echo ++$start;?></td>
<td><?php echo $value->slot->name;?></td>
<td><?php echo $value->licensePlate;?></td>
<td><?php echo $value->startTime;?></td>
<td><?php echo $value->stopTime;?></td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
<!-- /.box-body -->
<!-- /.box-footer-->
</div>
<!-- /.box -->
</div>
</div>
</section>
<!-- /.content -->
<!-- MODAL ROLE -->
<div class="modal fade" id="modal_role" role="dialog" aria-labelledby="largeModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 class="modal-title" id="myModalLabel">Search license Plate</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<form id="form_role" enctype="multipart/form-data" method="POST">
<div class="form-group col-md-12">
<label>license Plate</label>
<input type="text" class="form-control" name="licensePlate" id="licensePlate">
</div>
<div class="form-group col-md-12">
<br>
<button type="submit" id="btn_simpan_arsip" name="btn_simpan_arsip" class="btn btn-sm btn-primary"><i class="fa fa-search"></i> Search</button>
</div>
</form>
</div>
</div>
<!-- -->
<br>
</div>
</div>
</div>
</div>
<!-- END MODAL -->
</div>
<?php $this->load->view('main/footer')?>
<!-- Control Sidebar -->
<!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div>
</body>
</html>
<script>
function function_add(){
$('#modal_role').modal('show');
$('#form_role')[0].reset();
$('#form_role').attr('action',"<?php echo base_url()?>parking/searchLicense");
}
</script>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment