From c43e4efc24d07352e27888d72e5a3989c80ee471 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 2 May 2011 16:46:24 +1000 Subject: [PATCH] Think the shipment register is working OK --- controllers/shipments_controller.php | 16 +++++++++++++++- models/shipment.php | 20 ++++++++++++++++++++ views/shipments/edit.ctp | 14 ++++++++------ views/shipments/index.ctp | 7 +------ webroot/css/quotenik.css | 12 +++++++----- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/controllers/shipments_controller.php b/controllers/shipments_controller.php index 24863dcc..345332d3 100644 --- a/controllers/shipments_controller.php +++ b/controllers/shipments_controller.php @@ -68,6 +68,20 @@ class ShipmentsController extends AppController { //$this->Shipment->create($this->data); if ($this->Shipment->saveAll($this->data)) { + + $boxIDs = array(); + foreach($this->data['Box'] as $box) { + $boxIDs[] = $box['id']; + } + + $invoiceIDs = array(); + foreach($this->data['ShipmentInvoice'] as $si) { + $invoiceIDs[] = $si['id']; + } + + + + echo "SUCCESS"; } else { @@ -84,7 +98,7 @@ class ShipmentsController extends AppController { function ajax_add() { - $this->layout = 'ajax'; + //$this->layout = 'ajax'; if(!empty($this->data)) { $this->Shipment->create($this->data); diff --git a/models/shipment.php b/models/shipment.php index 93686e0c..d8f45b30 100644 --- a/models/shipment.php +++ b/models/shipment.php @@ -26,8 +26,18 @@ class Shipment extends AppModel { 'className' => 'User', 'foreignKey' => 'user_id', 'conditions' => array('User.type' => 'user') + ), + + 'Customer' => array( + 'className' => 'Customer', + 'foreignKey' => 'customer_id' + ), + 'Address' => array( + 'className' => 'Address', + 'foreignKey' => 'address_id' ) + ); var $hasMany = array( @@ -107,5 +117,15 @@ class Shipment extends AppModel { ) ); + + /*function beforeSave() { + $thisID = $this->data['Shipment']['id']; + + $this->Box->deleteAll(array('Box.shipment_id'=>$thisID)); + return true; + + }*/ + + } ?> \ No newline at end of file diff --git a/views/shipments/edit.ctp b/views/shipments/edit.ctp index 0b934a65..971c5fa8 100644 --- a/views/shipments/edit.ctp +++ b/views/shipments/edit.ctp @@ -33,7 +33,7 @@ echo $form->input('id', array('type'=>'hidden'));
  • - +
  • @@ -49,7 +49,7 @@ echo $form->input('id', array('type'=>'hidden'));
  • - +
  • @@ -63,10 +63,10 @@ echo $form->input('id', array('type'=>'hidden')); @@ -75,14 +75,14 @@ echo $form->input('id', array('type'=>'hidden'));
    input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer'));?> - input('customer_id', array('type'=>'hidden', 'id'=>'customer_id'));?> + input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?>
    Shipping Address:
    - + input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?>
    @@ -101,6 +101,8 @@ echo $form->input('id', array('type'=>'hidden')); data['Box'] as $box):?>
    + input("Box.{$boxNo}.id", array('type'=>'hidden'));?> + input("Box.{$boxNo}.shipment_id", array('type'=>'hidden', 'value'=>$this->data['Shipment']['id']));?> input("Box.{$boxNo}.length", array('label'=>'Length (cm)', 'div'=>'length'));?> input("Box.{$boxNo}.width", array('label'=>'Width (cm)', 'div'=>'width'));?> input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?> diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp index fa3aa635..d41a7573 100644 --- a/views/shipments/index.ctp +++ b/views/shipments/index.ctp @@ -91,12 +91,7 @@ - - - +