first commit

This commit is contained in:
dev-chiefworks
2022-05-31 16:21:53 -04:00
commit f76abffdcd
5978 changed files with 1078901 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
<div class="row">
<?php if ($this->session->flashdata('error')) { ?>
<div class="col-12">
<div class="alert alert-danger alert-dismissible bg-danger text-white border-0 fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<strong>Error - </strong> <?php echo $this->session->flashdata('error') ?>
</div>
</div>
<?php } ?>
<div class="col-lg-6">
<div class="form-group mb-3 <?php echo form_error('name') ? 'has-error' : '' ?>">
<label for="name">Name</label>
<input type="text"
value="<?php echo set_value('name', (isset($item) && isset($item['name'])) ? $item['name'] : null); ?>"
name="name"
class="form-control"
>
<div class="invalid-feedback text-danger">
<?php echo form_error('name') ? form_error('name') : '' ?>
</div>
</div>
<div class="form-group mb-3 <?php echo form_error('country_code') ? 'has-error' : '' ?>">
<label for="country_code">Country</label>
<select name="country_code"
id="country-code"
class="form-control <?php echo form_error('country_code') ? 'is-invalid' : ''; ?>"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($countryList as $country) {
$selected = set_value('country_code', $item['country_code']) == $country->code ? 'selected' : '';
echo '<option value="' . $country->code . '"' . $selected . '>' . $country->country . '</option>';
}
?>
</select>
<div class="invalid-feedback text-danger">
<?php echo form_error('country_code') ? form_error('country_code') : '' ?>
</div>
</div>
<div class="form-group mb-3 <?php echo form_error('longitude') ? 'has-error' : '' ?>">
<label for="longitude">Longitude</label>
<input type="text"
value="<?php echo set_value('longitude', (isset($item) && isset($item['longitude'])) ? $item['longitude'] : null); ?>"
name="longitude"
class="form-control"
>
<div class="invalid-feedback text-danger">
<?php echo form_error('longitude') ? form_error('longitude') : '' ?>
</div>
</div>
<div class="form-group mb-3 <?php echo form_error('type') ? 'has-error' : '' ?>">
<label for="type">Geofencing area types</label>
<select name="type"
class="form-control <?php echo form_error('type') ? 'is-invalid' : ''; ?>"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($geofencingAreaTypes as $type) {
$selected = set_value('type', $item['type']) == $type ? 'selected' : '';
echo '<option value="' . $type . '"' . $selected . '>' . ucfirst($type) . '</option>';
}
?>
</select>
<div class="invalid-feedback text-danger">
<?php echo form_error('type') ? form_error('type') : '' ?>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="form-group mb-3 <?php echo form_error('area') ? 'has-error' : '' ?>">
<label for="area">Area</label>
<input type="text"
value="<?php echo set_value('area', (isset($item) && isset($item['area'])) ? $item['area'] : null); ?>"
name="area"
class="form-control"
>
<div class="invalid-feedback text-danger">
<?php echo form_error('area') ? form_error('area') : '' ?>
</div>
</div>
<div class="form-group mb-3 <?php echo form_error('city_id') ? 'has-error' : '' ?>">
<label for="city-id">City</label>
<select name="city_id"
id="city-id"
class="form-control <?php echo form_error('city_id') ? 'is-invalid' : ''; ?>"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($cityList as $city) {
$selected = set_value('city_id', $item['city_id']) == $city->id ? 'selected' : '';
echo '<option value="' . $city->id . '" ' . $selected . '>' . $city->city . '</option>';
}
?>
</select>
<div class="invalid-feedback text-danger">
<?php echo form_error('city_id') ? form_error('city_id') : '' ?>
</div>
</div>
<div class="form-group mb-3 <?php echo form_error('latitude') ? 'has-error' : '' ?>">
<label for="latitude">Latitude</label>
<input type="text"
name="latitude"
value="<?php echo set_value('latitude', (isset($item) && isset($item['latitude'])) ? $item['latitude'] : null); ?>"
class="form-control <?php echo form_error('latitude') ? 'is-invalid' : ''; ?>"
>
<div class="invalid-feedback text-danger">
<?php echo form_error('latitude') ? form_error('latitude') : '' ?>
</div>
</div>
<div class="form-group mb-3 <?php echo form_error('boundaries') ? 'has-error' : '' ?>">
<label for="boundaries">Boundaries</label>
<textarea name="boundaries" cols="30" rows="10" placeholder="Enter a json format" class="form-control"><?php echo set_value('boundaries', (isset($item) && isset($item['boundaries'])) ? $item['boundaries'] : null); ?></textarea>
<p class="text-muted">Note: please enter a Json format</p>
<div class="invalid-feedback text-danger">
<?php echo form_error('boundaries') ? form_error('boundaries') : '' ?>
</div>
</div>
</div>
</div>
<script src="/assets/js/pages/geofence_area/_form.js" type="text/javascript"></script>
@@ -0,0 +1,35 @@
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row align-items-center">
<div class="col-12">
<div class="page-title-box">
<h4 class="page-title">Geofence area</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="header-title">Create new geofence area</h4>
<form action="/geofence_area/store" method="post">
<?php include '_form.php'; ?>
<div class="row">
<div class="pull-right">
<div class="btn-group" role="group">
<button type="submit" class="btn btn-primary mr-2">Create</button>
<a href="/geofence_area" class="btn btn-danger">Cancel</a>
</div>
</div>
</div>
</form>
</div> <!-- end card-body -->
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row-->
</div> <!-- container -->
+36
View File
@@ -0,0 +1,36 @@
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row align-items-center">
<div class="col-12">
<div class="page-title-box">
<h4 class="page-title">Geofence area</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="header-title">Edit geofence area</h4>
<form action="/geofence_area/<?php echo $itemId; ?>/update" method="post">
<?php include '_form.php'; ?>
<div class="row">
<div class="pull-right">
<div class="btn-group" role="group">
<button type="submit" class="btn btn-primary mr-2">Edit</button>
<a href="/geofence_area" class="btn btn-danger">Cancel</a>
</div>
</div>
</div>
</form>
</div> <!-- end card-body -->
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row-->
</div> <!-- container -->
+132
View File
@@ -0,0 +1,132 @@
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row align-items-center">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right text-right action">
<a href="/geofence_area/create" class="btn btn-success">New geofence area</a>
</div>
<h4 class="page-title">Geofence area</h4>
</div>
</div>
</div>
<!-- end page title -->
<!-- start alert -->
<?php if ($this->session->flashdata('success')) { ?>
<div class="col-12">
<div class="alert alert-success alert-dismissible bg-success text-white" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<?php echo $this->session->flashdata('success') ?>
</div>
</div>
<?php } ?>
<!-- end alert -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form class="search-block" action="/geofence_area" method="get">
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="city_id">City</label>
<select name="city_id"
class="form-control"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($cityList as $city) {
$selected = set_value('city_id', $filterData['city_id']) == $city->id ? 'selected' : '';
echo '<option value="' . $city->id . '"' . $selected . '>' . $city->city . '</option>';
}
?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<button class="btn btn-primary btn-search" type="submit">Search</button>
</div>
</div>
</form>
<div class="table-responsive-sm">
<table id="trips-datatable" class="table table-sm table-centered mb-0" width="100%">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Area</th>
<th>City name</th>
<th>Country name</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Type</th>
<th class="actions">Actions</th>
</tr>
</thead>
<tbody class="table-striped">
<?php foreach($list as $item): ?>
<tr>
<td><?php echo $item->id ?></td>
<td><?php echo $item->name ?></td>
<td><?php echo $item->area ?></td>
<td><?php echo $item->city_name ?></td>
<td><?php echo $item->country_name ?></td>
<td><?php echo $item->latitude ?></td>
<td><?php echo $item->longitude ?></td>
<td><?php echo $item->type ?></td>
<td class="actions">
<a href="/geofence_area/<?php echo $item->id; ?>/edit" class="btn btn-primary">View</a>
<button
type="button"
class="btn btn-danger btn-remove"
data-id="<?php echo $item->id ?>"
data-area-name="<?php echo $item->name ?>"
data-toggle="modal"
data-target="#remove-geofence-area-modal"
>Remove</button>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
<?php echo $pagination ?>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->
</div> <!-- container -->
<div id="remove-geofence-area-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="warning-header-modalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header modal-colored-header bg-warning">
<h4 class="modal-title" id="warning-header-modalLabel"></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<h5 class="mt-0">Remove warning</h5>
<p>This can not be undone. Do you want to conitnue?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-warning" id="removeBtn" data-id="">Continue</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script src="/assets/js/app.js" type="text/javascript"></script>
<script src="/assets/js/pages/geofence_area/list.js" type="text/javascript"></script>
@@ -0,0 +1,238 @@
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row align-items-center">
<div class="col-12">
<div class="page-title-box">
<h4 class="page-title">Price comparison</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="table-responsive-sm">
<form class="search-block" action="/geofence_area/comparePriceBetweenAreas" method="get">
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="city_id">City</label>
<select name="city_id"
class="form-control"
id="city-id"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($cityList as $city) {
$selected = set_value('city_id', $filterData['city_id']) == $city->id ? 'selected' : '';
echo '<option value="' . $city->id . '"' . $selected . '>' . $city->city . '</option>';
}
?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="">From area</label>
<select name="from_area_id"
class="area-selection form-control"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($areaList as $area) {
$selected = set_value('from_area_id', $filterData['from_area_id']) == $area->id ? 'selected' : '';
echo '<option value="' . $area->id . '"' . $selected . '>' . $area->name . '</option>';
}
?>
</select>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="">To area</label>
<select name="to_area_id"
class="area-selection form-control"
data-toggle="select2">
<option value="">Select</option>
<?php
foreach($areaList as $area) {
$selected = set_value('to_area_id', $filterData['to_area_id']) == $area->id ? 'selected' : '';
echo '<option value="' . $area->id . '"' . $selected . '>' . $area->name . '</option>';
}
?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<button class="btn btn-primary btn-search" type="submit">Search</button>
</div>
</div>
</form>
<table id="trips-datatable" class="table table-sm table-centered mb-0" width="100%">
<thead>
<tr>
<th>From area</th>
<th>To area</th>
<th>Price comparison</th>
</tr>
</thead>
<tbody class="table-striped">
<tr>
<td><?php echo $priceComparison['from_area']['name'] ?? '' ?></td>
<td><?php echo $priceComparison['to_area']['name'] ?? '' ?></td>
<td>
<?php
if (!empty($priceComparison['price_comparison'])) {
foreach ($priceComparison['price_comparison'] as $item) {
echo '<strong>Transport provider:</strong> ' . $item['transport_provider_name'] . '<br/>';
echo '<strong>avg:</strong> ' . $item['avg_price'] . '<br/><br/>';
}
} else {
echo '<strong class="text-danger">No Trip to compare.</strong>';
}
?>
</td>
</tr>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
<div class="google-map">
<!--The div element for the map -->
<div id="map"></div>
</div>
</div><!-- end col-->
</div>
<!-- end row-->
</div> <!-- container -->
<script>
window.addEventListener('DOMContentLoaded', function() {
var colors = ['red', 'green'];
// Utility function to make a polygon with some standard properties set
function makePolygon (paths, color) {
return (new google.maps.Polygon({
geodesic: true,
paths: paths,
strokeColor: color,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: color,
fillOpacity: 0.35
}));
};
// Run on page load
const initializeMap = function () {
// Set up map
let map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 1.3014223, lng: 103.8575394 },
zoom: 12,
disableDefaultUI: true,
});
const polygons = window.__global__.regions.map((region, index) => {
const color = colors[index % 5];
return makePolygon(region.polygons, color || colors[0]);
});
// Put sample polygons on the map with marker at approximated center
polygons.forEach(function (poly) {
poly.setMap(map);
});
}
window.__global__ = { ...(window.__global__ || {}), regions: [] };
const getRegionPolygon = function(polygon) {
return polygon.map(item => ({lat: item[1], lng: item[0]}))
}
const parseRegions = function(res) {
const startPolygon = getRegionPolygon(res.startPolygon);
const endPolygon = getRegionPolygon(res.endPolygon)
const regions = [
{
polygons : startPolygon
},
{
polygons : endPolygon
}
];
return regions;
}
const getRegions = function() {
const polygons = '<?php echo !empty($polygons) ? $polygons : '' ?>';
if (polygons) {
const parsedRegions = parseRegions(JSON.parse(polygons));
window.__global__.regions = parsedRegions;
initializeMap();
}
}
getRegions();
let cityEl = $('#city-id');
let areaEl = $('.area-selection');
var cityVal = cityEl.val();
getareaFromCityIdAjax(cityVal, areaEl);
cityEl.on('change', function() {
var cityId = $(this).val();
getareaFromCityIdAjax(cityId, areaEl);
})
///////// FUNCTION //////////////////
function getareaFromCityIdAjax(cityId, areaEl) {
$.ajax({
type: "GET",
url: "/geofence_area/getAreaListDependOnCityIdAjax",
data: {
'city_id' : cityId
},
cache: false,
success: function(res) {
res = JSON.parse(res);
if (res.success) {
var options = '<option value="">Select</option>';
var areaOldVal = areaEl.val();
var selected = '';
res.data.forEach(function(item, index) {
if (areaOldVal == item.id) {
selected = 'selected';
} else {
selected = '';
}
options += '<option ' + selected + ' value="' + item.id + '"' + '' + '>' + item.name + '</option>'
});
areaEl.html(options);
}
}
});
}
});
</script>