Fixed edit Enquiry user

This commit is contained in:
Karl Cordes 2011-04-29 13:07:30 +10:00
parent 62ff111e38
commit 70d53e892d
7 changed files with 72 additions and 27 deletions

View file

@ -394,7 +394,7 @@ class EnquiriesController extends AppController {
$this->data = $this->Enquiry->read(null, $id); $this->data = $this->Enquiry->read(null, $id);
} }
$enquiry = $this->Enquiry->read(null, $id); $enquiry = $this->Enquiry->read(null, $id);
$users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'))); $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'), 'conditions'=>array('User.type'=>'user')));
//$customer = $this->Enquiry->Customer->findById($enquiry['Enquiry']['customer_id']); //$customer = $this->Enquiry->Customer->findById($enquiry['Enquiry']['customer_id']);
$contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $enquiry['Enquiry']['customer_id']))); $contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $enquiry['Enquiry']['customer_id'])));

View file

@ -2,10 +2,10 @@
class Shipment extends AppModel { class Shipment extends AppModel {
var $name = 'Shipment'; var $name = 'Shipment';
var $validate = array( /* var $validate = array(
'freight_forwarder_id' => array('numeric'), 'freight_forwarder_id' => array('numeric'),
'airway_bill' => array('notempty') 'airway_bill' => array('notempty')
); ); */
var $recursive = 1; var $recursive = 1;

View file

@ -0,0 +1 @@
<?=$jobs_json;?>

View file

@ -0,0 +1 @@
<?=$POs_json?>

View file

@ -1,16 +1,6 @@
<div class="shipments index"> <div class="shipments index">
<h2><?php __('Shipments');?></h2> <h2><?php __('Shipments');?></h2>
<div id="alphaMessage">
<h3>This is Alpha version of this functionality</h3>
<pre>
You're welcome to look around. Don't start relying on anything in it just yet though.
Validation still needs to be finished. Also, Box weights/dimensions and Invoice details.
Will hopefully be finished tomorrow (Friday Apr 29) - Karl</pre>
</div>
<?php echo $javascript->link('shipment_index');?> <?php echo $javascript->link('shipment_index');?>
<p> <p>

View file

@ -1456,3 +1456,24 @@ table.shipments {
padding-left: 0; padding-left: 0;
margin: 0; margin: 0;
} }
.boxForm {
border: 1px solid;
width: 15em;
margin-top: 1em;
}
.boxForm input {
display: inline;
width: 50px;
}
.boxForm label {
float: left;
margin-right: 1em;
text-align: right;
width: 8em;
}
.boxForm div {
}

View file

@ -9,11 +9,11 @@ $(function() {
modal: true, modal: true,
buttons: { buttons: {
"New Shipment": function() { "New Shipment": function() {
var thisShipmentInputs = $('#ShipmentAddForm').find('input,select'); var thisShipmentInputs = $('#ShipmentAddForm').find('input,select,textarea');
$.post('/shipments/ajax_edit', thisShipmentInputs, function(data) { $.post('/shipments/ajax_edit', thisShipmentInputs, function(data) {
$( "#dialog-form" ).dialog('close'); $( "#dialog-form" ).dialog('close');
window.location.reload(); window.location.reload(); //Change this to fetch a new copy of the table and update a <div>.
}); });
}, },
@ -48,14 +48,19 @@ $(function() {
}); });
/**
* Display the relevent elements depending on this Shipment Type */
$("#shipmentType").change(function() { $("#shipmentType").change(function() {
var shipmentTypeID = getSelectedID('#shipmentType'); var shipmentTypeID = getSelectedID('#shipmentType');
shipmentTypeID = parseInt(shipmentTypeID);
$(".hiddenDefault").hide();
if(shipmentTypeID == 1) { //Import switch(shipmentTypeID) {
$("#importFields").show(); case 1:
$("#principle").show(); $("#importFields, #principle, #purchaseOrder, #freight_forwarder, #airway_bill, #boxes").show();
break;
default:
break;
} }
}); });
@ -93,7 +98,7 @@ $(function() {
//alert($('#PurchaseOrderID_'+ui.item.id).length); //alert($('#PurchaseOrderID_'+ui.item.id).length);
if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.' if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This PO is already in the List. Don't do anything.'
addToList('PurchaseOrder', ui.item.id, ui.item.value, $('#purchaseOrdersList')); addToList('PurchaseOrder', ui.item.id, ui.item.value, $('#purchaseOrdersList'));
} }
@ -107,15 +112,23 @@ $(function() {
select: function( event, ui ) { select: function( event, ui ) {
//alert(ui.item.value + ":" + ui.item.id); //alert(ui.item.value + ":" + ui.item.id);
if($('#JobID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.' if($('#JobID_'+ui.item.id).length == 0) { //This Job is already in the List. Don't do anything.'
addToList('Job', ui.item.id, ui.item.value, $('#jobsList')); addToList('Job', ui.item.id, ui.item.value, $('#jobsList'));
} }
} }
}); });
$("#addBox").button().click(function() {
addBox();
});
$(".removeBox").click(function() {
alert("REMOVE THIS SHIT MAN");
});
/** /**
* Resets the Form to its default site * Resets the Form to its default site
*/ */
@ -123,11 +136,27 @@ $(function() {
function resetForm() { function resetForm() {
$(".hiddenDefault").hide(); $(".hiddenDefault").hide();
$("#principle").hide();
$("#ShipmentAddForm")[0].reset(); $("#ShipmentAddForm")[0].reset();
} }
function addBox() {
var newBoxForm = $("#boxFactory").clone();
newBoxForm.attr('id','');
newBoxForm.show();
var closeButton = $('<button>X</button>');
closeButton.addClass('removeBox');
closeButton.button();
newBoxForm.prepend(closeButton);
$("#boxes").append(newBoxForm);
}
/** /**
* A more generic way of handling the HABTM <ul> <li>[REMOVE BUTTON] NAME [HIDDEN INPUT]</li> </ul> * A more generic way of handling the HABTM <ul> <li>[REMOVE BUTTON] NAME [HIDDEN INPUT]</li> </ul>
@ -171,4 +200,7 @@ $(function() {
}); });