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'));