72 lines
2.5 KiB
PHP
Executable file
72 lines
2.5 KiB
PHP
Executable file
<?php
|
|
class PurchaseInvoicesController extends AppController {
|
|
|
|
var $name = 'PurchaseInvoices';
|
|
var $helpers = array('Html', 'Form');
|
|
|
|
function index() {
|
|
$this->PurchaseInvoice->recursive = 0;
|
|
$this->set('purchaseInvoices', $this->paginate());
|
|
}
|
|
|
|
function view($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid PurchaseInvoice.', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
$this->set('purchaseInvoice', $this->PurchaseInvoice->read(null, $id));
|
|
}
|
|
|
|
function add() {
|
|
if (!empty($this->data)) {
|
|
$this->PurchaseInvoice->create();
|
|
if ($this->PurchaseInvoice->save($this->data)) {
|
|
$this->Session->setFlash(__('The PurchaseInvoice has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The PurchaseInvoice could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
$shipments = $this->PurchaseInvoice->Shipment->find('list');
|
|
$principles = $this->PurchaseInvoice->Principle->find('list');
|
|
$freightForwarders = $this->PurchaseInvoice->FreightForwarder->find('list');
|
|
$currencies = $this->PurchaseInvoice->Currency->find('list');
|
|
$this->set(compact('shipments', 'principles', 'freightForwarders', 'currencies'));
|
|
}
|
|
|
|
function edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
$this->Session->setFlash(__('Invalid PurchaseInvoice', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if (!empty($this->data)) {
|
|
if ($this->PurchaseInvoice->save($this->data)) {
|
|
$this->Session->setFlash(__('The PurchaseInvoice has been saved', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
} else {
|
|
$this->Session->setFlash(__('The PurchaseInvoice could not be saved. Please, try again.', true));
|
|
}
|
|
}
|
|
if (empty($this->data)) {
|
|
$this->data = $this->PurchaseInvoice->read(null, $id);
|
|
}
|
|
$shipments = $this->PurchaseInvoice->Shipment->find('list');
|
|
$principles = $this->PurchaseInvoice->Principle->find('list');
|
|
$freightForwarders = $this->PurchaseInvoice->FreightForwarder->find('list');
|
|
$currencies = $this->PurchaseInvoice->Currency->find('list');
|
|
$this->set(compact('shipments','principles','freightForwarders','currencies'));
|
|
}
|
|
|
|
function delete($id = null) {
|
|
if (!$id) {
|
|
$this->Session->setFlash(__('Invalid id for PurchaseInvoice', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
if ($this->PurchaseInvoice->del($id)) {
|
|
$this->Session->setFlash(__('PurchaseInvoice deleted', true));
|
|
$this->redirect(array('action'=>'index'));
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|