webroot/js/job_grid.js
This commit is contained in:
parent
593f5ad97e
commit
3fa7e3351d
|
|
@ -187,9 +187,6 @@ class UsersController extends AppController {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->redirect('/');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ class User extends AppModel {
|
||||||
|
|
||||||
var $validate = array(
|
var $validate = array(
|
||||||
'first_name' => array('notEmpty'),
|
'first_name' => array('notEmpty'),
|
||||||
'last_name' => array('notEmpty'),
|
|
||||||
'email' => array('email')
|
'email' => array('email')
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,39 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $javascript->link('jquery.jeditable.mini');
|
//echo $javascript->link('jquery.jeditable.mini');
|
||||||
echo $javascript->link('jobindex_editinplace');
|
//echo $javascript->link('jobindex_editinplace');
|
||||||
echo $javascript->link('addjob');
|
//echo $javascript->link('addjob');
|
||||||
|
echo $javascript->link('job_index');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<h2><?php __('Jobs');?></h2>
|
<h2><?php __('Jobs');?></h2>
|
||||||
|
|
||||||
|
<button id="SwitchToGrid">
|
||||||
|
Edit Jobs
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button id="SwitchToTable">
|
||||||
|
View Jobs
|
||||||
|
</button>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
echo $paginator->counter(array(
|
echo $paginator->counter(array(
|
||||||
'format' => __('Page %page% of %pages%, showing %current% Jobs out of %count% total, starting on record %start%, ending on %end%', true)
|
'format' => __('Page %page% of %pages%, showing %current% Jobs out of %count% total, starting on record %start%, ending on %end%', true)
|
||||||
));
|
));
|
||||||
?></p>
|
?></p>
|
||||||
<table cellpadding="0" cellspacing="0" class="mer">
|
<div class="paging">
|
||||||
|
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
||||||
|
| <?php echo $paginator->numbers();?>
|
||||||
|
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="jobsIndex">
|
||||||
|
|
||||||
|
|
||||||
|
<table cellpadding="0" cellspacing="0" class="mer">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th><?php echo $paginator->sort('created');?></th>
|
<th><?php echo $paginator->sort('created');?></th>
|
||||||
|
|
@ -221,7 +239,10 @@ echo $javascript->link('addjob');
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="paging">
|
<div class="paging">
|
||||||
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
|
||||||
| <?php echo $paginator->numbers();?>
|
| <?php echo $paginator->numbers();?>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
echo $javascript->link('slickgrid/plugins/slick.cellrangeselector');
|
echo $javascript->link('slickgrid/plugins/slick.cellrangeselector');
|
||||||
echo $javascript->link('slickgrid/plugins/slick.cellrangedecorator');
|
echo $javascript->link('slickgrid/plugins/slick.cellrangedecorator');
|
||||||
echo $javascript->link('slickgrid/plugins/slick.cellselectionmodel');
|
echo $javascript->link('slickgrid/plugins/slick.cellselectionmodel');
|
||||||
echo $javascript->link('jobindex');
|
echo $javascript->link('job_grid');
|
||||||
echo $scripts_for_layout; ?>
|
echo $scripts_for_layout; ?>
|
||||||
<style>
|
<style>
|
||||||
.cell-title {
|
.cell-title {
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,55 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Javascript to do the actual validation for Adding/Editing users in the modal window.
|
* Javascript to do the actual validation for Adding/Editing users in the modal window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var _loadingDiv = $("#ajaxLoading");
|
//var _loadingDiv = $("#ajaxLoading");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#submitUserButton').button();
|
$('#submitUserButton').button();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#UserAddUserForm').submit(function(){
|
$('#UserAddUserForm').submit(function(){
|
||||||
_loadingDiv.show();
|
|
||||||
$.post('/users/add_user',
|
$('#submitUserButton').button('disable');
|
||||||
$(this).serializeArray(),
|
|
||||||
afterValidate,
|
$.post("/users/add_user",
|
||||||
"json"
|
|
||||||
);
|
$('#UserAddUserForm').serializeArray(),
|
||||||
|
function(data) {
|
||||||
|
var dataArray = $.parseJSON(data);
|
||||||
|
if (dataArray.errors) {
|
||||||
|
onError(dataArray.errors);
|
||||||
|
} else if (dataArray.success) {
|
||||||
|
onSuccess(dataArray.success);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Post-submit callback
|
|
||||||
function afterValidate(data, status) {
|
|
||||||
$(".message").remove();
|
|
||||||
$(".error-message").remove();
|
|
||||||
|
|
||||||
if (data.errors) {
|
|
||||||
onError(data.errors);
|
|
||||||
} else if (data.success) {
|
|
||||||
onSuccess(data.success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSuccess(data) {
|
function onSuccess(data) {
|
||||||
flashMessage(data.message);
|
|
||||||
_loadingDiv.hide();
|
|
||||||
$('#submitUserButton').button('disable');
|
|
||||||
|
|
||||||
|
$(".message").remove();
|
||||||
|
flashMessage(data.message);
|
||||||
|
//_loadingDiv.hide();
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
// window.location.href = '/posts';
|
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}, 500);
|
}, 2000);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function onError(data) {
|
function onError(data) {
|
||||||
|
$('#submitUserButton').button('enable');
|
||||||
flashMessage(data.message);
|
flashMessage(data.message);
|
||||||
$.each(data.data, function(model, errors) {
|
$.each(data.data, function(model, errors) {
|
||||||
for (fieldName in this) {
|
for (fieldName in this) {
|
||||||
|
|
@ -59,7 +64,7 @@ $(function() {
|
||||||
function flashMessage(message) {
|
function flashMessage(message) {
|
||||||
var _insert = $(document.createElement('div')).css('display', 'none');
|
var _insert = $(document.createElement('div')).css('display', 'none');
|
||||||
_insert.attr('id', 'flashMessage').addClass('message').text(message);
|
_insert.attr('id', 'flashMessage').addClass('message').text(message);
|
||||||
_insert.insertAfter($("#UserAddUserForm")).fadeIn();
|
_insert.insertAfter($('#UserAddUserForm')).fadeIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
function camelize(string) {
|
function camelize(string) {
|
||||||
|
|
@ -70,7 +75,13 @@ $(function() {
|
||||||
}
|
}
|
||||||
s = s.join('');
|
s = s.join('');
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,322 +0,0 @@
|
||||||
function requiredFieldValidator(value) {
|
|
||||||
if (value == null || value == undefined || !value.length)
|
|
||||||
return {
|
|
||||||
valid:false,
|
|
||||||
msg:"This is a required field"
|
|
||||||
};
|
|
||||||
else
|
|
||||||
return {
|
|
||||||
valid:true,
|
|
||||||
msg:null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var grid;
|
|
||||||
var data = [];
|
|
||||||
|
|
||||||
var columns = [
|
|
||||||
{
|
|
||||||
id:"id",
|
|
||||||
name:"ID",
|
|
||||||
field:"id",
|
|
||||||
width:50,
|
|
||||||
cssClass:""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:"created",
|
|
||||||
name:"Date Created",
|
|
||||||
field:"created",
|
|
||||||
width: 100
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"title",
|
|
||||||
name:"Job",
|
|
||||||
field:"title",
|
|
||||||
width:120
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:"customer",
|
|
||||||
name:"Customer",
|
|
||||||
field:"customer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:"customer_order_number",
|
|
||||||
name:"Customer Ref",
|
|
||||||
field:"customer_order_number",
|
|
||||||
width:120,
|
|
||||||
resizable:true,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:"supplier_reference",
|
|
||||||
name:"Supplier Ref",
|
|
||||||
field:"supplier_reference",
|
|
||||||
width:120,
|
|
||||||
resizable:true,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:"date_order_received",
|
|
||||||
name:"Order Received",
|
|
||||||
field:"date_order_received",
|
|
||||||
minWidth:60,
|
|
||||||
editor:DateCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"date_order_placed_on_principle",
|
|
||||||
name:"Date Order Placed on Principle",
|
|
||||||
field:"date_order_placed_on_principle",
|
|
||||||
minWidth:60,
|
|
||||||
editor:DateCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"date_scheduled_ex_works",
|
|
||||||
name:"Scheduled Ex Works",
|
|
||||||
field:"date_scheduled_ex_works",
|
|
||||||
minWidth:60,
|
|
||||||
editor:DateCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"date_order_sent_to_customer",
|
|
||||||
name:"Date Sent to Customer",
|
|
||||||
field:"date_order_sent_to_customer",
|
|
||||||
minWidth:60,
|
|
||||||
editor:DateCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"domestic_freight_paid_by",
|
|
||||||
name:"Dom Freight Paid By",
|
|
||||||
field:"domestic_freight_paid_by",
|
|
||||||
minWidth:60
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"sale_category",
|
|
||||||
name:"Sale Category",
|
|
||||||
field:"sale_category",
|
|
||||||
minWidth:60
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"shipment_category",
|
|
||||||
name:"Shipment Category",
|
|
||||||
field:"shipment_category",
|
|
||||||
minWidth:60
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"domestic_freight_paid_by",
|
|
||||||
name:"Dom Freight Paid By",
|
|
||||||
field:"domestic_freight_paid_by",
|
|
||||||
minWidth:60
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"comments",
|
|
||||||
name:"Comments",
|
|
||||||
field:"comments",
|
|
||||||
minWidth:60,
|
|
||||||
editor:LongTextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"company_gross_sales_aud",
|
|
||||||
name:"Gross Sales AUD",
|
|
||||||
field:"company_gross_sales_aud",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"net_sales_aud",
|
|
||||||
name:"Net Sales AUD",
|
|
||||||
field:"net_sales_aud",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_profit_aud",
|
|
||||||
name:"Gross Profit AUD",
|
|
||||||
field:"gross_profit_aud",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"ato_exchange_rate",
|
|
||||||
name:"ATO Exchange Rate",
|
|
||||||
field:"ato_exchange_rate",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gst",
|
|
||||||
name:"GST",
|
|
||||||
field:"gst",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"currency_id",
|
|
||||||
name:"Currency",
|
|
||||||
field:"currency_id",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gst_amount",
|
|
||||||
name:"GST Amount",
|
|
||||||
field:"gst_amount",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_commisions",
|
|
||||||
name:"Gross Commisions",
|
|
||||||
field:"gross_commisions",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"invoiced_amount_inc_gst",
|
|
||||||
name:"invoiced amount inc gst",
|
|
||||||
field:"invoiced_amount_inc_gst",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"net_export_sales_aud",
|
|
||||||
name:"Net Export Sales AUD",
|
|
||||||
field:"net_export_sales_aud",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_profit_exports_aud",
|
|
||||||
name:"Gross Profit Exports AUD",
|
|
||||||
field:"gross_profit_exports_aud",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:"gp_percent",
|
|
||||||
name:"GP %",
|
|
||||||
field:"gp_percent",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_australian_sales_foreign_currency",
|
|
||||||
name:"Gross Australian Sales Foreign Currency",
|
|
||||||
field:"gross_australian_sales_foreign_currency",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"net_australian_sales_foreign_currency",
|
|
||||||
name:"Net Australian Sales Foreign Currency",
|
|
||||||
field:"net_australian_sales_foreign_currency",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_profit_value_australian_sales_foreign_currency",
|
|
||||||
name:"Gross Profit Value Aust Sales Foreign Currency",
|
|
||||||
field:"gross_profit_value_australian_sales_foreign_currency",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_export_sales_foreign_currency",
|
|
||||||
name:"Gross Export Sales Foreign Currency",
|
|
||||||
field:"gross_export_sales_foreign_currency",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"net_export_sales_foreign_currency",
|
|
||||||
name:"Net Export Sales Foreign Currency",
|
|
||||||
field:"net_export_sales_foreign_currency",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_profit_value_after_discount_exports_foreign_currency",
|
|
||||||
name:"GP Amount After Discount Exports Foreign Currency",
|
|
||||||
field:"gross_profit_value_after_discount_exports_foreign_currency",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"gross_commissions",
|
|
||||||
name:"Gross Commissions",
|
|
||||||
field:"gross_commissions",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id:"net_commissions",
|
|
||||||
name:"Net Commissions",
|
|
||||||
field:"net_commissions",
|
|
||||||
minWidth:60,
|
|
||||||
editor:TextCellEditor
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
var options = {
|
|
||||||
editable: true,
|
|
||||||
enableAddRow: false,
|
|
||||||
enableCellNavigation: true,
|
|
||||||
asyncEditorLoading: false,
|
|
||||||
autoEdit: false
|
|
||||||
};
|
|
||||||
|
|
||||||
$(function()
|
|
||||||
{
|
|
||||||
|
|
||||||
data = $.parseJSON($("#jsonObj").html());
|
|
||||||
|
|
||||||
grid = new Slick.Grid("#myGrid", data, columns, options);
|
|
||||||
|
|
||||||
//grid.registerPlugin(new Slick.CellRangeSelector());
|
|
||||||
|
|
||||||
grid.setSelectionModel(new Slick.CellSelectionModel());
|
|
||||||
|
|
||||||
grid.onAddNewRow.subscribe(function(e, args) {
|
|
||||||
var item = args.item;
|
|
||||||
var column = args.column;
|
|
||||||
grid.invalidateRow(data.length);
|
|
||||||
data.push(item);
|
|
||||||
grid.updateRowCount();
|
|
||||||
grid.render();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in a new issue