From 037df7d1da677de1a3a9a103145af603221b7c39 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 31 May 2010 15:54:44 +1000 Subject: [PATCH] Changes to add LineItem JS --- views/layouts/default.ctp | 23 +++++--------- views/line_items/view_table.ctp | 4 +-- views/products/view.ctp | 5 +++- views/quotes/view.ctp | 13 ++++++-- webroot/css/quotenik.css | 15 ++++++++-- webroot/js/addLineItem.js | 26 ++++++++++++---- webroot/js/costing_dialog.js | 53 ++++++++++++++++++++++++++------- webroot/js/search.js | 32 +++++++++----------- 8 files changed, 115 insertions(+), 56 deletions(-) diff --git a/views/layouts/default.ctp b/views/layouts/default.ctp index d84c3a74..0cca40f0 100755 --- a/views/layouts/default.ctp +++ b/views/layouts/default.ctp @@ -21,6 +21,7 @@ echo $javascript->link('jquery-ui'); echo $javascript->link('jquery.form'); + echo $javascript->link('jquery.validate.min'); echo $javascript->link('menu'); echo $javascript->link('search'); //echo $javascript->link('ajaxLoader'); @@ -72,11 +73,7 @@ -
  • link('Contacts', '/contacts/index'); ?> - -
  • +
  • link('Invoices', '/invoices/index'); ?>
  • -
  • link('Quotes', '/quotes/index'); ?> - -
  • - +
  • link('Principles', '/principles/index'); ?> diff --git a/views/quotes/view.ctp b/views/quotes/view.ctp index f0e3345c..1fd42529 100755 --- a/views/quotes/view.ctp +++ b/views/quotes/view.ctp @@ -133,11 +133,20 @@ foreach ($quote['QuotePage'] as $quotePage): echo $form->input('option', array('label'=>'Optional Item')); echo $form->input('quantity', array('class'=>'nocostinput')); - echo $form->input('principle_id', array('options'=>$principles, 'empty' =>'Select the Principle for this Product')); + echo $form->input('fromDB', array('label'=>'Is this product in the database already?', + 'empty'=>'', + 'type'=>'select', 'options'=>array('Yes'=>'Yes', 'No'=>'No'))); ?> - + + + + + input('principle_id', array('options'=>$principles, 'empty' =>'Select the Principle for this Product', 'div'=>'fromProductDB')); ?> + + + input('title', array('div'=>'blankItem')); echo $form->input('description', array('div'=>'blankItem')); diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index bb20b28e..4130fdba 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -1143,9 +1143,10 @@ form.cmxform label { } label span.rightHandLabel { - position: absolute; - left: 40em; - width: 25em; color: #088A4B; font-size: 85%; font-weight: normal; text-transform: uppercase; + position: relative; + display: inline-block; + left: 5em; + width: auto; color: #088A4B; font-size: 85%; font-weight: normal; text-transform: uppercase; } label span.purchaseCurrency { @@ -1170,6 +1171,10 @@ label span#exchangeConversion { } +form.cmxform { + width: 80%; +} + form.cmxform input { width: auto; display: inline; @@ -1229,4 +1234,8 @@ select.editinplace { position: relative; margin-top: 10em; margin-left: 10em; +} + +span.addLineItem { + clear: right; } \ No newline at end of file diff --git a/webroot/js/addLineItem.js b/webroot/js/addLineItem.js index 2efd769e..f271ed07 100644 --- a/webroot/js/addLineItem.js +++ b/webroot/js/addLineItem.js @@ -20,6 +20,7 @@ $(function() { $(".nocosting").hide(); $(".blankItem").hide(); + $(".fromProductDB").hide(); $("#addLineItem-form").dialog({ @@ -33,8 +34,8 @@ $(function() { $.post("/line_items/ajaxSave", $("#LineItemAddForm").serialize(), function(data) { fetchTable(); - $('#mydebug').html(data); - } + $('#mydebug').html(data); + } ); $("#LineItemAddForm").resetForm(); @@ -65,7 +66,7 @@ $(function() { .button() .click(function() { $.post("/quotes/ajaxpdf",quoteID, function(data) { - $('#mydebug').html(data); + $('#mydebug').html(data); }); }); @@ -81,14 +82,29 @@ $(function() { }); - $('#addBlankItem').button().click(function () { + $('#addBlankItem').button().click(function () { $("#LineItemPrincipleId").hide(); $(".blankItem").show(); $(".nocosting").show(); return false; - }); + }); + $('#LineItemFromDB').change(function () { + if(this.value == 'No') { + $(".blankItem").show(); + $(".nocosting").show(); + $(".fromProductDB").hide(); + } + else { + $(".fromProductDB").show(); + $(".blankItem").hide(); + $(".nocosting").hide(); + } + + + }); + }); diff --git a/webroot/js/costing_dialog.js b/webroot/js/costing_dialog.js index f455ee78..7bfc9365 100644 --- a/webroot/js/costing_dialog.js +++ b/webroot/js/costing_dialog.js @@ -1,21 +1,54 @@ $(function() { -/* - * Fetch the costing add form. Place it in element ID 'costingdiv' - * - * @todo - write a plugin that generalises the method. It would be handy with the cake way of doing things - * - */ -function AjaxFetchPage() { - $.post("/costings/", $("#LineItemQuoteId").serialize(), function (itemTable) { - $("#productTable").html(itemTable); +$("#costingdiv").dialog({ + autoOpen: false, + height: 800, + width: 800, + modal: true, + buttons: { + 'Add Costing': function() { + + $.post("/line_items/ajaxSave", $("#LineItemAddForm").serialize(), function(data) { + + fetchTable(); + $('#mydebug').html(data); + } + ); + + $("#LineItemAddForm").resetForm(); + $(this).dialog('close'); + }, + Cancel: function() { + $(this).dialog('close'); + } + }, + close: function() { + + } }); -} + +/** + * When add costing button is pressed. Bring up costing dialog + */ +$("#addCostingDialog").button().click(function () { + $.get('/costings/add/', function(data) { + $("#costingdiv").html(data); + $('#costingdiv').dialog('open'); + }) + }); + }); + + +function AjaxFetchPage() { + $.post("/costings/", $("#LineItemQuoteId").serialize(), function (itemTable) { + $("#productTable").html(itemTable); + }); +} diff --git a/webroot/js/search.js b/webroot/js/search.js index b1dc289f..5377a942 100644 --- a/webroot/js/search.js +++ b/webroot/js/search.js @@ -8,10 +8,10 @@ $(function() { - $("#ajaxLoading").hide(); + $("#ajaxLoading").hide(); - $("#ajaxLoading").bind("ajaxSend", function() { + $("#ajaxLoading").bind("ajaxSend", function() { $(this).show(); }).bind("ajaxComplete", function() { $(this).hide(); @@ -20,24 +20,23 @@ $(function() { -$("#dialogDiv").hide(); + $("#dialogDiv").hide(); - $("#dialogDiv").dialog({ + $("#dialogDiv").dialog({ autoOpen: false, width: 900, - height: 900, modal: true -}); + }); -$("#searchLink").click(function() { + $("#searchLink").click(function() { -$("#dialogDiv").dialog('open'); -return false; -}); + $("#dialogDiv").dialog('open'); + return false; + }); $("#searchButton").button().click(function() { @@ -46,7 +45,11 @@ return false; }); - + + + $("#dialogDiv").bind("dialogclose", function() { + $("#results").empty(); + }) }); @@ -57,12 +60,5 @@ function doSearch() { $.post("/enquiries/doSearch", $("#searchString").serialize(), function(data) { $("#results").html(data); }); - } - -function searchDialog() { - $("") -} - -