Various changes

This commit is contained in:
Karl Cordes 2012-04-29 12:29:16 +10:00
commit ea52721254
12 changed files with 464 additions and 25 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE `products` ADD `item_code` VARCHAR( 255 ) NOT NULL ,
ADD `item_description` VARCHAR( 255 ) NOT NULL;

View file

@ -99,7 +99,8 @@ class ProductsController extends AppController {
if (!empty($this->data)) { if (!empty($this->data)) {
if ($this->Product->save($this->data)) { if ($this->Product->save($this->data)) {
$this->Session->setFlash(__('The Product has been saved', true)); $this->Session->setFlash(__('The Product has been saved', true));
$this->redirect(array('action'=>'index')); $id = $this->Product->id;
$this->redirect(array('action'=>'view/'.$id));
} else { } else {
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true)); $this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
} }

View file

@ -57,9 +57,12 @@ class UsersController extends AppController {
$this->redirect($this->Auth->logout()); $this->redirect($this->Auth->logout());
} }
function index() { function index($type = 'user') {
$this->User->recursive = 0; $this->User->recursive = 0;
$this->set('users', $this->paginate());
$users = $this->paginate(array('User.type'=> $type));
$this->set('users', $users);
} }
/** /**

View file

@ -16,8 +16,8 @@ class Costing extends AppModel {
'LineItem' => array('className'=>'LineItem','foreignKey' => 'line_item_id' 'LineItem' => array('className'=>'LineItem','foreignKey' => 'line_item_id'
), ),
'PurchaseCurrency' => array('className' => 'Currency', 'foreignKey' => 'purchase_currency_id'), 'PurchaseCurrency' => array('className' => 'Currency', 'foreignKey' => 'purchase_currency_id', 'order'=>'PurchaseCurrency.name ASC'),
'SaleCurrency' => array('className' => 'Currency', 'foreignKey' => 'sale_currency_id') 'SaleCurrency' => array('className' => 'Currency', 'foreignKey' => 'sale_currency_id', 'order'=>'SaleCurrency.name ASC')

View file

@ -1,11 +1,11 @@
<div class="warning"> <div class="warning">
<p>WARNING: Deleting any records from these tables can have serious implications for data integrity.</p> <p>WARNING: Deleting any records from these tables can have serious implications for data integrity.</p>
<p>Records in other tables could potentially end up referencing non-existing records.</p> <p>ie.Records in other tables could potentially end up referencing non-existing records. if currency id 2 were deleted, all records referencing AUD will be break.</p>
<p>eg. If currency id 2 were deleted, all other records referencing AUD would lose that reference.</p> <p>Tread carefully.</p>
<p>Be careful!</p>
</div> </div>
<ul id="extraModels"> <ul id="extraModels">
<li><?=$html->link('Users','/users/index');?></li>
<li><?=$html->link('Countries', '/countries/index');?></li> <li><?=$html->link('Countries', '/countries/index');?></li>
<li><?=$html->link('Currencies', '/currencies/index');?></li> <li><?=$html->link('Currencies', '/currencies/index');?></li>

View file

@ -17,11 +17,14 @@ $('.ckeditor').ckeditor(config);
echo $form->input('title', array('class' => 'required', 'title'=>'Please Enter the Title for the Product')); echo $form->input('title', array('class' => 'required', 'title'=>'Please Enter the Title for the Product'));
echo $form->input('description', array('id' => 'description', 'class'=>'ckeditor')); echo $form->input('description', array('id' => 'description', 'class'=>'ckeditor'));
echo $form->input('item_code');
echo $form->input('item_description');
echo $form->input('notes'); echo $form->input('notes');
echo $html->image('calculator.png');
?> ?>

View file

@ -15,6 +15,11 @@ echo $javascript->link('edit_product');
echo $form->input('description'); echo $form->input('description');
echo $form->input('notes'); echo $form->input('notes');
echo $form->input('item_code');
echo $form->input('item_description');
?> ?>
</fieldset> </fieldset>
<?php echo $form->end(array('label' => 'Edit Product', 'class'=>'wymupdate'));?> <?php echo $form->end(array('label' => 'Edit Product', 'class'=>'wymupdate'));?>

View file

@ -21,18 +21,17 @@
<?php echo $product['Product']['description']; ?> <?php echo $product['Product']['description']; ?>
&nbsp; &nbsp;
</dd> </dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Item Code'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['item_code']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Item Decription'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['item_description']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Model Number'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['model_number']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Model Number Format'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['model_number_format']; ?>
&nbsp;
</dd>
</dl> </dl>
</div> </div>

View file

@ -9,6 +9,7 @@
echo $form->input('last_name'); echo $form->input('last_name');
echo $form->input('email'); echo $form->input('email');
echo $form->input('job_title'); echo $form->input('job_title');
echo $form->input('type', array('type'=>'hidden','value'=>'user'));
?> ?>
</fieldset> </fieldset>
<?php echo $form->end('Submit');?> <?php echo $form->end('Submit');?>

14
views/users/edit.ctp Normal file
View file

@ -0,0 +1,14 @@
<div class="users form">
<?php echo $form->create('User');?>
<fieldset>
<legend><?php __('Edit User');?></legend>
<?php
echo $form->input('username');
echo $form->input('first_name');
echo $form->input('last_name');
echo $form->input('email');
echo $form->input('job_title');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>

View file

@ -1636,10 +1636,6 @@ div.warning {
padding-bottom: 1em; padding-bottom: 1em;
} }
div.warning p {
padding: 0.5em;
}
#extraModels { #extraModels {
list-style: none; list-style: none;
} }

View file

@ -13,6 +13,24 @@ $(function() {
loadLineItems(); loadLineItems();
var docID = $('#documentID').html(); var docID = $('#documentID').html();
<<<<<<< HEAD
$("#flashMessage").hide();
$("#lineItemDetails").hide();
$( "#addLineItemModal" ).dialog({
autoOpen: false,
height: 900,
width: 600,
modal: true,
buttons: {
"Add Line Item": function() {
$('#LineItemDescription').ckeditor(function() {
this.updateElement();
});
=======
$("#flashMessage").hide(); $("#flashMessage").hide();
@ -30,9 +48,73 @@ $(function() {
this.updateElement(); this.updateElement();
}); });
>>>>>>> b15eee9619754852ad75ae598103249c33343064
var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea'); var thisLineItemInputs = $('#LineItemAddForm').find('input,select,textarea');
<<<<<<< HEAD
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);
}
});
},
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');
$.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();
}
});
=======
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) { $.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
if(data == 'SUCCESS') { if(data == 'SUCCESS') {
@ -100,13 +182,30 @@ $(function() {
modal: true, modal: true,
buttons: { buttons: {
"Edit Quote Details": function() { "Edit Quote Details": function() {
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$( "#QuoteDetails" ).dialog({
autoOpen: false,
height: 900,
width: 600,
modal: true,
buttons: {
"Edit Quote Details": function() {
<<<<<<< HEAD
=======
$('#QuoteCommercialComments').ckeditor(function() {
this.updateElement();
this.destroy();
});
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$('#QuoteCommercialComments').ckeditor(function() { $('#QuoteCommercialComments').ckeditor(function() {
this.updateElement(); this.updateElement();
this.destroy(); this.destroy();
}); });
<<<<<<< HEAD
var quoteInputs = $('#QuoteEditForm').find('input,select,textarea'); var quoteInputs = $('#QuoteEditForm').find('input,select,textarea');
@ -124,8 +223,36 @@ $(function() {
loadLineItems(); loadLineItems();
} }
}); });
=======
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();
}
});
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$( "#addJobConfirmation" ).dialog({
autoOpen: false,
height: 400,
width: 400,
modal: true,
buttons: {
"Create New Job and Order Acknowledgement": function() {
<<<<<<< HEAD
$( "#addJobConfirmation" ).dialog({ $( "#addJobConfirmation" ).dialog({
autoOpen: false, autoOpen: false,
@ -136,12 +263,22 @@ $(function() {
"Create New Job and Order Acknowledgement": function() { "Create New Job and Order Acknowledgement": function() {
var documentID = $("#documentID").html(); var documentID = $("#documentID").html();
=======
var documentID = $("#documentID").html();
//window.location.href = "/documents/convert_to_oa/"+documentID; //window.location.href = "/documents/convert_to_oa/"+documentID;
//var newOAform = $('#DocumentConvertToOaForm').find('input'); //var newOAform = $('#DocumentConvertToOaForm').find('input');
var newOAform = $('#DocumentConvertToOaForm'); var newOAform = $('#DocumentConvertToOaForm');
newOAform.submit(); newOAform.submit();
>>>>>>> b15eee9619754852ad75ae598103249c33343064
//window.location.href = "/documents/convert_to_oa/"+documentID;
//var newOAform = $('#DocumentConvertToOaForm').find('input');
var newOAform = $('#DocumentConvertToOaForm');
newOAform.submit();
<<<<<<< HEAD
/*$.post('/documents/convert_to_oa', newOAform, function(data) { /*$.post('/documents/convert_to_oa', newOAform, function(data) {
@ -155,6 +292,21 @@ $(function() {
$("#flashMessage").show(); $("#flashMessage").show();
loadLineItems();
});
*/
=======
/*$.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(); loadLineItems();
}); });
*/ */
@ -163,6 +315,7 @@ $(function() {
}, },
Cancel: function() { Cancel: function() {
$( this ).dialog( "close" ); $( this ).dialog( "close" );
>>>>>>> b15eee9619754852ad75ae598103249c33343064
} }
}, },
@ -170,6 +323,21 @@ $(function() {
} }
}); });
<<<<<<< HEAD
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
}
});
$("#pageContentFactory").hide();
=======
$("#pageContentFactory").hide(); $("#pageContentFactory").hide();
@ -191,8 +359,42 @@ $(function() {
$('#LineItemDescription').ckeditor(function() { $('#LineItemDescription').ckeditor(function() {
this.destroy(); this.destroy();
}); });
>>>>>>> b15eee9619754852ad75ae598103249c33343064
//Add a new Page Element.
$("#addPage").button().click(function(event) {
event.preventDefault();
<<<<<<< HEAD
newPage(false);
return false;
});
//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);
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No
<<<<<<< HEAD
$("#editLineItemModal").empty(); $("#editLineItemModal").empty();
@ -206,6 +408,7 @@ $(function() {
$("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No $("#LineItemItemNumber").val(nextItemNo); //Auto fill in the next Item No
=======
$("#productDetails").hide(); $("#productDetails").hide();
@ -222,8 +425,17 @@ $(function() {
$(".editLineItem").live('click', function() { $(".editLineItem").live('click', function() {
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$("#productDetails").hide();
<<<<<<< HEAD
$('#LineItemDescription').ckeditor(config);
showHideTextPrices();
$( "#addLineItemModal" ).dialog('open');
=======
$('#LineItemDescription').ckeditor(function() { $('#LineItemDescription').ckeditor(function() {
this.destroy(); this.destroy();
}); });
@ -237,11 +449,107 @@ $(function() {
$('#LineItemDescription').ckeditor(config); $('#LineItemDescription').ckeditor(config);
showHideTextPrices(); showHideTextPrices();
$( "#editLineItemModal" ).dialog('open'); $( "#editLineItemModal" ).dialog('open');
>>>>>>> b15eee9619754852ad75ae598103249c33343064
}); });
}); });
<<<<<<< HEAD
return false;
});
$(".editLineItem").live('click', function() {
$('#LineItemDescription').ckeditor(function() {
this.destroy();
=======
$("#principleSelect").live('change',function() {
var principleID = getSelectedID('#principleSelect');
$("#productDetails").hide();
$.get('/documents/getProducts/'+principleID, function(data) {
$('#productsDiv').html(data);
>>>>>>> b15eee9619754852ad75ae598103249c33343064
});
});
$("#productSelect").live('change',function() {
var productID = getSelectedID('#productSelect');
<<<<<<< HEAD
$("#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');
=======
$.get('/documents/getProductDetails/'+productID, function(data) {
$("#lineItemDetails").show();
$("#LineItemProductId").val(data.id);
$("#LineItemTitle").val(data.title);
>>>>>>> b15eee9619754852ad75ae598103249c33343064
var descText = '';
if(data.item_code) {
descText = descText + '<br><b>Item Code:</b> ' + data.item_code;
}
if(data.item_description) {
descText = descText + '<br><b>Item Description:</b> ' + data.item_description + '<br>';
}
descText = descText + data.description;
$("#LineItemDescription").val(descText);
}, "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();
$('.page').ckeditor(config);
});
$("#savePages").click(function() {
savePages();
<<<<<<< HEAD
$("#principleSelect").live('change',function() { $("#principleSelect").live('change',function() {
var principleID = getSelectedID('#principleSelect'); var principleID = getSelectedID('#principleSelect');
@ -312,6 +620,22 @@ $(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() { $("#editQuoteDetails").click(function() {
var quoteID = $("#quoteID").html(); var quoteID = $("#quoteID").html();
@ -331,8 +655,19 @@ $(function() {
$("#QuoteDetails").dialog('open'); $("#QuoteDetails").dialog('open');
}); });
}); });
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$("#editQuoteDetails").click(function() {
var quoteID = $("#quoteID").html();
<<<<<<< HEAD
$('#QuoteCommercialComments').ckeditor(function() {
this.destroy();
});
$.get('/quotes/edit/'+quoteID, function(data) {
=======
$("#generateFirstPage").click(function() { $("#generateFirstPage").click(function() {
if($(".firstPage").length == 0) { if($(".firstPage").length == 0) {
@ -343,8 +678,35 @@ $(function() {
$(".firstPage").val(data); $(".firstPage").val(data);
savePages(); savePages();
}); });
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$("#QuoteDetails").html(data);
<<<<<<< HEAD
$('#QuoteCommercialComments').ckeditor(config);
$("#QuoteDetails").dialog('open');
});
});
$("#generateFirstPage").click(function() {
=======
});
>>>>>>> b15eee9619754852ad75ae598103249c33343064
if($(".firstPage").length == 0) {
newPage(true);
}
$.get('/documents/generateFirstPage/'+docID, function(data) {
$(".firstPage").val(data);
savePages();
});
<<<<<<< HEAD
}); });
@ -376,6 +738,35 @@ $(function() {
$("#flashMessage").show(); $("#flashMessage").show();
=======
//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();
>>>>>>> b15eee9619754852ad75ae598103249c33343064
loadLineItems(); loadLineItems();
}); });
@ -573,6 +964,7 @@ function calculateQuickPrices() {
var discount_amount_total = $("#LineItemDiscountAmountTotal").val(); var discount_amount_total = $("#LineItemDiscountAmountTotal").val();
var gross_price = $("#LineItemGrossPrice").val(); var gross_price = $("#LineItemGrossPrice").val();
var net_price = $("#LineItemNetPrice").val(); var net_price = $("#LineItemNetPrice").val();
<<<<<<< HEAD
gross_price = quantity * gross_unit_price; gross_price = quantity * gross_unit_price;
$("#LineItemGrossPrice").val(gross_price); $("#LineItemGrossPrice").val(gross_price);
@ -588,6 +980,23 @@ function calculateQuickPrices() {
$("#LineItemNetPrice").val(net_price); $("#LineItemNetPrice").val(net_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_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);
>>>>>>> b15eee9619754852ad75ae598103249c33343064
$("#LineItemDiscountAmountUnit").val(discount_amount_unit); $("#LineItemDiscountAmountUnit").val(discount_amount_unit);
net_unit_price = gross_unit_price - discount_amount_unit; net_unit_price = gross_unit_price - discount_amount_unit;
$("#LineItemNetUnitPrice").val(net_unit_price); $("#LineItemNetUnitPrice").val(net_unit_price);
@ -633,7 +1042,13 @@ function checkNaN(value) {
else { else {
return value; return value;
} }
<<<<<<< HEAD
=======
>>>>>>> b15eee9619754852ad75ae598103249c33343064
} }