Shipment thing mostly functional. ShipmentInvoices and export,local to be done tomorrow

This commit is contained in:
Karl Cordes 2011-04-29 17:18:44 +10:00
parent 34162801b4
commit a6bffff40e
5 changed files with 130 additions and 13 deletions

View file

@ -2,7 +2,7 @@
class AddressesController extends AppController {
var $name = 'Addresses';
var $helpers = array('Html', 'Form', 'Ajax');
var $helpers = array('Html', 'Form');
var $components = array('RequestHandler');
function index() {
$this->Address->recursive = 0;
@ -81,5 +81,12 @@ class AddressesController extends AppController {
}
function customerAddresses($customerID) {
$this->layout = 'ajax';
$this->set('addresses', $this->Address->find('all', array('conditions'=>array('Customer.id'=>$customerID))));
}
}
?>

View file

@ -0,0 +1,19 @@
<script type="text/javascript">
$(function() {
$(".selectAddress").button();
});
</script>
<?foreach($addresses as $address):?>
<div class="address">
<span class="address"><?=$address['Address']['address']?></span>
<span class="city"><?=$address['Address']['city'];?></span>
<span class="state"><?=$address['State']['name'];?></span>
<span class="country"><?=$address['Country']['name'];?></span>
<button class="selectAddress" id="<?=$address['Address']['id']?>">Ship to this Address</button>
</div>
<?endforeach;?>

View file

@ -9,6 +9,7 @@
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<button class="newShipment">New Shipment</button>
<table cellpadding="0" cellspacing="0" class="shipments">
<tr>
<th><?php echo $paginator->sort('user_id');?></th>
@ -20,8 +21,9 @@
<th>Jobs</th>
<th><?php echo $paginator->sort('# Boxes','box_count');?></th>
<th>Box Details<br>
L x W x H (kg)
LxWxH (cm)
</th>
<th>Weight (kg)</th>
<th><?php echo $paginator->sort('freight_forwarder_id');?></th>
@ -88,29 +90,38 @@
<?php echo $shipment['Shipment']['box_count']; ?>
</td>
<td>
<td class="boxDimensions">
<?php
//This is nasty. Will fix this once its working.
?>
<?php
$totalWeight = 0;
$weightString = '';
foreach($shipment['Box'] as $box):?>
<?=$box['length']?> x <?=$box['width']?> x <?=$box['height']?> (<?=$box['weight']?> kg) <br>
<? $totalWeight += $box['weight']; ?>
<?=$box['length']?>x<?=$box['width']?>x<?=$box['height']?><br>
<?
$weightString .= $box['weight'].' kg <br>';
$totalWeight += $box['weight']; ?>
<?php endforeach;?>
</td>
<td> <?=$totalWeight?> kg</td>
<td> <?
$boxCount = $shipment['Shipment']['box_count'];
if($boxCount > 1) {
echo $weightString;
echo '<hr>';
}?>
<? if($boxCount != 0): ?>
<span class="totalWeight"><?=$totalWeight;?> kg</span></td>
<? endif;?>
<td>
<?php echo $html->link($shipment['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipment['FreightForwarder']['id'])); ?>
</td>
@ -136,7 +147,7 @@
</div>
<div class="actions">
<ul>
<li><button id="newShipment">New Shipment</button></li>
<li><button class="newShipment">New Shipment</button></li>
</ul>
</div>

View file

@ -1440,11 +1440,18 @@ table.shipments tr td {
border: 1px solid;
}
table.shipments tr td.boxDimensions {
text-align: left;
}
table.shipments {
border: 1px solid;
}
.habtmList {
list-style: none;
margin: 0;
@ -1477,3 +1484,18 @@ table.shipments {
.boxForm div {
}
span.totalWeight {
font-weight: bolder;
}
div.address {
border: 1px solid;
margin-top: 1em;
width: 15em;
}
div.address span {
display: block;
}

View file

@ -34,7 +34,7 @@ $(function() {
}
});
$( "#newShipment" ).button().click(function() {
$( ".newShipment" ).button().click(function() {
$( "#dialog-form" ).dialog( "open" );
@ -50,6 +50,13 @@ $(function() {
});
$('#date_dispatched_display').datepicker({
showButtonPanel: true,
dateFormat: 'd M yy',
altFormat: 'yy-mm-dd',
altField: '#date_dispatched'
});
/**
* Display the relevent elements depending on this Shipment Type */
$("#shipmentType").change(function() {
@ -58,9 +65,12 @@ $(function() {
$(".hiddenDefault").hide();
switch(shipmentTypeID) {
case 1:
case 1: //Import
$("#importFields, #principle, #purchaseOrder, #freight_forwarder, #airway_bill, #boxes").show();
break;
case 2: //Direct
$("#purchaseOrder, #job,#principle, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show();
default:
break;
}
@ -121,6 +131,20 @@ $(function() {
});
$("#customer_autocomplete").autocomplete({
source: "/customers/completeCustomer",
minLength: 2,
select: function( event, ui ) {
$("#customer_id").val(ui.item.id);
$.get('/addresses/customerAddresses/'+ui.item.id, function(data) {
$("#address").html(data);
$(".selectAddress", data).button();
});
}
})
$("#addBox").button().click(function() {
addBox(addedBoxes);
@ -131,6 +155,40 @@ $(function() {
$(this).parent().remove();
});
$(".selectAddress").live('click', function() {
var ID = $(this).attr('id');
$("#address_id").val(ID);
$(this).removeClass('selectAddress');
$(this).addClass('changeAddress');
$(".selectAddress").button('disable');
$(".selectAddress").parent('div').fadeOut();
$(this).button({
label: 'Select a different address'
});
$(this).button('enable');
});
$(".changeAddress").live('click', function() {
$("#address_id").val('');
$(this).removeClass('changeAddress');
$(this).button({
label: 'Ship to this Address'
});
$(this).addClass('selectAddress');
$(".selectAddress").parent('div').fadeIn();
$('.selectAddress').button('enable');
});
/**
* Resets the Form to its default site
*/