diff --git a/models/box.php b/models/box.php
index ab3f0bc9..3d3430eb 100644
--- a/models/box.php
+++ b/models/box.php
@@ -11,7 +11,7 @@ class Box extends AppModel {
'Shipment' => array(
'className' => 'Shipment',
'foreignKey' => 'shipment_id',
- 'counterCache' => true
+ 'counterCache' => 'box_count'
)
);
diff --git a/views/jobs/get_editable_row.ctp b/views/jobs/get_editable_row.ctp
index d3bd86e5..3313b53e 100644
--- a/views/jobs/get_editable_row.ctp
+++ b/views/jobs/get_editable_row.ctp
@@ -28,7 +28,10 @@
showButtonPanel: true,
dateFormat: 'd M yy',
altFormat: 'yy-mm-dd',
- altField: '#=$job['Job']['id']?>_date_order_sent_to_customer'
+ altField: '#=$job['Job']['id']?>_date_order_sent_to_customer',
+ onSelect: function(dateText, inst) {
+ $('#all_sent').val(1);
+ }
});
@@ -84,7 +87,7 @@
$('.export_sale_aud').attr("readonly",true);
$('.commissions_any_currency').addClass("highlighted");
}
- else {
+ else {
//Export Sale
if(currencyID == 2) {//Export Sale. AUD
$('.export_sale_aud').attr("readonly",false);
diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp
index 58636805..53a17ff3 100644
--- a/views/shipments/index.ctp
+++ b/views/shipments/index.ctp
@@ -18,7 +18,10 @@
Principle(s) |
PO(s) |
Jobs |
- sort('box_count');?> |
+ sort('# Boxes','box_count');?> |
+ Box Details
+ L x W x H (kg)
+ |
sort('freight_forwarder_id');?> |
@@ -84,6 +87,30 @@
|
+
+
+
+
+
+
+ =$box['length']?> x =$box['width']?> x =$box['height']?> (=$box['weight']?> kg)
+ $totalWeight += $box['weight']; ?>
+
+
+
+ |
+
+ =$totalWeight?> kg |
+
link($shipment['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipment['FreightForwarder']['id'])); ?>
|
diff --git a/webroot/js/shipment_index.js b/webroot/js/shipment_index.js
index cd5a14a8..4a63598f 100644
--- a/webroot/js/shipment_index.js
+++ b/webroot/js/shipment_index.js
@@ -2,6 +2,8 @@ $(function() {
resetForm();
+ var addedBoxes = 0;
+
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 900,
@@ -121,12 +123,12 @@ $(function() {
$("#addBox").button().click(function() {
- addBox();
+ addBox(addedBoxes);
+ addedBoxes++;
});
- $(".removeBox").click(function() {
- alert("REMOVE THIS SHIT MAN");
-
+ $(".removeBox").live('click',function() {
+ $(this).parent().remove();
});
/**
@@ -140,13 +142,48 @@ $(function() {
}
- function addBox() {
+ function addBox(addedBoxes) {
+
+ var model = 'Box';
+
var newBoxForm = $("#boxFactory").clone();
-
+
+ var boxNo = addedBoxes;
newBoxForm.attr('id','');
+ newBoxForm.addClass('boxForm');
newBoxForm.show();
+ //Set the appropriate naming for the fields so cake can work its magic.
+ //Should refactor into a function.
+ var div = newBoxForm.find('.length');
+ var ID = getCakeID(model,boxNo,'length');
+ var name = getCakeName(model, boxNo, 'length');
+ div.children('label').attr('for', ID);
+ div.children('input').attr('id', ID).attr('name', name);
+
+ div = newBoxForm.find('.width');
+ ID = getCakeID(model,boxNo,'width');
+ name = getCakeName(model, boxNo, 'width');
+ div.children('label').attr('for', ID);
+ div.children('input').attr('id', ID).attr('name', name);
+
+ div = newBoxForm.find('.height');
+ ID = getCakeID(model,boxNo,'height');
+ name = getCakeName(model, boxNo, 'height');
+ div.children('label').attr('for', ID);
+ div.children('input').attr('id', ID).attr('name', name);
+
+ div = newBoxForm.find('.weight');
+ ID = getCakeID(model,boxNo,'weight');
+ name = getCakeName(model, boxNo, 'weight');
+ div.children('label').attr('for', ID);
+ div.children('input').attr('id', ID).attr('name', name);
+
+
+
+
+
var closeButton = $('');
closeButton.addClass('removeBox');
closeButton.button();
@@ -157,6 +194,18 @@ $(function() {
}
+ function getCakeID(model, count, field) {
+ return model+count+capitalizeFirstLetter(field);
+ }
+
+ function getCakeName(model, count, field) {
+ return 'data['+model+']['+count+']['+field+']';
+ }
+
+ function capitalizeFirstLetter(string) {
+ return string.charAt(0).toUpperCase() + string.slice(1);
+ }
+
/**
* A more generic way of handling the HABTM - [REMOVE BUTTON] NAME [HIDDEN INPUT]
@@ -170,7 +219,9 @@ $(function() {
var thisHiddenInput = $('');
var modelString = '['+modelName+']';
+
thisHiddenInput.attr('name', 'data'+modelString+modelString+'[]');
+
thisHiddenInput.attr('value', id);
thisLI.attr('id', modelName+'ID_'+id);