@@ -33,6 +38,15 @@ echo $form->input('Document.id');
Save Pages
=$form->end();?>
+
=$document['Quote']['id']?>
+
+
//debug($this->data);?>
//debug($enquiry);?>
diff --git a/views/elements/enquiry_table.ctp b/views/elements/enquiry_table.ctp
index 95666126..6fd3c8a6 100755
--- a/views/elements/enquiry_table.ctp
+++ b/views/elements/enquiry_table.ctp
@@ -1,6 +1,6 @@
link('jquery.jeditable.mini'); ?>
-=$javascript->link('ajax_pagination_enquiry'); ?>
+ //$javascript->link('ajax_pagination_enquiry'); ?>
options(array('url'=>$this->passedArgs)); ?>
diff --git a/views/elements/line_items_table.ctp b/views/elements/line_items_table.ctp
new file mode 100644
index 00000000..d7413e17
--- /dev/null
+++ b/views/elements/line_items_table.ctp
@@ -0,0 +1,85 @@
+
+
+
+ ITEM NO.
+ QTY
+ DESCRIPTION
+ UNIT PRICE
+ TOTAL PRICE
+
+
+
+
+
+ =$currencyCode?>
+ =$currencyCode?>
+
+
+
+
+
+
+ if($li['option'] == 1) {
+ echo 'Option ';
+ }
+ ?>
+ =$li['item_number'];?>
+ =$li['quantity'];?>
+ =$li['title'];?>
+ =$li['description'];?>
+
+
+
+ =$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);?>
+
+
+
+ =$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);?>
+
+
+
+
+
+
+
+
+
+ =$totalsDescText['subtotal']?>
+
+ =$number->currency($totals['subtotal'], $currencyCode);?>
+
+
+
+
+ =$totalsDescText['gst'];?>
+
+
+ if($gst ==1) {
+ echo $number->currency($totals['gst'], $currencyCode);
+ }
+ else {
+ echo 'N/A';
+ }?>
+
+
+
+
+
+ =$totalsDescText['total'];?>
+ =$currencyCode?>
+ =$number->currency($totals['total'], $currencyCode);?>
+
+
+
diff --git a/views/elements/quote_table.ctp b/views/elements/quote_table.ctp
index 81f00d4b..53ad31e9 100755
--- a/views/elements/quote_table.ctp
+++ b/views/elements/quote_table.ctp
@@ -26,7 +26,7 @@
nice($quote['Quote']['created']);?>
- link(__('View', true), array('controller'=> 'quotes', 'action'=>'view', $quote['Quote']['id'])); ?>
+ link(__('View', true), array('controller'=> 'documents', 'action'=>'view', $quote['Quote']['document_id'])); ?>
link(__('Revise', true), array('controller'=>'quotes', 'action'=>'revise', $quote['Quote']['id'])); ?>
diff --git a/views/enquiries/index.ctp b/views/enquiries/index.ctp
index 6e00bcc7..ea42fd6a 100755
--- a/views/enquiries/index.ctp
+++ b/views/enquiries/index.ctp
@@ -1,8 +1,8 @@
- image('ajax-loader.gif'); ?>
-
-
-
+
image('ajax-loader.gif'); ?>
+
+
+
echo $this->element('enquiry_table', $enquiries, $status_list); ?>
diff --git a/views/enquiries/view.ctp b/views/enquiries/view.ctp
index 388ea88e..e250aaa1 100755
--- a/views/enquiries/view.ctp
+++ b/views/enquiries/view.ctp
@@ -123,7 +123,14 @@ $class = ' class="altrow"';?>
*/?>
-
+ 1) {
+ echo $enquiry['Enquiry']['quote_count'].' Quotes for this Enquiry';
+ }
+ else {
+ echo $enquiry['Enquiry']['quote_count'].' Quote for this Enquiry';
+
+ }?>
+
element('quote_table', $quotes); ?>
@@ -310,5 +317,5 @@ $class = ' class="altrow"';?>
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/views/line_items/ajax_delete.ctp b/views/line_items/ajax_delete.ctp
new file mode 100644
index 00000000..e69de29b
diff --git a/views/line_items/ajax_edit.ctp b/views/line_items/ajax_edit.ctp
new file mode 100644
index 00000000..e69de29b
diff --git a/views/line_items/get_table.ctp b/views/line_items/get_table.ctp
index 66187e25..d7c4c574 100644
--- a/views/line_items/get_table.ctp
+++ b/views/line_items/get_table.ctp
@@ -1,8 +1,8 @@
@@ -13,7 +13,7 @@ $(function() {
ITEM NO.
QTY
DESCRIPTION
-
UNIT
+ UNIT PRICE
TOTAL PRICE
ACTIONS
@@ -21,30 +21,76 @@ $(function() {
- =$currencies[$document['Quote']['currency_id']]?>
- =$currencies[$document['Quote']['currency_id']]?>
+ =$currencyCode?>
+ =$currencyCode?>
-
- =$li['item_number'];?>
+
+
+ if($li['option'] == 1) {
+ echo 'Option ';
+ }
+ ?>
+ =$li['item_number'];?>
=$li['quantity'];?>
=$li['title'];?>
- =$li['description'];?>
+ =$li['description'];?>
-
- =$li['unit_price'];?>
+
+
+ =$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);?>
+
-
- =$li['gross_price'];?>
+
+ =$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);?>
+
-
+
Edit
Remove
-
\ No newline at end of file
+
+
+
+
+ SUB-TOTAL (Excluding GST)
+
+ =$number->currency($totals['subtotal'], $currencyCode);?>
+
+
+
+
+
+ GST (10%)
+
+ =$number->currency($totals['gst'], $currencyCode);?>
+
+
+
+
+
+ TOTAL PAYABLE (INCLUDING GST)
+
+ =$number->currency($totals['total'], $currencyCode);?>
+
+
+
+
diff --git a/views/principles/view.ctp b/views/principles/view.ctp
index bcef08d7..b2448cfe 100755
--- a/views/principles/view.ctp
+++ b/views/principles/view.ctp
@@ -66,9 +66,10 @@
- echo $javascript->link('add_user'); ?>
-
+ //echo $javascript->link('add_user'); ?>
+
create('User');?>
@@ -141,4 +142,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/views/quotes/ajax_edit.ctp b/views/quotes/ajax_edit.ctp
new file mode 100644
index 00000000..e69de29b
diff --git a/views/quotes/edit.ctp b/views/quotes/edit.ctp
index 1755e3d3..8213b98f 100755
--- a/views/quotes/edit.ctp
+++ b/views/quotes/edit.ctp
@@ -1,34 +1,26 @@
-
-create('Quote');?>
-
-
- input('id');
- echo $form->input('enquiry_id');
- echo $form->input('currency_id');
- echo $form->input('revision');
- echo $form->input('delivery_time');
- echo $form->input('payment_terms');
- echo $form->input('days_valid');
- echo $form->input('date_issued');
- echo $form->input('valid_until');
- echo $form->input('delivery_point');
- echo $form->input('exchange_rate');
- echo $form->input('customs_duty');
- echo $form->input('document_id');
- ?>
-
-end('Submit');?>
-
-
-
- link(__('Delete', true), array('action' => 'delete', $form->value('Quote.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Quote.id'))); ?>
- link(__('List Quotes', true), array('action' => 'index'));?>
- link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?>
- link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?>
- link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
- link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
- link(__('List Documents', true), array('controller' => 'documents', 'action' => 'index')); ?>
- link(__('New Document', true), array('controller' => 'documents', 'action' => 'add')); ?>
-
-
+
+create('Quote',array('default'=>false));
+
+echo $form->input('id');
+echo $form->input('enquiry_id', array('type'=>'hidden'));
+echo $form->input('currency_id');
+echo $form->input('revision', array('type'=>'hidden'));
+echo $form->input('delivery_time');
+echo $form->input('payment_terms');
+echo $form->input('days_valid');
+echo $form->input('date_issued');
+echo $form->input('valid_until');
+echo $form->input('delivery_point');
+echo $form->input('exchange_rate');
+echo $form->input('customs_duty');
+echo $form->input('document_id',array('type'=>'hidden'));
+echo $form->input('commercial_comments', array('between'=>''));
+
+echo $form->end();
+?>
\ No newline at end of file
diff --git a/views/quotes/pdf.ctp b/views/quotes/pdf.ctp
index 195762ee..75b88fb9 100755
--- a/views/quotes/pdf.ctp
+++ b/views/quotes/pdf.ctp
@@ -56,7 +56,7 @@ foreach ($quote['QuotePage'] as $page) {
}
- $tcpdf->DetailsBox($enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'],
+ $tcpdf->DetailsBox($docTypeFullName, $enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'],
$enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $cmcRef,
$enquiry['Enquiry']['customer_reference'], $quote['Quote']['date_issued']);
diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css
index 81d07f69..354f0fe3 100755
--- a/webroot/css/quotenik.css
+++ b/webroot/css/quotenik.css
@@ -786,6 +786,10 @@ input#searchbox {
}
+input.number_input {
+ width: 80px;
+}
+
select {
clear: both;
font-size: 120%;
@@ -1232,7 +1236,7 @@ span.addLineItem {
table .jobsTable {
-
+
}
table.jobsTable tr th {
@@ -1365,7 +1369,7 @@ select.shipmentCategories {
/* CSS for the Job Reporting */
#yearMonths {
-
+
float: left;
margin-right: 4em;
}
@@ -1472,7 +1476,7 @@ table.shipments {
.invForm {
border: 1px solid;
-
+
margin-top: 1em;
}
@@ -1496,7 +1500,7 @@ div.address span {
position: absolute;
left: 50%;
top: 50%;
-
+
}
.pages {
@@ -1533,4 +1537,15 @@ table.lineItems tr th {
table.lineItems tr td.description {
text-align: left;
padding: 0.5em;
+}
+
+table.lineItems tr td.leftAlign {
+ text-align: left;
+}
+
+
+table.lineItems tr td.price {
+ padding-left: 0.5em;
+ padding-right: 0.5em;
+ white-space: nowrap;
}
\ No newline at end of file
diff --git a/webroot/js/document_add_edit.js b/webroot/js/document_add_edit.js
index 8e031c97..e0f3aeb6 100644
--- a/webroot/js/document_add_edit.js
+++ b/webroot/js/document_add_edit.js
@@ -1,4 +1,11 @@
-
+/**
+ * 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
+ */
$(function() {
@@ -11,18 +18,15 @@ $(function() {
$("#lineItemDetails").hide();
- $( "#lineItemModal" ).dialog({
+ $( "#addLineItemModal" ).dialog({
autoOpen: false,
height: 900,
width: 600,
modal: true,
buttons: {
"Add Line Item": function() {
- /*for ( instance in CKEDITOR.instances ) {
- CKEDITOR.instances[instance].updateElement();
- CKEDITOR.instances[instance].destroy();
- }*/
- $('#LineItemDescription').ckeditor(function() {
+
+ $('#QuoteCommercialComments').ckeditor(function() {
this.updateElement();
this.destroy();
});
@@ -31,14 +35,14 @@ $(function() {
var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
- $( "#lineItemModal" ).dialog('close');
- loadLineItems();
+ $( "#addLineItemModal" ).dialog('close');
+
});
},
Cancel: function() {
$( this ).dialog( "close" );
- loadLineItems();
+
}
},
close: function() {
@@ -47,9 +51,73 @@ $(function() {
}
});
-
+ $( "#editLineItemModal" ).dialog({
+ autoOpen: false,
+ height: 900,
+ width: 600,
+ modal: true,
+ buttons: {
+ "Edit Line Item": function() {
+
+ $('#LineItemDescription').ckeditor(function() {
+ this.updateElement();
+ this.destroy();
+ });
+ var thisLineItemInputs = $('#LineItemEditForm').find('input,select,textarea');
+
+ $.post('/line_items/ajax_edit', thisLineItemInputs, function(data) {
+ $( "#editLineItemModal" ).dialog('close');
+
+ });
+
+ },
+ 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();
+ }
+ });
+
+
$("#pageContentFactory").hide();
@@ -98,13 +166,29 @@ $(function() {
//Open the LineItem dialog
$("#addLineItem").button().click(function() {
+
+
var docID = $('#documentID').html();
+ $('#LineItemDescription').ckeditor(function() {
+ this.destroy();
+ });
+
+ $("#editLineItemModal").empty();
+
+ var nextItemNo = $(".lineItem").length;
+ nextItemNo++;
+
$.get('/line_items/add/'+docID, function(data) {
- $("#lineItemModal").html(data);
+ $("#addLineItemModal").html(data);
+
+
+ $("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No
+
+
$("#productDetails").hide();
$('#LineItemDescription').ckeditor(config);
- $( "#lineItemModal" ).dialog('open');
+ $( "#addLineItemModal" ).dialog('open');
});
@@ -112,6 +196,25 @@ $(function() {
});
+ $(".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);
+ $( "#editLineItemModal" ).dialog('open');
+
+ });
+ });
+
$("#principleSelect").live('change',function() {
@@ -183,9 +286,75 @@ $(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');
+ });
+ });
});
+$('.generateCommercialComments').live('click', function(event) {
+ event.preventDefault();
+
+
+
+ var deliveryTime = $("#QuoteDeliveryTime").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+ '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 loadLineItems() {
var documentID = $("#documentID").html();
@@ -194,4 +363,77 @@ function loadLineItems() {
$("#lineItems").html(data);
});
+}
+
+
+function calculateQuickPrices() {
+
+ 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();
+
+ 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_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);
+
+
+ $("#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 quantity = $('#LineItemQuantity').val();
+
+
+ var grossSellPrice = quantity * unitPrice;
+
+ //Calculate the Sale Discount amount.
+ var UnitDiscountAmount = (discountPercent/100) * unitPrice;
+
+ 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);
+
+ $('#grossPrice').val(grossSellPrice);
+
+ var netPrice = grossSellPrice - TotalDiscountAmount;
+ $('#netPrice').val(netPrice);
+
+}
+
+function checkNaN(value) {
+ if( isNaN(value) == true) {
+ return 0;
+ }
+ else {
+ return value;
+ }
}
\ No newline at end of file
diff --git a/webroot/js/global.js b/webroot/js/global.js
index d171ac6c..9bba2abe 100644
--- a/webroot/js/global.js
+++ b/webroot/js/global.js
@@ -59,7 +59,7 @@ var config = {
['Image','Table','HorizontalRule','SpecialChar'],
'/',
['Styles','Format'],
- ['Bold','Italic','Strike'],
+ ['Bold','Italic','Strike','Underline'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['Link','Unlink'],
['Maximize','-','About']