Shipment progress
This commit is contained in:
parent
ecd06c4f9d
commit
1bb9d77faf
|
|
@ -9,6 +9,12 @@ class BoxesController extends AppController {
|
|||
$this->set('boxes', $this->paginate());
|
||||
}
|
||||
|
||||
|
||||
function buildForm($count = 0) {
|
||||
$this->layout = 'ajax';
|
||||
$this->set('count', $count);
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid Box.', true));
|
||||
|
|
|
|||
|
|
@ -386,110 +386,6 @@ class JobsController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function add() {
|
||||
|
||||
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$this->Job->create();
|
||||
|
||||
$job_offset = 6141;
|
||||
|
||||
$number_of_jobs = $this->Job->findCount();
|
||||
$new_job_number = $job_offset + $number_of_jobs;
|
||||
|
||||
$enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']);
|
||||
|
||||
|
||||
|
||||
$monthYearShort = strtoupper(date("My"));
|
||||
|
||||
$jobLetter = $enquiry['State']['enqform'];
|
||||
|
||||
$this->data['Job']['title'] = $monthYearShort.$jobLetter."J".$new_job_number;
|
||||
$this->data['Job']['state_id'] = $enquiry['Enquiry']['state_id'];
|
||||
$this->data['Job']['customer_id'] = $enquiry['Enquiry']['customer_id'];
|
||||
$this->data['Job']['contact_id'] = $enquiry['Enquiry']['contact_id'];
|
||||
|
||||
|
||||
|
||||
if ($this->Job->save($this->data)) {
|
||||
$jobid = $this->Job->id;
|
||||
|
||||
//$this->Job->Enquiry->set('status_id', 3); //Change status to 'Job Won';
|
||||
$enquiry['Enquiry']['status_id'] = 3;
|
||||
|
||||
$this->Job->Enquiry->save($enquiry);
|
||||
|
||||
|
||||
$this->Session->setFlash(__('Job Saved', true));
|
||||
$this->redirect(array('action'=>'view', $jobid));
|
||||
} else {
|
||||
$this->Session->setFlash(__('Please Fix the Errors Below', true));
|
||||
$enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']);
|
||||
$this->set(compact('enquiry'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(isset($this->params['named']['enquiryid'])) {
|
||||
|
||||
$enquiry = $this->Job->Enquiry->findById($this->params['named']['enquiryid']);
|
||||
|
||||
$this->set(compact('enquiry'));
|
||||
}
|
||||
else {
|
||||
$this->Session->setFlash(__('Invalid Enquiry ID', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
}
|
||||
|
||||
$freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer");
|
||||
$this->set('freight_paid_options', $freight_paid_options);
|
||||
|
||||
$sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION");
|
||||
$this->set('sale_category_options', $sale_category_options);
|
||||
$this->set('shipment_category_options', $this->shipment_category_options());
|
||||
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->flash(__('Invalid Job', true), array('action'=>'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
$jobid = $this->data['Job']['id'];
|
||||
if ($this->Job->save($this->data)) {
|
||||
// $this->flash(__('The Job has been saved.', true), array('action'=>'view', $jobid));
|
||||
|
||||
$this->Session->setFlash(__('The Job has been saved', true));
|
||||
|
||||
$this->redirect(array('action' =>'view/'.$jobid), null, false);
|
||||
|
||||
} else {
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$job = $this->Job->read(null, $id);
|
||||
$this->data = $job;
|
||||
$this->set('currencies', $this->Job->Currency->find('list'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer");
|
||||
$this->set('freight_paid_options', $freight_paid_options);
|
||||
|
||||
$sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION");
|
||||
$this->set('sale_category_options', $sale_category_options);
|
||||
$this->set('shipment_category_options', $this->shipment_category_options());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function __isNotEmptyDate($date) {
|
||||
if($date == "0000-00-00") {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -27,37 +27,32 @@ class ShipmentsController extends AppController {
|
|||
$this->set('shipment', $this->Shipment->read(null, $id));
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!empty($this->data)) {
|
||||
$this->Shipment->create();
|
||||
if ($this->Shipment->save($this->data)) {
|
||||
$this->Session->setFlash(__('The Shipment has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The Shipment could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function add($action = 'add') {
|
||||
|
||||
$jobs = $this->Shipment->Job->find('list');
|
||||
$principles = $this->Shipment->Principle->find('list');
|
||||
$purchaseOrders = $this->Shipment->PurchaseOrder->find('list');
|
||||
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
||||
$this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders'));
|
||||
$shipmentType = $this->typeOptions();
|
||||
|
||||
$this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders', 'shipmentType'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function add_edit($action = 'add') {
|
||||
|
||||
$principles = $this->Shipment->Principle->find('list');
|
||||
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
||||
$this->set('principles', 'freightForwarders');
|
||||
|
||||
function typeOptions() {
|
||||
$options = array('','Import to CMC','Direct: Principle to Customer','Export','Local');
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for Shipment', true));
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ class Principle extends AppModel {
|
|||
|
||||
var $recursive = 0;
|
||||
|
||||
var $order = 'Principle.name ASC';
|
||||
|
||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||
var $belongsTo = array(
|
||||
'Country' => array('className' => 'Country',
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@
|
|||
|
||||
<li><?php echo $html->link('Shipments','/shipments/index');?>
|
||||
<ul>
|
||||
<li class="last"><?php echo $html->link('Shipments List', '/shipments/index');?></li>
|
||||
<li class=""><?php echo $html->link('Shipments List', '/shipments/index');?></li>
|
||||
<li class="last"><?php echo $html->link('New Shipment', '/shipments/add');?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,34 @@
|
|||
<div class="shipments form">
|
||||
<?=$javascript->link('shipment_add');?>
|
||||
|
||||
|
||||
<?php echo $form->create('Shipment');?>
|
||||
<fieldset>
|
||||
<legend><?php __('Add Shipment');?></legend>
|
||||
<fieldset>
|
||||
<legend><?php __('New Shipment');?></legend>
|
||||
|
||||
<?php
|
||||
echo $form->input('box_count');
|
||||
echo $form->input('freight_forwarder_id');
|
||||
echo $form->input('date_arrived');
|
||||
echo $form->input('date_dispatched');
|
||||
echo $form->input('airway_bill');
|
||||
echo $form->input('comments');
|
||||
echo $form->input('shipmentType', array('options'=>$shipmentType, 'id'=>'shipmentType'));
|
||||
|
||||
?>
|
||||
<div id="importFields">
|
||||
<?
|
||||
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>
|
||||
<?
|
||||
|
||||
echo $form->input('PurchaseOrder');
|
||||
echo $form->input('Job');
|
||||
echo $form->input('Principle');
|
||||
echo $form->input('PurchaseOrder');
|
||||
|
||||
|
||||
echo $form->input('freight_forwarder_id');
|
||||
echo $form->input('airway_bill');
|
||||
|
||||
echo $form->input('date_dispatched');
|
||||
|
||||
echo $form->input('comments');
|
||||
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('List Shipments', true), array('action' => 'index'));?></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 Boxes', true), array('controller' => 'boxes', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Box', true), array('controller' => 'boxes', 'action' => 'add')); ?> </li>
|
||||
<li><?php echo $html->link(__('List Shipment Invoices', true), array('controller' => 'shipment_invoices', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Shipment Invoice', true), array('controller' => 'shipment_invoices', 'action' => 'add')); ?> </li>
|
||||
<li><?php echo $html->link(__('List Jobs', true), array('controller' => 'jobs', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Job', true), array('controller' => 'jobs', '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 Purchase Orders', true), array('controller' => 'purchase_orders', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Purchase Order', true), array('controller' => 'purchase_orders', 'action' => 'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php echo $form->end();?>
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
<?php echo $form->create('Shipment');?>
|
||||
|
||||
<?php
|
||||
|
||||
echo $form->input('box_count');
|
||||
echo $form->input('freight_forwarder_id');
|
||||
echo $form->input('date_arrived');
|
||||
echo $form->input('date_dispatched');
|
||||
echo $form->input('airway_bill');
|
||||
echo $form->input('comments');
|
||||
echo $form->input('Job');
|
||||
echo $form->input('Principle');
|
||||
echo $form->input('PurchaseOrder');
|
||||
?>
|
||||
<?php echo $form->end('Submit');?>
|
||||
|
|
@ -104,19 +104,7 @@
|
|||
|
||||
|
||||
<div id="dialog-form" title="New Shipment">
|
||||
<?php echo $form->create('Shipment');?>
|
||||
<?php
|
||||
echo $form->input('box_count');
|
||||
echo $form->input('freight_forwarder_id');
|
||||
echo $form->input('date_arrived');
|
||||
echo $form->input('date_dispatched');
|
||||
echo $form->input('airway_bill');
|
||||
echo $form->input('comments');
|
||||
echo $form->input('Job');
|
||||
echo $form->input('Principle');
|
||||
echo $form->input('PurchaseOrder');
|
||||
?>
|
||||
<?php echo $form->end('Submit');?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php debug($shipments); ?>
|
||||
|
|
@ -1,82 +1,32 @@
|
|||
$(function() {
|
||||
|
||||
|
||||
var name = $( "#name" ),
|
||||
email = $( "#email" ),
|
||||
password = $( "#password" ),
|
||||
allFields = $( [] ).add( name ).add( email ).add( password ),
|
||||
tips = $( ".validateTips" );
|
||||
|
||||
function updateTips( t ) {
|
||||
tips
|
||||
.text( t )
|
||||
.addClass( "ui-state-highlight" );
|
||||
setTimeout(function() {
|
||||
tips.removeClass( "ui-state-highlight", 1500 );
|
||||
}, 500 );
|
||||
}
|
||||
|
||||
function checkLength( o, n, min, max ) {
|
||||
if ( o.val().length > max || o.val().length < min ) {
|
||||
o.addClass( "ui-state-error" );
|
||||
updateTips( "Length of " + n + " must be between " +
|
||||
min + " and " + max + "." );
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function checkRegexp( o, regexp, n ) {
|
||||
if ( !( regexp.test( o.val() ) ) ) {
|
||||
o.addClass( "ui-state-error" );
|
||||
updateTips( n );
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$( "#dialog-form" ).dialog({
|
||||
autoOpen: false,
|
||||
height: 300,
|
||||
height: 600,
|
||||
width: 350,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"New Shipment": function() {
|
||||
var bValid = true;
|
||||
allFields.removeClass( "ui-state-error" );
|
||||
|
||||
bValid = bValid && checkLength( name, "username", 3, 16 );
|
||||
bValid = bValid && checkLength( email, "email", 6, 80 );
|
||||
bValid = bValid && checkLength( password, "password", 5, 16 );
|
||||
|
||||
bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
|
||||
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
|
||||
bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
|
||||
bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );
|
||||
|
||||
if ( bValid ) {
|
||||
$( "#users tbody" ).append( "<tr>" +
|
||||
"<td>" + name.val() + "</td>" +
|
||||
"<td>" + email.val() + "</td>" +
|
||||
"<td>" + password.val() + "</td>" +
|
||||
"</tr>" );
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
},
|
||||
Cancel: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
},
|
||||
close: function() {
|
||||
allFields.val( "" ).removeClass( "ui-state-error" );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$( "#newShipment" )
|
||||
.button()
|
||||
.click(function() {
|
||||
$( "#newShipment" ).button().click(function() {
|
||||
|
||||
$.get('/shipments/add', function(data) {
|
||||
$("#dialog-form").html(data);
|
||||
$( "#dialog-form" ).dialog( "open" );
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue