diff --git a/models/currency.php b/models/currency.php
index 5e985103..9e19a6c3 100755
--- a/models/currency.php
+++ b/models/currency.php
@@ -32,7 +32,7 @@ class Currency extends AppModel {
);
- var $order = "Currency.name ASC";
+ var $order = "name ASC";
}
?>
diff --git a/views/costings/add.ctp b/views/costings/add.ctp
index 6a2e631b..9c64cffa 100755
--- a/views/costings/add.ctp
+++ b/views/costings/add.ctp
@@ -99,14 +99,5 @@ echo $form->input('sale_discount_amount', array('type'=>'hidden'));
echo $form->end('Submit');?>
-
-
- - link(__('List Costings', true), array('action' => 'index'));?>
- - link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
- - link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
- - link(__('List Line Items', true), array('controller' => 'line_items', 'action' => 'index')); ?>
- - link(__('New Line Item', true), array('controller' => 'line_items', 'action' => 'add')); ?>
- - link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
- - link(__('New Purchase Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
-
-
+
+
diff --git a/views/layouts/default.ctp b/views/layouts/default.ctp
index 60756b31..8272497a 100755
--- a/views/layouts/default.ctp
+++ b/views/layouts/default.ctp
@@ -1,42 +1,40 @@
-
-
+
-
+
-
-
+
+
- 0) {
- echo $html->meta('favicon.ico', '/img/core.png', array('type' => 'icon'));
- } else {
- echo $html->meta('icon');
- }
+if ($debugLevel > 0) {
+ echo $html->meta('favicon.ico', '/img/core.png', array('type' => 'icon'));
+} else {
+ echo $html->meta('icon');
+}
- echo $html->css('quotenik');
- echo $html->css('jquery-ui.custom.css');
+echo $html->css('quotenik');
+echo $html->css('jquery-ui.custom.css');
- //echo $javascript->link('ckeditor/ckeditor');
+//echo $javascript->link('ckeditor/ckeditor');
- echo $javascript->link('jquery');
+echo $javascript->link('jquery');
- echo $javascript->link('jquery-ui');
- echo $javascript->link('jquery.form');
- echo $javascript->link('menu');
- echo $javascript->link('global');
- echo $javascript->link('search');
- echo $javascript->link('jquery.jeditable.mini');
- echo $javascript->link('jquery.validate');
+echo $javascript->link('jquery-ui');
+echo $javascript->link('jquery.form');
+echo $javascript->link('menu');
+echo $javascript->link('global');
+echo $javascript->link('search');
+echo $javascript->link('jquery.jeditable.mini');
+echo $javascript->link('jquery.validate');
- echo $scripts_for_layout;
- ?>
+echo $scripts_for_layout;
+?>
@@ -48,14 +46,14 @@
- link('Login', '/users/login');
- } else {
- $logoutlink = $html->link('Logout', '/users/logout');
- echo $html->link($currentuser['User']['username'], '/users/view/' . $currentuser['User']['id']) . ' (' . $logoutlink . ')';
- }
- ?>
+link('Login', '/users/login');
+} else {
+ $logoutlink = $html->link('Logout', '/users/logout');
+ echo $html->link($currentuser['User']['username'], '/users/view/' . $currentuser['User']['id']) . ' (' . $logoutlink . ')';
+}
+?>
@@ -67,7 +65,7 @@
-
link('Documents', '/documents/index'); ?>
+ link('Documents', '/documents/index'); ?>
- link('Documents Index', '/documents/index'); ?>
@@ -76,12 +74,12 @@
link('Jobs', '/jobs/index'); ?>
-
- if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin'):
+
+if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin'):
- ?>
- - = $html->link('Reports', '/jobs/reports'); ?>
- endif; ?>
+?>
+ - = $html->link('Reports', '/jobs/reports'); ?>
+ endif; ?>
- link('Job List', '/jobs/index'); ?>
@@ -94,8 +92,8 @@
link('Direct Shipments', '/shipments/index/direct'); ?>
link('Export Shipments', '/shipments/index/export'); ?>
link('Local Shipments', '/shipments/index/local'); ?>
-
link('Monthly Deferred GST', '/shipments/reports'); ?>
-
link('Freight Forwarders', '/freight_forwarders'); ?>
+
link('Monthly Deferred GST', '/shipments/reports'); ?>
+
link('Freight Forwarders', '/freight_forwarders'); ?>
@@ -137,7 +135,7 @@
- echo $html->link('Users', '/users/index'); ?>
+ echo $html->link('Users', '/users/index'); ?>
- echo $html->link('Users Index', '/users/index');
- link('Add User', '/users/add');
@@ -152,12 +150,12 @@
-
- if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin'):
- ?>
-
- endif; ?>
+
+ if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin'):
+?>
+
+ endif; ?>
@@ -166,24 +164,24 @@
- check('Message.flash')):
- $session->flash();
- endif;
- ?>
+check('Message.flash')):
+ $session->flash();
+endif;
+?>
-
Loading, please wait
- image('ajax-loader.gif'); ?>
-
-
+
Loading, please wait
+ image('ajax-loader.gif'); ?>
+
+
@@ -191,51 +189,52 @@
- create('Enquiry', array('default' => false, 'id' => 'searchForm', 'default' => 'false'));
- echo 'Search';
- echo $html->image('system-search.png');
- echo '
';
- echo "Search for: Enquiry Number, Job Number, Customer, Contact or Customer Order Number
";
+create('Enquiry', array('default' => false, 'id' => 'searchForm', 'default' => 'false'));
+echo 'Search';
+echo $html->image('system-search.png');
+echo '
';
+echo "Search for: Enquiry Number, Job Number, Customer, Contact or Customer Order Number
";
- echo $form->input('Enquiry.search_string', array('label' => false, 'id' => 'searchString'));
- ?>
+echo $form->input('Enquiry.search_string', array('label' => false, 'id' => 'searchString'));
+?>
-
- echo $form->end();
- ?>
+
+echo $form->end();
+?>
-
Loading, please wait..
- image('ajax-loader.gif'); ?>
-
+ Loading, please wait..
+ image('ajax-loader.gif'); ?>
+
- ";
- ?>
+$mem_usage = memory_get_usage(true);
+
+if ($mem_usage < 1024)
+ echo $mem_usage . " bytes";
+elseif ($mem_usage < 1048576)
+ echo round($mem_usage / 1024, 2) . " kilobytes";
+else
+ echo round($mem_usage / 1048576, 2) . " megabytes";
+echo "
";
+?>
-
+
-
+
diff --git a/views/line_items/get_table.ctp b/views/line_items/get_table.ctp
index 97f3e289..e7411cdb 100644
--- a/views/line_items/get_table.ctp
+++ b/views/line_items/get_table.ctp
@@ -1,143 +1,152 @@
-
- ITEM NO. |
- QTY |
- DESCRIPTION |
- UNIT PRICE |
- TOTAL PRICE |
- ACTIONS |
-
-
- |
- |
- |
- =$currencyCode?> |
- =$currencyCode?> |
- |
-
+
+ ITEM NO. |
+ QTY |
+ DESCRIPTION |
+ UNIT PRICE |
+ TOTAL PRICE |
+ ACTIONS |
+
+
+ |
+ |
+ |
+ =$currencyCode?> |
+ =$currencyCode?> |
+ |
+
-
- $hasOptions = false;
+
+$hasOptions = false;
- foreach($document['LineItem'] as $li):?>
-
-
- if($li['option'] == 1) {
- echo 'Option ';
+if(count($document['LineItem']) == 0):
+?>
+ |
+| No Line Items have been Added Yet! |
+
+
+endif;
+?>
+
+ foreach($document['LineItem'] as $li):?>
+
+
+ if($li['option'] == 1) {
+ echo 'Option ';
- $hasOptions = true;
- }
- ?>
- =$li['item_number'];?> |
- =$li['quantity'];?> |
-
- =$li['title'];?>
- =$li['description'];?>
- |
-
-
- if($li['has_text_prices']):
- echo $li['unit_price_string'];
- ?>
-
- else:
- ?>
- =$number->currency($li['gross_unit_price'], $currencyCode);?>
- if($li['discount_percent']):?>
- less =$li['discount_percent']?>%
- discount
- (-=$number->currency($li['discount_amount_unit'], $currencyCode);?>)
- =
- =$number->currency($li['net_unit_price'], $currencyCode);?>
-
- endif;?>
- |
-
-
- if($li['has_text_prices']):
- echo $li['gross_price_string'];
- ?>
-
- else:
- ?>
- =$number->currency($li['gross_price'], $currencyCode);?>
- if($li['discount_percent']):?>
- less =$li['discount_percent']?>%
- discount
- =$number->currency($li['discount_amount_total'], $currencyCode);?>)
- =
- =$number->currency($li['net_price'], $currencyCode);?>
-
-
- |
-
-
-
- |
-
-
+ $hasOptions = true;
+}
+?>
+ =$li['item_number'];?>
+ =$li['quantity'];?> |
+
+ =$li['title'];?>
+ =$li['description'];?>
+ |
+
+
+if($li['has_text_prices']):
+ echo $li['unit_price_string'];
+?>
+
+else:
+?>
+ =$number->currency($li['gross_unit_price'], $currencyCode);?>
+ if($li['discount_percent']):?>
+ less =$li['discount_percent']?>%
+ discount
+ (-=$number->currency($li['discount_amount_unit'], $currencyCode);?>)
+ =
+ =$number->currency($li['net_unit_price'], $currencyCode);?>
+
+ endif;?>
+ |
+
+
+ if($li['has_text_prices']):
+ echo $li['gross_price_string'];
+?>
+
+ else:
+?>
+ =$number->currency($li['gross_price'], $currencyCode);?>
+ if($li['discount_percent']):?>
+ less =$li['discount_percent']?>%
+ discount
+ =$number->currency($li['discount_amount_total'], $currencyCode);?>)
+ =
+ =$number->currency($li['net_price'], $currencyCode);?>
+
+
+ |
+
+
+
+ |
+
+
-
- |
- |
- SUB-TOTAL (Excluding GST) |
- |
-
- if(!$hasOptions) {
- echo $number->currency($totals['subtotal'], $currencyCode);
- }
- else {
- echo $currencySymbol.'TBA';
- }
- ?>
- |
+
+ |
+ |
+ SUB-TOTAL (Excluding GST) |
+ |
+
+ if(!$hasOptions) {
+ echo $number->currency($totals['subtotal'], $currencyCode);
+ }
+ else {
+ echo $currencySymbol.'TBA';
+ }
+?>
+ |
- |
-
-
- |
- |
- GST (10%) |
- |
-
-
- if(!$hasOptions) {
- echo $number->currency($totals['gst'], $currencyCode);
- }
- else {
- echo $currencySymbol.'TBA';
- }
+ | |
+
+
+ |
+ |
+ GST (10%) |
+ |
+
+
+if(!$hasOptions) {
+ echo $number->currency($totals['gst'], $currencyCode);
+}
+else {
+ echo $currencySymbol.'TBA';
+}
- ?>
- |
- |
-
-
- |
- |
- TOTAL PAYABLE (INCLUDING GST) |
- |
-
- if(!$hasOptions) {
- echo $number->currency($totals['total'], $currencyCode);
- }
- else {
- echo $currencySymbol.'TBA';
- }
- ?> |
- |
-
+?>
+
+ |
+
+
+ |
+ |
+ TOTAL PAYABLE (INCLUDING GST) |
+ |
+
+if(!$hasOptions) {
+ echo $number->currency($totals['total'], $currencyCode);
+}
+else {
+ echo $currencySymbol.'TBA';
+}
+?> |
+ |
+
diff --git a/views/users/login.ctp b/views/users/login.ctp
index e572ba78..452154a3 100755
--- a/views/users/login.ctp
+++ b/views/users/login.ctp
@@ -1,3 +1,6 @@
+
+
+
diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css
index e97dad10..c1573586 100755
--- a/webroot/css/quotenik.css
+++ b/webroot/css/quotenik.css
@@ -1646,4 +1646,10 @@ div.warning p {
#extraModels li {
font-size: 1.5em;
-}
\ No newline at end of file
+}
+
+
+tr.no_items {
+ font-size: 2em;
+ padding: 0.5em;
+}
diff --git a/webroot/js/document_add_edit.js b/webroot/js/document_add_edit.js
index e6f57e4c..b94f0f92 100644
--- a/webroot/js/document_add_edit.js
+++ b/webroot/js/document_add_edit.js
@@ -2,7 +2,6 @@
* Could (should) tidy this up to move the Quote/Invoice etc Specific
* functionality into seperate files.
*
- * Will do this at some point. Today I just need to hammer this out.
*
* Karl - 20/5/2011
*/
@@ -10,631 +9,631 @@
$(function() {
- // var config defined in global.js
- loadLineItems();
- var docID = $('#documentID').html();
+ // var config defined in global.js
+ loadLineItems();
+ var docID = $('#documentID').html();
- $("#flashMessage").hide();
+ $("#flashMessage").hide();
- $("#lineItemDetails").hide();
+ $("#lineItemDetails").hide();
- $( "#addLineItemModal" ).dialog({
- autoOpen: false,
- height: 900,
- width: 600,
- modal: true,
- buttons: {
- "Add Line Item": function() {
-
- $('#LineItemDescription').ckeditor(function() {
- this.updateElement();
- });
+ $( "#addLineItemModal" ).dialog({
+ autoOpen: false,
+ height: 900,
+ width: 600,
+ modal: true,
+ buttons: {
+ "Add Line Item": function() {
+
+ $('#LineItemDescription').ckeditor(function() {
+ this.updateElement();
+ });
- var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
+ var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
- $.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
-
- if(data == 'SUCCESS') {
- loadLineItems();
- $( "#addLineItemModal" ).dialog('close');
- }
- else {
- alert("Line Item could not be saved")
- $('#LineItemDescription').ckeditor(config);
- }
+ $.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
- });
+ if(data == 'SUCCESS') {
+ loadLineItems();
+ $( "#addLineItemModal" ).dialog('close');
+ }
+ else {
+ alert("Line Item could not be saved")
+ $('#LineItemDescription').ckeditor(config);
+ }
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- close: function() {
- loadLineItems();
- }
-
- });
+ });
- $( "#editLineItemModal" ).dialog({
- autoOpen: false,
- height: 900,
- width: 600,
- modal: true,
- buttons: {
- "Edit Line Item": function() {
- $('#LineItemDescription').ckeditor(function() {
- this.updateElement();
- });
-
- var thisLineItemInputs = $('#LineItemEditForm').find('input,select,textarea');
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ close: function() {
+ loadLineItems();
+ }
- $.post('/line_items/ajax_edit', thisLineItemInputs, function(data) {
- if(data == 'SUCCESS') {
- $( "#editLineItemModal" ).dialog('close');
- }
- else {
- alert("Line Item could not be saved")
- $('#LineItemDescription').ckeditor(config);
- }
- });
+ });
- },
- Cancel: function() {
- $( "#editLineItemModal" ).dialog('close');
-
- }
- },
- close: function() {
- loadLineItems();
+ $( "#editLineItemModal" ).dialog({
+ autoOpen: false,
+ height: 900,
+ width: 600,
+ modal: true,
+ buttons: {
+ "Edit Line Item": function() {
+ $('#LineItemDescription').ckeditor(function() {
+ this.updateElement();
+ });
- }
+ var thisLineItemInputs = $('#LineItemEditForm').find('input,select,textarea');
+
+ $.post('/line_items/ajax_edit', thisLineItemInputs, function(data) {
+ if(data == 'SUCCESS') {
+ $( "#editLineItemModal" ).dialog('close');
+ }
+ else {
+ alert("Line Item could not be saved")
+ $('#LineItemDescription').ckeditor(config);
+ }
+ });
+
+ },
+ Cancel: function() {
+ $( "#editLineItemModal" ).dialog('close');
+
+ }
+ },
+ close: function() {
+ loadLineItems();
+
+ }
+ });
+
+
+ $( "#QuoteDetails" ).dialog({
+ autoOpen: false,
+ height: 900,
+ width: 600,
+ modal: true,
+ buttons: {
+ "Edit Quote Details": function() {
+
+
+ $('#QuoteCommercialComments').ckeditor(function() {
+ this.updateElement();
+ this.destroy();
+ });
+
+
+ var quoteInputs = $('#QuoteEditForm').find('input,select,textarea');
+
+ $.post('/quotes/ajax_edit', quoteInputs, function(data) {
+ $( "#QuoteDetails" ).dialog('close');
+ });
+
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+
+ }
+ },
+ close: function() {
+ loadLineItems();
+ }
+ });
+
+
+
+ $( "#addJobConfirmation" ).dialog({
+ autoOpen: false,
+ height: 400,
+ width: 400,
+ modal: true,
+ buttons: {
+ "Create New Job and Order Acknowledgement": function() {
+
+ var documentID = $("#documentID").html();
+
+ //window.location.href = "/documents/convert_to_oa/"+documentID;
+ //var newOAform = $('#DocumentConvertToOaForm').find('input');
+ var newOAform = $('#DocumentConvertToOaForm');
+ newOAform.submit();
+
+
+
+ /*$.post('/documents/convert_to_oa', newOAform, function(data) {
+ if(data =='SUCCESS') {
+ $("#flashMessage").html("Invoice Saved Successfully");
+ }
+ else {
+ $("#flashMessage").html("Unable to Save Invoice");
+ }
+
+ $("#flashMessage").show();
+
+
+ loadLineItems();
+ });
+ */
+
+
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+
+ }
+ },
+ close: function() {
+ }
+ });
+
+
+ $("#pageContentFactory").hide();
+
+
+ //Add a new Page Element.
+ $("#addPage").button().click(function(event) {
+ event.preventDefault();
+
+ newPage(false);
+ return false;
+ });
+
+
+ //Open the LineItem dialog
+ $(".addLineItem").button().click(function() {
+
+
+
+ $('#LineItemDescription').ckeditor(function() {
+ this.destroy();
});
- $( "#QuoteDetails" ).dialog({
- autoOpen: false,
- height: 900,
- width: 600,
- modal: true,
- buttons: {
- "Edit Quote Details": function() {
+ $("#editLineItemModal").empty();
- $('#QuoteCommercialComments').ckeditor(function() {
- this.updateElement();
- this.destroy();
- });
+
+ var nextItemNo = $(".lineItem").length;
+ nextItemNo++;
+
+ $.get('/line_items/add/'+docID, function(data) {
+ $("#addLineItemModal").html(data);
- var quoteInputs = $('#QuoteEditForm').find('input,select,textarea');
+ $("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No
- $.post('/quotes/ajax_edit', quoteInputs, function(data) {
- $( "#QuoteDetails" ).dialog('close');
- });
- },
- Cancel: function() {
- $( this ).dialog( "close" );
+ $("#productDetails").hide();
+
+ $('#LineItemDescription').ckeditor(config);
+
+ showHideTextPrices();
+
+ $( "#addLineItemModal" ).dialog('open');
- }
- },
- close: function() {
- loadLineItems();
- }
});
+ return false;
+ });
- $( "#addJobConfirmation" ).dialog({
- autoOpen: false,
- height: 400,
- width: 400,
- modal: true,
- buttons: {
- "Create New Job and Order Acknowledgement": function() {
-
- var documentID = $("#documentID").html();
-
- //window.location.href = "/documents/convert_to_oa/"+documentID;
- //var newOAform = $('#DocumentConvertToOaForm').find('input');
- var newOAform = $('#DocumentConvertToOaForm');
- newOAform.submit();
+ $(".editLineItem").live('click', function() {
-
- /*$.post('/documents/convert_to_oa', newOAform, function(data) {
- if(data =='SUCCESS') {
- $("#flashMessage").html("Invoice Saved Successfully");
- }
- else {
- $("#flashMessage").html("Unable to Save Invoice");
- }
-
- $("#flashMessage").show();
-
-
- loadLineItems();
- });
- */
-
-
- },
- Cancel: function() {
- $( this ).dialog( "close" );
-
- }
- },
- close: function() {
- }
+ $('#LineItemDescription').ckeditor(function() {
+ this.destroy();
});
-
- $("#pageContentFactory").hide();
+ $("#addLineItemModal").empty();
-
- //Add a new Page Element.
- $("#addPage").button().click(function(event) {
- event.preventDefault();
+ var thisLineItemID = $(this).parent('td').attr('id');
+ $.get('/line_items/edit/'+thisLineItemID, function(data) {
+ $("#editLineItemModal").html(data);
+ $("#productDetails").hide();
+ $('#LineItemDescription').ckeditor(config);
+ showHideTextPrices();
+ $( "#editLineItemModal" ).dialog('open');
- newPage(false);
- return false;
+ });
+ });
+
+
+ $("#principleSelect").live('change',function() {
+
+ var principleID = getSelectedID('#principleSelect');
+
+ $("#productDetails").hide();
+
+ $.get('/documents/getProducts/'+principleID, function(data) {
+ $('#productsDiv').html(data);
+ });
+ });
+
+
+ $("#productSelect").live('change',function() {
+
+ var productID = getSelectedID('#productSelect');
+
+ $.get('/documents/getProductDetails/'+productID, function(data) {
+
+ $("#lineItemDetails").show();
+ $("#LineItemProductId").val(data.id);
+ $("#LineItemTitle").val(data.title);
+ $("#LineItemDescription").val(data.description);
+
+
+ }, "json");
+ });
+
+
+ // Initialize the editor.
+ // Callback function can be passed and executed after full instance creation.
+ $('.page').ckeditor(config);
+
+
+ $("#LineItemHasTextPrices").live('change', function() {
+ showHideTextPrices();
+ });
+
+
+ //Remove this Page
+ $(".removePage").live('click',function() {
+
+ $('.page').ckeditor(function() {
+ this.destroy();
});
+ $(this).parents(".docPage").remove();
- //Open the LineItem dialog
- $(".addLineItem").button().click(function() {
-
-
-
- $('#LineItemDescription').ckeditor(function() {
- this.destroy();
- });
-
-
- $("#editLineItemModal").empty();
-
-
-
- var nextItemNo = $(".lineItem").length;
- nextItemNo++;
-
- $.get('/line_items/add/'+docID, function(data) {
- $("#addLineItemModal").html(data);
-
-
- $("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No
-
-
- $("#productDetails").hide();
-
- $('#LineItemDescription').ckeditor(config);
-
- showHideTextPrices();
-
- $( "#addLineItemModal" ).dialog('open');
-
- });
-
- return false;
- });
-
-
- $(".editLineItem").live('click', function() {
-
-
- $('#LineItemDescription').ckeditor(function() {
- this.destroy();
- });
-
- $("#addLineItemModal").empty();
-
- var thisLineItemID = $(this).parent('td').attr('id');
- $.get('/line_items/edit/'+thisLineItemID, function(data) {
- $("#editLineItemModal").html(data);
- $("#productDetails").hide();
- $('#LineItemDescription').ckeditor(config);
- showHideTextPrices();
- $( "#editLineItemModal" ).dialog('open');
-
- });
- });
-
-
- $("#principleSelect").live('change',function() {
-
- var principleID = getSelectedID('#principleSelect');
-
- $("#productDetails").hide();
-
- $.get('/documents/getProducts/'+principleID, function(data) {
- $('#productsDiv').html(data);
- });
- });
-
-
- $("#productSelect").live('change',function() {
-
- var productID = getSelectedID('#productSelect');
-
- $.get('/documents/getProductDetails/'+productID, function(data) {
-
- $("#lineItemDetails").show();
- $("#LineItemProductId").val(data.id);
- $("#LineItemTitle").val(data.title);
- $("#LineItemDescription").val(data.description);
-
-
- }, "json");
- });
-
-
- // Initialize the editor.
- // Callback function can be passed and executed after full instance creation.
$('.page').ckeditor(config);
-
- $("#LineItemHasTextPrices").live('change', function() {
- showHideTextPrices();
+ });
+
+
+ $("#savePages").click(function() {
+ savePages();
+
+ });
+
+
+ $(".quickpricing").live('change', function() {
+ calculateQuickPrices();
+ });
+
+
+ $('.removeLineItem').live('click', function() {
+ var thisLineItemID = $(this).parent('td').attr('id');
+ $.post('/line_items/ajax_delete/'+thisLineItemID, function(data) {
+ loadLineItems();
+ });
+ });
+
+
+ $("#editQuoteDetails").click(function() {
+ var quoteID = $("#quoteID").html();
+
+ $('#QuoteCommercialComments').ckeditor(function() {
+ this.destroy();
});
-
- //Remove this Page
- $(".removePage").live('click',function() {
+ $.get('/quotes/edit/'+quoteID, function(data) {
- $('.page').ckeditor(function() {
- this.destroy();
- });
- $(this).parents(".docPage").remove();
- $('.page').ckeditor(config);
+ $("#QuoteDetails").html(data);
+ $('#QuoteCommercialComments').ckeditor(config);
+
+ $("#QuoteDetails").dialog('open');
});
+ });
- $("#savePages").click(function() {
- savePages();
+ $("#generateFirstPage").click(function() {
- });
-
-
- $(".quickpricing").live('change', function() {
- calculateQuickPrices();
- });
-
-
- $('.removeLineItem').live('click', function() {
- var thisLineItemID = $(this).parent('td').attr('id');
- $.post('/line_items/ajax_delete/'+thisLineItemID, function(data) {
- loadLineItems();
- });
- });
-
-
- $("#editQuoteDetails").click(function() {
- var quoteID = $("#quoteID").html();
-
- $('#QuoteCommercialComments').ckeditor(function() {
- this.destroy();
- });
-
- $.get('/quotes/edit/'+quoteID, function(data) {
-
-
-
- $("#QuoteDetails").html(data);
-
- $('#QuoteCommercialComments').ckeditor(config);
-
- $("#QuoteDetails").dialog('open');
- });
- });
-
-
- $("#generateFirstPage").click(function() {
-
- if($(".firstPage").length == 0) {
- newPage(true);
- }
-
- $.get('/documents/generateFirstPage/'+docID, function(data) {
- $(".firstPage").val(data);
- savePages();
- });
-
-
-
- });
-
-
- //Invoice View
- $('#shippingDetails').ckeditor(config);
-
- $("#DocumentBillTo").ckeditor(config);
- $("#DocumentShipTo").ckeditor(config);
-
- $("#saveInvoiceButton").click(function() {
-
-
-
- updateTextFields(); //Update the CKEditor instances.
-
- var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
-
-
-
- $.post('/documents/ajax_edit', invoiceDetails, function(data) {
- if(data =='SUCCESS') {
- $("#flashMessage").html("Invoice Saved Successfully");
- }
- else {
- $("#flashMessage").html("Unable to Save Invoice");
- }
-
- $("#flashMessage").show();
-
-
- loadLineItems();
- });
-
- });
- //OA View.
- $("#saveOAButton").click(function() {
-
-
- updateTextFields(); //Update the CKEditor instances.
-
- var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
-
-
-
- $.post('/documents/ajax_edit', invoiceDetails, function(data) {
- if(data =='SUCCESS') {
- $("#flashMessage").html("Order Acknowledgement Saved Successfully");
- }
- else {
- $("#flashMessage").html("Unable to Save Order Acknowledgement");
- }
-
- $("#flashMessage").show();
-
-
- loadLineItems();
- });
+ if($(".firstPage").length == 0) {
+ newPage(true);
+ }
+ $.get('/documents/generateFirstPage/'+docID, function(data) {
+ $(".firstPage").val(data);
+ savePages();
});
- $("#createJobAndOA").click(function() {
- $("#addJobConfirmation").dialog('open');
+ });
+
+
+ //Invoice View
+ $('#shippingDetails').ckeditor(config);
+
+ $("#DocumentBillTo").ckeditor(config);
+ $("#DocumentShipTo").ckeditor(config);
+
+ $("#saveInvoiceButton").click(function() {
+
+
+
+ updateTextFields(); //Update the CKEditor instances.
+
+ var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
+
+
+
+ $.post('/documents/ajax_edit', invoiceDetails, function(data) {
+ if(data =='SUCCESS') {
+ $("#flashMessage").html("Invoice Saved Successfully");
+ }
+ else {
+ $("#flashMessage").html("Unable to Save Invoice");
+ }
+
+ $("#flashMessage").show();
+
+
+ loadLineItems();
});
+ });
+ //OA View.
+ $("#saveOAButton").click(function() {
+
+
+ updateTextFields(); //Update the CKEditor instances.
+
+ var invoiceDetails = $('#DocumentEditForm').find('input,select,textarea');
+
+
+
+ $.post('/documents/ajax_edit', invoiceDetails, function(data) {
+ if(data =='SUCCESS') {
+ $("#flashMessage").html("Order Acknowledgement Saved Successfully");
+ }
+ else {
+ $("#flashMessage").html("Unable to Save Order Acknowledgement");
+ }
+
+ $("#flashMessage").show();
+
+
+ loadLineItems();
+ });
+
+ });
+
+
+
+ $("#createJobAndOA").click(function() {
+ $("#addJobConfirmation").dialog('open');
+ });
+
});
$('.generateCommercialComments').live('click', function(event) {
- event.preventDefault();
-
-
-
- var deliveryTime = $("#QuoteDeliveryTime").val();
- var deliveryTF = $("#QuoteDeliveryTimeFrame").val();
- var paymentTerms = $("#QuotePaymentTerms").val();
- var daysValid = $("#QuoteDaysValid").val();
- var deliveryPoint = $("#QuoteDeliveryPoint").val();
- var exchangeRate = $("#QuoteExchangeRate").val();
- var customsDuty = $("#QuoteCustomsDuty").val();
+ event.preventDefault();
- deliveryTime = deliveryTime.toUpperCase();
- paymentTerms = paymentTerms.toUpperCase();
- deliveryPoint = deliveryPoint.toUpperCase();
-
- var commComments = $("#commCommentsInitialString").clone();
- var commList = commComments.find('ol');
+ var deliveryTime = $("#QuoteDeliveryTime").val();
+ var deliveryTF = $("#QuoteDeliveryTimeFrame").val();
+ var paymentTerms = $("#QuotePaymentTerms").val();
+ var daysValid = $("#QuoteDaysValid").val();
+ var deliveryPoint = $("#QuoteDeliveryPoint").val();
+ var exchangeRate = $("#QuoteExchangeRate").val();
+ var customsDuty = $("#QuoteCustomsDuty").val();
+
+
+ deliveryTime = deliveryTime.toUpperCase();
+ paymentTerms = paymentTerms.toUpperCase();
+ deliveryPoint = deliveryPoint.toUpperCase();
+
+ var commComments = $("#commCommentsInitialString").clone();
+
+ var commList = commComments.find('ol');
+
+ commList.append('DELIVERY IS ESTIMATED AT '+deliveryTime+ ' '+deliveryTF+ ' FROM RECEIPT OF YOUR TECHNICALLY AND COMMERCIALLY CLEAR ORDER');
+ commList.append('PAYMENT TERMS: '+paymentTerms+'');
+ commList.append('QUOTATION IS VALID FOR '+daysValid+' DAYS');
+ commList.append('ALL PRICES ARE '+deliveryPoint+'');
+ commList.append('EXCHANGE RATE: '+exchangeRate+'');
+ commList.append('CUSTOMS DUTY INCLUDED AT: '+customsDuty+'');
+ commList.append('GST 10% EXTRA');
+ commList.append('WHEN PAYMENTS ARE MADE INTO OUR BANK ACCOUNT, BANK CHARGES ARE YOUR RESPONSIBILITY');
+ $('#QuoteCommercialComments').val(commComments.html());
+
- commList.append('DELIVERY IS ESTIMATED AT '+deliveryTime+ ' '+deliveryTF+ ' FROM RECEIPT OF YOUR TECHNICALLY AND COMMERCIALLY CLEAR ORDER');
- commList.append('PAYMENT TERMS: '+paymentTerms+'');
- commList.append('QUOTATION IS VALID FOR '+daysValid+' DAYS');
- commList.append('ALL PRICES ARE '+deliveryPoint+'');
- commList.append('EXCHANGE RATE: '+exchangeRate+'');
- commList.append('CUSTOMS DUTY INCLUDED AT: '+customsDuty+'');
- commList.append('GST 10% EXTRA');
- commList.append('WHEN PAYMENTS ARE MADE INTO OUR BANK ACCOUNT, BANK CHARGES ARE YOUR RESPONSIBILITY');
- $('#QuoteCommercialComments').val(commComments.html());
-
-
});
function showHideTextPrices() {
- if( $('#LineItemHasTextPrices').val() == 1) {
- $("#noCosting").hide();
- $("#noCosting").find('input').val('');
- $("#textPrices").show();
- }
- else {
- $("#noCosting").show();
- $("#textPrices").hide();
- }
+ if( $('#LineItemHasTextPrices').val() == 1) {
+ $("#noCosting").hide();
+ $("#noCosting").find('input').val('');
+ $("#textPrices").show();
+ }
+ else {
+ $("#noCosting").show();
+ $("#textPrices").hide();
+ }
}
function updateTextFields() {
- $('#shippingDetails').ckeditor(function() {
- this.updateElement();
- });
+ $('#shippingDetails').ckeditor(function() {
+ this.updateElement();
+ });
- $("#DocumentBillTo").ckeditor(function() {
- this.updateElement();
- });
- $("#DocumentShipTo").ckeditor(function() {
- this.updateElement();
- });
+ $("#DocumentBillTo").ckeditor(function() {
+ this.updateElement();
+ });
+ $("#DocumentShipTo").ckeditor(function() {
+ this.updateElement();
+ });
}
function newPage(firstPage) {
-
- $('.page').ckeditor(function() {
- this.destroy();
- });
+
+ $('.page').ckeditor(function() {
+ this.destroy();
+ });
- var newPage = $('#pageContentFactory').clone();
- newPage.removeAttr('id');
- newPage.show();
+ var newPage = $('#pageContentFactory').clone();
+ newPage.removeAttr('id');
+ newPage.show();
-
- var pageCount = $('.docPage').length;
- //alert(pageCount);
+ var pageCount = $('.docPage').length;
- pageCount++;
- var model = 'DocPage';
- var field = 'content';
- var ID = getCakeID(model,pageCount, field);
- var name = getCakeName(model, pageCount, field);
-
- newPage.find('label').attr('for', ID);
-
- newPage.find('textarea').attr('id', ID).attr('name', name);
- newPage.addClass('docPage');
+ //alert(pageCount);
+
+ pageCount++;
+ var model = 'DocPage';
+ var field = 'content';
+ var ID = getCakeID(model,pageCount, field);
+ var name = getCakeName(model, pageCount, field);
+
+ newPage.find('label').attr('for', ID);
+
+ newPage.find('textarea').attr('id', ID).attr('name', name);
+ newPage.addClass('docPage');
- if(firstPage == true) {
- newPage.find('textarea').addClass('firstPage');
- }
+ if(firstPage == true) {
+ newPage.find('textarea').addClass('firstPage');
+ }
- var hiddenName = getCakeName(model, pageCount, 'page_number');
+ var hiddenName = getCakeName(model, pageCount, 'page_number');
- newPage.append('');
- $('.pages').append(newPage);
-
- $('.page').ckeditor(config);
+ newPage.append('');
+ $('.pages').append(newPage);
+
+ $('.page').ckeditor(config);
}
function savePages() {
- var docPages = $('#DocumentEditForm').find('input,select,textarea');
+ var docPages = $('#DocumentEditForm').find('input,select,textarea');
- $('.page').ckeditor(function() {
- this.updateElement();
- });
+ $('.page').ckeditor(function() {
+ this.updateElement();
+ });
- $.post('/documents/ajax_edit', docPages, function(data) {
- if(data =='SUCCESS') {
- $("#flashMessage").html("Pages Saved Successfully");
- }
- else {
- $("#flashMessage").html("Unable to Save Pages");
- }
+ $.post('/documents/ajax_edit', docPages, function(data) {
+ if(data =='SUCCESS') {
+ $("#flashMessage").html("Pages Saved Successfully");
+ }
+ else {
+ $("#flashMessage").html("Unable to Save Pages");
+ }
- $("#flashMessage").show();
+ $("#flashMessage").show();
- loadLineItems();
- });
+ loadLineItems();
+ });
}
function loadLineItems() {
- var documentID = $("#documentID").html();
+ var documentID = $("#documentID").html();
- /*$.get('/line_items/getTable/'+documentID, function(data) {
- $("#lineItems").html(data);
+ /*$.get('/line_items/getTable/'+documentID, function(data) {
+ $("#lineItems").html(data);
});*/
-
- $.ajax({
- url: '/line_items/getTable/'+documentID,
- cache: false,
- success: function(data) {
- $("#lineItems").html(data);
- }
- });
-
+
+ $.ajax({
+ url: '/line_items/getTable/'+documentID,
+ cache: false,
+ success: function(data) {
+ $("#lineItems").html(data);
+ }
+ });
+
}
function calculateQuickPrices() {
- var quantity = $('#LineItemQuantity').val();
+ var quantity = $('#LineItemQuantity').val();
- var gross_unit_price = $("#LineItemGrossUnitPrice").val();
- var net_unit_price = $("#LineItemNetUnitPrice").val();
- var discount_percent = $("#LineItemDiscountPercent").val();
- var discount_amount_unit = $("#LineItemDiscountAmountUnit").val();
- var discount_amount_total = $("#LineItemDiscountAmountTotal").val();
- var gross_price = $("#LineItemGrossPrice").val();
- var net_price = $("#LineItemNetPrice").val();
+ var gross_unit_price = $("#LineItemGrossUnitPrice").val();
+ var net_unit_price = $("#LineItemNetUnitPrice").val();
+ var discount_percent = $("#LineItemDiscountPercent").val();
+ var discount_amount_unit = $("#LineItemDiscountAmountUnit").val();
+ var discount_amount_total = $("#LineItemDiscountAmountTotal").val();
+ var gross_price = $("#LineItemGrossPrice").val();
+ var net_price = $("#LineItemNetPrice").val();
- gross_price = quantity * gross_unit_price;
- $("#LineItemGrossPrice").val(gross_price);
+ gross_price = quantity * gross_unit_price;
+ $("#LineItemGrossPrice").val(gross_price);
- discount_amount_unit = (discount_percent/100) * gross_unit_price;
- discount_amount_unit = discount_amount_unit.toFixed(2);
+ discount_amount_unit = (discount_percent/100) * gross_unit_price;
+ discount_amount_unit = discount_amount_unit.toFixed(2);
- discount_amount_total = (discount_percent/100) * gross_price;
- discount_amount_total = discount_amount_total.toFixed(2);
- $("#LineItemDiscountAmountTotal").val(discount_amount_total);
+ discount_amount_total = (discount_percent/100) * gross_price;
+ discount_amount_total = discount_amount_total.toFixed(2);
+ $("#LineItemDiscountAmountTotal").val(discount_amount_total);
- net_price = gross_price - discount_amount_total;
- $("#LineItemNetPrice").val(net_price);
+ net_price = gross_price - discount_amount_total;
+ $("#LineItemNetPrice").val(net_price);
+
+
+ $("#LineItemDiscountAmountUnit").val(discount_amount_unit);
+ net_unit_price = gross_unit_price - discount_amount_unit;
+ $("#LineItemNetUnitPrice").val(net_unit_price);
- $("#LineItemDiscountAmountUnit").val(discount_amount_unit);
- net_unit_price = gross_unit_price - discount_amount_unit;
- $("#LineItemNetUnitPrice").val(net_unit_price);
-
-
}
function calcNetPrice() {
- var discountPercent = $("#discountPercent").val();
- var unitPrice = $('#unitPrice').val();
+ var discountPercent = $("#discountPercent").val();
+ var unitPrice = $('#unitPrice').val();
- var quantity = $('#LineItemQuantity').val();
+ var quantity = $('#LineItemQuantity').val();
- var grossSellPrice = quantity * unitPrice;
+ var grossSellPrice = quantity * unitPrice;
- //Calculate the Sale Discount amount.
- var UnitDiscountAmount = (discountPercent/100) * unitPrice;
+ //Calculate the Sale Discount amount.
+ var UnitDiscountAmount = (discountPercent/100) * unitPrice;
- var TotalDiscountAmount = (discountPercent/100) * grossSellPrice;
- UnitDiscountAmount = UnitDiscountAmount.toFixed(2);
- TotalDiscountAmount = TotalDiscountAmount.toFixed(2);
+ var TotalDiscountAmount = (discountPercent/100) * grossSellPrice;
+ UnitDiscountAmount = UnitDiscountAmount.toFixed(2);
+ TotalDiscountAmount = TotalDiscountAmount.toFixed(2);
- $('#total_discountAmount').val(TotalDiscountAmount);
- $('#discountAmountEach').val(UnitDiscountAmount);
- $('#net_price_each').val(unitPrice - UnitDiscountAmount);
+ $('#total_discountAmount').val(TotalDiscountAmount);
+ $('#discountAmountEach').val(UnitDiscountAmount);
+ $('#net_price_each').val(unitPrice - UnitDiscountAmount);
- $('#grossPrice').val(grossSellPrice);
+ $('#grossPrice').val(grossSellPrice);
- var netPrice = grossSellPrice - TotalDiscountAmount;
- $('#netPrice').val(netPrice);
+ var netPrice = grossSellPrice - TotalDiscountAmount;
+ $('#netPrice').val(netPrice);
}
function checkNaN(value) {
- if( isNaN(value) == true) {
- return 0;
- }
- else {
- return value;
- }
+ if( isNaN(value) == true) {
+ return 0;
+ }
+ else {
+ return value;
+ }
-
-}
\ No newline at end of file
+
+}