Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var EcommerceOrdersView = function () { |
| 2 | |||
| 3 | |||
| 4 | var handleInvoices = function () { |
||
| 5 | |||
| 6 | var grid = new Datatable(); |
||
| 7 | |||
| 8 | grid.init({ |
||
| 9 | src: $("#datatable_invoices"), |
||
| 10 | onSuccess: function (grid) { |
||
| 11 | // execute some code after table records loaded |
||
| 12 | }, |
||
| 13 | onError: function (grid) { |
||
| 14 | // execute some code on network or other general error |
||
| 15 | }, |
||
| 16 | loadingMessage: 'Loading...', |
||
| 17 | dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options |
||
| 18 | |||
| 19 | // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout |
||
| 20 | // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/scripts/datatable.js). |
||
| 21 | // So when dropdowns used the scrollable div should be removed. |
||
| 22 | //"dom": "<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r>t<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>>", |
||
| 23 | |||
| 24 | "lengthMenu": [ |
||
| 25 | [10, 20, 50, 100, 150, -1], |
||
| 26 | [19, 20, 50, 100, 150, "All"] // change per page values here |
||
| 27 | ], |
||
| 28 | "pageLength": 10, // default record count per page |
||
| 29 | "ajax": { |
||
| 30 | "url": "demo/ecommerce_order_invoices.php", // ajax source |
||
| 31 | }, |
||
| 32 | "order": [ |
||
| 33 | [1, "asc"] |
||
| 34 | ] // set first column as a default sort by asc |
||
| 35 | } |
||
| 36 | }); |
||
| 37 | |||
| 38 | // handle group actionsubmit button click |
||
| 39 | grid.getTableWrapper().on('click', '.table-group-action-submit', function (e) { |
||
| 40 | e.preventDefault(); |
||
| 41 | var action = $(".table-group-action-input", grid.getTableWrapper()); |
||
| 42 | if (action.val() != "" && grid.getSelectedRowsCount() > 0) { |
||
| 43 | grid.setAjaxParam("customActionType", "group_action"); |
||
| 44 | grid.setAjaxParam("customActionName", action.val()); |
||
| 45 | grid.setAjaxParam("id", grid.getSelectedRows()); |
||
| 46 | grid.getDataTable().ajax.reload(); |
||
| 47 | grid.clearAjaxParams(); |
||
| 48 | } else if (action.val() == "") { |
||
| 49 | Metronic.alert({ |
||
| 50 | type: 'danger', |
||
| 51 | icon: 'warning', |
||
| 52 | message: 'Please select an action', |
||
| 53 | container: grid.getTableWrapper(), |
||
| 54 | place: 'prepend' |
||
| 55 | }); |
||
| 56 | } else if (grid.getSelectedRowsCount() === 0) { |
||
| 57 | Metronic.alert({ |
||
| 58 | type: 'danger', |
||
| 59 | icon: 'warning', |
||
| 60 | message: 'No record selected', |
||
| 61 | container: grid.getTableWrapper(), |
||
| 62 | place: 'prepend' |
||
| 63 | }); |
||
| 64 | } |
||
| 65 | }); |
||
| 66 | } |
||
| 67 | |||
| 68 | var handleCreditMemos = function () { |
||
| 69 | |||
| 70 | var grid = new Datatable(); |
||
| 71 | |||
| 72 | grid.init({ |
||
| 73 | src: $("#datatable_credit_memos"), |
||
| 74 | onSuccess: function (grid) { |
||
| 75 | // execute some code after table records loaded |
||
| 76 | }, |
||
| 77 | onError: function (grid) { |
||
| 78 | // execute some code on network or other general error |
||
| 79 | }, |
||
| 80 | loadingMessage: 'Loading...', |
||
| 81 | dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options |
||
| 82 | |||
| 83 | // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout |
||
| 84 | // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/scripts/datatable.js). |
||
| 85 | // So when dropdowns used the scrollable div should be removed. |
||
| 86 | //"dom": "<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r>t<'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>>", |
||
| 87 | |||
| 88 | "lengthMenu": [ |
||
| 89 | [10, 20, 50, 100, 150, -1], |
||
| 90 | [10, 20, 50, 100, 150, "All"] // change per page values here |
||
| 91 | ], |
||
| 92 | "pageLength": 10, // default record count per page |
||
| 93 | "ajax": { |
||
| 94 | "url": "demo/ecommerce_order_credit_memos.php", // ajax source |
||
| 95 | }, |
||
| 96 | "columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column) |
||
| 97 | 'orderable': true, |
||
| 98 | 'targets': [0] |
||
| 99 | }], |
||
| 100 | "order": [ |
||
| 101 | [0, "asc"] |
||
| 102 | ] // set first column as a default sort by asc |
||
| 103 | } |
||
| 104 | }); |
||
| 105 | |||
| 106 | } |
||
| 107 | |||
| 108 | var handleShipment = function () { |
||
| 109 | |||
| 110 | var grid = new Datatable(); |
||
| 111 | |||
| 112 | grid.init({ |
||
| 113 | src: $("#datatable_shipment"), |
||
| 114 | onSuccess: function (grid) { |
||
| 115 | // execute some code after table records loaded |
||
| 116 | }, |
||
| 117 | onError: function (grid) { |
||
| 118 | // execute some code on network or other general error |
||
| 119 | }, |
||
| 120 | loadingMessage: 'Loading...', |
||
| 121 | dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options |
||
| 122 | "lengthMenu": [ |
||
| 123 | [10, 20, 50, 100, 150, -1], |
||
| 124 | [10, 20, 50, 100, 150, "All"] // change per page values here |
||
| 125 | ], |
||
| 126 | "pageLength": 10, // default record count per page |
||
| 127 | "ajax": { |
||
| 128 | "url": "demo/ecommerce_order_shipment.php", // ajax source |
||
| 129 | }, |
||
| 130 | "columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column) |
||
| 131 | 'orderable': true, |
||
| 132 | 'targets': [0] |
||
| 133 | }], |
||
| 134 | "order": [ |
||
| 135 | [0, "asc"] |
||
| 136 | ] // set first column as a default sort by asc |
||
| 137 | } |
||
| 138 | }); |
||
| 139 | } |
||
| 140 | |||
| 141 | var handleHistory = function () { |
||
| 142 | |||
| 143 | var grid = new Datatable(); |
||
| 144 | |||
| 145 | grid.init({ |
||
| 146 | src: $("#datatable_history"), |
||
| 147 | onSuccess: function (grid) { |
||
| 148 | // execute some code after table records loaded |
||
| 149 | }, |
||
| 150 | onError: function (grid) { |
||
| 151 | // execute some code on network or other general error |
||
| 152 | }, |
||
| 153 | loadingMessage: 'Loading...', |
||
| 154 | dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options |
||
| 155 | "lengthMenu": [ |
||
| 156 | [10, 20, 50, 100, 150, -1], |
||
| 157 | [10, 20, 50, 100, 150, "All"] // change per page values here |
||
| 158 | ], |
||
| 159 | "pageLength": 10, // default record count per page |
||
| 160 | "ajax": { |
||
| 161 | "url": "demo/ecommerce_order_history.php", // ajax source |
||
| 162 | }, |
||
| 163 | "columnDefs": [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column) |
||
| 164 | 'orderable': true, |
||
| 165 | 'targets': [0] |
||
| 166 | }], |
||
| 167 | "order": [ |
||
| 168 | [0, "asc"] |
||
| 169 | ] // set first column as a default sort by asc |
||
| 170 | } |
||
| 171 | }); |
||
| 172 | |||
| 173 | // handle group actionsubmit button click |
||
| 174 | grid.getTableWrapper().on('click', '.table-group-action-submit', function (e) { |
||
| 175 | e.preventDefault(); |
||
| 176 | var action = $(".table-group-action-input", grid.getTableWrapper()); |
||
| 177 | if (action.val() != "" && grid.getSelectedRowsCount() > 0) { |
||
| 178 | grid.setAjaxParam("customActionType", "group_action"); |
||
| 179 | grid.setAjaxParam("customActionName", action.val()); |
||
| 180 | grid.setAjaxParam("id", grid.getSelectedRows()); |
||
| 181 | grid.getDataTable().ajax.reload(); |
||
| 182 | grid.clearAjaxParams(); |
||
| 183 | } else if (action.val() == "") { |
||
| 184 | Metronic.alert({ |
||
| 185 | type: 'danger', |
||
| 186 | icon: 'warning', |
||
| 187 | message: 'Please select an action', |
||
| 188 | container: grid.getTableWrapper(), |
||
| 189 | place: 'prepend' |
||
| 190 | }); |
||
| 191 | } else if (grid.getSelectedRowsCount() === 0) { |
||
| 192 | Metronic.alert({ |
||
| 193 | type: 'danger', |
||
| 194 | icon: 'warning', |
||
| 195 | message: 'No record selected', |
||
| 196 | container: grid.getTableWrapper(), |
||
| 197 | place: 'prepend' |
||
| 198 | }); |
||
| 199 | } |
||
| 200 | }); |
||
| 201 | } |
||
| 202 | |||
| 203 | var initPickers = function () { |
||
| 204 | //init date pickers |
||
| 205 | $('.date-picker').datepicker({ |
||
| 206 | rtl: Metronic.isRTL(), |
||
| 207 | autoclose: true |
||
| 208 | }); |
||
| 209 | |||
| 210 | $(".datetime-picker").datetimepicker({ |
||
| 211 | isRTL: Metronic.isRTL(), |
||
| 212 | autoclose: true, |
||
| 213 | todayBtn: true, |
||
| 214 | pickerPosition: (Metronic.isRTL() ? "bottom-right" : "bottom-left"), |
||
| 215 | minuteStep: 10 |
||
| 216 | }); |
||
| 217 | } |
||
| 218 | |||
| 219 | return { |
||
| 220 | |||
| 221 | //main function to initiate the module |
||
| 222 | init: function () { |
||
| 223 | initPickers(); |
||
| 224 | |||
| 225 | handleInvoices(); |
||
| 226 | handleCreditMemos(); |
||
| 227 | handleShipment(); |
||
| 228 | handleHistory(); |
||
| 229 | } |
||
| 230 | |||
| 231 | }; |
||
| 232 | |||
| 233 | }(); |