2010-07-16 00:52:57 -07:00
|
|
|
<?php
|
|
|
|
|
class PurchaseOrdersController extends AppController {
|
|
|
|
|
|
|
|
|
|
var $name = 'PurchaseOrders';
|
|
|
|
|
var $helpers = array('Html', 'Form', 'Javascript');
|
|
|
|
|
|
2010-09-06 20:57:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
var $paginate = array(
|
|
|
|
|
|
|
|
|
|
'contain' => false,
|
|
|
|
|
'limit' => 100,
|
|
|
|
|
'order'=>array('PurchaseOrder.id' => 'desc')
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
2010-07-16 00:52:57 -07:00
|
|
|
function index() {
|
2010-09-06 20:57:28 -07:00
|
|
|
$this->PurchaseOrder->recursive = 1;
|
2010-07-16 00:52:57 -07:00
|
|
|
$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'));
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
?>
|