diff --git a/app/Controller/ItemTypesController.php b/app/Controller/ItemTypesController.php
index 81c0913..2a23e82 100644
--- a/app/Controller/ItemTypesController.php
+++ b/app/Controller/ItemTypesController.php
@@ -1,104 +1,32 @@
request->is('post')) {
+ $this->ItemType->create();
+ if ($this->ItemType->save($this->request->data)) {
+ $this->Session->setFlash(__('The item type has been saved.'));
+ } else {
+ $this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
+ }
+ }
-/**
- * index method
- *
- * @return void
- */
- public function index() {
- $this->ItemType->recursive = 0;
- $this->set('itemTypes', $this->Paginator->paginate());
- }
-
-/**
- * view method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function view($id = null) {
- if (!$this->ItemType->exists($id)) {
- throw new NotFoundException(__('Invalid item type'));
- }
- $options = array('conditions' => array('ItemType.' . $this->ItemType->primaryKey => $id));
- $this->set('itemType', $this->ItemType->find('first', $options));
- }
-
-/**
- * add method
- *
- * @return void
- */
- public function add() {
- if ($this->request->is('post')) {
- $this->ItemType->create();
- if ($this->ItemType->save($this->request->data)) {
- $this->Session->setFlash(__('The item type has been saved.'));
- return $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
- }
- }
- }
-
-/**
- * edit method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function edit($id = null) {
- if (!$this->ItemType->exists($id)) {
- throw new NotFoundException(__('Invalid item type'));
- }
- if ($this->request->is(array('post', 'put'))) {
- if ($this->ItemType->save($this->request->data)) {
- $this->Session->setFlash(__('The item type has been saved.'));
- return $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
- }
- } else {
- $options = array('conditions' => array('ItemType.' . $this->ItemType->primaryKey => $id));
- $this->request->data = $this->ItemType->find('first', $options);
- }
- }
-
-/**
- * delete method
- *
- * @throws NotFoundException
- * @param string $id
- * @return void
- */
- public function delete($id = null) {
- $this->ItemType->id = $id;
- if (!$this->ItemType->exists()) {
- throw new NotFoundException(__('Invalid item type'));
- }
- $this->request->allowMethod('post', 'delete');
- if ($this->ItemType->delete()) {
- $this->Session->setFlash(__('The item type has been deleted.'));
- } else {
- $this->Session->setFlash(__('The item type could not be deleted. Please, try again.'));
- }
- return $this->redirect(array('action' => 'index'));
- }
+ $this->ItemType->recursive = 0;
+ $this->set('itemTypes', $this->ItemType->find('list'));
+ }
}
diff --git a/app/Controller/ItemsController.php b/app/Controller/ItemsController.php
index 6e7c7ff..69b4559 100644
--- a/app/Controller/ItemsController.php
+++ b/app/Controller/ItemsController.php
@@ -30,11 +30,19 @@ class ItemsController extends AppController
public function view($id = null)
{
- if (!$this->ItemType->exists($id)) {
+ if (!$this->Item->exists($id)) {
throw new NotFoundException(__('Invalid item type'));
}
- $options = array('conditions' => array('ItemType.id' => $id));
- $this->set('itemType', $this->ItemType->find('first', $options));
+ if ($this->request->is(array('post', 'put'))) {
+ $this->StockHistory->create();
+ if ($this->StockHistory->save($this->request->data)) {
+ $this->Session->setFlash(__('The item type has been saved.'));
+ } else {
+ $this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
+ }
+ }
+ $options = array('conditions' => array('Item.id' => $id));
+ $this->set('item', $this->Item->find('first', $options));
}
public function edit($id = null)
@@ -50,8 +58,10 @@ class ItemsController extends AppController
$this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
}
} else {
- $options = array('conditions' => array('ItemType.id' => $id));
- $this->request->data = $this->ItemType->find('first', $options);
+ $options = array('conditions' => array('Item.id' => $id));
+ $this->request->data = $this->Item->find('first', $options);
+ $this->set('itemTypes', $this->ItemType->find('list'));
+ $this->set('stockUnitTypes', $this->StockUnitType->find('list'));
}
}
diff --git a/app/Controller/StockUnitTypesController.php b/app/Controller/StockUnitTypesController.php
new file mode 100644
index 0000000..2aea58b
--- /dev/null
+++ b/app/Controller/StockUnitTypesController.php
@@ -0,0 +1,22 @@
+request->is('post')) {
+ $this->StockUnitType->create();
+ if ($this->StockUnitType->save($this->request->data)) {
+ $this->Session->setFlash(__('The item type has been saved.'));
+ } else {
+ $this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
+ }
+ }
+
+ $this->StockUnitType->recursive = 0;
+ $this->set('items', $this->StockUnitType->find('list'));
+ }
+
+}
\ No newline at end of file
diff --git a/app/Model/ItemType.php b/app/Model/ItemType.php
index 580cb60..0ea04b3 100644
--- a/app/Model/ItemType.php
+++ b/app/Model/ItemType.php
@@ -8,5 +8,17 @@ class ItemType extends AppModel
public $name = 'ItemType';
public $displayField = 'name';
public $hasMany = array('Item');
+ public $validate = array(
+ 'name' => array(
+ 'isUnique' => array(
+ 'rule' => 'isUnique',
+ 'message' => 'Name must be unique'
+ ),
+ 'minLength' => array(
+ 'rule' => array('minLength', 3),
+ 'message' => 'Name must be at least 3 letters'
+ )
+ )
+ );
}
\ No newline at end of file
diff --git a/app/Model/StockUnitType.php b/app/Model/StockUnitType.php
index e686d29..c17cb76 100644
--- a/app/Model/StockUnitType.php
+++ b/app/Model/StockUnitType.php
@@ -8,5 +8,17 @@ class StockUnitType extends AppModel
public $name = 'StockUnitType';
public $displayField = 'name';
public $hasMany = array('Item');
+ public $validate = array(
+ 'name' => array(
+ 'isUnique' => array(
+ 'rule' => 'isUnique',
+ 'message' => 'Name must be unique'
+ ),
+ 'minLength' => array(
+ 'rule' => array('minLength', 3),
+ 'message' => 'Name must be at least 3 letters'
+ )
+ )
+ );
}
\ No newline at end of file
diff --git a/app/View/ItemTypes/add.ctp b/app/View/ItemTypes/add.ctp
deleted file mode 100644
index 3ba79b2..0000000
--- a/app/View/ItemTypes/add.ctp
+++ /dev/null
@@ -1,19 +0,0 @@
-
-Form->create('ItemType'); ?>
-
-
- Form->input('name');
- ?>
-
-Form->end(__('Submit')); ?>
-
-
-
-
-
- Html->link(__('List Item Types'), array('action' => 'index')); ?>
- Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?>
- Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?>
-
-
diff --git a/app/View/ItemTypes/edit.ctp b/app/View/ItemTypes/edit.ctp
deleted file mode 100644
index ceb9f58..0000000
--- a/app/View/ItemTypes/edit.ctp
+++ /dev/null
@@ -1,21 +0,0 @@
-
-Form->create('ItemType'); ?>
-
-
- Form->input('id');
- echo $this->Form->input('name');
- ?>
-
-Form->end(__('Submit')); ?>
-
-
-
-
-
- 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'))); ?>
- Html->link(__('List Item Types'), array('action' => 'index')); ?>
- Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?>
- Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?>
-
-
diff --git a/app/View/ItemTypes/index.ctp b/app/View/ItemTypes/index.ctp
index c735afc..b91440b 100644
--- a/app/View/ItemTypes/index.ctp
+++ b/app/View/ItemTypes/index.ctp
@@ -1,50 +1,47 @@
-
-
-
-
-
- Paginator->sort('id'); ?>
- Paginator->sort('name'); ?>
- Paginator->sort('modified'); ?>
- Paginator->sort('created'); ?>
-
-
-
-
-
-
-
-
-
-
-
- Html->link(__('View'), array('action' => 'view', $itemType['ItemType']['id'])); ?>
- Html->link(__('Edit'), array('action' => 'edit', $itemType['ItemType']['id'])); ?>
- Form->postLink(__('Delete'), array('action' => 'delete', $itemType['ItemType']['id']), array(), __('Are you sure you want to delete # %s?', $itemType['ItemType']['id'])); ?>
-
-
-
-
-
-
- Paginator->counter(array(
- 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
- ));
- ?>
-
- 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'));
- ?>
-
-
-
-
-
- Html->link(__('New Item Type'), array('action' => 'add')); ?>
- Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?>
- Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?>
-
+
+
+ Form->create('ItemType');
+ echo $this->Form->inputs(array(), array('created', 'modified'));
+ echo $this->Form->end(__('Submit'));
+ ?>
+
+
+
+
+
+ ID
+ Name
+
+
+
+ $name): ?>
+
+
+
+
+
+
+
+
+ ID
+ Name
+
+
+
diff --git a/app/View/ItemTypes/view.ctp b/app/View/ItemTypes/view.ctp
deleted file mode 100644
index 70c4600..0000000
--- a/app/View/ItemTypes/view.ctp
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Html->link(__('Edit Item Type'), array('action' => 'edit', $itemType['ItemType']['id'])); ?>
- Form->postLink(__('Delete Item Type'), array('action' => 'delete', $itemType['ItemType']['id']), array(), __('Are you sure you want to delete # %s?', $itemType['ItemType']['id'])); ?>
- Html->link(__('List Item Types'), array('action' => 'index')); ?>
- Html->link(__('New Item Type'), array('action' => 'add')); ?>
- Html->link(__('List Items'), array('controller' => 'items', 'action' => 'index')); ?>
- Html->link(__('New Item'), array('controller' => 'items', 'action' => 'add')); ?>
-
-
-
diff --git a/app/View/Items/edit.ctp b/app/View/Items/edit.ctp
index 23b8ea5..5c9bfed 100644
--- a/app/View/Items/edit.ctp
+++ b/app/View/Items/edit.ctp
@@ -1,5 +1,5 @@
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'));
\ No newline at end of file
diff --git a/app/View/Items/index.ctp b/app/View/Items/index.ctp
index 5190b5e..4406feb 100644
--- a/app/View/Items/index.ctp
+++ b/app/View/Items/index.ctp
@@ -1,46 +1,4 @@
+
+
+
+ ID
+ Quantity
+ Placement
+ When
+
+
+
+ %d
+ %d
+ %s
+ %s
+ ',
+ $history['id'],
+ $history['amount_in_stock'],
+ $history['location'],
+ $history['created']
+ );
+ }
+ ?>
+
+
+ ID
+ Quantity
+ Placement
+ When
+
+
+
\ No newline at end of file
diff --git a/app/View/Layouts/default.ctp b/app/View/Layouts/default.ctp
index 73f538b..790e2a2 100644
--- a/app/View/Layouts/default.ctp
+++ b/app/View/Layouts/default.ctp
@@ -20,6 +20,49 @@
echo $this->fetch('css');
echo $this->fetch('script');
?>
+
@@ -28,8 +71,8 @@
diff --git a/app/View/StockUnitTypes/index.ctp b/app/View/StockUnitTypes/index.ctp
new file mode 100644
index 0000000..fb02b6c
--- /dev/null
+++ b/app/View/StockUnitTypes/index.ctp
@@ -0,0 +1,47 @@
+
+
+ Form->create('StockUnitType');
+ echo $this->Form->inputs(array(), array('created', 'modified'));
+ echo $this->Form->end(__('Submit'));
+ ?>
+
+
+
+
+
+
+ ID
+ Name
+
+
+
+ $name): ?>
+
+
+
+
+
+
+
+
+ ID
+ Name
+
+
+
diff --git a/app/webroot/css/styles.css b/app/webroot/css/styles.css
index 08391a9..0afd2bf 100644
--- a/app/webroot/css/styles.css
+++ b/app/webroot/css/styles.css
@@ -33,22 +33,22 @@ h1 {
clear: both;
}
-#items-table {
+.dataTable {
width: 100%;
margin: 15px;
}
-#items-table thead > tr > td, #items-table tfoot > tr > td {
+.dataTable thead > tr > td, .dataTable tfoot > tr > td {
font-weight: bold;
padding-top: 10px;
padding-bottom: 10px;
}
-#items-table tbody > tr, thead > tr {
+.dataTable tbody > tr, thead > tr {
border-bottom: 1px solid #ececec;
}
-#items-table tbody > tr > td {
+.dataTable tbody > tr > td {
padding-top: 5px;
padding-bottom: 5px;
}
@@ -58,11 +58,11 @@ table .actions a {
padding-right: 5px;
}
-#items-table_filter {
+.dataTables_filter {
padding: 10px;
}
-#items-table_filter input[type=search] {
+.dataTables_filter input[type=search] {
padding: 10px;
font-size: 15px;
width: 200px;
@@ -95,4 +95,10 @@ form .input select {
#flashMessage {
padding: 20px;
background-color: #fafafa;
+}
+
+hr {
+ width: 100%;
+ background-color: black;
+ color: black;
}
\ No newline at end of file