Think the shipment register is working OK

This commit is contained in:
Karl Cordes 2011-05-02 16:46:24 +10:00
parent 9760614a0d
commit c43e4efc24
5 changed files with 51 additions and 18 deletions

View file

@ -68,6 +68,20 @@ class ShipmentsController extends AppController {
//$this->Shipment->create($this->data); //$this->Shipment->create($this->data);
if ($this->Shipment->saveAll($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"; echo "SUCCESS";
} }
else { else {
@ -84,7 +98,7 @@ class ShipmentsController extends AppController {
function ajax_add() { function ajax_add() {
$this->layout = 'ajax'; //$this->layout = 'ajax';
if(!empty($this->data)) { if(!empty($this->data)) {
$this->Shipment->create($this->data); $this->Shipment->create($this->data);

View file

@ -26,8 +26,18 @@ class Shipment extends AppModel {
'className' => 'User', 'className' => 'User',
'foreignKey' => 'user_id', 'foreignKey' => 'user_id',
'conditions' => array('User.type' => 'user') 'conditions' => array('User.type' => 'user')
),
'Customer' => array(
'className' => 'Customer',
'foreignKey' => 'customer_id'
),
'Address' => array(
'className' => 'Address',
'foreignKey' => 'address_id'
) )
); );
var $hasMany = array( 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;
}*/
} }
?> ?>

View file

@ -33,7 +33,7 @@ echo $form->input('id', array('type'=>'hidden'));
<li id="PrincipleID_<?=$principle['id']?>"> <li id="PrincipleID_<?=$principle['id']?>">
<button class="removeFromList">X</button> <button class="removeFromList">X</button>
<?=$principle['name'];?> <?=$principle['name'];?>
<input type="hidden" name="data[Principle][Principle[]" value="<?=$principle['id']?>"> <input type="hidden" name="data[Principle][Principle][]" value="<?=$principle['id']?>">
</li> </li>
<?php endforeach?> <?php endforeach?>
</ul> </ul>
@ -49,7 +49,7 @@ echo $form->input('id', array('type'=>'hidden'));
<li id="PurchaseOrderID_<?=$po['id']?>"> <li id="PurchaseOrderID_<?=$po['id']?>">
<button class="removeFromList">X</button> <button class="removeFromList">X</button>
<?=$po['title'];?> <?=$po['title'];?>
<input type="hidden" name="data[PurchaseOrder][PurchaseOrder[]" value="<?=$po['id']?>"> <input type="hidden" name="data[PurchaseOrder][PurchaseOrder][]" value="<?=$po['id']?>">
</li> </li>
<?php endforeach?> <?php endforeach?>
</ul> </ul>
@ -63,10 +63,10 @@ echo $form->input('id', array('type'=>'hidden'));
<ul id="jobsList" class="habtmList"> <ul id="jobsList" class="habtmList">
<?php foreach($this->data['Job'] as $job):?> <?php foreach($this->data['Job'] as $job):?>
<li id="JobID_<?=$po['job']?>"> <li id="JobID_<?=$job['id']?>">
<button class="removeFromList">X</button> <button class="removeFromList">X</button>
<?=$job['title'];?> <?=$job['title'];?>
<input type="hidden" name="data[PurchaseOrder][PurchaseOrder[]" value="<?=$job['id']?>"> <input type="hidden" name="data[Job][Job][]" value="<?=$job['id']?>">
</li> </li>
<?php endforeach?> <?php endforeach?>
</ul> </ul>
@ -75,14 +75,14 @@ echo $form->input('id', array('type'=>'hidden'));
<div id="customer" class="hiddenDefault"> <div id="customer" class="hiddenDefault">
<?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer'));?> <?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer'));?>
<?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id'));?> <?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?>
</div> </div>
<div id="addressSpan" class="hiddenDefault"> <div id="addressSpan" class="hiddenDefault">
<span>Shipping Address:</span> <span>Shipping Address:</span>
</div> </div>
<div id="address" class="hiddenDefault"> <div id="address" class="hiddenDefault">
<?=$form->input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?>
</div> </div>
@ -101,6 +101,8 @@ echo $form->input('id', array('type'=>'hidden'));
<?php foreach($this->data['Box'] as $box):?> <?php foreach($this->data['Box'] as $box):?>
<div id="" class="boxForm"> <div id="" class="boxForm">
<button class="removeBox">X</button> <button class="removeBox">X</button>
<?=$form->input("Box.{$boxNo}.id", array('type'=>'hidden'));?>
<?=$form->input("Box.{$boxNo}.shipment_id", array('type'=>'hidden', 'value'=>$this->data['Shipment']['id']));?>
<?=$form->input("Box.{$boxNo}.length", array('label'=>'Length (cm)', 'div'=>'length'));?> <?=$form->input("Box.{$boxNo}.length", array('label'=>'Length (cm)', 'div'=>'length'));?>
<?=$form->input("Box.{$boxNo}.width", array('label'=>'Width (cm)', 'div'=>'width'));?> <?=$form->input("Box.{$boxNo}.width", array('label'=>'Width (cm)', 'div'=>'width'));?>
<?=$form->input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?> <?=$form->input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?>

View file

@ -91,12 +91,7 @@
</td> </td>
<td class="boxDimensions"> <td class="boxDimensions">
<?php
//This is nasty. Will fix this once its working.
?>
<?php <?php
$totalWeight = 0; $totalWeight = 0;

View file

@ -392,13 +392,13 @@ th {
text-align: center; text-align: center;
} }
th a { th a {
display: block; display: block;
padding: 2px 4px; padding: 2px 4px;
text-decoration: none; text-decoration: none;
} }
th a:hover { th a:hover {
color: #333; color: #333;
text-decoration: none; text-decoration: none;
} }
@ -1280,7 +1280,7 @@ table.jobsTable tbody {
table.jobsTable tr th { table.jobsTable tr th {
border: 1px solid; border: 1px solid;
font-size: 70%; font-size: 70%;
} }
/** Header Colors for Job table to replaced 'Book1'. */ /** Header Colors for Job table to replaced 'Book1'. */
@ -1428,7 +1428,7 @@ span.year {
} }
tr.cancelled td { tr.cancelled td {
text-decoration: line-through; text-decoration: line-through;
} }
@ -1438,10 +1438,12 @@ tr.cancelled td {
table.shipments tr td { table.shipments tr td {
font-size: 80%; font-size: 80%;
border: 1px solid; border: 1px solid;
white-space: nowrap;
} }
table.shipments tr td.boxDimensions { table.shipments tr td.boxDimensions {
text-align: left; text-align: left;
white-space: nowrap;
} }
@ -1486,7 +1488,7 @@ table.shipments {
} }
span.totalWeight { span.totalWeight {
font-weight: bolder; font-weight: bolder;
} }