diff --git a/controllers/boxes_controller.php b/controllers/boxes_controller.php index a038bbbb..e54fd9aa 100644 --- a/controllers/boxes_controller.php +++ b/controllers/boxes_controller.php @@ -9,6 +9,12 @@ class BoxesController extends AppController { $this->set('boxes', $this->paginate()); } + + function buildForm($count = 0) { + $this->layout = 'ajax'; + $this->set('count', $count); + } + function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid Box.', true)); diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index e3ccc822..b11ae466 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -386,110 +386,6 @@ class JobsController extends AppController { } } - - function add() { - - - - if (!empty($this->data)) { - $this->Job->create(); - - $job_offset = 6141; - - $number_of_jobs = $this->Job->findCount(); - $new_job_number = $job_offset + $number_of_jobs; - - $enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']); - - - - $monthYearShort = strtoupper(date("My")); - - $jobLetter = $enquiry['State']['enqform']; - - $this->data['Job']['title'] = $monthYearShort.$jobLetter."J".$new_job_number; - $this->data['Job']['state_id'] = $enquiry['Enquiry']['state_id']; - $this->data['Job']['customer_id'] = $enquiry['Enquiry']['customer_id']; - $this->data['Job']['contact_id'] = $enquiry['Enquiry']['contact_id']; - - - - if ($this->Job->save($this->data)) { - $jobid = $this->Job->id; - - //$this->Job->Enquiry->set('status_id', 3); //Change status to 'Job Won'; - $enquiry['Enquiry']['status_id'] = 3; - - $this->Job->Enquiry->save($enquiry); - - - $this->Session->setFlash(__('Job Saved', true)); - $this->redirect(array('action'=>'view', $jobid)); - } else { - $this->Session->setFlash(__('Please Fix the Errors Below', true)); - $enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']); - $this->set(compact('enquiry')); - } - } - else { - if(isset($this->params['named']['enquiryid'])) { - - $enquiry = $this->Job->Enquiry->findById($this->params['named']['enquiryid']); - - $this->set(compact('enquiry')); - } - else { - $this->Session->setFlash(__('Invalid Enquiry ID', true)); - $this->redirect(array('action'=>'index')); - } - } - - $freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer"); - $this->set('freight_paid_options', $freight_paid_options); - - $sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION"); - $this->set('sale_category_options', $sale_category_options); - $this->set('shipment_category_options', $this->shipment_category_options()); - - } - - function edit($id = null) { - if (!$id && empty($this->data)) { - $this->flash(__('Invalid Job', true), array('action'=>'index')); - } - if (!empty($this->data)) { - $jobid = $this->data['Job']['id']; - if ($this->Job->save($this->data)) { - // $this->flash(__('The Job has been saved.', true), array('action'=>'view', $jobid)); - - $this->Session->setFlash(__('The Job has been saved', true)); - - $this->redirect(array('action' =>'view/'.$jobid), null, false); - - } else { - } - } - if (empty($this->data)) { - $job = $this->Job->read(null, $id); - $this->data = $job; - $this->set('currencies', $this->Job->Currency->find('list')); - - } - - - - - $freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer"); - $this->set('freight_paid_options', $freight_paid_options); - - $sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION"); - $this->set('sale_category_options', $sale_category_options); - $this->set('shipment_category_options', $this->shipment_category_options()); - - - } - - function __isNotEmptyDate($date) { if($date == "0000-00-00") { return true; diff --git a/controllers/shipments_controller.php b/controllers/shipments_controller.php index 76604b74..ffee1135 100644 --- a/controllers/shipments_controller.php +++ b/controllers/shipments_controller.php @@ -1,8 +1,8 @@ Shipment->recursive = 0; - $this->set('shipments', $this->paginate()); + function index() { + $this->Shipment->recursive = 0; + $this->set('shipments', $this->paginate()); + } + + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid Shipment.', true)); + $this->redirect(array('action'=>'index')); } + $this->set('shipment', $this->Shipment->read(null, $id)); + } - function view($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid Shipment.', true)); - $this->redirect(array('action'=>'index')); - } - $this->set('shipment', $this->Shipment->read(null, $id)); + + + + + function add($action = 'add') { + + $jobs = $this->Shipment->Job->find('list'); + $principles = $this->Shipment->Principle->find('list'); + $purchaseOrders = $this->Shipment->PurchaseOrder->find('list'); + $freightForwarders = $this->Shipment->FreightForwarder->find('list'); + $shipmentType = $this->typeOptions(); + + $this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders', 'shipmentType')); + + + + } + + + function typeOptions() { + $options = array('','Import to CMC','Direct: Principle to Customer','Export','Local'); + return $options; + } + + + + function delete($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid id for Shipment', true)); + $this->redirect(array('action'=>'index')); } - - function add() { - if (!empty($this->data)) { - $this->Shipment->create(); - if ($this->Shipment->save($this->data)) { - $this->Session->setFlash(__('The Shipment has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The Shipment could not be saved. Please, try again.', true)); - } - } - $jobs = $this->Shipment->Job->find('list'); - $principles = $this->Shipment->Principle->find('list'); - $purchaseOrders = $this->Shipment->PurchaseOrder->find('list'); - $freightForwarders = $this->Shipment->FreightForwarder->find('list'); - $this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders')); - } - - - - - function add_edit($action = 'add') { - - $principles = $this->Shipment->Principle->find('list'); - $freightForwarders = $this->Shipment->FreightForwarder->find('list'); - $this->set('principles', 'freightForwarders'); - - } - - - - - function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for Shipment', true)); - $this->redirect(array('action'=>'index')); - } - if ($this->Shipment->del($id)) { - $this->Session->setFlash(__('Shipment deleted', true)); - $this->redirect(array('action'=>'index')); - } + if ($this->Shipment->del($id)) { + $this->Session->setFlash(__('Shipment deleted', true)); + $this->redirect(array('action'=>'index')); } + } } ?> \ No newline at end of file diff --git a/models/principle.php b/models/principle.php index a53a938d..6d940955 100755 --- a/models/principle.php +++ b/models/principle.php @@ -5,6 +5,8 @@ class Principle extends AppModel { var $recursive = 0; + var $order = 'Principle.name ASC'; + //The Associations below have been created with all possible keys, those that are not needed can be removed var $belongsTo = array( 'Country' => array('className' => 'Country', diff --git a/views/layouts/default.ctp b/views/layouts/default.ctp index 9a5608a6..50145b75 100755 --- a/views/layouts/default.ctp +++ b/views/layouts/default.ctp @@ -77,7 +77,8 @@