| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704 |
- var FormValidation = function () {
- return {
- //main function to initiate the module
- init: function () {
- // for more info visit the official plugin documentation:
- // http://docs.$.com/Plugins/Validation
- var form1 = $('#form');
- var error1 = $('.alert-danger', form1);
- var success1 = $('.alert-success', form1);
- $.validator.setDefaults({
- errorElement: 'span', //default input error message container
- errorClass: 'help-block help-block-error', // default input error message classfocusInvalid: false, // do not focus the last invalid input
- ignore: "",
- invalidHandler: function (event, validator) { //display error alert on form submit
- success1.hide();
- error1.show();
- App.scrollTo(error1, -200);
- },
- highlight: function (element) { // hightlight error inputs
- $(element)
- .closest('.form-group').addClass('has-error'); // set error class to the control group
- },
- unhighlight: function (element) { // revert the change done by hightlight
- $(element)
- .closest('.form-group').removeClass('has-error'); // set error class to the control group
- },
- success: function (label) {
- label
- .closest('.form-group').removeClass('has-error'); // set success class to the control group
- },
- submitHandler: function (form) {
- success1.show();
- error1.hide();
- form.submit();
- }
- });
- }
- };
- }();
- var FormValidationUsers = function () {
- return {
- //main function to initiate the module
- init: function () {
- // for more info visit the official plugin documentation:
- // http://docs.$.com/Plugins/Validation
- var form1 = $('.form-users');
- var error1 = $('.alert-error', form1);
- var success1 = $('.alert-success', form1);
- $.validator.setDefaults({
- errorElement: 'span', //default input error message container
- errorClass: 'help-inline', // default input error message class
- focusInvalid: false, // do not focus the last invalid input
- ignore: "",
- invalidHandler: function (event, validator) { //display error alert on form submit
- success1.hide();
- error1.show();
- App.scrollTo(error1, -200);
- },
- highlight: function (element) { // hightlight error inputs
- $(element)
- .closest('.help-inline').removeClass('ok'); // display OK icon
- $(element)
- .closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group
- },
- unhighlight: function (element) { // revert the change dony by hightlight
- $(element)
- .closest('.control-group').removeClass('error'); // set error class to the control group
- },
- success: function (label) {
- label
- .addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon
- .closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group
- },
- submitHandler: function (form) {
- success1.show();
- error1.hide();
- form.submit();
- }
- });
- }
- };
- }();
- var TableAdvanced = function () {
- var initTable1 = function () {
- var table = $('.tableadvanced');
- var filter = $('#filter').val();
- var buscar_ = { };
- var page_ = 0;
- /* Table tools samples: https://www.datatables.net/release-datatables/extras/TableTools/ */
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-medium input-inline";
- /* Set tabletools buttons and button container */
- if(filter != ""){ buscar_ = { search: filter }; }
- if( $('#current_page').length > 0 ){ page_ = ($('#current_page').val() - 1) * 20;}
- var oTable = table.dataTable({
- // Internationalisation. For more info refer to http://datatables.net/manual/i18n
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- "order": [
- // [0, 'asc']
- ],
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- "search": buscar_,
- // set the initial value
- "pageLength": 20,
- "iDisplayStart": page_,
- "dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
- "fnDrawCallback": function( oSettings ) {
- $('a.filtros').on( 'click', function (e) {
- e.preventDefault();
- var url_ = $(this).attr('href');
- url_ += '?filter=' + $('#filter').val();
- url_ += '¤t_page=' + $('#current_page').val();
- console.log(url_);
- window.location.href = url_;
- });
- $('a.filtros2').on( 'click', function (e) {
- e.preventDefault();
- var url_ = $(this).attr('href');
- url_ += '&filter=' + $('#filter').val();
- url_ += '¤t_page=' + $('#current_page').val();
- console.log(url_);
- window.location.href = url_;
- });
- }
- });
- var tableWrapper = $('.tableadvanced_wrapper'); // datatable creates the table wrapper by adding with id {your_table_jd}_wrapper
- tableWrapper.find('.dataTables_length select').select2(); // initialize select2 dropdown
- if( $('#current_page').length > 0 ){
- $('.tableadvanced').on( 'page.dt', function () {
- var oSettings = oTable.fnSettings();
- var page = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
- $('#current_page').val(page);
- });
- }
- }
- return {
- //main function to initiate the module
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTable1();
- }
- };
- }();
- var TableAdvancedSingleSelection = function () {
- var initTable1 = function () {
- var table = $('.tableadvancedSingleSelection');
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-medium input-inline";
- var oTable = table.DataTable({
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- "order": [],
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"]
- ],
- "pageLength": 20,
- "tableTools": {
- "sRowSelect": "single"
- },
- "dom": "<'row'<'col-md-6 col-sm-12 hidden'T><'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>"
- });
- var tableWrapper = $('.tableadvanced_wrapper');
- tableWrapper.find('.dataTables_length select').select2();
- }
- return {
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTable1();
- }
- };
- }();
- var TableWithCheckbox = function () {
- //var rows_selected = [];
- var initTableCheckbox = function () {
- var table = $('.tableWithCheckbox');
- /* Table tools samples: https://www.datatables.net/release-datatables/extras/TableTools/ */
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-xlarge input-inline";
- /* Set tabletools buttons and button container */
- var oTable = table.dataTable({
- // Internationalisation. For more info refer to http://datatables.net/manual/i18n
- 'columnDefs': [{
- 'targets': 0,
- 'searchable':false,
- 'orderable':false,
- 'className': 'dt-body-center',
- 'render': function (data, type, full, meta) {
- return '<input type="checkbox" name="id[]">';
- }
- }],
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- 'order': [3, 'asc'],
- "rowCallback": function(row, data, dataIndex){
- // Get row ID
- var rowId = data[0];
- // If row ID is in the list of selected row IDs
- if($.inArray(rowId, rows_selected) !== -1){
- $(row).find('input[type="checkbox"]').prop('checked', true);
- $(row).addClass('selected');
- }
- },
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- // set the initial value
- "pageLength": -1,
- "dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>" // horizobtal scrollable datatable
- });
- var tableWrapper = $('.tableadvanced_wrapper'); // datatable creates the table wrapper by adding with id {your_table_jd}_wrapper
- tableWrapper.find('.dataTables_length select').select2(); // initialize select2 dropdown
- var table = $('.tableWithCheckbox').DataTable();
- // Handle click on checkbox
- $('.tableWithCheckbox tbody').on('click', 'input[type="checkbox"]', function(e){
- var $row = $(this).closest('tr');
- // Get row data
- var data = table.row($row).data();
- // Get row ID
- // var rowId = data[0];
- var rowId = $row.attr('id').substring($row.attr('id').indexOf('_') + 1, $row.attr('id').length);
- // Determine whether row ID is in the list of selected row IDs
- var index = $.inArray(rowId, rows_selected);
- // If checkbox is checked and row ID is not in list of selected row IDs
- if(this.checked && index === -1){
- rows_selected.push(rowId);
- // Otherwise, if checkbox is not checked and row ID is in list of selected row IDs
- } else if (!this.checked && index !== -1){
- rows_selected.splice(index, 1);
- }
- if(this.checked){
- $row.addClass('selected');
- //$row.css('background-color', '#34495E');
- } else {
- //$row.css('background-color', '#F9F9F9');
- $row.removeClass('selected');
- }
- // Update state of "Select all" control
- updateDataTableSelectAllCtrl(table);
- // Prevent click event from propagating to parent
- e.stopPropagation();
- });
- // Handle click on table cells with checkboxes
- $('.tableWithCheckbox').on('click', 'tbody td, thead th:first-child', function(e){
- $(this).parent().find('input[type="checkbox"]').trigger('click');
- });
- // Handle click on "Select all" control
- $('thead input[name="select_all"]', table.table().container()).on('click', function(e){
- if(this.checked){
- $('.tableWithCheckbox tbody input[type="checkbox"]:not(:checked)').trigger('click');
- } else {
- $('.tableWithCheckbox tbody input[type="checkbox"]:checked').trigger('click');
- }
- // Prevent click event from propagating to parent
- e.stopPropagation();
- });
- // Handle table draw event
- table.on('draw', function(){
- // Update state of "Select all" control
- updateDataTableSelectAllCtrl(table);
- });
- function updateDataTableSelectAllCtrl(table){
- var $table = table.table().node();
- var $chkbox_all = $('tbody input[type="checkbox"]', $table);
- var $chkbox_checked = $('tbody input[type="checkbox"]:checked', $table);
- var chkbox_select_all = $('thead input[name="select_all"]', $table).get(0);
- // If none of the checkboxes are checked
- if($chkbox_checked.length === 0){
- chkbox_select_all.checked = false;
- if('indeterminate' in chkbox_select_all){
- chkbox_select_all.indeterminate = false;
- }
- // If all of the checkboxes are checked
- } else if ($chkbox_checked.length === $chkbox_all.length){
- chkbox_select_all.checked = true;
- if('indeterminate' in chkbox_select_all){
- chkbox_select_all.indeterminate = false;
- }
- // If some of the checkboxes are checked
- } else {
- chkbox_select_all.checked = true;
- if('indeterminate' in chkbox_select_all){
- chkbox_select_all.indeterminate = true;
- }
- }
- }
- }
- return {
- //main function to initiate the module
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTableCheckbox();
- }
- };
- }();
- var tableWithCheckboxAjax = function () {
- //var arrayForRows = [];
- var initTableCheckboxAjax = function (tableClass, columns, order, extraParams, arrayForRows) {
- var table = $(tableClass);
- /* Table tools samples: https://www.datatables.net/release-datatables/extras/TableTools/ */
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-xlarge input-inline";
- /* Set tabletools buttons and button container */
- var oTable = table.dataTable({
- "processing": true,
- "serverSide": true,
- "ajax": {
- "url": $(tableClass).data('source'),
- "data": function ( d ) {
- d.busqueda = $(tableClass).closest('.dataTables_wrapper').find('input[type="search"]').val();
- d.pointsale = $('#pointsale').val();
- // son los parametros custom de cada tabla, se envia el obj.
- for(var param in extraParams){
- d[param] = extraParams[param];
- }
- }
- },
- "drawCallback": function( settings ) {
- arrayForRows.length = 0;
- },
- 'columns': columns,
- 'columnDefs': [{
- 'targets': 0,
- 'searchable':false,
- 'orderable':false,
- 'className': 'dt-body-center',
- 'render': function (data, type, full, meta) {
- return '<input type="checkbox" name="id[]">';
- }
- }],
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "sProcessing": "Cargando...",
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- 'order': [order, 'asc'],
- "rowCallback": function(row, data, dataIndex) {
- // Get row ID
- var rowId = data[0];
- // If row ID is in the list of selected row IDs
- if($.inArray(rowId, arrayForRows) !== -1){
- $(row).find('input[type="checkbox"]').prop('checked', true);
- $(row).addClass('selected');
- }
- },
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- // set the initial value
- "pageLength": 20,
- "dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>" // horizobtal scrollable datatable
- });
- var tableWrapper = $('.tableadvanced_wrapper'); // datatable creates the table wrapper by adding with id {your_table_jd}_wrapper
- tableWrapper.find('.dataTables_length select').select2(); // initialize select2 dropdown
- var table = $(tableClass).DataTable();
- // Handle click on checkbox
- $(tableClass + ' tbody').on('click', 'input[type="checkbox"]', function(e){
- var $row = $(this).closest('tr');
- // Get row data
- var data = table.row($row).data();
- // Get row ID
- // var rowId = data[0];
- var rowId = $row.attr('id').substring($row.attr('id').indexOf('_') + 1, $row.attr('id').length);
- // Determine whether row ID is in the list of selected row IDs
- var index = $.inArray(rowId, arrayForRows);
- // If checkbox is checked and row ID is not in list of selected row IDs
- if(this.checked && index === -1) {
- arrayForRows.push(rowId);
- // Otherwise, if checkbox is not checked and row ID is in list of selected row IDs
- } else if (!this.checked && index !== -1) {
- arrayForRows.splice(index, 1);
- }
- if(this.checked){
- $row.addClass('selected');
- //$row.css('background-color', '#34495E');
- } else {
- //$row.css('background-color', '#F9F9F9');
- $row.removeClass('selected');
- }
- // Update state of "Select all" control
- updateDataTableSelectAllCtrl(table);
- // Prevent click event from propagating to parent
- e.stopPropagation();
- });
- // Handle click on table cells with checkboxes
- $(tableClass).on('click', 'tbody td, thead th:first-child', function(e){
- $(this).parent().find('input[type="checkbox"]').trigger('click');
- });
- // Handle click on "Select all" control
- $('thead input[name="select_all"]', table.table().container()).on('click', function(e){
- if(this.checked){
- $(tableClass + ' tbody input[type="checkbox"]:not(:checked)').trigger('click');
- } else {
- $(tableClass + ' tbody input[type="checkbox"]:checked').trigger('click');
- }
- // Prevent click event from propagating to parent
- e.stopPropagation();
- });
- // Handle table draw event
- table.on('draw', function(){
- // Update state of "Select all" control
- updateDataTableSelectAllCtrl(table);
- });
- function updateDataTableSelectAllCtrl(table){
- var $table = table.table().node();
- var $chkbox_all = $('tbody input[type="checkbox"]', $table);
- var $chkbox_checked = $('tbody input[type="checkbox"]:checked', $table);
- var chkbox_select_all = $('thead input[name="select_all"]', $table).get(0);
- // If none of the checkboxes are checked
- if($chkbox_checked.length === 0){
- chkbox_select_all.checked = false;
- if('indeterminate' in chkbox_select_all){
- chkbox_select_all.indeterminate = false;
- }
- // If all of the checkboxes are checked
- } else if ($chkbox_checked.length === $chkbox_all.length){
- chkbox_select_all.checked = true;
- if('indeterminate' in chkbox_select_all){
- chkbox_select_all.indeterminate = false;
- }
- // If some of the checkboxes are checked
- } else {
- chkbox_select_all.checked = true;
- if('indeterminate' in chkbox_select_all){
- chkbox_select_all.indeterminate = true;
- }
- }
- }
- }
- return {
- //main function to initiate the module
- init: function (tableClass, columns, order, data, arrayForRows) {
- if (!$().dataTable) {
- return;
- }
- initTableCheckboxAjax(tableClass, columns, order, data, arrayForRows);
- }
- };
- }();
- var TablePagination = function () {
- var initTable3 = function () {
- var table = $('.tablePag');
- // begin: third table
- table.dataTable({
- // Internationalisation. For more info refer to http://datatables.net/manual/i18n
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias"
- },
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- // set the initial value
- "pageLength": 20,
- // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
- // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
- // So when dropdowns used the scrollable div should be removed.
- "dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
- "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
- "order": [
- [0, "asc"]
- ] // set first column as a default sort by asc
- });
- var tableWrapper = $('.tablePag_wrapper');
- // table.find('.group-checkable').change(function () {
- // var set = $(this).attr("data-set");
- // var checked = $(this).is(":checked");
- // $(set).each(function () {
- // if (checked) {
- // $(this).attr("checked", true);
- // } else {
- // $(this).attr("checked", false);
- // }
- // });
- // $.uniform.update(set);
- // });
- tableWrapper.find('.dataTables_length select').select2(); // initialize select2 dropdown
- }
- return {
- //main function to initiate the module
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTable3();
- }
- };
- }();
- var TableChecks = function () {
- var initTable1 = function () {
- var table = $('.tablechecks');
- // begin first table
- table.dataTable({
- // Internationalisation. For more info refer to http://datatables.net/manual/i18n
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- // Or you can use remote translation file
- //"language": {
- // url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
- //},
- // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
- // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
- // So when dropdowns used the scrollable div should be removed.
- //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
- "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
- "columnDefs": [ {
- "targets": 0,
- "orderable": false,
- "searchable": false
- }],
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- // set the initial value
- "pageLength": 20,
- "columnDefs": [{ // set default column settings
- 'orderable': false,
- 'targets': [0]
- }, {
- "searchable": false,
- "targets": [0]
- }],
- "order": [
- [1, "asc"]
- ] // set first column as a default sort by asc
- });
- var tableWrapper = $('.tablechecks_wrapper');
- table.find('.group-checkable').on('change', function () {
- var set = $(this).attr("data-set");
- var checked = $(this).is(":checked");
- $(set).each(function () {
- if (checked) {
- $(this).prop("checked", true);
- } else {
- $(this).prop("checked", false);
- }
- });
- $.uniform.update(set);
- });
- table.on('change', 'tbody tr .checkboxes', function () {
- $(this).parents('tr').toggleClass("active");
- });
- }
- return {
- //main function to initiate the module
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTable1();
- }
- };
- }();
- var handleDateFormat = function () {
- var shortDateFormat = 'dd/MM/yyyy';
- var longDateFormat = 'dd/MM/yyyy HH:mm:ss';
- $(".shortDateFormat").each(function (idx, elem) {
- if ($(elem).is(":input")) {
- $(elem).val($.format.date($(elem).val(), shortDateFormat));
- } else {
- $(elem).text($.format.date($(elem).text(), shortDateFormat));
- }
- });
- $(".longDateFormat").each(function (idx, elem) {
- if ($(elem).is(":input")) {
- $(elem).val($.format.date($(elem).val(), longDateFormat));
- } else {
- $(elem).text($.format.date($(elem).text(), longDateFormat));
- }
- });
- }
- var handleDatePickers = function () {
- if ($().datepicker) {
- $('.date-picker').datepicker({
- rtl: App.isRTL(),
- orientation: "left",
- autoclose: true
- });
- //$('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
- }
- /* Workaround to restrict daterange past date select: http://stackoverflow.com/questions/11933173/how-to-restrict-the-selectable-date-ranges-in-bootstrap-datepicker */
- }
- var handleMultiSelect = function () {
- $('.searchable').multiSelect({
- selectableHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Buscar productos disponibles'>",
- selectionHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='Buscar productos seleccionados'>",
- afterInit: function(ms) {
- var that = this,
- $selectableSearch = that.$selectableUl.prev(),
- $selectionSearch = that.$selectionUl.prev(),
- selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
- selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
- that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
- .on('keydown', function(e){
- if (e.which === 40){
- that.$selectableUl.focus();
- return false;
- }
- });
- that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
- .on('keydown', function(e){
- if (e.which == 40){
- that.$selectionUl.focus();
- return false;
- }
- });
- },
- afterSelect: function(){
- this.qs1.cache();
- this.qs2.cache();
- },
- afterDeselect: function(){
- this.qs1.cache();
- this.qs2.cache();
- }
- });
- $('.multi-select').multiSelect({
- keepOrder: true,
- selectableOptgroup: true
- });
- $('#select-all').click(function(){
- $('.multi-select').multiSelect('select_all');
- return false;
- });
- $('#deselect-all').click(function(){
- $('.multi-select').multiSelect('deselect_all');
- return false;
- });
- }
- var handleNestedSelects = function (){
- $('select[data-option-dependent=true]').each(function (i) {
- var observer_dom_id = $(this).data('opt-id');
- var observed_dom_id = $(this).data('option-observed');
- var url_mask = $(this).data('option-url');
- var key_method = $(this).data('option-key-method');
- var value_method = $(this).data('option-value-method');
- var prompt = $('<option value=\"\">').text('Seleccione');
- if($(this).data('option-prompt') != undefined ){
- prompt = $('<option value=\"\">').text( $(this).data('option-prompt') );
- }
- // var prompt = $(this).has('option[value=]').size() ? $(this).find('option[value=]') : $('<option value=\"\">').text('Select a specialization');
- var regexp = /:[0-9a-zA-Z_]+:/g;
- var observer = $('select.' + observer_dom_id);
- var observed = $('.' + observed_dom_id);
- if (!observer.val() && observed.size() > 1) {
- observer.attr('disabled', true);
- }
- observed.on('change', function () {
- observer.empty().append(prompt);
- if (observed.val()) {
- url = url_mask.replace(regexp, observed.val());
- $.getJSON(url, function (data) {
- $.each(data, function (i, object) {
- observer.append($('<option>').attr('value', object[key_method]).text(object[value_method]));
- observer.attr('disabled', false);
- });
- });
- }
- });
- });
- }
- var oTable;
- var handleInputMasks = function () {
- $.extend($().inputmask.defaults, {
- 'autounmask': true
- });
- $(".mask_phone").inputmask("mask", {"mask": "(999) 999-9999"}); //specifying fn & options
- $(".mask_number").inputmask({ "mask": "9", "repeat": 10, "greedy": false }); // ~ mask "9" or mask "99" or ... mask "9999999999"
- $(".mask_decimal").inputmask('decimal', { rightAlignNumerics: false }); //disables the right alignment of the decimal input
- $(".mask_currency").inputmask('999,999,999.99', { numericInput: true });
- // $(".mask_rfc").inputmask("mask", {"mask":"9-a{1,3}9{1,3}" });
- }
- var TableAdvancedPrintable = function () {
- var initTablePrintable = function () {
- var filter = $('#filter').val();
- var buscar_ = { };
- var page_ = 0;
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-medium input-inline";
- if(filter != ""){ buscar_ = { search: filter }; }
- if( $('#current_page').length > 0 ){ page_ = ($('#current_page').val() - 1) * 20;}
- $.extend(true, $.fn.DataTable.TableTools.classes, {
- "container": " pull-right margin-bottom-10",
- "buttons": {
- "normal": "btn btn-primary margin-right-10",
- "disabled": "disabled"
- },
- "collection": {
- "container": "DTTT_dropdown dropdown-menu tabletools-dropdown-menu "
- }
- });
- var table = $('.tableadvancedprintable');
- var oTable = table.dataTable({
- "dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f><'col-md-6 col-sm-12'>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
- "tableTools": {
- "sSwfPath": "/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
- "aButtons": [
- {
- "sExtends": "collection",
- "sButtonText": "Acciones <i class='fa fa-angle-down'></i>",
- "aButtons": [{
- "sExtends": "print",
- "footer": false,
- "exportOptions": {
- "columns": ':not(:last-child)',
- },
- "sButtonText": "Imprimir",
- "sInfo": 'Presiona "CTR+P" para imprmir o "ESC" para salir',
- "sMessage": function() {
- return "<h2>" + $('#title_for_print').val() + "</h2>";
- },
- "fnClick": function( nButton, oConfig ) {
- $(window).keyup(closePrintView);
- this.fnPrint( true, oConfig );
- }
- }]
- }]
- },
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- "order": [
- // [0, 'asc']
- ],
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- "search": buscar_,
- // set the initial value
- "pageLength": 20,
- "iDisplayStart": page_,
- "bServerSide": false,
- "fnDrawCallback": function( oSettings ) {
- $('a.filtros').on( 'click', function (e) {
- e.preventDefault();
- var url_ = $(this).attr('href');
- url_ += '?filter=' + $('#filter').val();
- url_ += '¤t_page=' + $('#current_page').val();
- console.log(url_);
- window.location.href = url_;
- });
- $('a.filtros2').on( 'click', function (e) {
- e.preventDefault();
- var url_ = $(this).attr('href');
- url_ += '&filter=' + $('#filter').val();
- url_ += '¤t_page=' + $('#current_page').val();
- console.log(url_);
- window.location.href = url_;
- });
- }
- });
- var closePrintView = function(e) {
- if(e.which == 27) {
- printViewClosed();
- }
- };
- function printViewClosed() {
- $(window).unbind('keyup', closePrintView);
- }
- if( $('#current_page').length > 0 ){
- $('.tableadvancedprintable').on( 'page.dt', function () {
- var oSettings = oTable.fnSettings();
- var page = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
- $('#current_page').val(page);
- });
- }
- }
- return {
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTablePrintable();
- }
- };
- }();
- var TableAdvancedPrintableAjax = function () {
- var initTablePrintableAjax = function () {
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-medium input-inline";
- var table = $('.tableadvancedprintableAjax').DataTable({
- "processing": true,
- "serverSide": true,
- "ajax": {
- "url": $('.tableadvancedprintableAjax').data('source'),
- "data": function ( d ) {
- d.busqueda = $('input[type="search"]').val();
- d.location = $('#pointsale').val();
- d.category = $('#category').val();
- d.sub_category = $('#sub_category').val();
- }
- },
- "dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "sProcessing": "Cargando...",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- "order": [
- // [0, 'asc']
- ],
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- "pageLength": 20
- });
- var closePrintView = function(e) {
- if(e.which == 27) {
- printViewClosed();
- }
- };
- function printViewClosed() {
- $(window).unbind('keyup', closePrintView);
- }
- }
- return {
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTablePrintableAjax();
- }
- };
- }();
- var TableAdvancedAjax = function () {
- //create JSON array for aoColumnDefs
- var initTableAjax = function () {
- var table = $('.tableadvancedAjax');
- var filter = $('#filter').val();
- var buscar_ = { };
- var page_ = 0;
- $.fn.dataTableExt.oStdClasses.sFilterInput = "form-control input-medium input-inline";
- if(filter != "")
- {
- buscar_ = { search: filter };
- }
- if($('#current_page').length > 0)
- {
- page_ = ($('#current_page').val() - 1) * 20;
- }
- var oTable = table.dataTable({
- "processing": true,
- "serverSide": true,
- "ajax": {
- "url": $('.tableadvancedAjax').data('source'),
- "data": function ( d ) {
- d.busqueda = $('input[type="search"]').val();
- $('#filter').val(d.busqueda);
- }
- },
- "language": {
- "aria": {
- "sortAscending": ": activate to sort column ascending",
- "sortDescending": ": activate to sort column descending"
- },
- "emptyTable": "No hay informacion en la tabla",
- "sProcessing": "Cargando...",
- "info": "Mostrando del _START_ al _END_ de _TOTAL_ registros",
- "infoEmpty": "No se encontraron coincidencias",
- "infoFiltered": "(filtrado un total de _MAX_ registros)",
- "lengthMenu": "Mostrar _MENU_ registros",
- "search": "Buscar:",
- "zeroRecords": "No se encontraron coincidencias",
- "paginate": {
- "sPrevious": "Ant",
- "sNext": "Sig"
- }
- },
- "order": [
- // [0, 'asc']
- ],
- "lengthMenu": [
- [20, 50, 75, 100, -1],
- [20, 50, 75, 100, "Todos"] // change per page values here
- ],
- "dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
- "search": buscar_,
- // set the initial value
- "pageLength": 20,
- "iDisplayStart": page_,
- "fnDrawCallback": function( oSettings ) {
- $('a.filtros').on( 'click', function (e) {
- e.preventDefault();
- var url_ = $(this).attr('href');
- url_ += '?filter=' + $('#filter').val();
- url_ += '¤t_page=' + $('#current_page').val();
- window.location.href = url_;
- });
- $('a.filtros2').on( 'click', function (e) {
- e.preventDefault();
- var url_ = $(this).attr('href');
- url_ += '&filter=' + $('#filter').val();
- url_ += '¤t_page=' + $('#current_page').val();
- window.location.href = url_;
- });
- }
- });
- var tableWrapper = $('.tableadvancedAjax_wrapper');
- tableWrapper.find('.dataTables_length select').select2();
- if( $('#current_page').length > 0 ){
- $('.tableadvancedAjax').on( 'page.dt', function () {
- var oSettings = oTable.fnSettings();
- var page = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
- $('#current_page').val(page);
- });
- }
- }
- return {
- init: function () {
- if (!$().dataTable) {
- return;
- }
- initTableAjax();
- }
- };
- }();
- var FormWizard = function () {
- return {
- //main function to initiate the module
- init: function () {
- if (!jQuery().bootstrapWizard) {
- return;
- }
- var form = $('#submit_form');
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
- // jQuery.validator.setDefaults({
- // doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
- // errorElement: 'span', //default input error message container
- // errorClass: 'help-block help-block-error', // default input error message class
- // focusInvalid: false, // do not focus the last invalid input
- // errorPlacement: function (error, element) { // render error placement for each input type
- // if (element.attr("name") == "gender") { // for uniform radio buttons, insert the after the given container
- // error.insertAfter("#form_gender_error");
- // } else if (element.attr("name") == "modulos[]") { // for uniform checkboxes, insert the after the given container
- // error.insertAfter("#form_payment_error");
- // } else {
- // error.insertAfter(element); // for other inputs, just perform default behavior
- // }
- // },
- // invalidHandler: function (event, validator) { //display error alert on form submit
- // success.hide();
- // error.show();
- // App.scrollTo(error, -200);
- // },
- // highlight: function (element) { // hightlight error inputs
- // $(element)
- // .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
- // },
- // unhighlight: function (element) { // revert the change done by hightlight
- // $(element)
- // .closest('.form-group').removeClass('has-error'); // set error class to the control group
- // },
- // success: function (label) {
- // if (label.attr("for") == "gender" || label.attr("for") == "modulos[]") { // for checkboxes and radio buttons, no need to show OK icon
- // label
- // .closest('.form-group').removeClass('has-error').addClass('has-success');
- // label.remove(); // remove error label here
- // } else { // display success icon for other inputs
- // label
- // .addClass('valid') // mark the current input as valid and display OK icon
- // .closest('.form-group').removeClass('has-error').addClass('has-success'); // set success class to the control group
- // }
- // },
- // submitHandler: function (form) {
- // success.show();
- // error.hide();
- // form.submit();
- // //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
- // }
- // });
- var displayConfirm = function() {
- $('#tab4 .form-control-static', form).each(function(){
- var input = $('[name="'+$(this).attr("data-display")+'"]', form);
- if (input.is(":radio")) {
- input = $('[name="'+$(this).attr("data-display")+'"]:checked', form);
- }
- if (input.is(":text") || input.is("textarea")) {
- $(this).html(input.val());
- } else if (input.is("select")) {
- $(this).html(input.find('option:selected').text());
- } else if (input.is(":radio") && input.is(":checked")) {
- $(this).html(input.attr("data-title"));
- } else if ($(this).attr("data-display") == 'modulos[]') {
- var modulos = [];
- $('[name="modulos[]"]:checked', form).each(function(){
- modulos.push($(this).attr('data-title'));
- });
- $(this).html(modulos.join(" <br>"));
- }
- });
- }
- var displayConfirm = function() {
- $('.form-control-static', form).each(function(){
- var input = $('[name="'+$(this).attr("data-display")+'"]', form);
- if (input.is(":radio")) {
- input = $('[name="'+$(this).attr("data-display")+'"]:checked', form);
- }
- if (input.is(":text") || input.is("textarea")) {
- $(this).html(input.val());
- } else if (input.is("select") && !(input.attr("multiple")) ) {
- $(this).html(input.find('option:selected').text());
- } else if (input.is(":radio") && input.is(":checked")) {
- $(this).html(input.attr("data-title"));
- } else if ($(this).attr("data-display") == 'modulos[]') {
- var modulos = [];
- $('#modulos :selected', form).each(function(){
- modulos.push($(this).html());
- });
- $(this).html(modulos.join(" <br>"));
- }
- });
- }
- var handleTitle = function(tab, navigation, index) {
- var total = navigation.find('li').length;
- var current = index + 1;
- // set wizard title
- $('.step-title', $('#form_wizard_1')).text('Step ' + (index + 1) + ' of ' + total);
- // set done steps
- jQuery('li', $('#form_wizard_1')).removeClass("done");
- var li_list = navigation.find('li');
- for (var i = 0; i < index; i++) {
- jQuery(li_list[i]).addClass("done");
- }
- if (current == 1) {
- $('#form_wizard_1').find('.button-previous').hide();
- } else {
- $('#form_wizard_1').find('.button-previous').show();
- }
- if (current >= total) {
- $('#form_wizard_1').find('.button-next').hide();
- $('#form_wizard_1').find('.button-submit').show();
- displayConfirm();
- } else {
- $('#form_wizard_1').find('.button-next').show();
- $('#form_wizard_1').find('.button-submit').hide();
- }
- App.scrollTo($('.page-title'));
- }
- // default form wizard
- $('#form_wizard_1').bootstrapWizard({
- 'nextSelector': '.button-next',
- 'previousSelector': '.button-previous',
- onTabClick: function (tab, navigation, index, clickedIndex) {
- return false;
- /*
- success.hide();
- error.hide();
- if (form.valid() == false) {
- return false;
- }
- handleTitle(tab, navigation, clickedIndex);
- */
- },
- onNext: function (tab, navigation, index) {
- // success.hide();
- // error.hide();
- // if (form.valid() == false) {
- // return false;
- // }
- handleTitle(tab, navigation, index);
- },
- onPrevious: function (tab, navigation, index) {
- // success.hide();
- // error.hide();
- handleTitle(tab, navigation, index);
- },
- onTabShow: function (tab, navigation, index) {
- var total = navigation.find('li').length;
- var current = index + 1;
- var $percent = (current / total) * 100;
- $('#form_wizard_1').find('.progress-bar').css({
- width: $percent + '%'
- });
- }
- });
- $('#form_wizard_1').find('.button-previous').hide();
- $('#form_wizard_1 .button-submit').click(function () {
- // alert('Finished! Hope you like it :)');
- if(window.location.pathname.includes('users')) {
- $('#submit_form').submit();
- } else {
- submitForm();
- }
- }).hide();
- }
- };
- }();
- var FormWizard_sale_return = function () {
- return {
- init: function () {
- if (!jQuery().bootstrapWizard) {
- return;
- }
- var form = $('#submit_form');
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
- var handleTitle = function(tab, navigation, index) {
- var total = navigation.find('li').length;
- var current = index + 1;
- jQuery('li', $('#form_wizard_product_return')).removeClass("done");
- var li_list = navigation.find('li');
- for (var i = 0; i < index; i++) {
- jQuery(li_list[i]).addClass("done");
- }
- if (current == 1) {
- $('#form_wizard_product_return').find('.button-previous').hide();
- } else {
- $('#form_wizard_product_return').find('.button-previous').show();
- }
- if (current >= total) {
- $('#form_wizard_product_return').find('.button-next').hide();
- $('#form_wizard_product_return').find('.button-submit').show();
- } else {
- $('#form_wizard_product_return').find('.button-next').show();
- $('#form_wizard_product_return').find('.button-submit').hide();
- }
- // App.scrollTo($('.page-title'));
- }
- $('#form_wizard_product_return').bootstrapWizard({
- 'nextSelector': '.button-next',
- 'previousSelector': '.button-previous',
- onTabClick: function (tab, navigation, index, clickedIndex) {
- return false;
- },
- onNext: function (tab, navigation, index) {
- shouldStep = nextStep(index);
- if (index != 0) {
- $('#form_wizard_product_return').find('.button-previous').show();
- } else {
- $('#form_wizard_product_return').find('.button-previous').hide();
- }
- if(shouldStep) {
- handleTitle(tab, navigation, index);
- }
- return shouldStep;
- },
- onPrevious: function (tab, navigation, index) {
- handleTitle(tab, navigation, index);
- },
- onTabShow: function (tab, navigation, index) {
- var total = navigation.find('li').length;
- var current = index + 1;
- var $percent = (current / total) * 100;
- $('#form_wizard_product_return').find('.progress-bar').css({
- width: $percent + '%'
- });
- }
- });
- $('#form_wizard_product_return').find('.button-previous').hide();
- $('#form_wizard_product_return .button-submit').click(function () {
- $(this).hide();
- submitForm();
- }).hide();
- }
- };
- }();
- var MakeChart = function(type, data, container, categoryField, valueField) {
- if(type == 'serial') {
- var chart = AmCharts.makeChart(container, {
- "type": 'serial',
- "theme": "light",
- "dataProvider": data,
- "gridAboveGraphs": true,
- "startDuration": 1,
- "graphs": [ {
- "balloonText": "[[category]]: <b>[[value]]</b>",
- "fillAlphas": 0.8,
- "lineAlpha": 0.2,
- "type": "column",
- "valueField": valueField
- } ],
- "chartCursor": {
- "categoryBalloonEnabled": false,
- "cursorAlpha": 0,
- "zoomable": false
- },
- "categoryField": categoryField,
- "categoryAxis": {
- "gridPosition": "start",
- "gridAlpha": 0,
- "tickPosition": "start",
- "tickLength": 20
- }
- });
- } else if(type == 'pie') {
- // pie chart
- var chart = AmCharts.makeChart( container, {
- "type": "pie",
- "theme": "light",
- "dataProvider": data,
- "titleField": categoryField,
- "valueField": valueField,
- "labelRadius": 5,
- "radius": "42%",
- "innerRadius": "60%",
- "labelText": "[[title]]",
- });
- }
- }
- $(document).on("page:change", function() {
- Layout.init();
- $(document).ajaxError(function(event,xhr,options,exc) {
- var errors = JSON.parse(xhr.responseText);
- var er ="<ul>";
- for(var i = 0; i < errors.length; i++){
- var list = errors[i];
- er += "<li>"+list+"</li>"
- }
- er+="</ul>"
- var kk = " <div class='alert alert-danger'><strong>Tiene un error no se puede guardar</strong><br>"+er+"</div> "
- $("#error_explanation").html(kk);
- });
- if($('.numbersep').get(0) ){
- var numbersSeparation = function () {
- var numers = $('span.numbers');
- return numers.each(function(){
- $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
- })
- }
- }
- if($('.nestedselect').get(0) ){
- handleNestedSelects();
- }
- if($('.make-switch').get(0)){
- $(":checkbox").bootstrapSwitch();
- }
- if($('.select2').get(0)){
- $('select.select2').select2({
- placeholder: "Seleccione",
- "language": {
- "noResults": function(){
- return "No se encontraron coincidencias";
- }
- },
- escapeMarkup: function (markup) {
- return markup;
- }
- });
- }
- if($('.select2-allow-clear-todas').get(0)){
- $('select.select2-allow-clear-todas').select2({
- allowClear: true,
- placeholder: "Todas",
- width: null,
- placeholder: "Seleccione",
- "language": {
- "noResults": function(){
- return "No se encontraron coincidencias";
- }
- },
- escapeMarkup: function (markup) {
- return markup;
- }
- });
- }
- if($('#form').get(0) ){
- FormValidation.init();
- }
- if($('.tableadvanced').get(0) ){
- TableAdvanced.init();
- $('.dataTables_filter input[type=search]').on( 'keyup', function () {
- $('#filter').val( this.value );
- } );
- }
- if($('.tableadvancedSingleSelection').get(0) ){
- TableAdvancedSingleSelection.init();
- }
- if($('.tableadvancedprintable').get(0) ){
- TableAdvancedPrintable.init();
- $('.dataTables_filter input[type=search]').on( 'keyup', function () {
- $('#filter').val( this.value );
- } );
- }
- if($('.tableadvancedprintableAjax').get(0) ){
- TableAdvancedPrintableAjax.init();
- }
- if($('.tableadvancedAjax').get(0) ){
- TableAdvancedAjax.init();
- }
- if($('.tablechecks').get(0) ){
- TableChecks.init();
- }
- if($('.tablePag').get(0) ){
- TablePagination.init();
- }
- if($('.longDateFormat').get(0) || $('.shortDateFormat').get(0)){
- handleDateFormat();
- }
- if($('.date-picker').get(0)){
- handleDatePickers();
- }
- if ($('.date-range').get(0) ){
- handleDateRangePickers();
- }
- if ($('.mask_phone').get(0) || $('.mask_number').get(0) || $('.mask_decimal').get(0) || $('.mask_currency').get(0)){
- handleInputMasks();
- }
- if ($('.multi-select').get(0)){
- handleMultiSelect();
- }
- if($('.tableWithCheckbox').get(0) ){
- TableWithCheckbox.init();
- }
- // if($('.tableWithCheckboxAjax').get(0) ){
- // tableWithCheckboxAjax.init();
- // }
- if($('.tableCheckBoxNoSearch').get(0) ){
- tableCheckBoxNoSearch.init();
- }
- if($('#form_wizard_1').get(0) ){
- FormWizard.init();
- }
- if($('#form_wizard_product_return').get(0) ){
- FormWizard_sale_return.init();
- }
- // $('.form_modal').click(function () {
- // var $modal = $('#form_modal');
- // $modal.modal();
- // });
- //Override the default confirm dialog by rails
- $.rails.allowAction = function(link){
- if (link.data("confirm") == undefined){
- return true;
- }
- $.rails.showConfirmationDialog(link);
- return false;
- }
- //User click confirm button
- $.rails.confirmed = function(link){
- link.data("confirm", null);
- link.trigger("click.rails");
- }
- //Display the confirmation dialog
- $.rails.showConfirmationDialog = function(link){
- bootbox.dialog({
- message: link.data("confirm"),
- buttons: {
- "Cancelar": {
- label: "Cancelar",
- className: "btn-default"
- },
- success: {
- label: "OK",
- className: "btn-primary",
- callback: function() {
- $.rails.confirmed(link);
- }
- }
- }
- });
- }
- });
|