diff --git a/controllers/contacts_controller.php b/controllers/contacts_controller.php deleted file mode 100755 index af7a682a..00000000 --- a/controllers/contacts_controller.php +++ /dev/null @@ -1,118 +0,0 @@ - array('order' => array('Contact.customer_id' => 'asc')), - 'Enquiry' => array('order' => array('Enquiry.id' => 'asc')) - ); - - - function index() { - $this->Contact->recursive = 0; - $this->set('contacts', $this->paginate()); - } - - function view($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid Contact.', true)); - $this->redirect(array('action'=>'index')); - } - $this->set('contact', $this->Contact->read(null, $id)); - //$enquiries = $this->Contact->Enquiry->findAllByContactId($id); - $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.contact_id' => $id))); - //$this->set('enquiries', $this->paginate($enquiries)); - $statuses = $this->Contact->Enquiry->Status->find('all'); - $status_list = array(); - foreach ($statuses as $status) { - $status_list[] = array($status['Status']['id'], $status['Status']['name']); - } - $this->set('status_list', $status_list); - - } - - - - function add_to_customer($customerid = null) { - - if(isset($this->params['named']['customerid'])) { - $customerid = $this->params['named']['customerid']; - } - if (!$customerid && empty($this->data)) { - $this->Session->setFlash(__('Invalid Customer ID', true)); - $this->redirect(array('controller'=>'Enquiries', 'action'=>'index')); - } - if (!empty($this->data)) { - - $this->Contact->create(); - if ($this->Contact->save($this->data)) { - $this->Session->setFlash(__('The Contact has been saved', true)); - $this->redirect(array('controller' => 'Customers', 'action'=>'view/'.$this->data['Contact']['customer_id'])); - } else { - $this->Session->setFlash(__('The Contact could not be saved. Please try again.', true)); - } - } - $contact_categories = $this->Contact->ContactCategory->find('list'); - $customer = $this->Contact->Customer->findById($customerid); - $this->set(compact('customer', 'contact_categories')); - } - - function add_another($increment) { - $this->set('contact_categories', $this->Contact->ContactCategory->find('list')); - $this->set('increment', $increment); - - } - function remove_another($increment) { - $this->set('increment', $increment); - } - function add_one($customerid) { - $contact_categories = $this->Contact->ContactCategory->find('list'); - $this->set('customerid', $customerid); - $this->set('contact_categories', $contact_categories); - } - function remove_one($customerid) { - $contacts = $this->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customerid))); - $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name')); - $this->set('contacts', $contacts); - $this->set('customerid', $customerid); - } - - function edit($id = null) { - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid Contact', true)); - $this->redirect(array('action'=>'index')); - } - if (!empty($this->data)) { - $this->data['Contact']['name'] = $this->data['Contact']['first_name'].' '.$this->data['Contact']['last_name']; - if ($this->Contact->save($this->data)) { - $customerid = $this->data['Contact']['customer_id']; - - $this->Session->setFlash(__('The Contact has been saved', true)); - $this->redirect(array('controller' => 'Customers', 'action'=>'view/'.$customerid)); - } else { - $this->Session->setFlash(__('The Contact could not be saved. Please, try again.', true)); - } - } - if (empty($this->data)) { - $this->data = $this->Contact->read(null, $id); - } - $customers = $this->Contact->Customer->find('list'); - $contact_categories = $this->Contact->ContactCategory->find('list'); - $this->set(compact('customers', 'contact_categories')); - } - - function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for Contact', true)); - $this->redirect(array('action'=>'index')); - } - if ($this->Contact->del($id)) { - $this->Session->setFlash(__('Contact deleted', true)); - $this->redirect(array('action'=>'index')); - } - } - -} -?> diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index 19b0edb3..c3680e58 100755 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -84,7 +84,8 @@ class CustomersController extends AppController { if ($this->Customer->saveAll($this->data)) { $this->Session->setFlash(__('The Customer has been saved', true)); $id = $this->Customer->id; - $this->redirect(array('action'=>'view/'.$id)); + debug($this->data); + //$this->redirect(array('action'=>'view/'.$id)); } else { $this->Session->setFlash(__('The Customer could not be saved. Please, try again.', true)); diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index b11ae466..383f7f79 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -396,6 +396,44 @@ class JobsController extends AppController { } + function autocomplete() { + $this->layout = 'ajax'; + + $query = strtolower($_GET["term"]); + + //$this->set('customers_json', print_r($this->data)); + + if($query == null) { + return; + } + + App::import('Core', 'Sanitize'); + + $query = Sanitize::clean($query); + + $jobs = $this->Job->find('list', array( + 'conditions' => array( + 'Job.title LIKE' => '%'.$query.'%' + ),'fields' => array('Job.title'), + 'order' => array('Job.title ASC') + + + + )); + + //print_r($POs); + + foreach ($jobs as $id => $job) { + $job_list[] = array('id'=> $id, 'label' => $job); + } + + $jobs_json = json_encode($job_list); + + $this->set('jobs_json', $jobs_json); + + } + + /** * Need to fix the customer_id which hasn't been set for these 500odd records. * diff --git a/controllers/principles_controller.php b/controllers/principles_controller.php index 5b995064..6b418839 100755 --- a/controllers/principles_controller.php +++ b/controllers/principles_controller.php @@ -1,76 +1,75 @@ array('limit' => 50, 'order' => array('Principle.name' => 'asc')), - 'Enquiry' => array('limit' => 150, 'order' => array('Enquiry.id' => 'desc')) - ); + var $paginate = array( + 'Principle' => array('limit' => 50, 'order' => array('Principle.name' => 'asc')), + 'Enquiry' => array('limit' => 150, 'order' => array('Enquiry.id' => 'desc')) + ); - function index() { - $this->Principle->recursive = 0; - $this->set('principles', $this->paginate()); - $this->set('enquiries', $this->paginate()); + function index() { + $this->Principle->recursive = 0; + $this->set('principles', $this->paginate()); + $this->set('enquiries', $this->paginate()); + } + + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid Principle.', true)); + $this->redirect(array('action'=>'index')); } - - function view($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid Principle.', true)); - $this->redirect(array('action'=>'index')); - } - $this->set('principle', $this->Principle->read(null, $id)); - $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id))); - $this->set('addresses', $this->Principle->PrincipleAddress->findAllByPrincipleId($id)); - $this->set('principleContacts', $this->Principle->PrincipleContact->find('all', array('conditions'=>array('PrincipleContact.principle_id'=>$id)))); - $statuses = $this->Principle->Enquiry->Status->find('all'); - $status_list = array(); - foreach ($statuses as $status) { - $status_list[] = array($status['Status']['id'], $status['Status']['name']); - } - $this->set('status_list', $status_list); - $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id))); - + $this->set('principle', $this->Principle->read(null, $id)); + $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id))); + $this->set('addresses', $this->Principle->PrincipleAddress->findAllByPrincipleId($id)); + $this->set('principleContacts', $this->Principle->PrincipleContact->find('all', array('conditions'=>array('PrincipleContact.principle_id'=>$id)))); + $statuses = $this->Principle->Enquiry->Status->find('all'); + $status_list = array(); + foreach ($statuses as $status) { + $status_list[] = array($status['Status']['id'], $status['Status']['name']); } + $this->set('status_list', $status_list); + $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.principle_id' => $id))); - function add() { - if (!empty($this->data)) { - $this->Principle->create(); - if ($this->Principle->save($this->data)) { - $this->Session->setFlash(__('The Principle has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true)); - } - } - $countries = $this->Principle->Country->find('list'); - $currencies = $this->Principle->Currency->find('list'); - $this->set(compact('countries', 'currencies')); + } + + function add() { + if (!empty($this->data)) { + $this->Principle->create(); + if ($this->Principle->save($this->data)) { + $this->Session->setFlash(__('The Principle has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true)); + } } + $countries = $this->Principle->Country->find('list'); + $currencies = $this->Principle->Currency->find('list'); + $this->set(compact('countries', 'currencies')); + } - function edit($id = null) { - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid Principle', true)); - $this->redirect(array('action'=>'index')); - } - if (!empty($this->data)) { - if ($this->Principle->save($this->data)) { - $this->Session->setFlash(__('The Principle has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true)); - } - } - if (empty($this->data)) { - $this->data = $this->Principle->read(null, $id); - } - $countries = $this->Principle->Country->find('list'); - $currencies = $this->Principle->Currency->find('list'); - $this->set(compact('countries','currencies')); + function edit($id = null) { + if (!$id && empty($this->data)) { + $this->Session->setFlash(__('Invalid Principle', true)); + $this->redirect(array('action'=>'index')); } + if (!empty($this->data)) { + if ($this->Principle->save($this->data)) { + $this->Session->setFlash(__('The Principle has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The Principle could not be saved. Please, try again.', true)); + } + } + if (empty($this->data)) { + $this->data = $this->Principle->read(null, $id); + } + $countries = $this->Principle->Country->find('list'); + $currencies = $this->Principle->Currency->find('list'); + $this->set(compact('countries','currencies')); + } - } ?> diff --git a/controllers/purchase_orders_controller.php b/controllers/purchase_orders_controller.php index a5117bbb..07e428c1 100755 --- a/controllers/purchase_orders_controller.php +++ b/controllers/purchase_orders_controller.php @@ -1,84 +1,125 @@ false, - 'limit' => 100, - 'order'=>array('PurchaseOrder.id' => 'desc') + 'contain' => false, + 'limit' => 100, + 'order'=>array('PurchaseOrder.id' => 'desc') ); - function index() { - $this->PurchaseOrder->recursive = 1; - $this->set('purchaseOrders', $this->paginate()); + function index() { + $this->PurchaseOrder->recursive = 1; + $this->set('purchaseOrders', $this->paginate()); + } + + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid PurchaseOrder.', true)); + $this->redirect(array('action'=>'index')); + } + $this->set('purchaseOrder', $this->PurchaseOrder->read(null, $id)); + } + + function add() { + if (!empty($this->data)) { + $this->PurchaseOrder->create(); + + $count = $this->PurchaseOrder->findCount(); + $count++; + + $offset = 2060; + + $count += $offset; + + $newPOnumber = "CMCPO".$count; + + $this->data['PurchaseOrder']['title'] = $newPOnumber; + + + if ($this->PurchaseOrder->save($this->data)) { + $this->Session->setFlash(__('The PurchaseOrder has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true)); + } + } + $jobs = $this->PurchaseOrder->Job->find('list'); + $principles = $this->PurchaseOrder->Principle->find('list'); + $documents = $this->PurchaseOrder->Document->find('list'); + $this->set(compact('jobs', 'principles', 'documents')); + } + + function edit($id = null) { + if (!$id && empty($this->data)) { + $this->Session->setFlash(__('Invalid PurchaseOrder', true)); + $this->redirect(array('action'=>'index')); + } + if (!empty($this->data)) { + if ($this->PurchaseOrder->save($this->data)) { + $this->Session->setFlash(__('The PurchaseOrder has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true)); + } + } + if (empty($this->data)) { + $this->data = $this->PurchaseOrder->read(null, $id); + } + $jobs = $this->PurchaseOrder->Job->find('list'); + $principles = $this->PurchaseOrder->Principle->find('list'); + $documents = $this->PurchaseOrder->Document->find('list'); + $this->set(compact('jobs','principles','documents')); + } + + + function autocomplete() { + $this->layout = 'ajax'; + + $query = strtolower($_GET["term"]); + + //$this->set('customers_json', print_r($this->data)); + + if($query == null) { + return; } - function view($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid PurchaseOrder.', true)); - $this->redirect(array('action'=>'index')); - } - $this->set('purchaseOrder', $this->PurchaseOrder->read(null, $id)); + App::import('Core', 'Sanitize'); + + $query = Sanitize::clean($query); + + $POs = $this->PurchaseOrder->find('list', array( + 'conditions' => array( + 'PurchaseOrder.title LIKE' => '%'.$query.'%' + ),'fields' => array('PurchaseOrder.title'), + 'order' => array('PurchaseOrder.title ASC') + + + + )); + + //print_r($POs); + + foreach ($POs as $id => $po) { + $po_list[] = array('id'=> $id, 'label' => $po); } - function add() { - if (!empty($this->data)) { - $this->PurchaseOrder->create(); + $POs_json = json_encode($po_list); - $count = $this->PurchaseOrder->findCount(); - $count++; + $this->set('POs_json', $POs_json); - $offset = 2060; - - $count += $offset; - - $newPOnumber = "CMCPO".$count; - - $this->data['PurchaseOrder']['title'] = $newPOnumber; + } - if ($this->PurchaseOrder->save($this->data)) { - $this->Session->setFlash(__('The PurchaseOrder has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true)); - } - } - $jobs = $this->PurchaseOrder->Job->find('list'); - $principles = $this->PurchaseOrder->Principle->find('list'); - $documents = $this->PurchaseOrder->Document->find('list'); - $this->set(compact('jobs', 'principles', 'documents')); - } - function edit($id = null) { - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid PurchaseOrder', true)); - $this->redirect(array('action'=>'index')); - } - if (!empty($this->data)) { - if ($this->PurchaseOrder->save($this->data)) { - $this->Session->setFlash(__('The PurchaseOrder has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The PurchaseOrder could not be saved. Please, try again.', true)); - } - } - if (empty($this->data)) { - $this->data = $this->PurchaseOrder->read(null, $id); - } - $jobs = $this->PurchaseOrder->Job->find('list'); - $principles = $this->PurchaseOrder->Principle->find('list'); - $documents = $this->PurchaseOrder->Document->find('list'); - $this->set(compact('jobs','principles','documents')); - } - /*function delete($id = null) { + /*function delete($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid id for PurchaseOrder', true)); $this->redirect(array('action'=>'index')); diff --git a/controllers/shipments_controller.php b/controllers/shipments_controller.php index ffee1135..61474617 100644 --- a/controllers/shipments_controller.php +++ b/controllers/shipments_controller.php @@ -17,6 +17,13 @@ class ShipmentsController extends AppController { function index() { $this->Shipment->recursive = 0; $this->set('shipments', $this->paginate()); + + $principles = $this->Shipment->Principle->find('list'); + $freightForwarders = $this->Shipment->FreightForwarder->find('list'); + $shipmentType = $this->typeOptions(false); + $shipmentTypeShort = $this->typeOptions(true); + $this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort')); + } function view($id = null) { @@ -27,27 +34,46 @@ class ShipmentsController extends AppController { $this->set('shipment', $this->Shipment->read(null, $id)); } - - - - - 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'); - $shipmentType = $this->typeOptions(); - - $this->set(compact('jobs', 'principles', 'purchaseOrders', 'freightForwarders', 'shipmentType')); + function ajax_edit() { + $this->layout = 'ajax'; + + if(!empty($this->data)) { + if ($this->Shipment->saveAll($this->data)) { + echo "SUCCESS"; + } + else { + echo "FAILURE"; + } + } + else { + return; + } } - function typeOptions() { - $options = array('','Import to CMC','Direct: Principle to Customer','Export','Local'); + + /* Moved the Views for Adding/Editing to elements. Called from the Index. + * + * function add($action = 'add') { + + $principles = $this->Shipment->Principle->find('list'); + $freightForwarders = $this->Shipment->FreightForwarder->find('list'); + $shipmentType = $this->typeOptions(); + $this->set(compact('principles', 'freightForwarders', 'shipmentType')); + }*/ + + + function typeOptions($short = false) { + if($short == false) { + $options = array('','Import: Principle to CMC','Direct: Principle to Customer','Export','Local'); + } + else { + $options = array('','Import','Direct','Export','Local'); + } + return $options; } diff --git a/models/shipment.php b/models/shipment.php index 3328c13f..a975a144 100644 --- a/models/shipment.php +++ b/models/shipment.php @@ -21,7 +21,13 @@ class Shipment extends AppModel { 'FreightService' => array( 'className' => 'FreightService', 'foreignKey' => 'freight_service_id' + ), + 'User' => array( + 'className' => 'User', + 'foreignKey' => 'user_id', + 'conditions' => array('User.type' => 'user') ) + ); var $hasMany = array( diff --git a/views/layouts/default.ctp b/views/layouts/default.ctp index 50145b75..23367771 100755 --- a/views/layouts/default.ctp +++ b/views/layouts/default.ctp @@ -78,7 +78,6 @@
  • link('Shipments','/shipments/index');?>
  • diff --git a/views/shipments/add.ctp b/views/shipments/add.ctp index 089a17d4..9fb91677 100644 --- a/views/shipments/add.ctp +++ b/views/shipments/add.ctp @@ -2,9 +2,6 @@ create('Shipment');?> -
    - - input('shipmentType', array('options'=>$shipmentType, 'id'=>'shipmentType')); @@ -13,13 +10,19 @@ input('date_arrived_display', array('label'=>'Date Arrived', 'id'=>'date_arrived_display')); echo $form->input('date_arrived', array('type'=>'hidden', 'id'=>'date_arrived')); + ?> - + input('Principle', array('type'=>'select', 'multiple'=>true)); ?> + + + + input('PurchaseOrder'); echo $form->input('Job'); - echo $form->input('Principle'); + echo $form->input('freight_forwarder_id'); @@ -30,5 +33,4 @@ echo $form->input('comments'); ?> -
    end();?> diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp index 750f1071..38be6b34 100644 --- a/views/shipments/index.ctp +++ b/views/shipments/index.ctp @@ -9,6 +9,7 @@ ?>

    + @@ -28,16 +29,26 @@ foreach ($shipments as $shipment): ?> + - + + + @@ -104,7 +113,7 @@
    - + element('add_shipment');?>
    \ No newline at end of file diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index 423d07a7..fc47672e 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -1437,4 +1437,22 @@ tr.cancelled td { table.shipments tr td { font-size: 80%; + border: 1px solid; } + +table.shipments { + border: 1px solid; +} + + +.habtmList { + list-style: none; + margin: 0; + padding: 0; +} + +.habtmList li { + padding-top: 0.5em; + padding-left: 0; + margin: 0; +} \ No newline at end of file diff --git a/webroot/js/shipment_add.js b/webroot/js/shipment_add.js new file mode 100644 index 00000000..f540978a --- /dev/null +++ b/webroot/js/shipment_add.js @@ -0,0 +1,42 @@ +$(function() { + + + $('#date_arrived_display').datepicker({ + showButtonPanel: true, + dateFormat: 'd M yy', + altFormat: 'yy-mm-dd', + altField: '#date_arrived' + }); + + $("#importFields").hide(); + + + + + + $("#shipmentType").change(function() { + + var shipmentTypeID = getShipmentTypeID(); + + if(shipmentTypeID == 1) { + $("#importFields").show(); + } + + + + }); + + + + + function getShipmentTypeID() { + var id; + $("#shipmentType :selected").each(function(i, selected) { + id = this.value; + }); + return id; + } + + +}); + diff --git a/webroot/js/shipment_index.js b/webroot/js/shipment_index.js index be3b145b..0b02cf73 100644 --- a/webroot/js/shipment_index.js +++ b/webroot/js/shipment_index.js @@ -1,32 +1,174 @@ $(function() { - - + resetForm(); $( "#dialog-form" ).dialog({ autoOpen: false, - height: 600, - width: 350, + height: 900, + width: 600, modal: true, buttons: { "New Shipment": function() { + var thisShipmentInputs = $('#ShipmentAddForm').find('input,select'); + + $.post('/shipments/ajax_edit', thisShipmentInputs, function(data) { + $( "#dialog-form" ).dialog('close'); + window.location.reload(); + }); }, Cancel: function() { $( this ).dialog( "close" ); + $("#ShipmentAddForm")[0].reset(); + $("#principlesList").empty(); } }, close: function() { + + $("#importFields").hide(); + $("#principle").hide(); + } }); $( "#newShipment" ).button().click(function() { - $.get('/shipments/add', function(data) { - $("#dialog-form").html(data); $( "#dialog-form" ).dialog( "open" ); - }); }); + + + + $('#date_arrived_display').datepicker({ + showButtonPanel: true, + dateFormat: 'd M yy', + altFormat: 'yy-mm-dd', + altField: '#date_arrived' + }); + + + + $("#shipmentType").change(function() { + + var shipmentTypeID = getSelectedID('#shipmentType'); + + if(shipmentTypeID == 1) { //Import + $("#importFields").show(); + $("#principle").show(); + } + + }); + + //Remove X button clicked. + $('.removeFromList').live('click', function() { + $(this).parent().remove(); + }); + + + + $('#addPrinciple').button().click(function() { + + var principleID = getSelectedID('#PrinciplePrinciple'); + + if($('#PrincipleID_'+principleID).length > 0) { //This Principle is already in the List. Don't do anything.' + return false; + } + + var principleName =getSelectedText('#PrinciplePrinciple'); + + //addPrincipleToList(principleID); + addToList('Principle', principleID, principleName, $('#principlesList') ); + + return false; + + }); + + + $( "#purchase_order_autocomplete" ).autocomplete({ + source: "/purchase_orders/autocomplete", + minLength: 2, + select: function( event, ui ) { + //alert(ui.item.value + ":" + ui.item.id); + //alert($('#PurchaseOrderID_'+ui.item.id).length); + + + if($('#PurchaseOrderID_'+ui.item.id).length == 0) { //This Principle is already in the List. Don't do anything.' + addToList('PurchaseOrder', ui.item.id, ui.item.value, $('#purchaseOrdersList')); + } + + + } + }); + + $( "#job_autocomplete" ).autocomplete({ + source: "/jobs/autocomplete", + minLength: 2, + select: function( event, ui ) { + //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.' + addToList('Job', ui.item.id, ui.item.value, $('#jobsList')); + } + + + } + }); + + + /** + * Resets the Form to its default site + */ + + function resetForm() { + + $(".hiddenDefault").hide(); + $("#principle").hide(); + $("#ShipmentAddForm")[0].reset(); + } + + + + /** + * A more generic way of handling the HABTM + */ + function addToList(modelName, id, value, ULelement) { + var thisLI = $('
  • '); + var thisButton = $(''); + thisButton.addClass('removeFromList'); + thisButton.button(); + + var thisHiddenInput = $(''); + + var modelString = '['+modelName+']'; + thisHiddenInput.attr('name', 'data'+modelString+modelString+'[]'); + thisHiddenInput.attr('value', id); + + thisLI.attr('id', modelName+'ID_'+id); + thisLI.html(value); + thisLI.prepend(thisButton); + thisLI.append(thisHiddenInput); + ULelement.append(thisLI); + + } + + + function getSelectedID(elementID) { + var id; + $(elementID+" :selected").each(function(i, selected) { + id = this.value; + }); + return id; + } + + function getSelectedText(elementID) { + var text; + $(elementID+" :selected").each(function(i, selected) { + text = $(selected).text(); + }); + return text; + } + + + }); \ No newline at end of file
    sort('user_id');?> sort('date_arrived');?> sort('date_dispatched');?> sort('type');?>
    + - - - + echo $html->link($initials, array('controller'=> 'users', 'action'=>'view', $shipment['User']['id'])); ?> - + element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived'])); + ?> + + element('isEmptyDate', array('date'=>$shipment['Shipment']['date_dispatched'])); + ?> + + @@ -83,9 +94,7 @@ - link(__('View', true), array('action' => 'view', $shipment['Shipment']['id'])); ?> - link(__('Edit', true), array('action' => 'edit', $shipment['Shipment']['id'])); ?> - link(__('Delete', true), array('action' => 'delete', $shipment['Shipment']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $shipment['Shipment']['id'])); ?> +