From 82a3f9a3e21f191e5f93932cc557ccc686015999 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 17 Feb 2016 23:34:53 +0100 Subject: [PATCH] Add new dialogs to all pages (use modal-dlg class) #116 Bootstrapify customer edit form (almost done) Bootstrapify item excel impor --- application/controllers/Reports.php | 8 +- application/helpers/table_helper.php | 19 +-- application/views/customers/excel_import.php | 18 +-- application/views/customers/form.php | 75 +++++------ application/views/giftcards/manage.php | 2 +- application/views/item_kits/manage.php | 2 +- application/views/items/excel_import.php | 39 +++--- application/views/items/form.php | 6 +- application/views/items/manage.php | 4 +- application/views/partial/header.php | 2 +- application/views/people/form_basic_info.php | 117 ++++++++++-------- application/views/people/manage.php | 4 +- application/views/receivings/receiving.php | 4 +- application/views/reports/tabular_details.php | 2 +- application/views/sales/register.php | 6 +- application/views/suppliers/manage.php | 2 +- dist/opensourcepos.js | 55 ++++++-- dist/opensourcepos.min.js | 6 +- js/manage_tables.js | 55 ++++++-- templates/spacelab/views/partial/header.php | 2 +- 20 files changed, 239 insertions(+), 189 deletions(-) diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index 1778e6ece..7afa0e465 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -61,7 +61,7 @@ class Reports extends Secure_area $summary_data = array(anchor('sales/edit/'.$report_data['sale_id'] . '/width:'.FORM_WIDTH, 'POS '.$report_data['sale_id'], - array('class' => 'thickbox')), + array('class' => 'modal')), $report_data['sale_date'], $report_data['items_purchased'], $report_data['employee_name'], @@ -85,7 +85,7 @@ class Reports extends Secure_area $summary_data = array(anchor('receivings/edit/'.$report_data['receiving_id'] . '/width:'.FORM_WIDTH, 'RECV '.$report_data['receiving_id'], - array('class' => 'thickbox')), + array('class' => 'modal')), $report_data['receiving_date'], $report_data['items_purchased'], $report_data['employee_name'], @@ -872,7 +872,7 @@ class Reports extends Secure_area foreach($report_data['summary'] as $key=>$row) { - $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'] . '/width:'.FORM_WIDTH, 'POS '.$row['sale_id'], array('class' => 'thickbox')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']); + $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'] . '/width:'.FORM_WIDTH, 'POS '.$row['sale_id'], array('class' => 'modal')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']); foreach($report_data['details'][$key] as $drow) { @@ -915,7 +915,7 @@ class Reports extends Secure_area foreach($report_data['summary'] as $key=>$row) { - $summary_data[] = array(anchor('receivings/edit/'.$row['receiving_id'].'/width:'.FORM_WIDTH, 'RECV '.$row['receiving_id'], array('class' => 'thickbox')), $row['receiving_date'], $row['items_purchased'], $row['employee_name'], $row['supplier_name'], to_currency($row['total']), $row['payment_type'], $row['invoice_number'], $row['comment']); + $summary_data[] = array(anchor('receivings/edit/'.$row['receiving_id'].'/width:'.FORM_WIDTH, 'RECV '.$row['receiving_id'], array('class' => 'modal')), $row['receiving_date'], $row['items_purchased'], $row['employee_name'], $row['supplier_name'], to_currency($row['total']), $row['payment_type'], $row['invoice_number'], $row['comment']); foreach($report_data['details'][$key] as $drow) { diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 5a44e5ec1..f1c17f59e 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -77,7 +77,7 @@ function get_sales_manage_sale_data_row($sale, $controller) $table_data_row.=''.$sale['payment_type'].''; $table_data_row.=''.$sale['invoice_number'].''; $table_data_row.=''; - $table_data_row.=anchor($controller_name."/edit/" . $sale['sale_id'] . "/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))); + $table_data_row.=anchor($controller_name."/edit/" . $sale['sale_id'] . "/width:$width", $CI->lang->line('common_edit'),array('class'=>'modal','title'=>$CI->lang->line($controller_name.'_update'))); $table_data_row.='    '; $table_data_row.='' . $CI->lang->line('sales_show_receipt') . ''; $table_data_row.='    '; @@ -174,8 +174,8 @@ function get_person_data_row($person,$controller) $table_data_row.=''.character_limiter($person->last_name,13).''; $table_data_row.=''.character_limiter($person->first_name,13).''; $table_data_row.=''.mailto($person->email,character_limiter($person->email,22)).''; - $table_data_row.=''.character_limiter($person->phone_number,13).''; - $table_data_row.=''.anchor($controller_name."/view/$person->person_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).''; + $table_data_row.=''.character_limiter($person->phone_number,13).''; + $table_data_row.=''.anchor($controller_name."/view/$person->person_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_update'))).''; $table_data_row.=''; return $table_data_row; @@ -262,7 +262,7 @@ function get_supplier_data_row($supplier,$controller) $table_data_row.=''.mailto($supplier->email,character_limiter($supplier->email,22)).''; $table_data_row.=''.character_limiter($supplier->phone_number,13).''; $table_data_row.=''.character_limiter($supplier->person_id,5).''; - $table_data_row.=''.anchor($controller_name."/view/$supplier->person_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).''; + $table_data_row.=''.anchor($controller_name."/view/$supplier->person_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_update'))).''; $table_data_row.=''; return $table_data_row; @@ -358,9 +358,10 @@ function get_item_data_row($item,$controller) } } $table_data_row.='' . $image . ''; - $table_data_row.=''. $CI->lang->line('common_edit').''; - $table_data_row.=''. $CI->lang->line('common_inv'). ''. - '    ' . $CI->lang->line('common_det'). '';//inventory detail_ + $table_data_row.=''.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_update'))).''; + + $table_data_row.=''.anchor($controller_name."/inventory/$item->item_id/width:$width", $CI->lang->line('common_inv'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_count')))./*'';//inventory count + $table_data_row.=''*/'    '.anchor($controller_name."/count_details/$item->item_id/width:$width", $CI->lang->line('common_det'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_details_count'))).'';//inventory details $table_data_row.=''; @@ -428,7 +429,7 @@ function get_giftcard_data_row($giftcard,$controller) $table_data_row.=''.$giftcard->first_name.''; $table_data_row.=''.$giftcard->giftcard_number.''; $table_data_row.=''.to_currency($giftcard->value).''; - $table_data_row.=''.anchor($controller_name."/view/$giftcard->giftcard_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).''; + $table_data_row.=''.anchor($controller_name."/view/$giftcard->giftcard_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_update'))).''; $table_data_row.=''; return $table_data_row; @@ -497,7 +498,7 @@ function get_item_kit_data_row($item_kit, $controller) $table_data_row.=''.character_limiter($item_kit->description, 25).''; $table_data_row.=''.to_currency($item_kit->total_cost_price).''; $table_data_row.=''.to_currency($item_kit->total_unit_price).''; - $table_data_row.=''.anchor($controller_name."/view/$item_kit->item_kit_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).''; + $table_data_row.=''.anchor($controller_name."/view/$item_kit->item_kit_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'modal-dlg','title'=>$CI->lang->line($controller_name.'_update'))).''; $table_data_row.=''; return $table_data_row; diff --git a/application/views/customers/excel_import.php b/application/views/customers/excel_import.php index 551ed4b86..3e31388f8 100644 --- a/application/views/customers/excel_import.php +++ b/application/views/customers/excel_import.php @@ -1,28 +1,22 @@ -'item_form')); ?> +'item_form', 'class'=>'form-horizontal')); ?>
lang->line('customers_import_items_excel'); ?>
lang->line('common_download_import_template'); ?>
lang->line('common_import'); ?> -
- lang->line('common_import_file_path').':', 'name',array('class'=>'wide')); ?> -
+
+ lang->line('common_import_file_path').':', 'name',array('class'=>'control-label col-xs-3')); ?> +
'file_path', 'id'=>'file_path', + 'class'=>'form-control', 'value'=>'') );?>
- 'submitf', - 'id'=>'submitf', - 'value'=>$this->lang->line('common_submit'), - 'class'=>'btn btn-primary btn-sm pull-right') - ); ?>
@@ -37,7 +31,7 @@ $(document).ready(function() $(form).ajaxSubmit({ success:function(response) { - tb_remove(); + dialog_support.hide();; post_person_form_submit(response); }, dataType:'json' diff --git a/application/views/customers/form.php b/application/views/customers/form.php index 22390a5a9..7c9afdf88 100644 --- a/application/views/customers/form.php +++ b/application/views/customers/form.php @@ -1,48 +1,37 @@ -person_id,array('id'=>'customer_form')); ?> -
lang->line('common_fields_required_message'); ?>
- -
- lang->line("customers_basic_information"); ?> - load->view("people/form_basic_info"); ?> +person_id,array('id'=>'customer_form', 'class'=>'form-horizontal')); ?> +
lang->line('common_fields_required_message'); ?>
+ +load->view("people/form_basic_info"); ?> -
- lang->line('customers_company_name').':', 'company_name'); ?> -
- 'company_name', - 'value'=>$person_info->company_name) - );?> -
-
+
+lang->line('customers_company_name'), 'company_name', array('class' => 'control-label col-xs-3')); ?> +
+ 'company_name', + 'class'=>'form-control', + 'value'=>$person_info->company_name) + );?> +
+
-
- lang->line('customers_account_number').':', 'account_number'); ?> -
- 'account_number', - 'id'=>'account_number', - 'class'=>'account_number', - 'value'=>$person_info->account_number) - );?> -
-
+
+lang->line('customers_account_number'), 'account_number', array('class' => 'control-label col-xs-3')); ?> +
+ 'account_number', + 'id'=>'account_number', + 'class'=>'account_number form-control', + 'value'=>$person_info->account_number) + );?> +
+
-
- lang->line('customers_taxable').':', 'taxable'); ?> -
- taxable == '' ? TRUE : (boolean)$person_info->taxable);?> -
-
- - 'submit', - 'id'=>'submit', - 'value'=>$this->lang->line('common_submit'), - 'class'=>'btn btn-primary btn-sm pull-right') - ); - ?> -
+
+lang->line('customers_taxable'), 'taxable', array('class' => 'control-label col-xs-3')); ?> +
+ taxable == '' ? TRUE : (boolean)$person_info->taxable, 'class="form-control"');?> +
+
+ diff --git a/application/views/people/form_basic_info.php b/application/views/people/form_basic_info.php index 65bde7e43..176ba1da0 100644 --- a/application/views/people/form_basic_info.php +++ b/application/views/people/form_basic_info.php @@ -1,6 +1,6 @@ -
-lang->line('common_first_name').':', 'first_name',array('class'=>'required')); ?> -
+
+lang->line('common_first_name'), 'first_name',array('class' => 'control-label col-xs-3')); ?> +
'first_name', 'id'=>'first_name', @@ -8,9 +8,9 @@ );?>
-
-lang->line('common_last_name').':', 'last_name',array('class'=>'required')); ?> -
+
+lang->line('common_last_name'), 'last_name',array('class'=>'required control-label required col-xs-3')); ?> +
'last_name', 'id'=>'last_name', @@ -19,14 +19,15 @@
-
-lang->line('common_gender').':', 'gender', -!empty($basic_version) ? array('class'=>'required') : array()); ?> -
+
+lang->line('common_gender'), 'gender', +!empty($basic_version) ? array('class'=>'control-label required col-xs-3') : array()); ?> +
'gender', 'type'=>'radio', 'id'=>'gender', + 'class'=>'form-control', 'value'=>1, 'checked'=>$person_info->gender === '1') ); @@ -35,6 +36,7 @@ 'name'=>'gender', 'type'=>'radio', 'id'=>'gender', + 'class'=>'form-control', 'value'=>0, 'checked'=>$person_info->gender === '0') ); @@ -43,97 +45,104 @@
-
-lang->line('common_email').':', 'email'); ?> -
+
+lang->line('common_email'), 'email', array('class' => 'control-label col-xs-3')); ?> +
'email', 'id'=>'email', + 'class'=>'form-control', 'value'=>$person_info->email) );?>
-
-lang->line('common_phone_number').':', 'phone_number'); ?> -
+
+lang->line('common_phone_number'), 'phone_number', array('class' => 'control-label col-xs-3')); ?> +
'phone_number', 'id'=>'phone_number', + 'class'=>'form-control', 'value'=>$person_info->phone_number));?>
-
-lang->line('common_address_1').':', 'address_1'); ?> -
+
+lang->line('common_address_1'), 'address_1', array('class' => 'control-label col-xs-3')); ?> +
'address_1', 'id'=>'address_1', + 'class'=>'form-control', 'value'=>$person_info->address_1));?>
-
-lang->line('common_address_2').':', 'address_2'); ?> -
+
+lang->line('common_address_2'), 'address_2', array('class' => 'control-label col-xs-3')); ?> +
'address_2', 'id'=>'address_2', + 'class'=>'form-control', 'value'=>$person_info->address_2));?>
-
-lang->line('common_city').':', 'city'); ?> -
+
+lang->line('common_city'), 'city', array('class' => 'control-label col-xs-3')); ?> +
'city', 'id'=>'city', + 'class'=>'form-control', 'value'=>$person_info->city));?>
-
-lang->line('common_state').':', 'state'); ?> -
+
+lang->line('common_state'), 'state', array('class' => 'control-label col-xs-3')); ?> +
'state', 'id'=>'state', + 'class'=>'form-control', 'value'=>$person_info->state));?>
-
-lang->line('common_zip').':', 'zip'); ?> -
+
+lang->line('common_zip'), 'zip', array('class' => 'control-label col-xs-3')); ?> +
'zip', 'id'=>'postcode', + 'class'=>'form-control', 'value'=>$person_info->zip));?>
-
-lang->line('common_country').':', 'country'); ?> -
+
+lang->line('common_country'), 'country', array('class' => 'control-label col-xs-3')); ?> +
'country', 'id'=>'country', + 'class'=>'form-control', 'value'=>$person_info->country));?>
-
-lang->line('common_comments').':', 'comments'); ?> -
+
+lang->line('common_comments'), 'comments', array('class' => 'control-label col-xs-3')); ?> +
'comments', 'id'=>'comments', - 'value'=>$person_info->comments, - 'rows'=>'5', - 'cols'=>'17') - );?> + 'class'=>'form-control', + 'value'=>$person_info->comments + ));?>
@@ -143,29 +152,29 @@ $(document).ready(function() { nominatim.init({ fields : { - postcode : { - dependencies : ["postcode", "city", "state", "country"], - response : { - field : 'postalcode', - format: ["postcode", "village|town|hamlet|city_district|city", "state", "country"] + postcode : { + dependencies : ["postcode", "city", "state", "country"], + response : { + field : 'postalcode', + format: ["postcode", "village|town|hamlet|city_district|city", "state", "country"] } }, - + city : { - dependencies : ["postcode", "city", "state", "country"], - response : { - format: ["postcode", "village|town|hamlet|city_district|city", "state", "country"] + dependencies : ["postcode", "city", "state", "country"], + response : { + format: ["postcode", "village|town|hamlet|city_district|city", "state", "country"] } }, - + state : { dependencies : ["state", "country"] }, - + country : { - dependencies : ["state", "country"] + dependencies : ["state", "country"] } - + }, language : 'config->item('language');?>' }); diff --git a/application/views/people/manage.php b/application/views/people/manage.php index 8a43d5105..bc67850cb 100644 --- a/application/views/people/manage.php +++ b/application/views/people/manage.php @@ -64,7 +64,7 @@ function post_person_form_submit(response) ?> " . $this->lang->line('common_import_excel') . "
", - array('class'=>'thickbox none', 'title'=>'Import Items from Excel')); + array('class'=>'modal-dlg none', 'title'=>'Import Items from Excel')); ?> " . $this->lang->line($controller_name . '_new') . "
", - array('class'=>'thickbox none', 'title'=>$this->lang->line($controller_name . '_new'))); + array('class'=>'modal-dlg none', 'title'=>$this->lang->line($controller_name . '_new'))); ?>
diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index 0b430c585..90ff641aa 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -53,7 +53,7 @@ if(isset($error))
".$this->lang->line('sales_new_item')."
", - array('class'=>'thickbox none','title'=>$this->lang->line('sales_new_item'))); + array('class'=>'modal-dlg none','title'=>$this->lang->line('sales_new_item'))); ?>
@@ -207,7 +207,7 @@ if(isset($error))

lang->line('common_or'); ?>

".$this->lang->line('recvs_new_supplier')."
", - array('class'=>'thickbox none','title'=>$this->lang->line('recvs_new_supplier'))); + array('class'=>'modal-dlg none','title'=>$this->lang->line('recvs_new_supplier'))); ?>
 
diff --git a/application/views/reports/tabular_details.php b/application/views/reports/tabular_details.php index e694d2742..8a4933aae 100644 --- a/application/views/reports/tabular_details.php +++ b/application/views/reports/tabular_details.php @@ -108,7 +108,7 @@ else update_sortable_table(); animate_row(row); row.find("a.expand").click(expand_handler).text(sign); - tb_init(row.find("a.thickbox")); + dialog_support.init(row.find("a.modal")); }); set_feedback(response.message, 'alert alert-dismissible alert-success', false); } diff --git a/application/views/sales/register.php b/application/views/sales/register.php index b6a91a345..299d52a00 100644 --- a/application/views/sales/register.php +++ b/application/views/sales/register.php @@ -46,7 +46,7 @@ if (isset($success)) ".$this->lang->line('sales_suspended_sales')."
", - array('class'=>'thickbox none','title'=>$this->lang->line('sales_suspended_sales'))); + array('class'=>'modal-dlg none','title'=>$this->lang->line('sales_suspended_sales'))); ?> @@ -60,7 +60,7 @@ if (isset($success))
".$this->lang->line('sales_new_item')."
", - array('class'=>'thickbox none','title'=>$this->lang->line('sales_new_item'))); + array('class'=>'modal-dlg none','title'=>$this->lang->line('sales_new_item'))); ?>
@@ -229,7 +229,7 @@ if (isset($success))

lang->line('common_or'); ?>

".$this->lang->line('sales_new_customer')."
", - array('class'=>'thickbox none','title'=>$this->lang->line('sales_new_customer'))); + array('class'=>'modal-dlg none','title'=>$this->lang->line('sales_new_customer'))); ?>
diff --git a/application/views/suppliers/manage.php b/application/views/suppliers/manage.php index 99b78d619..7f6bbb355 100644 --- a/application/views/suppliers/manage.php +++ b/application/views/suppliers/manage.php @@ -61,7 +61,7 @@ function post_person_form_submit(response)
lang->line('common_list_of').' '.$this->lang->line('module_'.$controller_name); ?>
" . $this->lang->line($controller_name . '_new') . "
", - array('class'=>'thickbox none', 'title'=>$this->lang->line($controller_name . '_new'))); + array('class'=>'modal-dlg none', 'title'=>$this->lang->line($controller_name . '_new'))); ?>
diff --git a/dist/opensourcepos.js b/dist/opensourcepos.js index 602d1c670..c69bb6725 100644 --- a/dist/opensourcepos.js +++ b/dist/opensourcepos.js @@ -44518,7 +44518,7 @@ function do_search(show_feedback,on_complete) $('#search').removeClass("ac_loading"); //$('#spinner').hide(); //re-init elements in new table, as table tbody children were replaced - tb_init('#sortable_table a.thickbox'); + dialog_support.init('#sortable_table a.modal-dlg'); $('#pagination').html(response.pagination); $('#sortable_table tbody :checkbox').click(checkbox_click); $("#select_all").attr('checked',false); @@ -44766,7 +44766,7 @@ function reinit_row(checkbox_id) enable_row_selection(new_row); //Re-init some stuff as we replaced row update_sortable_table(); - tb_init(new_row.find("a.thickbox")); + dialog_support.init(new_row.find("a.modal-dlg")); //re-enable e-mail new_checkbox.click(checkbox_click); } @@ -44819,21 +44819,52 @@ function get_visible_checkbox_ids() dialog_support = (function() { - var submit_form = function(button_id) { - return function(dialog_ref) + var btn_id, dialog_ref; + + var hide = function() { + debugger;; + dialog_ref.close(); + }; + + var clicked_id = function() { + return btn_id; + }; + + var submit = function(button_id) { + btn_id = button_id; + return function(dlog_ref) { - dialog_support.clicked_button = button_id; - $('#item_form').submit(); - dialog_support.hide_dialog = function() { - dialog_ref.close(); - }; + dialog_ref = dlog_ref; + $('form', dlog_ref.$modalBody).submit(); } }; + var init = function(selector) { + $(selector).click(function(event) { + var $link = $(event.target); + $link = $link.is("a") ? $link : $link.parents("a"); + BootstrapDialog.show({ + title: $link.attr('title'), + message: $('
').load($link.attr('href')), + buttons: [{ + id: 'submit', + label: 'submit', + action: submit('submit') + }] + }); + event.preventDefault(); + }); + }; + + $(document).ready(function() { + init("a.modal-dlg"); + }); + return { - hide: function () {}, - clicked_button : undefined, - submit: submit_form + hide: hide, + clicked_id: clicked_id, + init: init, + submit: submit }; })(); diff --git a/dist/opensourcepos.min.js b/dist/opensourcepos.min.js index b85ecbd7a..6c02f4aef 100644 --- a/dist/opensourcepos.min.js +++ b/dist/opensourcepos.min.js @@ -1,5 +1,5 @@ -/*! opensourcepos 16-02-2016 */ -function get_dimensions(){var a={width:0,height:0};return"number"==typeof window.innerWidth?(a.width=window.innerWidth,a.height=window.innerHeight):document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)?(a.width=document.documentElement.clientWidth,a.height=document.documentElement.clientHeight):document.body&&(document.body.clientWidth||document.body.clientHeight)&&(a.width=document.body.clientWidth,a.height=document.body.clientHeight),a}function set_feedback(a,b,c){a?($("#feedback_bar").removeClass().addClass(b).html(a).css("opacity","1"),c||$("#feedback_bar").fadeTo(5e3,1).fadeTo("fast",0)):$("#feedback_bar").css("opacity","0")}function checkbox_click(a){a.stopPropagation(),do_email(enable_email.url),$(a.target).attr("checked")?$(a.target).parent().parent().find("td").addClass("selected").css("backgroundColor",""):$(a.target).parent().parent().find("td").removeClass()}function enable_search(a){a.format_item||(format_item=function(a){return a[0]}),enable_search.enabled||(enable_search.enabled=!0),$("#search").click(function(){$(this).attr("value","")});var b=$("#search").autocomplete(a.suggest_url,{max:100,delay:10,selectFirst:!1,formatItem:a.format_item,extraParams:a.extra_params});return $("#search").result(function(){do_search(!0,a.on_complete)}),attach_search_listener(),$("#search_form").submit(function(b){b.preventDefault(),$("#limit_from").val(0),get_selected_values().length>0&&!confirm(a.confirm_search_message)||do_search(!0,a.on_complete)}),b}function attach_search_listener(){$("#pagination a").click(function(a){if($("#search").val()||$("#search_form input:checked")){a.preventDefault();var b=a.currentTarget.href.split("/"),c=b.pop();$("#limit_from").val(c),do_search(!0)}})}function do_search(a,b){enable_search.enabled&&(a&&$("#search").addClass("ac_loading"),$.post($("#search_form").attr("action"),$("#search_form").serialize(),function(a){$("#sortable_table tbody").html(a.rows),"function"==typeof b&&b(a),$("#search").removeClass("ac_loading"),tb_init("#sortable_table a.thickbox"),$("#pagination").html(a.pagination),$("#sortable_table tbody :checkbox").click(checkbox_click),$("#select_all").attr("checked",!1),a.total_rows>0&&(update_sortable_table(),enable_row_selection()),attach_search_listener()},"json"))}function enable_email(a){enable_email.enabled||(enable_email.enabled=!0),enable_email.url||(enable_email.url=a),$("#select_all, #sortable_table tbody :checkbox").click(checkbox_click)}function do_email(a){enable_email.enabled&&$.post(a,{"ids[]":get_selected_values()},function(a){$("#email").attr("href",a)})}function enable_checkboxes(){$("#sortable_table tbody :checkbox").click(checkbox_click)}function enable_delete(a,b){enable_delete.enabled||(enable_delete.enabled=!0),$("#delete").click(function(c){if(c.preventDefault(),$("#sortable_table tbody :checkbox:checked").length>0){if(!confirm(a))return!1;do_delete($(this).attr("href"))}else alert(b)})}function do_delete(a){if(enable_delete.enabled){var b=get_selected_values(),c=get_selected_rows();$.post(a,{"ids[]":b},function(a){a.success?($(c).each(function(){$(this).find("td").animate({backgroundColor:"green"},1200,"linear").end().animate({opacity:0},1200,"linear",function(){$(this).remove(),$("#sortable_table tbody tr").length>0&&update_sortable_table()})}),set_feedback(a.message,"alert alert-dismissible alert-success",!1)):set_feedback(a.message,"alert alert-dismissible alert-danger",!0)},"json")}}function enable_bulk_edit(a){enable_bulk_edit.enabled||(enable_bulk_edit.enabled=!0),$("#bulk_edit").click(function(b){b.preventDefault(),$("#sortable_table tbody :checkbox:checked").length>0?(tb_show($(this).attr("title"),$(this).attr("href"),!1),$(this).blur()):alert(a)})}function enable_select_all(){enable_select_all.enabled||(enable_select_all.enabled=!0),$("#select_all").click(function(){$("#sortable_table tbody :checkbox").each($(this).attr("checked")?function(){$(this).attr("checked",!0),$(this).parent().parent().find("td").addClass("selected").css("backgroundColor","")}:function(){$(this).attr("checked",!1),$(this).parent().parent().find("td").removeClass()})})}function enable_row_selection(a){enable_row_selection.enabled||(enable_row_selection.enabled=!0),"undefined"==typeof a&&(a=$("#sortable_table tbody tr")),a.hover(function(){$(this).find("td").addClass("over").css("backgroundColor",""),$(this).css("cursor","pointer")},function(){$(this).find("td").hasClass("selected")||$(this).find("td").removeClass()}),a.click(function(){var a=$(this).find(":checkbox");a.attr("checked",!a.attr("checked")),do_email(enable_email.url),a.attr("checked")?$(this).find("td").addClass("selected").css("backgroundColor",""):$(this).find("td").removeClass()})}function update_sortable_table(){if($("#sortable_table").trigger("update"),"undefined"!=typeof $("#sortable_table")[0].config){var a=$("#sortable_table")[0].config.sortList;$("#sortable_table").trigger("sorton",[a])}else window.init_table_sorting&&init_table_sorting()}function get_table_row(a){a=a||$("input[name='sale_id']").val();var b=$("#sortable_table tbody :checkbox[value='"+a+"']");return 0===b.length&&(b=$("#sortable_table tbody a[href*='/"+a+"/']")),b}function update_row(a,b,c){$.post(b,{row_id:a},function(b){var d=get_table_row(a).parent().parent();d.replaceWith(b),reinit_row(a),hightlight_row(a),c&&"function"==typeof c&&c()},"html")}function reinit_row(a){var b=$("#sortable_table tbody tr :checkbox[value="+a+"]"),c=b.parent().parent();enable_row_selection(c),update_sortable_table(),tb_init(c.find("a.thickbox")),b.click(checkbox_click)}function animate_row(a,b){b=b||"#e1ffdd",a.find("td").css("backgroundColor","#ffffff").animate({backgroundColor:b},"slow","linear").animate({backgroundColor:b},5e3).animate({backgroundColor:"#ffffff"},"slow","linear")}function hightlight_row(a){var b=$("#sortable_table tbody tr :checkbox[value="+a+"]"),c=b.parent().parent();animate_row(c)}function get_selected_values(){var a=new Array;return $("#sortable_table tbody :checkbox:checked").each(function(){a.push($(this).val())}),a}function get_selected_rows(){var a=new Array;return $("#sortable_table tbody :checkbox:checked").each(function(){a.push($(this).parent().parent())}),a}function get_visible_checkbox_ids(){var a=new Array;return $("#sortable_table tbody :checkbox").each(function(){a.push($(this).val())}),a}function phpjsDate(a,b){var c,d,e=this,f=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"],g=/\\?(.?)/gi,h=function(a,b){return d[a]?d[a]():b},i=function(a,b){for(a=String(a);a.length=b&&1==parseInt(a%100/10,10)&&(b=0),["st","nd","rd"][b-1]||"th"},w:function(){return c.getDay()},z:function(){var a=new Date(d.Y(),d.n()-1,d.j()),b=new Date(d.Y(),0,1);return Math.round((a-b)/864e5)},W:function(){var a=new Date(d.Y(),d.n()-1,d.j()-d.N()+3),b=new Date(a.getFullYear(),0,4);return i(1+Math.round((a-b)/864e5/7),2)},F:function(){return f[6+d.n()]},m:function(){return i(d.n(),2)},M:function(){return d.F().slice(0,3)},n:function(){return c.getMonth()+1},t:function(){return new Date(d.Y(),d.n(),0).getDate()},L:function(){var a=d.Y();return a%4===0&a%100!==0|a%400===0},o:function(){var a=d.n(),b=d.W(),c=d.Y();return c+(12===a&&9>b?1:1===a&&b>9?-1:0)},Y:function(){return c.getFullYear()},y:function(){return d.Y().toString().slice(-2)},a:function(){return c.getHours()>11?"pm":"am"},A:function(){return d.a().toUpperCase()},B:function(){var a=3600*c.getUTCHours(),b=60*c.getUTCMinutes(),d=c.getUTCSeconds();return i(Math.floor((a+b+d+3600)/86.4)%1e3,3)},g:function(){return d.G()%12||12},G:function(){return c.getHours()},h:function(){return i(d.g(),2)},H:function(){return i(d.G(),2)},i:function(){return i(c.getMinutes(),2)},s:function(){return i(c.getSeconds(),2)},u:function(){return i(1e3*c.getMilliseconds(),6)},e:function(){throw"Not supported (see source code of date() for timezone on how to add support)"},I:function(){var a=new Date(d.Y(),0),b=Date.UTC(d.Y(),0),c=new Date(d.Y(),6),e=Date.UTC(d.Y(),6);return a-b!==c-e?1:0},O:function(){var a=c.getTimezoneOffset(),b=Math.abs(a);return(a>0?"-":"+")+i(100*Math.floor(b/60)+b%60,4)},P:function(){var a=d.O();return a.substr(0,3)+":"+a.substr(3,2)},T:function(){return"UTC"},Z:function(){return 60*-c.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(g,h)},r:function(){return"D, d M Y H:i:s O".replace(g,h)},U:function(){return c/1e3|0}},this.date=function(a,b){return e=this,c=void 0===b?new Date:new Date(b instanceof Date?b:1e3*b),a.replace(g,h)},this.date(a,b)}if(function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=!!a&&"length"in a&&a.length,c=na.type(a);return"function"===c||na.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(na.isFunction(b))return na.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return na.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(xa.test(b))return na.filter(b,a,c);b=na.filter(b,a)}return na.grep(a,function(a){return na.inArray(a,b)>-1!==c})}function e(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}function f(a){var b={};return na.each(a.match(Da)||[],function(a,c){b[c]=!0}),b}function g(){da.addEventListener?(da.removeEventListener("DOMContentLoaded",h),a.removeEventListener("load",h)):(da.detachEvent("onreadystatechange",h),a.detachEvent("onload",h))}function h(){(da.addEventListener||"load"===a.event.type||"complete"===da.readyState)&&(g(),na.ready())}function i(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(Ia,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:Ha.test(c)?na.parseJSON(c):c}catch(e){}na.data(a,b,c)}else c=void 0}return c}function j(a){var b;for(b in a)if(("data"!==b||!na.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function k(a,b,c,d){if(Ga(a)){var e,f,g=na.expando,h=a.nodeType,i=h?na.cache:a,j=h?a[g]:a[g]&&g;if(j&&i[j]&&(d||i[j].data)||void 0!==c||"string"!=typeof b)return j||(j=h?a[g]=ca.pop()||na.guid++:g),i[j]||(i[j]=h?{}:{toJSON:na.noop}),("object"==typeof b||"function"==typeof b)&&(d?i[j]=na.extend(i[j],b):i[j].data=na.extend(i[j].data,b)),f=i[j],d||(f.data||(f.data={}),f=f.data),void 0!==c&&(f[na.camelCase(b)]=c),"string"==typeof b?(e=f[b],null==e&&(e=f[na.camelCase(b)])):e=f,e}}function l(a,b,c){if(Ga(a)){var d,e,f=a.nodeType,g=f?na.cache:a,h=f?a[na.expando]:na.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){na.isArray(b)?b=b.concat(na.map(b,na.camelCase)):b in d?b=[b]:(b=na.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;for(;e--;)delete d[b[e]];if(c?!j(d):!na.isEmptyObject(d))return}(c||(delete g[h].data,j(g[h])))&&(f?na.cleanData([a],!0):la.deleteExpando||g!=g.window?delete g[h]:g[h]=void 0)}}}function m(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return na.css(a,b,"")},i=h(),j=c&&c[3]||(na.cssNumber[b]?"":"px"),k=(na.cssNumber[b]||"px"!==j&&+i)&&Ka.exec(na.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,na.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}function n(a){var b=Sa.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function o(a,b){var c,d,e=0,f="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||na.nodeName(d,b)?f.push(d):na.merge(f,o(d,b));return void 0===b||b&&na.nodeName(a,b)?na.merge([a],f):f}function p(a,b){for(var c,d=0;null!=(c=a[d]);d++)na._data(c,"globalEval",!b||na._data(b[d],"globalEval"))}function q(a){Oa.test(a.type)&&(a.defaultChecked=a.checked)}function r(a,b,c,d,e){for(var f,g,h,i,j,k,l,m=a.length,r=n(b),s=[],t=0;m>t;t++)if(g=a[t],g||0===g)if("object"===na.type(g))na.merge(s,g.nodeType?[g]:g);else if(Ua.test(g)){for(i=i||r.appendChild(b.createElement("div")),j=(Pa.exec(g)||["",""])[1].toLowerCase(),l=Ta[j]||Ta._default,i.innerHTML=l[1]+na.htmlPrefilter(g)+l[2],f=l[0];f--;)i=i.lastChild;if(!la.leadingWhitespace&&Ra.test(g)&&s.push(b.createTextNode(Ra.exec(g)[0])),!la.tbody)for(g="table"!==j||Va.test(g)?""!==l[1]||Va.test(g)?0:i:i.firstChild,f=g&&g.childNodes.length;f--;)na.nodeName(k=g.childNodes[f],"tbody")&&!k.childNodes.length&&g.removeChild(k);for(na.merge(s,i.childNodes),i.textContent="";i.firstChild;)i.removeChild(i.firstChild);i=r.lastChild}else s.push(b.createTextNode(g));for(i&&r.removeChild(i),la.appendChecked||na.grep(o(s,"input"),q),t=0;g=s[t++];)if(d&&na.inArray(g,d)>-1)e&&e.push(g);else if(h=na.contains(g.ownerDocument,g),i=o(r.appendChild(g),"script"),h&&p(i),c)for(f=0;g=i[f++];)Qa.test(g.type||"")&&c.push(g);return i=null,r}function s(){return!0}function t(){return!1}function u(){try{return da.activeElement}catch(a){}}function v(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)v(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=t;else if(!e)return a;return 1===f&&(g=e,e=function(a){return na().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=na.guid++)),a.each(function(){na.event.add(this,b,e,d,c)})}function w(a,b){return na.nodeName(a,"table")&&na.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function x(a){return a.type=(null!==na.find.attr(a,"type"))+"/"+a.type,a}function y(a){var b=eb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function z(a,b){if(1===b.nodeType&&na.hasData(a)){var c,d,e,f=na._data(a),g=na._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)na.event.add(b,c,h[c][d])}g.data&&(g.data=na.extend({},g.data))}}function A(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!la.noCloneEvent&&b[na.expando]){e=na._data(b);for(d in e.events)na.removeEvent(b,d,e.handle);b.removeAttribute(na.expando)}"script"===c&&b.text!==a.text?(x(b).text=a.text,y(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),la.html5Clone&&a.innerHTML&&!na.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&Oa.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}function B(a,b,c,d){b=fa.apply([],b);var e,f,g,h,i,j,k=0,l=a.length,m=l-1,n=b[0],p=na.isFunction(n);if(p||l>1&&"string"==typeof n&&!la.checkClone&&db.test(n))return a.each(function(e){var f=a.eq(e);p&&(b[0]=n.call(this,e,f.html())),B(f,b,c,d)});if(l&&(j=r(b,a[0].ownerDocument,!1,a,d),e=j.firstChild,1===j.childNodes.length&&(j=e),e||d)){for(h=na.map(o(j,"script"),x),g=h.length;l>k;k++)f=j,k!==m&&(f=na.clone(f,!0,!0),g&&na.merge(h,o(f,"script"))),c.call(a[k],f,k);if(g)for(i=h[h.length-1].ownerDocument,na.map(h,y),k=0;g>k;k++)f=h[k],Qa.test(f.type||"")&&!na._data(f,"globalEval")&&na.contains(i,f)&&(f.src?na._evalUrl&&na._evalUrl(f.src):na.globalEval((f.text||f.textContent||f.innerHTML||"").replace(fb,"")));j=e=null}return a}function C(a,b,c){for(var d,e=b?na.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||na.cleanData(o(d)),d.parentNode&&(c&&na.contains(d.ownerDocument,d)&&p(o(d,"script")),d.parentNode.removeChild(d));return a}function D(a,b){var c=na(b.createElement(a)).appendTo(b.body),d=na.css(c[0],"display");return c.detach(),d}function E(a){var b=da,c=jb[a];return c||(c=D(a,b),"none"!==c&&c||(ib=(ib||na("