first commit
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col col-lg-9">
|
||||
<div class="row">
|
||||
<!-- Media library -->
|
||||
<div class="panel-heading">
|
||||
<h6 class="panel-title text-semibold">My Float Version Managerment</h6>
|
||||
</div>
|
||||
<div class="row">
|
||||
<form method="GET" action="/myfloat_version/index">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="">Platform</label>
|
||||
<select class="form-control" name="platform_filter">
|
||||
<option value="0">All Platform</option>
|
||||
<?php foreach ($platforms as $value):?>
|
||||
<option
|
||||
<?=(isset($filterData['platform_filter']) && $value['id'] == $filterData['platform_filter']) ? 'selected' : ''?>
|
||||
value="<?php echo $value['id']; ?>">
|
||||
<?php echo $value['platform']; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="">Text (name or notes or url)</label>
|
||||
<input type="text" class="form-control" name="text_filter" value="<?= $filterData['text_filter'] ?? '';?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="">Released</label>
|
||||
<input type="text" class="form-control" name="released_filter" value="<?= $filterData['released_filter'] ?? (date('Y-m-d', strtotime('-30 days')).' - '.date('Y-m-d')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="">Rev count</label>
|
||||
<input type="number" class="form-control" name="rev_count_filter" value="<?= $filterData['rev_count_filter'] ?? '';?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="">Short hash</label>
|
||||
<input type="text" class="form-control" name="short_hash_filter" value="<?= $filterData['short_hash_filter'] ?? '';?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-3 col-sm-2">
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<div style="margin-top: 7px">
|
||||
<button type="submit" class=" btn btn-primary btn-sm">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="m-y-sm"><?= $links ?: '' ?></div>
|
||||
<div>
|
||||
<table class="table table-bordered table-hover table-striped" >
|
||||
<thead class="bg-indigo">
|
||||
<th>ID</th>
|
||||
<th>Platform</th>
|
||||
<th>Name</th>
|
||||
<th>Released</th>
|
||||
<th>Notes</th>
|
||||
<th>Rev Count</th>
|
||||
<th>Short Hash</th>
|
||||
<th>URL</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<?php foreach ($versions as $key => $version):?>
|
||||
<tr id="<?=$version["id"]?>-<?=$version['platform_id']?>" style="word-break:break-all;">
|
||||
<td style="word-break:keep-all"><?php echo $version['id']; ?></td>
|
||||
<td class="text-center"><?php echo $version['platform']; ?></td>
|
||||
<td><?php echo $version['name']; ?></td>
|
||||
<td><?php echo $version['released']; ?></td>
|
||||
<td><?php echo $version['notes']; ?></td>
|
||||
<td><?php echo $version['rev_count']; ?></td>
|
||||
<td><?php echo $version['short_hash']; ?></td>
|
||||
<td><?php echo $version['url']; ?></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-sm btn-primary" style="width:60px;margin:5px" onclick="return viewVersion(this);">View</button>
|
||||
<button type="button" class="btn btn-sm btn-danger" style="width:60px;margin:5px" onclick="return deleteVersion('<?= $version["id"]?>');">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-lg-3">
|
||||
<div class="card" style="width: 100%; background-color: lemonchiffon; padding: 5px;">
|
||||
<div class="card-body" id="card_form">
|
||||
<font id="message" color=red><?=$message?> </font>
|
||||
<form id="editform" name="editform" method="post" action="" autocomplete="off">
|
||||
<div class="form-group">
|
||||
<label for="platform_id"">Platform</label>
|
||||
<select class="form-control" id="platform_id" name="platform_id">
|
||||
<?php foreach ($platforms as $value):?>
|
||||
<option
|
||||
<?=(isset($platform_id) && $value['id'] == $platform_id) ? 'selected' : ''?>
|
||||
value="<?php echo $value['id']; ?>">
|
||||
<?php echo $value['platform']; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="name"">Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" maxlength="50" placeholder="Name" value="<?=$name?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="released">Released</label>
|
||||
<input type="text" class="form-control" id="released" name="released" maxlength="50" placeholder="Released" value="<?=$released?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="notes">Notes</label>
|
||||
<textarea rows="5" class="form-control" id="notes" name="notes" maxlength="500" placeholder="Notes"><?=$notes?></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="rev_count"">Rev Count</label>
|
||||
<input type="text" autocomplete="off" class="form-control" id="rev_count" name="rev_count" maxlength="25" placeholder="Rev Count" value="<?=$rev_count?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="short_hash"">Short Hash</label>
|
||||
<input type="text"" autocomplete="off" class="form-control" id="short_hash" name="short_hash" maxlength="125" placeholder="Short Hash" value="<?=$short_hash?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="url"">URL</label>
|
||||
<input type="text"" class="form-control" id="url" name="url" maxlength="255" placeholder="URL" value="<?=$url?>" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="hidden" class="form-control" id="id" name="id" value="" />
|
||||
<button type="submit" onclick="submitForm()" name="gobtn" id="gotbtn" class="btn btn-info btn-block btn-sm"><?=$form_button?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#released').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
showDropdowns: true,
|
||||
today: false,
|
||||
editable: false,
|
||||
minYear: <?=date("Y")?>,
|
||||
maxYear: <?=date("Y") + 10?>, /*parseInt(moment().format('YYYY'),10),*/
|
||||
locale: {
|
||||
format: 'YYYY-MM-DD'
|
||||
}
|
||||
}, function(start, end, label) {
|
||||
var years = moment().diff(start, 'years');
|
||||
});
|
||||
|
||||
/*********** date range picker ***********/
|
||||
let datepickerOptions = {
|
||||
autoUpdateInput: false,
|
||||
locale: {
|
||||
format: 'YYYY-MM-DD',
|
||||
cancelLabel: 'Clear'
|
||||
}
|
||||
};
|
||||
|
||||
let fromToElement = $('input[name="released_filter"]');
|
||||
const fromToVal = fromToElement.val();
|
||||
if (fromToVal == '') {
|
||||
datepickerOptions.startDate = moment().subtract(30, 'days').format('YYYY-MM-DD');
|
||||
datepickerOptions.endDate = moment().format('YYYY-MM-DD');
|
||||
}
|
||||
fromToElement.daterangepicker(datepickerOptions);
|
||||
|
||||
fromToElement.on('apply.daterangepicker', function(ev, picker) {
|
||||
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
|
||||
});
|
||||
|
||||
fromToElement.on('cancel.daterangepicker', function(ev, picker) {
|
||||
fromToElement.val('');
|
||||
});
|
||||
/***************************************/
|
||||
});
|
||||
|
||||
var table = document.getElementsByTagName("table")[0];
|
||||
var tbody = table.getElementsByTagName("tbody")[0];
|
||||
tbody.onclick = function (e) {
|
||||
e = e || window.event;
|
||||
var target = e.srcElement || e.target;
|
||||
fillFormData(target)
|
||||
};
|
||||
|
||||
function viewVersion(ele){
|
||||
var target = ele.parentElement;
|
||||
fillFormData(target)
|
||||
}
|
||||
|
||||
function fillFormData(target){
|
||||
|
||||
while (target && target.nodeName !== "TR") {
|
||||
target = target.parentNode;
|
||||
}
|
||||
|
||||
if (target) {
|
||||
var all_rows = target.parentNode.children;
|
||||
for (i = 0; i < all_rows.length; i++) {
|
||||
all_rows[i].style.backgroundColor = "";
|
||||
}
|
||||
var cells = target.getElementsByTagName("td");
|
||||
|
||||
var info=target.id.split('-');
|
||||
document.getElementsByName('id')[0].value = cells[0].innerHTML;
|
||||
document.getElementsByName('platform_id')[0].value = info[1];
|
||||
document.getElementsByName('name')[0].value = cells[2].innerHTML;
|
||||
document.getElementsByName('released')[0].value = cells[3].innerHTML;
|
||||
document.getElementsByName('notes')[0].value = cells[4].innerHTML;
|
||||
document.getElementsByName('rev_count')[0].value = cells[5].innerHTML;
|
||||
document.getElementsByName('short_hash')[0].value = cells[6].innerHTML;
|
||||
document.getElementsByName('url')[0].value = cells[7].innerHTML;
|
||||
document.getElementsByName('gobtn')[0].innerText = "Update";
|
||||
target.style.backgroundColor="lightgreen";
|
||||
}
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
var frm = document.getElementsByName('editform')[0];
|
||||
frm.submit();
|
||||
return false;
|
||||
}
|
||||
|
||||
function deleteVersion(id) {
|
||||
if (!confirm('Are you sure you want to delete?')) return false;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/myfloat_version/deleteVersion?id='+id, true);
|
||||
xhr.responseType = 'json';
|
||||
xhr.onload = function() {
|
||||
var status = xhr.status;
|
||||
if (status === 200) {
|
||||
if (xhr.response.state === "successful") {
|
||||
window.location.href = "/myfloat_version/index";
|
||||
}
|
||||
$('#message').html(xhr.response.message);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user