Initial commit

This commit is contained in:
mareksebera 2014-09-10 20:20:58 +02:00
commit 3b93da31de
1004 changed files with 265840 additions and 0 deletions

View file

@ -0,0 +1,34 @@
<?php
/**
* Application level Controller
*
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Controller
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Controller', 'Controller');
/**
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @package app.Controller
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
*/
class AppController extends Controller {
}

View file

View file

@ -0,0 +1,104 @@
<?php
App::uses('AppController', 'Controller');
/**
* ItemTypes Controller
*
* @property ItemType $ItemType
* @property PaginatorComponent $Paginator
*/
class ItemTypesController extends AppController {
/**
* Components
*
* @var array
*/
public $components = array('Paginator');
/**
* 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'));
}
}

View file

@ -0,0 +1,74 @@
<?php
App::uses('AppController', 'Controller');
class ItemsController extends AppController
{
public $uses = array('Item', 'ItemType', 'StockUnitType', 'StockHistory');
public function index()
{
$this->set('items', $this->Item->find('all'));
}
public function add()
{
if ($this->request->is('post')) {
//die(print_r($this->request->data));
$this->StockHistory->create();
if ($this->StockHistory->saveAll($this->request->data)) {
$this->Session->setFlash(__('The item type has been saved.'));
$this->redirect(array('action' => 'index'));
return;
} else {
$this->Session->setFlash(__('The item type could not be saved. Please, try again.'));
}
}
$this->set('itemTypes', $this->ItemType->find('list'));
$this->set('stockUnitTypes', $this->StockUnitType->find('list'));
}
public function view($id = null)
{
if (!$this->ItemType->exists($id)) {
throw new NotFoundException(__('Invalid item type'));
}
$options = array('conditions' => array('ItemType.id' => $id));
$this->set('itemType', $this->ItemType->find('first', $options));
}
public function edit($id = null)
{
if (!$this->Item->exists($id)) {
throw new NotFoundException(__('Invalid item type'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->Item->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.id' => $id));
$this->request->data = $this->ItemType->find('first', $options);
}
}
public function delete($id = null)
{
$this->Item->id = $id;
if (!$this->Item->exists()) {
throw new NotFoundException(__('Invalid item type'));
}
$this->request->allowMethod('post', 'delete');
$this->Item->set('is_deleted', 1);
if ($this->Item->save()) {
$this->Session->setFlash(__('The item type has been deleted.'));
} else {
$this->Session->setFlash(__('The item type could not be deleted. Please, try again.'));
}
$this->redirect(array('action' => 'index'));
}
}