Shipment register 95 complete

This commit is contained in:
Karl Cordes 2011-05-09 11:11:23 +10:00
parent 6188e20090
commit 1eb297b035
24 changed files with 419 additions and 470 deletions

View file

@ -47,16 +47,25 @@ class FreightForwardersController extends AppController {
}
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for FreightForwarder', true));
$this->redirect(array('action'=>'index'));
function ajax_add() {
$this->layout = 'ajax';
if(!empty($this->data['Shipment']['newFreightForwarderName'])) {
$this->FreightForwarder->create();
$this->data['FreightForwarder']['name'] = trim($this->data['Shipment']['newFreightForwarderName']);
if($this->FreightForwarder->save($this->data['FreightForwarder'])) {
echo "SUCCESS";
}
if ($this->FreightForwarder->del($id)) {
$this->Session->setFlash(__('FreightForwarder deleted', true));
$this->redirect(array('action'=>'index'));
else {
echo "FAIL";
}
}
}
function build_options() {
$this->layout = 'ajax';
$this->set('freight_forwarders',$this->FreightForwarder->find('list'));
}
}
?>

View file

@ -28,10 +28,10 @@ class ShipmentInvoicesController extends AppController {
}
}
$shipments = $this->ShipmentInvoice->Shipment->find('list');
$freight_forwarders = $this->ShipmentInvoice->FreightForwarder->find('list');
$principles = $this->ShipmentInvoice->Principle->find('list');
$currencies = $this->ShipmentInvoice->Currency->find('list');
$this->set(compact('shipments', 'principles', 'currencies', 'freight_forwarders'));
$freightForwarders = $this->ShipmentInvoice->FreightForwarder->find('list');
$this->set(compact('shipments', 'principles', 'currencies', 'freightForwarders'));
}
function edit($id = null) {
@ -53,7 +53,8 @@ class ShipmentInvoicesController extends AppController {
$shipments = $this->ShipmentInvoice->Shipment->find('list');
$principles = $this->ShipmentInvoice->Principle->find('list');
$currencies = $this->ShipmentInvoice->Currency->find('list');
$this->set(compact('shipments','principles','currencies'));
$freightForwarders = $this->ShipmentInvoice->FreightForwarder->find('list');
$this->set(compact('shipments','principles','currencies','freightForwarders'));
}
function delete($id = null) {

View file

@ -66,7 +66,9 @@ class ShipmentsController extends AppController {
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
$shipmentType = $this->typeOptions(false);
$shipmentTypeShort = $this->typeOptions(true);
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort'));
$currencies = $this->Shipment->ShipmentInvoice->Currency->find('list');
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies'));
}
@ -84,7 +86,10 @@ class ShipmentsController extends AppController {
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
$shipmentType = $this->typeOptions(false);
$shipmentTypeShort = $this->typeOptions(true);
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort'));
$currencies = $this->Shipment->ShipmentInvoice->Currency->find('list');
$invoiceType = $this->invoiceTypeOptions();
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies','invoiceType', 'yesNo'));
}
@ -97,7 +102,8 @@ class ShipmentsController extends AppController {
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
$shipmentType = $this->typeOptions(false);
$shipmentTypeShort = $this->typeOptions(true);
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort'));
$currencies = $this->Shipment->ShipmentInvoice->Currency->find('list');
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies'));
}
@ -116,13 +122,14 @@ class ShipmentsController extends AppController {
$boxIDs = array();
foreach($this->data['Box'] as $box) {
$boxIDs[] = $box['id'];
}
$invoiceIDs = array();
foreach($this->data['ShipmentInvoice'] as $si) {
$invoiceIDs[] = $si['id'];
}
print_r($boxIDs);
@ -173,6 +180,12 @@ class ShipmentsController extends AppController {
}*/
function invoiceTypeOptions() {
$options = array('', 'Freight','Customs','Principle');
return $options;
}
function typeOptions($short = false) {
if($short == false) {
$options = array('','Import: Principle to CMC','Direct: Principle to Customer','Export','Local');

View file

@ -51,6 +51,11 @@ class Job extends AppModel {
'Email' => array(
'className' => 'Email',
'joinTable' => 'emails_jobs',
),
'Shipment' => array(
'className' => 'Shipment',
'joinTable' => 'shipments_jobs',
)
);

View file

@ -2,13 +2,6 @@
class ShipmentInvoice extends AppModel {
var $name = 'ShipmentInvoice';
/*var $validate = array(
'shipment_id' => array('numeric'),
'principle_id' => array('numeric'),
'currency_id' => array('numeric'),
'invoice_number' => array('notempty'),
'approved' => array('numeric')
);*/
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
@ -18,7 +11,7 @@ class ShipmentInvoice extends AppModel {
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache'=>true
'counterCache' => 'shipment_invoice_count',
),
'Principle' => array(
'className' => 'Principle',
@ -27,17 +20,19 @@ class ShipmentInvoice extends AppModel {
'fields' => '',
'order' => ''
),
'FreightForwarder' => array(
'className' => 'FreightForwarder',
'foreignKey' => 'freight_forwarder_id'
),
'Currency' => array(
'className' => 'Currency',
'foreignKey' => 'currency_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'FreightForwarder' => array(
'className' => 'FreightForwarder',
'foreignKey' => 'freight_forwarder_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);

View file

@ -0,0 +1,186 @@
<?php echo $form->create('Shipment', array('default'=>false));?>
<?php
echo $form->input('user_id', array('type'=>'hidden', 'value'=>$currentuser['User']['id']));
echo $form->input('type', array('options'=>$shipmentType, 'id'=>'shipmentType'));
echo $form->input('id', array('type'=>'hidden'));
?>
<div id="importFields" class="hiddenDefault">
<?
echo $form->input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_arrived']))));
echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived'));
?>
</div>
<div id="dateDispatched" class="hiddenDefault">
<?
echo $form->input('date_dispatched_display', array('label'=>'Date Dispatched', 'id'=>'date_dispatched_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_dispatched']))));
echo $form->input('date_dispatched', array('type'=>'hidden', 'id'=>'date_dispatched'));
?>
</div>
<div id="principle" class="hiddenDefault">
<? echo $form->input('Principle', array('name'=>'PrincipleSelect', 'type'=>'select', 'multiple'=>false)); ?>
<button id="addPrinciple">Add Principle to this Shipment</button>
<ul id="principlesList" class="habtmList">
<?php foreach($this->data['Principle'] as $principle):?>
<li id="PrincipleID_<?=$principle['id']?>">
<button class="removeFromList">X</button>
<?=$principle['name'];?>
<input type="hidden" name="data[Principle][Principle][]" value="<?=$principle['id']?>">
</li>
<?php endforeach?>
</ul>
</div>
<div id="purchaseOrder" class="hiddenDefault">
<?
echo $form->input('purchase_order', array('id'=>'purchase_order_autocomplete' ,'label'=>'Purchase Order (start typing and select from the list)'));?>
<ul id="purchaseOrdersList" class="habtmList">
<?php foreach($this->data['PurchaseOrder'] as $po):?>
<li id="PurchaseOrderID_<?=$po['id']?>">
<button class="removeFromList">X</button>
<?=$po['title'];?>
<input type="hidden" name="data[PurchaseOrder][PurchaseOrder][]" value="<?=$po['id']?>">
</li>
<?php endforeach?>
</ul>
</div>
<div id="job" class="hiddenDefault">
<?
echo $form->input('job', array('id'=>'job_autocomplete'));
?>
<ul id="jobsList" class="habtmList">
<?php foreach($this->data['Job'] as $job):?>
<li id="JobID_<?=$job['id']?>">
<button class="removeFromList">X</button>
<?=$job['title'];?>
<input type="hidden" name="data[Job][Job][]" value="<?=$job['id']?>">
</li>
<?php endforeach?>
</ul>
</div>
<div id="customer" class="hiddenDefault">
<?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer', 'value'=>$this->data['Customer']['name']));?>
<?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?>
</div>
<div id="addressSpan" class="hiddenDefault">
<span>Shipping Address:</span>
</div>
<div id="address" class="hiddenDefault">
<?=$form->input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?>
</div>
<div id="freight_forwarder" class="hiddenDefault">
<?=$form->input('freight_forwarder_id');?>
<button class="addFreightForwarder hiddenDefault">Add Freight Forwarder</button>
<div id="newFreightForwarderDiv" class="hiddenDefault">
<?=$form->input('newFreightForwarderName');?>
<button class="saveNewFF">Save</button>
<button class="cancelNewFF">Cancel</button>
</div>
</div>
<div id="airway_bill" class="hiddenDefault">
<?=$form->input('airway_bill');?>
</div>
<div id="boxes" class="hiddenDefault">
<button id="addBox">Add Box</button>
<?php $boxNo = 0;?>
<?php foreach($this->data['Box'] as $box):?>
<div id="" class="boxForm">
<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}.width", array('label'=>'Width (cm)', 'div'=>'width'));?>
<?=$form->input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?>
<?=$form->input("Box.{$boxNo}.weight", array('label'=>'Weight (kg)', 'div'=>'weight'));?>
</div>
<?php
$boxNo++;
endforeach;?>
</div>
<div id="invoices" class="hiddenDefault">
<button id="addInvoice">Add Invoice</button>
<?
$invNo = 0;
?>
<?
foreach($this->data['ShipmentInvoice'] as $invoice):?>
<div class="invForm">
<button class="removeInvoice">X</button>
<?
echo $form->input("ShipmentInvoice.{$invNo}.id", array('type'=>'hidden'));
echo $form->input("ShipmentInvoice.{$invNo}.shipment_id", array('type'=>'hidden', 'value'=>$this->data['Shipment']['id']));
echo $form->input("ShipmentInvoice.{$invNo}.currency_id");
echo $form->input("ShipmentInvoice.{$invNo}.freight_forwarder_id");
echo $form->input("ShipmentInvoice.{$invNo}.invoice_number");
echo $form->input("ShipmentInvoice.{$invNo}.invoice_amount");
echo $form->input("ShipmentInvoice.{$invNo}.gst_amount");
echo $form->input("ShipmentInvoice.{$invNo}.deferred_gst");
echo $form->input("ShipmentInvoice.{$invNo}.approved");
echo $form->input("ShipmentInvoice.{$invNo}.paid");
echo $form->input("ShipmentInvoice.{$invNo}.date_paid");
echo $form->input("ShipmentInvoice.{$invNo}.invoice_type");
?>
</div>
<?
$invNo++;
endforeach;?>
</div>
<div id="comments" class="hiddenDefault">
<?=$form->input('comments');?>
</div>
<?php echo $form->end();?>
<div id="boxFactory" class="hiddenDefault">
<?=$form->input('length', array('label'=>'Length (cm)', 'div'=>'length'));?>
<?=$form->input('width', array('label'=>'Width (cm)', 'div'=>'width'));?>
<?=$form->input('height', array('label'=>'Height (cm)', 'div'=>'height'));?>
<?=$form->input('weight', array('label'=>'Weight (kg)', 'div'=>'weight'));?>
</div>
<div id="invoiceFactory" class="hiddenDefault">
<?
echo $form->input("invoice_type", array('type'=>'select','label'=>'Invoice Type', 'div'=>'inv_invoice_type', 'options'=>$invoiceType));
echo $form->input("currency_id",array('label'=>'Currency', 'div'=>'inv_currency_id', 'options'=>$currencies));
echo $form->input("freight_forwarder_id", array('label'=>'Freight Forwarder', 'div'=>'inv_freight_forwarder_id', 'options'=>$freightForwarders));
echo $form->input("invoice_number", array('label'=>'Invoice Number', 'div'=>'inv_invoice_number'));
echo $form->input("invoice_amount", array('label'=>'Invoice Amount', 'div'=>'inv_invoice_amount'));
echo $form->input("gst_amount", array('label'=>'GST Amount', 'div'=>'inv_gst_amount'));
echo $form->input("deferred_gst", array('label'=>'Deferred GST?', 'div'=>'inv_deferred_gst', 'options'=>$yesNo));
echo $form->input("deferred_gst_amount", array('label'=>'Deferred GST Amount', 'div'=>'inv_deferred_gst_amount'));
echo $form->input("approved", array('label'=>'Approved', 'div'=>'inv_approved'));
echo $form->input("paid", array('label'=>'Paid', 'div'=>'inv_paid'));
echo $form->input("date_paid", array('label'=>'Date Paid', 'div'=>'inv_date_paid'));
?>
</div>

View file

@ -1,92 +0,0 @@
<?php echo $form->create('Shipment', array('default'=>false));?>
<?php
echo $form->input('user_id', array('type'=>'hidden', 'value'=>$currentuser['User']['id']));
echo $form->input('type', array('options'=>$shipmentType, 'id'=>'shipmentType'));
echo $form->input('id', array('type'=>'hidden'));
?>
<div id="importFields" class="hiddenDefault">
<?
echo $form->input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display'));
echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived'));
?>
</div>
<div id="dateDispatched" class="hiddenDefault">
<?
echo $form->input('date_dispatched_display', array('label'=>'Date dispatched', 'id'=>'date_dispatched_display'));
echo $form->input('date_dispatched', array('type'=>'hidden', 'id'=>'date_dispatched'));
?>
</div>
<div id="principle" class="hiddenDefault">
<? echo $form->input('Principle', array('name'=>'PrincipleSelect', 'type'=>'select', 'multiple'=>false)); ?>
<button id="addPrinciple">Add Principle</button>
<ul id="principlesList" class="habtmList">
</ul>
</div>
<div id="purchaseOrder" class="hiddenDefault">
<?
echo $form->input('purchase_order', array('id'=>'purchase_order_autocomplete'));?>
<ul id="purchaseOrdersList" class="habtmList">
</ul>
</div>
<div id="job" class="hiddenDefault">
<?
echo $form->input('job', array('id'=>'job_autocomplete'));
?>
<ul id="jobsList" class="habtmList">
</ul>
</div>
<div id="customer" class="hiddenDefault">
<?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer'));?>
<?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id'));?>
</div>
<div id="addressSpan" class="hiddenDefault">
<span>Shipping Address:</span>
</div>
<div id="address" class="hiddenDefault">
</div>
<div id="freight_forwarder" class="hiddenDefault">
<?=$form->input('freight_forwarder_id');?>
</div>
<div id="airway_bill" class="hiddenDefault">
<?=$form->input('airway_bill');?>
</div>
<div id="boxes" class="hiddenDefault">
<button id="addBox">Add Box</button>
</div>
<div id="comments" class="hiddenDefault">
<?=$form->input('comments');?>
</div>
<?php echo $form->end();?>
<div id="boxFactory" class="hiddenDefault">
<?=$form->input('Box.0.length', array('label'=>'Length (cm)', 'div'=>'length'));?>
<?=$form->input('Box.0.width', array('label'=>'Width (cm)', 'div'=>'width'));?>
<?=$form->input('Box.0.height', array('label'=>'Height (cm)', 'div'=>'height'));?>
<?=$form->input('Box.0.weight', array('label'=>'Weight (kg)', 'div'=>'weight'));?>
</div>

View file

@ -1,6 +1,10 @@
<?php
if($date == "0000-00-00") {
if(empty($date)) {
echo "";
}
else if($date == "0000-00-00") {
echo "";
}
else {

View file

@ -13,9 +13,16 @@
</th>
<th>Weight (kg)</th>
<th><?php echo $paginator->sort('freight_forwarder_id');?></th>
<th><?php echo $paginator->sort('airway_bill');?></th>
<th># Invoices</th>
<th>Issued By</th>
<th>Invoice Amount</th>
<th>Deferred GST</th>
<th>Approved?</th>
<th>Paid?</th>
<th>Date Paid</th>
<th><?php echo $paginator->sort('comments');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
@ -110,6 +117,20 @@
<td>
<?php echo $shipment['Shipment']['airway_bill']; ?>
</td>
<td>
<?=$shipment['Shipment']['shipment_invoice_count'];?>
</td>
<td>Issued By Principle/FF name
</td>
<td>Invoice amount</td>
<td>Deferred GST amount</td>
<td>Approved?</td>
<td>Paid</td>
<td>Date Paid</td>
<td>
<?php echo $shipment['Shipment']['comments']; ?>
</td>

View file

@ -1,7 +1,6 @@
<table cellpadding="0" cellspacing="0" class="shipments">
<tr>
<th class="actions"><?php __('Actions');?></th>
<th><?php echo $paginator->sort('date_arrived');?></th>
<th><?php echo $paginator->sort('date_dispatched');?></th>
<th><?php echo $paginator->sort('type');?></th>
<th>Principle(s)</th>
@ -28,11 +27,6 @@
<button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived']));
?>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched']));

View file

@ -1,12 +1,9 @@
<table cellpadding="0" cellspacing="0" class="shipments">
<tr>
<th class="actions"><?php __('Actions');?></th>
<th><?php echo $paginator->sort('date_arrived');?></th>
<th><?php echo $paginator->sort('date_dispatched');?></th>
<th><?php echo $paginator->sort('type');?></th>
<th>Principle(s)</th>
<th>PO(s)</th>
<th>Jobs</th>
<th>Job(s)</th>
<th><?php echo $paginator->sort('# Boxes','box_count');?></th>
<th>Box Details<br>
LxWxH (cm)
@ -28,11 +25,6 @@
<button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived']));
?>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched']));
@ -43,27 +35,6 @@
<?php echo $shipmentTypeShort[$shipment['Shipment']['type']]; ?>
</td>
<td>
<?php foreach($shipment['Principle'] as $principle):?>
<? if(!empty($principle['short_name'])) {
echo $html->link($principle['short_name'], array('controller'=>'principles','action'=>'view',$principle['id']));
}
else {
echo $html->link($principle['name'], array('controller'=>'principles','action'=>'view',$principle['id']));
}
?>
<br>
<?php endforeach;?>
</td>
<td>
<?php foreach($shipment['PurchaseOrder'] as $po):?>
<?=$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));?>
<br>
<?endforeach;?>
</td>
<td>
<?php foreach($shipment['Job'] as $job):?>
<?=$html->link($job['title'], array('controller'=>'jobs', 'action'=>'view', $job['id']));?>

View file

@ -2,11 +2,9 @@
<tr>
<th class="actions"><?php __('Actions');?></th>
<th><?php echo $paginator->sort('date_arrived');?></th>
<th><?php echo $paginator->sort('date_dispatched');?></th>
<th><?php echo $paginator->sort('type');?></th>
<th>Principle(s)</th>
<th>PO(s)</th>
<th>Jobs</th>
<th><?php echo $paginator->sort('# Boxes','box_count');?></th>
<th>Box Details<br>
LxWxH (cm)
@ -33,11 +31,6 @@
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived']));
?>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched']));
?>
</td>
<td>
<?php echo $shipmentTypeShort[$shipment['Shipment']['type']]; ?>
@ -64,12 +57,6 @@
<?endforeach;?>
</td>
<td>
<?php foreach($shipment['Job'] as $job):?>
<?=$html->link($job['title'], array('controller'=>'jobs', 'action'=>'view', $job['id']));?>
<br>
<?endforeach;?>
</td>
<td>
<?php echo $shipment['Shipment']['box_count']; ?>

View file

@ -1,11 +1,8 @@
<table cellpadding="0" cellspacing="0" class="shipments">
<tr>
<th class="actions"><?php __('Actions');?></th>
<th><?php echo $paginator->sort('date_arrived');?></th>
<th><?php echo $paginator->sort('date_dispatched');?></th>
<th><?php echo $paginator->sort('type');?></th>
<th>Principle(s)</th>
<th>PO(s)</th>
<th>Jobs</th>
<th><?php echo $paginator->sort('# Boxes','box_count');?></th>
<th>Box Details<br>
@ -28,11 +25,6 @@
<button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived']));
?>
</td>
<td>
<?php
echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched']));
@ -43,27 +35,6 @@
<?php echo $shipmentTypeShort[$shipment['Shipment']['type']]; ?>
</td>
<td>
<?php foreach($shipment['Principle'] as $principle):?>
<? if(!empty($principle['short_name'])) {
echo $html->link($principle['short_name'], array('controller'=>'principles','action'=>'view',$principle['id']));
}
else {
echo $html->link($principle['name'], array('controller'=>'principles','action'=>'view',$principle['id']));
}
?>
<br>
<?php endforeach;?>
</td>
<td>
<?php foreach($shipment['PurchaseOrder'] as $po):?>
<?=$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));?>
<br>
<?endforeach;?>
</td>
<td>
<?php foreach($shipment['Job'] as $job):?>
<?=$html->link($job['title'], array('controller'=>'jobs', 'action'=>'view', $job['id']));?>

View file

@ -56,11 +56,6 @@
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit Job', true), array('action' => 'edit', $job['Job']['id'])); ?> </li>
<li><?php echo $html->link(__('Delete Job', true), array('action' => 'delete', $job['Job']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $job['Job']['id'])); ?> </li>
<li><?php echo $html->link(__('List Jobs', true), array('action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Job', true), array('action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -18,6 +18,7 @@
<th>Net Sales AUD</th>
<th>Gross Profit AUD</th>
<th>Net Export Sales Converted to Or Invoiced in AUD</th>
<th>Gross Profit Value Export in AUD</th>
<th>GP% Excl Commissions</th>
<th>ATO Exchange Rate</th>

View file

@ -11,6 +11,8 @@
echo $form->input('invoice_amount');
echo $form->input('deferred_gst');
echo $form->input('approved');
echo $form->input('paid');
echo $form->input('date_paid');
echo $form->input('invoice_type');
?>
</fieldset>
@ -19,13 +21,5 @@
<div class="actions">
<ul>
<li><?php echo $html->link(__('List ShipmentInvoices', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -12,6 +12,8 @@
echo $form->input('invoice_amount');
echo $form->input('deferred_gst');
echo $form->input('approved');
echo $form->input('paid');
echo $form->input('date_paid');
echo $form->input('invoice_type');
?>
</fieldset>
@ -21,13 +23,5 @@
<ul>
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('ShipmentInvoice.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('ShipmentInvoice.id'))); ?></li>
<li><?php echo $html->link(__('List ShipmentInvoices', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -17,6 +17,8 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('invoice_amount');?></th>
<th><?php echo $paginator->sort('deferred_gst');?></th>
<th><?php echo $paginator->sort('approved');?></th>
<th><?php echo $paginator->sort('paid');?></th>
<th><?php echo $paginator->sort('date_paid');?></th>
<th><?php echo $paginator->sort('invoice_type');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
@ -33,16 +35,16 @@ foreach ($shipmentInvoices as $shipmentInvoice):
<?php echo $shipmentInvoice['ShipmentInvoice']['id']; ?>
</td>
<td>
<?php echo $html->link($shipmentInvoice['Shipment']['id'], array('controller' => 'shipments', 'action' => 'view', $shipmentInvoice['Shipment']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['shipment_id']; ?>
</td>
<td>
<?php echo $html->link($shipmentInvoice['Principle']['name'], array('controller' => 'principles', 'action' => 'view', $shipmentInvoice['Principle']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['principle_id']; ?>
</td>
<td>
<?php echo $html->link($shipmentInvoice['Currency']['name'], array('controller' => 'currencies', 'action' => 'view', $shipmentInvoice['Currency']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['currency_id']; ?>
</td>
<td>
<?php echo $html->link($shipmentInvoice['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipmentInvoice['FreightForwarder']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['freight_forwarder_id']; ?>
</td>
<td>
<?php echo $shipmentInvoice['ShipmentInvoice']['invoice_number']; ?>
@ -56,6 +58,12 @@ foreach ($shipmentInvoices as $shipmentInvoice):
<td>
<?php echo $shipmentInvoice['ShipmentInvoice']['approved']; ?>
</td>
<td>
<?php echo $shipmentInvoice['ShipmentInvoice']['paid']; ?>
</td>
<td>
<?php echo $shipmentInvoice['ShipmentInvoice']['date_paid']; ?>
</td>
<td>
<?php echo $shipmentInvoice['ShipmentInvoice']['invoice_type']; ?>
</td>
@ -76,13 +84,5 @@ foreach ($shipmentInvoices as $shipmentInvoice):
<div class="actions">
<ul>
<li><?php echo $html->link(__('New ShipmentInvoice', true), array('action' => 'add')); ?></li>
<li><?php echo $html->link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -6,24 +6,24 @@
<?php echo $shipmentInvoice['ShipmentInvoice']['id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipment'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipment Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($shipmentInvoice['Shipment']['id'], array('controller' => 'shipments', 'action' => 'view', $shipmentInvoice['Shipment']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['shipment_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($shipmentInvoice['Principle']['name'], array('controller' => 'principles', 'action' => 'view', $shipmentInvoice['Principle']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['principle_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Currency'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Currency Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($shipmentInvoice['Currency']['name'], array('controller' => 'currencies', 'action' => 'view', $shipmentInvoice['Currency']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['currency_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Freight Forwarder'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Freight Forwarder Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($shipmentInvoice['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipmentInvoice['FreightForwarder']['id'])); ?>
<?php echo $shipmentInvoice['ShipmentInvoice']['freight_forwarder_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Invoice Number'); ?></dt>
@ -46,6 +46,16 @@
<?php echo $shipmentInvoice['ShipmentInvoice']['approved']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Paid'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $shipmentInvoice['ShipmentInvoice']['paid']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Date Paid'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $shipmentInvoice['ShipmentInvoice']['date_paid']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Invoice Type'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $shipmentInvoice['ShipmentInvoice']['invoice_type']; ?>
@ -59,13 +69,5 @@
<li><?php echo $html->link(__('Delete ShipmentInvoice', true), array('action' => 'delete', $shipmentInvoice['ShipmentInvoice']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $shipmentInvoice['ShipmentInvoice']['id'])); ?> </li>
<li><?php echo $html->link(__('List ShipmentInvoices', true), array('action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New ShipmentInvoice', true), array('action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Shipments', true), array('controller' => 'shipments', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Shipment', true), array('controller' => 'shipments', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Freight Forwarders', true), array('controller' => 'freight_forwarders', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Freight Forwarder', true), array('controller' => 'freight_forwarders', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -1,2 +1,2 @@
<?=$javascript->link('add_edit_shipment');?>
<?=$this->element('add_shipment');?>
<?=$this->element('add_edit_shipment', array('invoiceType'=>$invoiceType));?>

View file

@ -1,133 +1,5 @@
<?=$javascript->link('add_edit_shipment');?>
<?php echo $form->create('Shipment', array('default'=>false));?>
<?php
echo $form->input('user_id', array('type'=>'hidden', 'value'=>$currentuser['User']['id']));
echo $form->input('type', array('options'=>$shipmentType, 'id'=>'shipmentType'));
echo $form->input('id', array('type'=>'hidden'));
?>
<div id="importFields" class="hiddenDefault">
<?
echo $form->input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_arrived']))));
echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived'));
?>
</div>
<div id="dateDispatched" class="hiddenDefault">
<?
echo $form->input('date_dispatched_display', array('label'=>'Date Dispatched', 'id'=>'date_dispatched_display', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Shipment']['date_dispatched']))));
echo $form->input('date_dispatched', array('type'=>'hidden', 'id'=>'date_dispatched'));
?>
</div>
<div id="principle" class="hiddenDefault">
<? echo $form->input('Principle', array('name'=>'PrincipleSelect', 'type'=>'select', 'multiple'=>false)); ?>
<button id="addPrinciple">Add Principle</button>
<ul id="principlesList" class="habtmList">
<?php foreach($this->data['Principle'] as $principle):?>
<li id="PrincipleID_<?=$principle['id']?>">
<button class="removeFromList">X</button>
<?=$principle['name'];?>
<input type="hidden" name="data[Principle][Principle][]" value="<?=$principle['id']?>">
</li>
<?php endforeach?>
</ul>
</div>
<div id="purchaseOrder" class="hiddenDefault">
<?
echo $form->input('purchase_order', array('id'=>'purchase_order_autocomplete'));?>
<ul id="purchaseOrdersList" class="habtmList">
<?php foreach($this->data['PurchaseOrder'] as $po):?>
<li id="PurchaseOrderID_<?=$po['id']?>">
<button class="removeFromList">X</button>
<?=$po['title'];?>
<input type="hidden" name="data[PurchaseOrder][PurchaseOrder][]" value="<?=$po['id']?>">
</li>
<?php endforeach?>
</ul>
</div>
<div id="job" class="hiddenDefault">
<?
echo $form->input('job', array('id'=>'job_autocomplete'));
?>
<ul id="jobsList" class="habtmList">
<?php foreach($this->data['Job'] as $job):?>
<li id="JobID_<?=$job['id']?>">
<button class="removeFromList">X</button>
<?=$job['title'];?>
<input type="hidden" name="data[Job][Job][]" value="<?=$job['id']?>">
</li>
<?php endforeach?>
</ul>
</div>
<div id="customer" class="hiddenDefault">
<?=$form->input('customer', array('id'=>'customer_autocomplete', 'label'=>'Customer', 'value'=>$this->data['Customer']['name']));?>
<?=$form->input('customer_id', array('type'=>'hidden', 'id'=>'customer_id', 'value'=>$this->data['Shipment']['customer_id']));?>
</div>
<div id="addressSpan" class="hiddenDefault">
<span>Shipping Address:</span>
</div>
<div id="address" class="hiddenDefault">
<?=$form->input('address_id', array('type'=>'hidden', 'id'=>'address_id', 'value'=>$this->data['Shipment']['address_id']));?>
</div>
<div id="freight_forwarder" class="hiddenDefault">
<?=$form->input('freight_forwarder_id');?>
</div>
<div id="airway_bill" class="hiddenDefault">
<?=$form->input('airway_bill');?>
</div>
<div id="boxes" class="hiddenDefault">
<button id="addBox">Add Box</button>
<?php $boxNo = 0;?>
<?php foreach($this->data['Box'] as $box):?>
<div id="" class="boxForm">
<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}.width", array('label'=>'Width (cm)', 'div'=>'width'));?>
<?=$form->input("Box.{$boxNo}.height", array('label'=>'Height (cm)', 'div'=>'height'));?>
<?=$form->input("Box.{$boxNo}.weight", array('label'=>'Weight (kg)', 'div'=>'weight'));?>
</div>
<?php
$boxNo++;
endforeach;?>
</div>
<div id="comments" class="hiddenDefault">
<?=$form->input('comments');?>
</div>
<?php echo $form->end();?>
<div id="boxFactory" class="hiddenDefault">
<?=$form->input('length', array('label'=>'Length (cm)', 'div'=>'length'));?>
<?=$form->input('width', array('label'=>'Width (cm)', 'div'=>'width'));?>
<?=$form->input('height', array('label'=>'Height (cm)', 'div'=>'height'));?>
<?=$form->input('weight', array('label'=>'Weight (kg)', 'div'=>'weight'));?>
</div>
<?=$this->element('add_edit_shipment', array('invoiceType'=>$invoiceType));?>
<?php debug($this->data); ?>

View file

@ -15,7 +15,8 @@
<div class="scrollHorizontal">
<?=$this->element('shipment_index_'.$type);?>
<? //$this->element('shipment_index_'.$type);?>
<?=$this->element('shipment_index_all');?>
</div>
</div>

View file

@ -1183,45 +1183,6 @@ label span#exchangeConversion {
}
form.cmxform {
width: 80%;
}
form.cmxform input {
width: auto;
display: inline;
}
form.cmxform fieldset ol {
margin: 0;
padding: 0;
}
form.cmxform fieldset li {
list-style: none;
padding: 5px;
margin: 0;
}
form.cmxform fieldset fieldset {
border: none;
margin: 3px 0 0;
}
form.cmxform fieldset fieldset legend {
padding: 0 0 5px;
font-weight: normal;
}
form.cmxform fieldset fieldset label {
display: block;
}
form.cmxform em {
font-weight: bold;
font-style: normal;
color: #f00;
}
form.cmxform fieldset fieldset label {
margin-left: 123px; /* Width plus 3 (html space) */
}
#sortable { list-style-type: none; margin: 0; padding: 0; }
@ -1377,7 +1338,7 @@ select.job_status {
.scrollHorizontal {
height: 800px;
height: 500px;
overflow:scroll;
}
@ -1477,16 +1438,17 @@ table.shipments {
width: 50px;
}
.boxForm label {
float: left;
margin-right: 1em;
text-align: right;
width: 8em;
}
.boxForm div {
}
.invForm {
border: 1px solid;
width: 15em;
margin-top: 1em;
}
span.totalWeight {
font-weight: bolder;

View file

@ -1,6 +1,9 @@
$(function() {
var addedBoxes = $(".boxForm").length;
var addedInvoices = $('.invForm').length;
$('button').button();
displayReleventFields();
@ -32,8 +35,33 @@ $(function() {
$(this).parent().remove();
});
//Add a new Freight Forwarder.
$('.addFreightForwarder').live('click', function() {
$('#newFreightForwarderDiv').show();
$(this).hide();
});
//Cancel adding a new Freight Forwarder.
$('.cancelNewFF').live('click', function() {
$('#newFreightForwarderDiv').hide();
$('.addFreightForwarder').show();
});
//Save the new Freight Forwarder. **TODO : Handle errors **.
$('.saveNewFF').live('click', function() {
$.post('/freight_forwarders/ajax_add', $('#newFreightForwarder'), function(data) {
if(data == 'SUCCESS') {
$.get('/freight_forwarders/build_options', function(newOptions) {
$('#ShipmentFreightForwarderId').html(newOptions);
$('#newFreightForwarderDiv').hide();
$('.addFreightForwarder').show();
});
}
});
});
//Add a(nother) Principle to this Shipment
$('#addPrinciple').button().click(function() {
var principleID = getSelectedID('#PrinciplePrinciple');
@ -106,6 +134,17 @@ $(function() {
});
$("#addInvoice").button().click(function() {
addInvoice(addedInvoices);
addedInvoices++;
});
$(".removeInvoice").live('click',function() {
$(this).parent().remove();
});
$(".selectAddress").live('click', function() {
var ID = $(this).attr('id');
$("#address_id").val(ID);
@ -147,25 +186,29 @@ $(function() {
switch(shipmentTypeID) {
case 1: //Import
$("#importFields, #principle, #purchaseOrder, #freight_forwarder, #airway_bill, #boxes").show();
$("#importFields, #principle, #purchaseOrder").show();
showCommonFields();
break;
case 2: //Direct
$("#purchaseOrder, #job,#principle, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show();
$("#purchaseOrder, #job,#principle, #dateDispatched, #customer, #address, #addressSpan").show();
showCommonFields();
break;
case 3: //Export
$("#job, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show();
$("#job, #dateDispatched, #customer, #address, #addressSpan").show();
showCommonFields();
break;
case 4: //Local
$("#job, #dateDispatched, #customer, #address, #addressSpan, #freight_forwarder, #airway_bill, #boxes").show();
break;
default:
$("#job, #dateDispatched, #customer, #address, #addressSpan").show();
showCommonFields();
break;
}
}
//Show the fields in the shipment form that are available
//for all 4 cases
function showCommonFields() {
$("#airway_bill, #boxes, #invoices, #freight_forwarder, #comments").show();
}
function addBox(addedBoxes) {
@ -176,39 +219,24 @@ $(function() {
var boxNo = addedBoxes;
newBoxForm.attr('id','');
newBoxForm.removeAttr('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');
var boxFields = ['length', 'width', 'height', 'weight'];
var div;
var ID;
var name;
$.each(boxFields, function(index, field) {
div = newBoxForm.find('.'+field);
ID = getCakeID(model,boxNo,field);
name = getCakeName(model, boxNo, field);
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 = $('<button>X</button>');
closeButton.addClass('removeBox');
@ -220,6 +248,41 @@ $(function() {
}
function addInvoice(addedInvoices) {
var model = 'ShipmentInvoice';
var invoiceNo = addedInvoices;
var newInvoiceForm = $('#invoiceFactory').clone();
newInvoiceForm.removeAttr('id');
newInvoiceForm.addClass('invForm');
newInvoiceForm.show();
var invFields = ['currency_id', 'freight_forwarder_id', 'invoice_number',
'invoice_amount','gst_amount','deferred_gst', 'deferred_gst_amount','approved', 'paid', 'date_paid','invoice_type'];
var div;
var ID;
$.each(invFields, function(index,field) {
div = newInvoiceForm.find('.inv_'+field);
ID = getCakeID(model,invoiceNo, field);
name = getCakeName(model, invoiceNo, field);
div.children('label').attr('for', ID);
div.children('input').attr('id', ID).attr('name', name);
});
var closeButton = $('<button>X</button>');
closeButton.addClass('removeBox');
closeButton.button();
newInvoiceForm.prepend(closeButton);
$("#invoices").append(newInvoiceForm);
}
function getCakeID(model, count, field) {
return model+count+capitalizeFirstLetter(field);
}