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,19 +0,0 @@
<div class="itemTypes form">
<?php echo $this->Form->create('ItemType'); ?>
<fieldset>
<legend><?php echo __('Add Item Type'); ?></legend>
<?php
echo $this->Form->input('name');
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('List Item Types'), array('action' => 'index')); ?></li>
<li><?php echo $this->Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -1,21 +0,0 @@
<div class="itemTypes form">
<?php echo $this->Form->create('ItemType'); ?>
<fieldset>
<legend><?php echo __('Edit Item Type'); ?></legend>
<?php
echo $this->Form->input('id');
echo $this->Form->input('name');
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('ItemType.id')), array(), __('Are you sure you want to delete # %s?', $this->Form->value('ItemType.id'))); ?></li>
<li><?php echo $this->Html->link(__('List Item Types'), array('action' => 'index')); ?></li>
<li><?php echo $this->Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -1,50 +1,47 @@
<div class="itemTypes index">
<h2><?php echo __('Item Types'); ?></h2>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Paginator->sort('name'); ?></th>
<th><?php echo $this->Paginator->sort('modified'); ?></th>
<th><?php echo $this->Paginator->sort('created'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($itemTypes as $itemType): ?>
<tr>
<td><?php echo h($itemType['ItemType']['id']); ?>&nbsp;</td>
<td><?php echo h($itemType['ItemType']['name']); ?>&nbsp;</td>
<td><?php echo h($itemType['ItemType']['modified']); ?>&nbsp;</td>
<td><?php echo h($itemType['ItemType']['created']); ?>&nbsp;</td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('action' => 'view', $itemType['ItemType']['id'])); ?>
<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $itemType['ItemType']['id'])); ?>
<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $itemType['ItemType']['id']), array(), __('Are you sure you want to delete # %s?', $itemType['ItemType']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?> </p>
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('New Item Type'), array('action' => 'add')); ?></li>
<li><?php echo $this->Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?> </li>
</ul>
<script type="text/javascript">
$(document).ready(function () {
var table = $("#item-types-table").DataTable({
paging: false,
orderMulti: true,
info: false,
columns: [
{searchable: true},
{searchable: true}
],
search: {
caseInsensitive: true
}
});
});
</script>
<div id="item-type-add">
<?php
echo $this->Form->create('ItemType');
echo $this->Form->inputs(array(), array('created', 'modified'));
echo $this->Form->end(__('Submit'));
?>
</div>
<br class="clear"/>
<hr/>
<table id="item-types-table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php foreach ($itemTypes as $id => $name): ?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $name; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</tfoot>
</table>

View file

@ -1,75 +0,0 @@
<div class="itemTypes view">
<h2><?php echo __('Item Type'); ?></h2>
<dl>
<dt><?php echo __('Id'); ?></dt>
<dd>
<?php echo h($itemType['ItemType']['id']); ?>
&nbsp;
</dd>
<dt><?php echo __('Name'); ?></dt>
<dd>
<?php echo h($itemType['ItemType']['name']); ?>
&nbsp;
</dd>
<dt><?php echo __('Modified'); ?></dt>
<dd>
<?php echo h($itemType['ItemType']['modified']); ?>
&nbsp;
</dd>
<dt><?php echo __('Created'); ?></dt>
<dd>
<?php echo h($itemType['ItemType']['created']); ?>
&nbsp;
</dd>
</dl>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('Edit Item Type'), array('action' => 'edit', $itemType['ItemType']['id'])); ?> </li>
<li><?php echo $this->Form->postLink(__('Delete Item Type'), array('action' => 'delete', $itemType['ItemType']['id']), array(), __('Are you sure you want to delete # %s?', $itemType['ItemType']['id'])); ?> </li>
<li><?php echo $this->Html->link(__('List Item Types'), array('action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('New Item Type'), array('action' => 'add')); ?> </li>
<li><?php echo $this->Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?> </li>
</ul>
</div>
<div class="related">
<h3><?php echo __('Related Items'); ?></h3>
<?php if (!empty($itemType['Item'])): ?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php echo __('Id'); ?></th>
<th><?php echo __('Item Type Id'); ?></th>
<th><?php echo __('Name'); ?></th>
<th><?php echo __('Stock Unit Type Id'); ?></th>
<th><?php echo __('Detail'); ?></th>
<th><?php echo __('Modified'); ?></th>
<th><?php echo __('Created'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php foreach ($itemType['Item'] as $item): ?>
<tr>
<td><?php echo $item['id']; ?></td>
<td><?php echo $item['item_type_id']; ?></td>
<td><?php echo $item['name']; ?></td>
<td><?php echo $item['stock_unit_type_id']; ?></td>
<td><?php echo $item['detail']; ?></td>
<td><?php echo $item['modified']; ?></td>
<td><?php echo $item['created']; ?></td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('controller' => 'items', 'action' => 'view', $item['id'])); ?>
<?php echo $this->Html->link(__('Edit'), array('controller' => 'items', 'action' => 'edit', $item['id'])); ?>
<?php echo $this->Form->postLink(__('Delete'), array('controller' => 'items', 'action' => 'delete', $item['id']), array(), __('Are you sure you want to delete # %s?', $item['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $this->Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?> </li>
</ul>
</div>
</div>

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>

View file

@ -20,6 +20,49 @@
echo $this->fetch('css');
echo $this->fetch('script');
?>
<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;
};
</script>
</head>
<body>
<div id="container">
@ -28,8 +71,8 @@
<ul id="top-menu">
<li><?php echo $this->Html->link(__('All Items'), array('controller' => 'items', 'action' => 'index')) ?></li>
<li><?php echo $this->Html->link(__('Add Item'), array('controller' => 'items', 'action' => 'add')) ?></li>
<li><?php echo $this->Html->link(__('Add Item Type'), array('controller' => 'item_types', 'action' => 'add')) ?></li>
<li><?php echo $this->Html->link(__('Add Unit Type'), array('controller' => 'unit_types', 'action' => 'add')) ?></li>
<li><?php echo $this->Html->link(__('Add Item Type'), array('controller' => 'item_types', 'action' => 'index')) ?></li>
<li><?php echo $this->Html->link(__('Add Unit Type'), array('controller' => 'stock_unit_types', 'action' => 'index')) ?></li>
</ul>
<br class="clear"/>
</div>

View file

@ -0,0 +1,47 @@
<script type="text/javascript">
$(document).ready(function () {
var table = $("#item-units-table").DataTable({
paging: false,
orderMulti: true,
info: false,
columns: [
{searchable: true},
{searchable: true}
],
search: {
caseInsensitive: true
}
});
});
</script>
<div id="item-units-add">
<?php
echo $this->Form->create('StockUnitType');
echo $this->Form->inputs(array(), array('created', 'modified'));
echo $this->Form->end(__('Submit'));
?>
</div>
<br class="clear"/>
<hr/>
<table id="item-units-table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $id => $name): ?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $name; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</tfoot>
</table>