83 lines
2.5 KiB
PHP
83 lines
2.5 KiB
PHP
|
|
<?php
|
||
|
|
class PurchaseOrdersController extends AppController {
|
||
|
|
|
||
|
|
var $name = 'PurchaseOrders';
|
||
|
|
var $helpers = array('Html', 'Form', 'Javascript');
|
||
|
|
|
||
|
|
function index() {
|
||
|
|
$this->PurchaseOrder->recursive = 0;
|
||
|
|
$this->set('purchaseOrders', $this->paginate());
|
||
|
|
}
|
||
|
|
|
||
|
|
function view($id = null) {
|
||
|
|
if (!$id) {
|
||
|
|
$this->Session->setFlash(__('Invalid PurchaseOrder.', true));
|
||
|
|
$this->redirect(array('action'=>'index'));
|
||
|
|
}
|
||
|
|
$this->set('purchaseOrder', $this->PurchaseOrder->read(null, $id));
|
||
|
|
}
|
||
|
|
|
||
|
|
function add() {
|
||
|
|
if (!empty($this->data)) {
|
||
|
|
$this->PurchaseOrder->create();
|
||
|
|
|
||
|
|
$count = $this->PurchaseOrder->findCount();
|
||
|
|
$count++;
|
||
|
|
|
||
|
|
$offset = 2060;
|
||
|
|
|
||
|
|
$count += $offset;
|
||
|
|
|
||
|
|
$newPOnumber = "CMCPO".$count;
|
||
|
|
|
||
|
|
$this->data['PurchaseOrder']['title'] = $newPOnumber;
|
||
|
|
|
||
|
|
|
||
|
|
if ($this->PurchaseOrder->save($this->data)) {
|
||
|
|
$this->Session->setFlash(__('The PurchaseOrder has been saved', true));
|
||
|
|
$this->redirect(array('action'=>'index'));
|
||
|
|
} else {
|
||
|
|
$this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$jobs = $this->PurchaseOrder->Job->find('list');
|
||
|
|
$principles = $this->PurchaseOrder->Principle->find('list');
|
||
|
|
$documents = $this->PurchaseOrder->Document->find('list');
|
||
|
|
$this->set(compact('jobs', 'principles', 'documents'));
|
||
|
|
}
|
||
|
|
|
||
|
|
function edit($id = null) {
|
||
|
|
if (!$id && empty($this->data)) {
|
||
|
|
$this->Session->setFlash(__('Invalid PurchaseOrder', true));
|
||
|
|
$this->redirect(array('action'=>'index'));
|
||
|
|
}
|
||
|
|
if (!empty($this->data)) {
|
||
|
|
if ($this->PurchaseOrder->save($this->data)) {
|
||
|
|
$this->Session->setFlash(__('The PurchaseOrder has been saved', true));
|
||
|
|
$this->redirect(array('action'=>'index'));
|
||
|
|
} else {
|
||
|
|
$this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (empty($this->data)) {
|
||
|
|
$this->data = $this->PurchaseOrder->read(null, $id);
|
||
|
|
}
|
||
|
|
$jobs = $this->PurchaseOrder->Job->find('list');
|
||
|
|
$principles = $this->PurchaseOrder->Principle->find('list');
|
||
|
|
$documents = $this->PurchaseOrder->Document->find('list');
|
||
|
|
$this->set(compact('jobs','principles','documents'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/*function delete($id = null) {
|
||
|
|
if (!$id) {
|
||
|
|
$this->Session->setFlash(__('Invalid id for PurchaseOrder', true));
|
||
|
|
$this->redirect(array('action'=>'index'));
|
||
|
|
}
|
||
|
|
if ($this->PurchaseOrder->del($id)) {
|
||
|
|
$this->Session->setFlash(__('PurchaseOrder deleted', true));
|
||
|
|
$this->redirect(array('action'=>'index'));
|
||
|
|
}
|
||
|
|
}*/
|
||
|
|
|
||
|
|
}
|
||
|
|
?>
|