Commit 3d073cd0 authored by Oky Rahmanto's avatar Oky Rahmanto
Browse files

Merge branch 'development' of https://gitlab.informatika.org/setiawan/six7...

Merge branch 'development' of https://gitlab.informatika.org/setiawan/six7 into feature/authpagecustomer
parents dd17070a 5c68a5e8
Pipeline #23685 passed with stage
in 31 seconds
......@@ -71,6 +71,11 @@ $route['default_controller'] = 'Main';
$route['master/slot/save'] = 'Master/slot_save';
$route['master/slot/delete/(:any)'] = 'Master/slot_delete/$1';
$route['master/slot/put'] = 'Master/slot_put';
$route['master/rate'] = 'Master/rate_view';
$route['master/rate/id/(:any)'] = 'Master/rate_id/$1';
$route['master/rate/save'] = 'Master/rate_save';
$route['master/rate/delete/(:any)'] = 'Master/rate_delete/$1';
$route['master/rate/put'] = 'Master/rate_put';
/*USERS*/
$route['users/roleview'] = 'Users/role_view';
......
......@@ -9,6 +9,7 @@ class Master extends CI_Controller {
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_rate = 'https://api.easy-parking.ourcode.site/api/rate/';
function __construct(){
parent::__construct();
......@@ -616,6 +617,209 @@ class Master extends CI_Controller {
}
/*END MANAGE SLOT*/
/*MANAGE RATE*/
function rate_get(){
//create a new cURL resource
$ch = curl_init($this->url_rate);
//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 rate_id($id){
//create a new cURL resource
$ch = curl_init($this->url_rate."id/".$id);
//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;
echo $result;
}
function rate_view(){
$data = $this->rate_get();
$this->load->view('menu/header-menu.php');
$this->load->view('master/rate',$data);
}
function rate_save(){
$description = $this->input->post('description');
$price = $this->input->post('price');
$startDate = $this->input->post('startDate');
$endDate = $this->input->post('endDate');
//create a new cURL resource
$ch = curl_init($this->url_rate);
// //setup request to send json via POST
$data = array(
'description' => $description,
'price' => (float)$price,
'startDate' => date("c",strtotime($startDate)),
'endDate' => date("c",strtotime($endDate)),
);
$param = json_encode($data);
//echo $param;
//exit;
//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('master/rate'));
}
function rate_delete(){
$id = $this->uri->segment('4');
//create a new cURL resource
$ch = curl_init($this->url_rate.$id);
// setup request to send json via POST
// $param = http_build_query(array('name' => $name));
$data = array(
'id' => $id,
);
$param = json_encode($data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
// //attach encoded JSON string to the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
// curl_setopt($ch, CURLOPT_POST, 1);
//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);
$responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
//close cURL resource
curl_close($ch);
$alert = 'alert-success';
$message = 'Data Berhasil Dihapus';
if ($responseCode != 200) {
$message = 'Data tidak bisa dihapus, sudah dipakai di zona';
$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('master/rate'));
}
function rate_put(){
$id = $this->input->post('id');
$description = $this->input->post('description');
$price = $this->input->post('price');
$startDate = $this->input->post('startDate');
$endDate = $this->input->post('endDate');
//create a new cURL resource
$ch = curl_init($this->url_rate);
// setup request to send json via POST
// $param = http_build_query(array('name' => $name));
$data = array(
'id' => $id,
'description' => $description,
'price' => (float)$price,
'startDate' => date("c",strtotime($startDate)),
'endDate' => date("c",strtotime($endDate)),
);
$param = json_encode($data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
// //attach encoded JSON string to the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
// curl_setopt($ch, CURLOPT_POST, 1);
//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);
$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('master/rate'));
}
/*END MANAGE RATE*/
......
<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>
Master Rate/Price
<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 echo $this->session->flashdata('notifikasi');?>
<a class="btn btn-success btn-sm" onclick="function_add()" href="#"><i class="fa fa-plus"></i>Add Rate/price</a>
</div>
<div class="box-body">
<div style="max-width: auto; overflow-x: auto;">
<table id="example1" class="table table-bordered table-striped small">
<thead>
<tr>
<th>NO</th>
<th>DESCRIPTION</th>
<th>RATE/PRICE</th>
<th>START DATE</th>
<th>END DATE</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php
if (count($result)>0){
$start = 0;
foreach ($result as $value)
{ ?>
<tr>
<td><?php echo ++$start;?></td>
<td><?php echo $value->description;?></td>
<td><?php echo $value->price;?></td>
<td><?php echo $value->startDate;?></td>
<td><?php echo $value->endDate;?></td>
<td>
<a class="btn btn-warning btn-xs" href="#" onclick="function_edit('<?= $value->id;?>')"><i class="fa fa-edit"></i></a>
<a href="<?php echo base_url('master/rate/delete')?>/<?php echo $value->id?>" onclick="javascript: return confirm('Data akan dihapus ?')" class="btn btn-danger btn-xs "><i class="fa fa-trash"></i>
</a>
</td>
</tr>
<?php
}
}
?>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
<!-- /.box-body -->
<!-- /.box-footer-->
</div>
<!-- /.box -->
</div>
</div>
</section>
<!-- /.content -->
<!-- MODAL RATE -->
<div class="modal fade" id="modal_rate" 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">Edit</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<form id="form_rate" enctype="multipart/form-data" method="POST">
<div class="form-group col-md-12" id="labelId">
<label>ID</label>
<input readonly type="text" class="form-control" name="id" id="id">
</div>
<div class="form-group col-md-12">
<label>Description</label>
<input type="text" class="form-control" name="description" id="description">
</div>
<div class="form-group col-md-4">
<label>Rate/price</label>
<input type="number" class="form-control" name="price" id="price" min=0 max=9999>
</div>
<div class="form-group col-md-4">
<label>Start Date</label>
<input type="date" class="form-control" name="startDate" id="startDateId">
</div>
<div class="form-group col-md-4">
<label>End Date</label>
<input type="date" class="form-control" name="endDate" id="endDateId">
</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-check"></i>Simpan Data</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_rate').modal('show');
$('#form_rate')[0].reset();
$('#form_rate').attr('action',"<?php echo base_url()?>master/rate/save");
$('#myModalLabel').text('Add Rate/Price');
$('#labelId').hide();
$("#startDateId").val(getFormattedDate(today()));
$("#endDateId").val(getFormattedDate(today()));
}
function function_edit(id){
$('#form_rate').attr('action',"<?php echo base_url()?>master/rate/put");
$('#myModalLabel').text('Edit Rate/Price');
$('#labelId').show();
$.get("<?php echo site_url('master/rate/id');?>/"+id).done(function(response){
$('#modal_rate').modal('show');
response=JSON.parse(response);
$('#id').val(response.id);
$('#description').val(response.description);
$('#price').val(response.price);
$('#startDateId').val(getFormattedDate(getTanggal(response.startDate)));
$('#endDateId').val(getFormattedDate(getTanggal(response.endDate)));
});
}
function today() {
return new Date();
}
function getTanggal(date) {
return new Date(date);
}
// Get formatted date YYYY-MM-DD
function getFormattedDate(date) {
return date.getFullYear()
+ "-"
+ ("0" + (date.getMonth() + 1)).slice(-2)
+ "-"
+ ("0" + date.getDate()).slice(-2);
}
</script>
\ No newline at end of file
......@@ -68,12 +68,18 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<li class="treeview">
<a href="#">
<i class="fa fa-folder"></i>
<span>Area Parkir</span>
<span>Area Parkir & Rate</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li>
<a href="<?php echo base_url()?>master/rate">
<i class="fa fa-circle-o"></i>
Rate/Price
</a>
</li>
<li>
<a href="<?php echo base_url()?>master/location">
<i class="fa fa-circle-o"></i>
......
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