Index/Add views for StockUnitType and ItemType, View/Update for Item, Style to apply on all tables, DataTables used on details and indexes

This commit is contained in:
mareksebera 2014-09-10 22:16:10 +02:00
parent be2b39c5eb
commit 5d4d209549
15 changed files with 322 additions and 313 deletions

View file

@ -1,5 +1,5 @@
<?php
echo $this->Form->create('Item');
echo $this->Form->inputs(array(), array('created', 'modified'));
echo $this->Form->inputs(array(), array('created', 'modified', 'is_deleted'));
echo $this->Form->end(__('Save'));

View file

@ -1,46 +1,4 @@
<script type="text/javascript">
jQuery.fn.DataTable.ext.type.search.string = function (data) {
return !data ?
'' :
typeof data === 'string' ?
data
.replace(/\n/g, ' ')
.replace(/á/g, 'a')
.replace(/é/g, 'e')
.replace(/í/g, 'i')
.replace(/ó/g, 'o')
.replace(/ú/g, 'u')
.replace(/ê/g, 'e')
.replace(/î/g, 'i')
.replace(/ô/g, 'o')
.replace(/è/g, 'e')
.replace(/ï/g, 'i')
.replace(/ü/g, 'u')
.replace(/ě/g, 'e')
.replace(/š/g, 's')
.replace(/č/g, 'c')
.replace(/ř/g, 'r')
.replace(/ž/g, 'z')
.replace(/ý/g, 'y')
.replace(/ö/g, 'o')
.replace(/ä/g, 'a')
.replace(/ň/g, 'n')
.replace(/Ě/g, 'e')
.replace(/Š/g, 's')
.replace(/Č/g, 'c')
.replace(/Ř/g, 'r')
.replace(/Ž/g, 'z')
.replace(/Ý/g, 'y')
.replace(/Á/g, 'a')
.replace(/Í/g, 'i')
.replace(/É/g, 'e')
.replace(/Ň/g, 'n')
.replace(/Ť/g, 't')
.replace(/Ď/g, 'd')
.replace(/ç/g, 'c') :
data;
};
$(document).ready(function () {
var table = $("#items-table").DataTable({
paging: false,

89
app/View/Items/view.ctp Normal file
View file

@ -0,0 +1,89 @@
<table class="dataTable">
<tr>
<td>ID</td>
<td><?php echo $item['Item']['id']; ?></td>
</tr>
<tr>
<td>Name</td>
<td><?php echo $item['Item']['name']; ?></td>
</tr>
<tr>
<td>Type</td>
<td><?php echo $item['ItemType']['name']; ?></td>
</tr>
<tr>
<td>Stock Quantity</td>
<td><?php echo $item['StockHistory'][0]['amount_in_stock'] . ' ' . $item['StockUnitType']['name']; ?></td>
</tr>
<tr>
<td>Placement</td>
<td><?php echo $item['StockHistory'][0]['location']; ?></td>
</tr>
</table>
<br class="clear"/>
<hr/>
<h2>Update Stock Quantity and Placement</h2>
<?php
echo $this->Form->create('StockHistory');
echo $this->Form->hidden('item_id', array('value' => $item['Item']['id']));
echo $this->Form->inputs(array(), array('created', 'modified', 'item_id'));
echo $this->Form->end(__('Save'));
?>
<br class="clear"/>
<hr/>
<h2>Item Stock History</h2>
<script type="text/javascript">
$(document).ready(function () {
var table = $("#item-stock-history").DataTable({
paging: false,
orderMulti: true,
info: false,
columns: [
{searchable: true},
{searchable: true},
{searchable: true},
{searchable: true},
],
order: [
[3, 'desc']
],
search: {
caseInsensitive: true
}
});
});
</script>
<table id="item-stock-history">
<thead>
<tr>
<td>ID</td>
<td>Quantity</td>
<td>Placement</td>
<td>When</td>
</tr>
</thead>
<?php
foreach ($item['StockHistory'] as $history) {
printf(
'<tr>
<td>%d</td>
<td>%d</td>
<td>%s</td>
<td>%s</td>
</tr>',
$history['id'],
$history['amount_in_stock'],
$history['location'],
$history['created']
);
}
?>
<tfoot>
<tr>
<td>ID</td>
<td>Quantity</td>
<td>Placement</td>
<td>When</td>
</tr>
</tfoot>
</table>