From 70d53e892d46cf78053c580bd65bf2edf6581baa Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Fri, 29 Apr 2011 13:07:30 +1000 Subject: [PATCH] Fixed edit Enquiry user --- controllers/enquiries_controller.php | 2 +- models/shipment.php | 4 +- views/jobs/autocomplete.ctp | 1 + views/purchase_orders/autocomplete.ctp | 1 + views/shipments/index.ctp | 10 ----- webroot/css/quotenik.css | 21 +++++++++ webroot/js/shipment_index.js | 60 ++++++++++++++++++++------ 7 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 views/jobs/autocomplete.ctp create mode 100644 views/purchase_orders/autocomplete.ctp diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index 719874c6..e8a0238f 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -394,7 +394,7 @@ class EnquiriesController extends AppController { $this->data = $this->Enquiry->read(null, $id); } $enquiry = $this->Enquiry->read(null, $id); - $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'))); + $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'), 'conditions'=>array('User.type'=>'user'))); //$customer = $this->Enquiry->Customer->findById($enquiry['Enquiry']['customer_id']); $contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $enquiry['Enquiry']['customer_id']))); diff --git a/models/shipment.php b/models/shipment.php index a975a144..93686e0c 100644 --- a/models/shipment.php +++ b/models/shipment.php @@ -2,10 +2,10 @@ class Shipment extends AppModel { var $name = 'Shipment'; - var $validate = array( + /* var $validate = array( 'freight_forwarder_id' => array('numeric'), 'airway_bill' => array('notempty') - ); + ); */ var $recursive = 1; diff --git a/views/jobs/autocomplete.ctp b/views/jobs/autocomplete.ctp new file mode 100644 index 00000000..42d11ebe --- /dev/null +++ b/views/jobs/autocomplete.ctp @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/purchase_orders/autocomplete.ctp b/views/purchase_orders/autocomplete.ctp new file mode 100644 index 00000000..18ba206b --- /dev/null +++ b/views/purchase_orders/autocomplete.ctp @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp index b73eb22b..58636805 100644 --- a/views/shipments/index.ctp +++ b/views/shipments/index.ctp @@ -1,16 +1,6 @@

-
-

This is Alpha version of this functionality

-
-	You're welcome to look around. Don't start relying on anything in it just yet though.
-
-	Validation still needs to be finished. Also, Box weights/dimensions and Invoice details.
-
-	Will hopefully be finished tomorrow (Friday Apr 29) - Karl
-
- link('shipment_index');?>

diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index fc47672e..8cfe109c 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -1455,4 +1455,25 @@ table.shipments { padding-top: 0.5em; padding-left: 0; margin: 0; +} + +.boxForm { + border: 1px solid; + width: 15em; + margin-top: 1em; +} + +.boxForm input { + display: inline; + width: 50px; +} + +.boxForm label { + float: left; + margin-right: 1em; + text-align: right; + width: 8em; +} + +.boxForm div { } \ No newline at end of file diff --git a/webroot/js/shipment_index.js b/webroot/js/shipment_index.js index 0b02cf73..cd5a14a8 100644 --- a/webroot/js/shipment_index.js +++ b/webroot/js/shipment_index.js @@ -9,11 +9,11 @@ $(function() { modal: true, buttons: { "New Shipment": function() { - var thisShipmentInputs = $('#ShipmentAddForm').find('input,select'); + var thisShipmentInputs = $('#ShipmentAddForm').find('input,select,textarea'); $.post('/shipments/ajax_edit', thisShipmentInputs, function(data) { $( "#dialog-form" ).dialog('close'); - window.location.reload(); + window.location.reload(); //Change this to fetch a new copy of the table and update a

. }); }, @@ -48,14 +48,19 @@ $(function() { }); - + /** + * Display the relevent elements depending on this Shipment Type */ $("#shipmentType").change(function() { - var shipmentTypeID = getSelectedID('#shipmentType'); - - if(shipmentTypeID == 1) { //Import - $("#importFields").show(); - $("#principle").show(); + shipmentTypeID = parseInt(shipmentTypeID); + $(".hiddenDefault").hide(); + + switch(shipmentTypeID) { + case 1: + $("#importFields, #principle, #purchaseOrder, #freight_forwarder, #airway_bill, #boxes").show(); + break; + default: + break; } }); @@ -93,7 +98,7 @@ $(function() { //alert($('#PurchaseOrderID_'+ui.item.id).length); - if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.' + if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This PO is already in the List. Don't do anything.' addToList('PurchaseOrder', ui.item.id, ui.item.value, $('#purchaseOrdersList')); } @@ -107,15 +112,23 @@ $(function() { select: function( event, ui ) { //alert(ui.item.value + ":" + ui.item.id); - if($('#JobID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.' + if($('#JobID_'+ui.item.id).length == 0) { //This Job is already in the List. Don't do anything.' addToList('Job', ui.item.id, ui.item.value, $('#jobsList')); - } - - + } } }); + + $("#addBox").button().click(function() { + addBox(); + }); + + $(".removeBox").click(function() { + alert("REMOVE THIS SHIT MAN"); + + }); + /** * Resets the Form to its default site */ @@ -123,11 +136,27 @@ $(function() { function resetForm() { $(".hiddenDefault").hide(); - $("#principle").hide(); $("#ShipmentAddForm")[0].reset(); } + function addBox() { + var newBoxForm = $("#boxFactory").clone(); + + + newBoxForm.attr('id',''); + newBoxForm.show(); + + var closeButton = $(''); + closeButton.addClass('removeBox'); + closeButton.button(); + + newBoxForm.prepend(closeButton); + + $("#boxes").append(newBoxForm); + } + + /** * A more generic way of handling the HABTM
  • [REMOVE BUTTON] NAME [HIDDEN INPUT]
@@ -170,5 +199,8 @@ $(function() { } + + + }); \ No newline at end of file