diff --git a/images/[calzatura] (importata).map b/images/[calzatura] (importata).map new file mode 100644 index 0000000..f6ba15b --- /dev/null +++ b/images/[calzatura] (importata).map @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/images/calzatura (1).png b/images/calzatura (1).png new file mode 100644 index 0000000..30d5339 Binary files /dev/null and b/images/calzatura (1).png differ diff --git a/images/calzatura.png b/images/calzatura.png index 00e9342..8578a51 100644 Binary files a/images/calzatura.png and b/images/calzatura.png differ diff --git a/public/assets/js/jquery-tabledit-master/CHANGELOG.md b/public/assets/js/jquery-tabledit-master/CHANGELOG.md new file mode 100644 index 0000000..cbaffcd --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/CHANGELOG.md @@ -0,0 +1,55 @@ +v1.2.3 (2015/04/20) +------------------- +- Added 'bower.json' to use this package manager +- Added 'tbody' in the selector during the construction of the structure, to avoid problems with the 'tfoot' +- Now when you tab in a row, the form is saved. Only if there is no save button + +v1.2.2 (2015/04/02) +------------------- +- Updated 'example.php' file +- Updated project page with examples and documentation +- Now if 'onAjax()' hook returns false, does not send the ajax request +- Added 'rowIdentifier' option to change the name of attribute in td element for the row identifier +- Fixed bug that allows you to change to edit mode with mouse click when the line was deleted +- Quick fix for issue that sometimes could not remove the warning class on the edited rows + +v1.2.1 (2015/03/10) +------------------- +- Improved the select element +- Does not add hidden save button if the 'editButton' option is false +- Does not add hidden restore button if the 'deleteButton' option is false +- Added a new option 'autoFocus' to enable or not the focus in the first input when click in edit button +- Added a new hook 'onAjax(action, serialize)' that runs before the ajax request + +v1.2.0 (2015/03/07) +------------------- +- Added 'saveButton' and 'restoreButton' options +- Added 'toolbarClass' and 'groupClass' options +- Changed 'removeButton' option to 'deleteButton' +- Changed 'remove' action to 'delete' +- Removed 'textSelection' option, using CSS to prevent the text is selected with double click +- Removed 'confirmText' option, because a button was created to confirm the removal +- Removed form wrapped on table, because now it serialize inputs instead of the form +- In 'buttons' option now have a new child 'action' to change name of action input ('edit', 'delete' and 'restore') +- Redesign of toolbox and changed name to toolbar +- Minor code improvement +- Fixed some bugs + +v1.1.1 (2015/03/05) +------------------- +- Fixed bug when creates the form wrapped on table + +v1.1.0 (2015/02/08) +------------------- +- Added toolbox column with edit and remove buttons +- Added effect on table row when ajax request fails +- Added effect on table row when changes are saved with success +- Added 'onAlways()' hook, that is executed whenever there is an ajax request +- Change 'onComplete(response)' hook to 'onSuccess(data, textStatus, jqXHR)' +- Change 'onError()' hook to 'onFail(jqXHR, textStatus, errorThrown)' +- Fixed some minor bugs +- Minor code improvement + +v1.0.0 (2015/01/30) +------------------- +- Initial release \ No newline at end of file diff --git a/public/assets/js/jquery-tabledit-master/LICENSE b/public/assets/js/jquery-tabledit-master/LICENSE new file mode 100644 index 0000000..16e5d7e --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Celso Marques + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/public/assets/js/jquery-tabledit-master/README.md b/public/assets/js/jquery-tabledit-master/README.md new file mode 100644 index 0000000..1df96d2 --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/README.md @@ -0,0 +1,18 @@ +# jQuery-Tabledit v1.2.3 +Inline editor for HTML tables compatible with Bootstrap. + + +## Examples +http://markcell.github.io/jquery-tabledit/#examples + + +## Documentation +http://markcell.github.io/jquery-tabledit/#documentation + + +## Changelog +See [CHANGELOG.md](https://github.com/markcell/jquery-tabledit/blob/master/CHANGELOG.md) file. + + +## License +Code released under the MIT license. diff --git a/public/assets/js/jquery-tabledit-master/bower.json b/public/assets/js/jquery-tabledit-master/bower.json new file mode 100644 index 0000000..a85ba08 --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/bower.json @@ -0,0 +1,24 @@ +{ + "name": "markcell/jquery-tabledit", + "version": "1.2.3", + "description": "Inline editor for HTML tables compatible with Bootstrap.", + "main": "jquery.tabledit.js", + "license": "MIT", + "homepage": "http://markcell.github.io/jquery-tabledit", + "keywords": [ + "html", + "table", + "edit", + "bootstrap", + "spreadsheet", + "inline", + "editor" + ], + "ignore": [ + "*.md", + "*.php" + ], + "dependencies": { + "jquery": "jquery/jquery" + } +} \ No newline at end of file diff --git a/public/assets/js/jquery-tabledit-master/example.php b/public/assets/js/jquery-tabledit-master/example.php new file mode 100644 index 0000000..c31adb3 --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/example.php @@ -0,0 +1,27 @@ + 'Failed to connect to MySQL: ' . mysqli_connect_error())); + exit; +} + +if ($input['action'] === 'edit') { + $mysqli->query("UPDATE users SET username='" . $input['username'] . "', email='" . $input['email'] . "', avatar='" . $input['avatar'] . "' WHERE id='" . $input['id'] . "'"); +} else if ($input['action'] === 'delete') { + $mysqli->query("UPDATE users SET deleted=1 WHERE id='" . $input['id'] . "'"); +} else if ($input['action'] === 'restore') { + $mysqli->query("UPDATE users SET deleted=0 WHERE id='" . $input['id'] . "'"); +} + +mysqli_close($mysqli); + +echo json_encode($input); diff --git a/public/assets/js/jquery-tabledit-master/jquery.tabledit.js b/public/assets/js/jquery-tabledit-master/jquery.tabledit.js new file mode 100644 index 0000000..201e0e4 --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/jquery.tabledit.js @@ -0,0 +1,611 @@ +/*! + * Tabledit v1.2.3 (https://github.com/markcell/jQuery-Tabledit) + * Copyright (c) 2015 Celso Marques + * Licensed under MIT (https://github.com/markcell/jQuery-Tabledit/blob/master/LICENSE) + */ + +/** + * @description Inline editor for HTML tables compatible with Bootstrap + * @version 1.2.3 + * @author Celso Marques + */ + +if (typeof jQuery === 'undefined') { + throw new Error('Tabledit requires jQuery library.'); +} + +(function($) { + 'use strict'; + + $.fn.Tabledit = function(options) { + if (!this.is('table')) { + throw new Error('Tabledit only works when applied to a table.'); + } + + var $table = this; + + var defaults = { + url: window.location.href, + inputClass: 'form-control input-sm', + toolbarClass: 'btn-toolbar', + groupClass: 'btn-group btn-group-sm', + dangerClass: 'danger', + warningClass: 'warning', + mutedClass: 'text-muted', + eventType: 'click', + rowIdentifier: 'id', + hideIdentifier: false, + autoFocus: true, + editButton: true, + deleteButton: true, + saveButton: true, + restoreButton: true, + buttons: { + edit: { + class: 'btn btn-sm btn-default', + html: '', + action: 'edit' + }, + delete: { + class: 'btn btn-sm btn-default', + html: '', + action: 'delete' + }, + save: { + class: 'btn btn-sm btn-success', + html: 'Save' + }, + restore: { + class: 'btn btn-sm btn-warning', + html: 'Restore', + action: 'restore' + }, + confirm: { + class: 'btn btn-sm btn-danger', + html: 'Confirm' + } + }, + onDraw: function() { return; }, + onSuccess: function() { return; }, + onFail: function() { return; }, + onAlways: function() { return; }, + onAjax: function() { return; } + }; + + var settings = $.extend(true, defaults, options); + + var $lastEditedRow = 'undefined'; + var $lastDeletedRow = 'undefined'; + var $lastRestoredRow = 'undefined'; + + /** + * Draw Tabledit structure (identifier column, editable columns, toolbar column). + * + * @type {object} + */ + var Draw = { + columns: { + identifier: function() { + // Hide identifier column. + if (settings.hideIdentifier) { + $table.find('th:nth-child(' + parseInt(settings.columns.identifier[0]) + 1 + '), tbody td:nth-child(' + parseInt(settings.columns.identifier[0]) + 1 + ')').hide(); + } + + var $td = $table.find('tbody td:nth-child(' + (parseInt(settings.columns.identifier[0]) + 1) + ')'); + + $td.each(function() { + // Create hidden input with row identifier. + var span = '' + $(this).text() + ''; + var input = ''; + + // Add elements to table cell. + $(this).html(span + input); + + // Add attribute "id" to table row. + $(this).parent('tr').attr(settings.rowIdentifier, $(this).text()); + }); + }, + editable: function() { + for (var i = 0; i < settings.columns.editable.length; i++) { + var $td = $table.find('tbody td:nth-child(' + (parseInt(settings.columns.editable[i][0]) + 1) + ')'); + + $td.each(function() { + // Get text of this cell. + var text = $(this).text(); + + // Add pointer as cursor. + if (!settings.editButton) { + $(this).css('cursor', 'pointer'); + } + + // Create span element. + var span = '' + text + ''; + + // Check if exists the third parameter of editable array. + if (typeof settings.columns.editable[i][2] !== 'undefined') { + // Create select element. + var input = ''; + } else { + // Create text input element. + var input = ''; + } + + // Add elements and class "view" to table cell. + $(this).html(span + input); + $(this).addClass('tabledit-view-mode'); + }); + } + }, + toolbar: function() { + if (settings.editButton || settings.deleteButton) { + var editButton = ''; + var deleteButton = ''; + var saveButton = ''; + var restoreButton = ''; + var confirmButton = ''; + + // Add toolbar column header if not exists. + if ($table.find('th.tabledit-toolbar-column').length === 0) { + $table.find('tr:first').append(''); + } + + // Create edit button. + if (settings.editButton) { + editButton = ''; + } + + // Create delete button. + if (settings.deleteButton) { + deleteButton = ''; + confirmButton = ''; + } + + // Create save button. + if (settings.editButton && settings.saveButton) { + saveButton = ''; + } + + // Create restore button. + if (settings.deleteButton && settings.restoreButton) { + restoreButton = ''; + } + + var toolbar = '
\n\ +
' + editButton + deleteButton + '
\n\ + ' + saveButton + '\n\ + ' + confirmButton + '\n\ + ' + restoreButton + '\n\ +
'; + + // Add toolbar column cells. + $table.find('tbody>tr').append('' + toolbar + ''); + } + } + } + }; + + /** + * Change to view mode or edit mode with table td element as parameter. + * + * @type object + */ + var Mode = { + view: function(td) { + // Get table row. + var $tr = $(td).parent('tr'); + // Disable identifier. + $(td).parent('tr').find('.tabledit-input.tabledit-identifier').prop('disabled', true); + // Hide and disable input element. + $(td).find('.tabledit-input').blur().hide().prop('disabled', true); + // Show span element. + $(td).find('.tabledit-span').show(); + // Add "view" class and remove "edit" class in td element. + $(td).addClass('tabledit-view-mode').removeClass('tabledit-edit-mode'); + // Update toolbar buttons. + if (settings.editButton) { + $tr.find('button.tabledit-save-button').hide(); + $tr.find('button.tabledit-edit-button').removeClass('active').blur(); + } + }, + edit: function(td) { + Delete.reset(td); + // Get table row. + var $tr = $(td).parent('tr'); + // Enable identifier. + $tr.find('.tabledit-input.tabledit-identifier').prop('disabled', false); + // Hide span element. + $(td).find('.tabledit-span').hide(); + // Get input element. + var $input = $(td).find('.tabledit-input'); + // Enable and show input element. + $input.prop('disabled', false).show(); + // Focus on input element. + if (settings.autoFocus) { + $input.focus(); + } + // Add "edit" class and remove "view" class in td element. + $(td).addClass('tabledit-edit-mode').removeClass('tabledit-view-mode'); + // Update toolbar buttons. + if (settings.editButton) { + $tr.find('button.tabledit-edit-button').addClass('active'); + $tr.find('button.tabledit-save-button').show(); + } + } + }; + + /** + * Available actions for edit function, with table td element as parameter or set of td elements. + * + * @type object + */ + var Edit = { + reset: function(td) { + $(td).each(function() { + // Get input element. + var $input = $(this).find('.tabledit-input'); + // Get span text. + var text = $(this).find('.tabledit-span').text(); + // Set input/select value with span text. + if ($input.is('select')) { + $input.find('option').filter(function() { + return $.trim($(this).text()) === text; + }).attr('selected', true); + } else { + $input.val(text); + } + // Change to view mode. + Mode.view(this); + }); + }, + submit: function(td) { + // Send AJAX request to server. + var ajaxResult = ajax(settings.buttons.edit.action); + + if (ajaxResult === false) { + return; + } + + $(td).each(function() { + // Get input element. + var $input = $(this).find('.tabledit-input'); + // Set span text with input/select new value. + if ($input.is('select')) { + $(this).find('.tabledit-span').text($input.find('option:selected').text()); + } else { + $(this).find('.tabledit-span').text($input.val()); + } + // Change to view mode. + Mode.view(this); + }); + + // Set last edited column and row. + $lastEditedRow = $(td).parent('tr'); + } + }; + + /** + * Available actions for delete function, with button as parameter. + * + * @type object + */ + var Delete = { + reset: function(td) { + // Reset delete button to initial status. + $table.find('.tabledit-confirm-button').hide(); + // Remove "active" class in delete button. + $table.find('.tabledit-delete-button').removeClass('active').blur(); + }, + submit: function(td) { + Delete.reset(td); + // Enable identifier hidden input. + $(td).parent('tr').find('input.tabledit-identifier').attr('disabled', false); + // Send AJAX request to server. + var ajaxResult = ajax(settings.buttons.delete.action); + // Disable identifier hidden input. + $(td).parents('tr').find('input.tabledit-identifier').attr('disabled', true); + + if (ajaxResult === false) { + return; + } + + // Add class "deleted" to row. + $(td).parent('tr').addClass('tabledit-deleted-row'); + // Hide table row. + $(td).parent('tr').addClass(settings.mutedClass).find('.tabledit-toolbar button:not(.tabledit-restore-button)').attr('disabled', true); + // Show restore button. + $(td).find('.tabledit-restore-button').show(); + // Set last deleted row. + $lastDeletedRow = $(td).parent('tr'); + }, + confirm: function(td) { + // Reset all cells in edit mode. + $table.find('td.tabledit-edit-mode').each(function() { + Edit.reset(this); + }); + // Add "active" class in delete button. + $(td).find('.tabledit-delete-button').addClass('active'); + // Show confirm button. + $(td).find('.tabledit-confirm-button').show(); + }, + restore: function(td) { + // Enable identifier hidden input. + $(td).parent('tr').find('input.tabledit-identifier').attr('disabled', false); + // Send AJAX request to server. + var ajaxResult = ajax(settings.buttons.restore.action); + // Disable identifier hidden input. + $(td).parents('tr').find('input.tabledit-identifier').attr('disabled', true); + + if (ajaxResult === false) { + return; + } + + // Remove class "deleted" to row. + $(td).parent('tr').removeClass('tabledit-deleted-row'); + // Hide table row. + $(td).parent('tr').removeClass(settings.mutedClass).find('.tabledit-toolbar button').attr('disabled', false); + // Hide restore button. + $(td).find('.tabledit-restore-button').hide(); + // Set last restored row. + $lastRestoredRow = $(td).parent('tr'); + } + }; + + /** + * Send AJAX request to server. + * + * @param {string} action + */ + function ajax(action) + { + var serialize = $table.find('.tabledit-input').serialize() + + if (!serialize) { + return false; + } + + serialize += '&action=' + action; + + var result = settings.onAjax(action, serialize); + + if (result === false) { + return false; + } + + var jqXHR = $.post(settings.url, serialize, function(data, textStatus, jqXHR) { + if (action === settings.buttons.edit.action) { + $lastEditedRow.removeClass(settings.dangerClass).addClass(settings.warningClass); + setTimeout(function() { + //$lastEditedRow.removeClass(settings.warningClass); + $table.find('tr.' + settings.warningClass).removeClass(settings.warningClass); + }, 1400); + } + + settings.onSuccess(data, textStatus, jqXHR); + }, 'json'); + + jqXHR.fail(function(jqXHR, textStatus, errorThrown) { + if (action === settings.buttons.delete.action) { + $lastDeletedRow.removeClass(settings.mutedClass).addClass(settings.dangerClass); + $lastDeletedRow.find('.tabledit-toolbar button').attr('disabled', false); + $lastDeletedRow.find('.tabledit-toolbar .tabledit-restore-button').hide(); + } else if (action === settings.buttons.edit.action) { + $lastEditedRow.addClass(settings.dangerClass); + } + + settings.onFail(jqXHR, textStatus, errorThrown); + }); + + jqXHR.always(function() { + settings.onAlways(); + }); + + return jqXHR; + } + + Draw.columns.identifier(); + Draw.columns.editable(); + Draw.columns.toolbar(); + + settings.onDraw(); + + if (settings.deleteButton) { + /** + * Delete one row. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-delete-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + // Get current state before reset to view mode. + var activated = $(this).hasClass('active'); + + var $td = $(this).parents('td'); + + Delete.reset($td); + + if (!activated) { + Delete.confirm($td); + } + + event.handled = true; + } + }); + + /** + * Delete one row (confirm). + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-confirm-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + var $td = $(this).parents('td'); + + Delete.submit($td); + + event.handled = true; + } + }); + } + + if (settings.restoreButton) { + /** + * Restore one row. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-restore-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + Delete.restore($(this).parents('td')); + + event.handled = true; + } + }); + } + + if (settings.editButton) { + /** + * Activate edit mode on all columns. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-edit-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + var $button = $(this); + + // Get current state before reset to view mode. + var activated = $button.hasClass('active'); + + // Change to view mode columns that are in edit mode. + Edit.reset($table.find('td.tabledit-edit-mode')); + + if (!activated) { + // Change to edit mode for all columns in reverse way. + $($button.parents('tr').find('td.tabledit-view-mode').get().reverse()).each(function() { + Mode.edit(this); + }); + } + + event.handled = true; + } + }); + + /** + * Save edited row. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-save-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + // Submit and update all columns. + Edit.submit($(this).parents('tr').find('td.tabledit-edit-mode')); + + event.handled = true; + } + }); + } else { + /** + * Change to edit mode on table td element. + * + * @param {object} event + */ + $table.on(settings.eventType, 'tr:not(.tabledit-deleted-row) td.tabledit-view-mode', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + // Reset all td's in edit mode. + Edit.reset($table.find('td.tabledit-edit-mode')); + + // Change to edit mode. + Mode.edit(this); + + event.handled = true; + } + }); + + /** + * Change event when input is a select element. + */ + $table.on('change', 'select.tabledit-input:visible', function(event) { + if (event.handled !== true) { + // Submit and update the column. + Edit.submit($(this).parent('td')); + + event.handled = true; + } + }); + + /** + * Click event on document element. + * + * @param {object} event + */ + $(document).on('click', function(event) { + var $editMode = $table.find('.tabledit-edit-mode'); + // Reset visible edit mode column. + if (!$editMode.is(event.target) && $editMode.has(event.target).length === 0) { + Edit.reset($table.find('.tabledit-input:visible').parent('td')); + } + }); + } + + /** + * Keyup event on table element. + * + * @param {object} event + */ + $table.on('keyup', function(event) { + // Get input element with focus or confirmation button. + var $input = $table.find('.tabledit-input:visible'); + var $button = $table.find('.tabledit-confirm-button'); + + if ($input.length > 0) { + var $td = $input.parents('td'); + } else if ($button.length > 0) { + var $td = $button.parents('td'); + } else { + return; + } + + // Key? + switch (event.keyCode) { + case 9: // Tab. + if (!settings.editButton) { + Edit.submit($td); + Mode.edit($td.closest('td').next()); + } + break; + case 13: // Enter. + Edit.submit($td); + break; + case 27: // Escape. + Edit.reset($td); + Delete.reset($td); + break; + } + }); + + return this; + }; +}(jQuery)); diff --git a/public/assets/js/jquery-tabledit-master/jquery.tabledit.min.js b/public/assets/js/jquery-tabledit-master/jquery.tabledit.min.js new file mode 100644 index 0000000..2d4b259 --- /dev/null +++ b/public/assets/js/jquery-tabledit-master/jquery.tabledit.min.js @@ -0,0 +1,6 @@ +/*! + * Tabledit v1.2.3 (https://github.com/markcell/jQuery-Tabledit) + * Copyright (c) 2015 Celso Marques + * Licensed under MIT (https://github.com/markcell/jQuery-Tabledit/blob/master/LICENSE) + */ +if("undefined"==typeof jQuery)throw new Error("Tabledit requires jQuery library.");!function(t){"use strict";t.fn.Tabledit=function(e){function n(e){var n=i.find(".tabledit-input").serialize()+"&action="+e,a=d.onAjax(e,n);if(a===!1)return!1;var l=t.post(d.url,n,function(t,n,a){e===d.buttons.edit.action&&(s.removeClass(d.dangerClass).addClass(d.warningClass),setTimeout(function(){i.find("tr."+d.warningClass).removeClass(d.warningClass)},1400)),d.onSuccess(t,n,a)},"json");return l.fail(function(t,n,i){e===d.buttons["delete"].action?(o.removeClass(d.mutedClass).addClass(d.dangerClass),o.find(".tabledit-toolbar button").attr("disabled",!1),o.find(".tabledit-toolbar .tabledit-restore-button").hide()):e===d.buttons.edit.action&&s.addClass(d.dangerClass),d.onFail(t,n,i)}),l.always(function(){d.onAlways()}),l}if(!this.is("table"))throw new Error("Tabledit only works when applied to a table.");var i=this,a={url:window.location.href,inputClass:"form-control input-sm",toolbarClass:"btn-toolbar",groupClass:"btn-group btn-group-sm",dangerClass:"danger",warningClass:"warning",mutedClass:"text-muted",eventType:"click",rowIdentifier:"id",hideIdentifier:!1,autoFocus:!0,editButton:!0,deleteButton:!0,saveButton:!0,restoreButton:!0,buttons:{edit:{"class":"btn btn-sm btn-default",html:'',action:"edit"},"delete":{"class":"btn btn-sm btn-default",html:'',action:"delete"},save:{"class":"btn btn-sm btn-success",html:"Save"},restore:{"class":"btn btn-sm btn-warning",html:"Restore",action:"restore"},confirm:{"class":"btn btn-sm btn-danger",html:"Confirm"}},onDraw:function(){},onSuccess:function(){},onFail:function(){},onAlways:function(){},onAjax:function(){}},d=t.extend(!0,a,e),s="undefined",o="undefined",l="undefined",r={columns:{identifier:function(){d.hideIdentifier&&i.find("th:nth-child("+parseInt(d.columns.identifier[0])+"1), tbody td:nth-child("+parseInt(d.columns.identifier[0])+"1)").hide();var e=i.find("tbody td:nth-child("+(parseInt(d.columns.identifier[0])+1)+")");e.each(function(){var e=''+t(this).text()+"",n='';t(this).html(e+n),t(this).parent("tr").attr(d.rowIdentifier,t(this).text())})},editable:function(){for(var e=0;e";if("undefined"!=typeof d.columns.editable[e][2]){var a='"}else var a='';t(this).html(i+a),t(this).addClass("tabledit-view-mode")})}},toolbar:function(){if(d.editButton||d.deleteButton){var t="",e="",n="",a="",s="";0===i.find("th.tabledit-toolbar-column").length&&i.find("tr:first").append(''),d.editButton&&(t='"),d.deleteButton&&(e='",s='"),d.editButton&&d.saveButton&&(n='"),d.deleteButton&&d.restoreButton&&(a='");var o='
\n
'+t+e+"
\n "+n+"\n "+s+"\n "+a+"\n
";i.find("tr:gt(0)").append(''+o+"")}}}},u={view:function(e){var n=t(e).parent("tr");t(e).parent("tr").find(".tabledit-input.tabledit-identifier").prop("disabled",!0),t(e).find(".tabledit-input").blur().hide().prop("disabled",!0),t(e).find(".tabledit-span").show(),t(e).addClass("tabledit-view-mode").removeClass("tabledit-edit-mode"),d.editButton&&(n.find("button.tabledit-save-button").hide(),n.find("button.tabledit-edit-button").removeClass("active").blur())},edit:function(e){c.reset(e);var n=t(e).parent("tr");n.find(".tabledit-input.tabledit-identifier").prop("disabled",!1),t(e).find(".tabledit-span").hide();var i=t(e).find(".tabledit-input");i.prop("disabled",!1).show(),d.autoFocus&&i.focus(),t(e).addClass("tabledit-edit-mode").removeClass("tabledit-view-mode"),d.editButton&&(n.find("button.tabledit-edit-button").addClass("active"),n.find("button.tabledit-save-button").show())}},b={reset:function(e){t(e).each(function(){var e=t(this).find(".tabledit-input"),n=t(this).find(".tabledit-span").text();e.is("select")?e.find("option").filter(function(){return t.trim(t(this).text())===n}).attr("selected",!0):e.val(n),u.view(this)})},submit:function(e){var i=n(d.buttons.edit.action);i!==!1&&(t(e).each(function(){var e=t(this).find(".tabledit-input");t(this).find(".tabledit-span").text(e.is("select")?e.find("option:selected").text():e.val()),u.view(this)}),s=t(e).parent("tr"))}},c={reset:function(t){i.find(".tabledit-confirm-button").hide(),i.find(".tabledit-delete-button").removeClass("active").blur()},submit:function(e){c.reset(e),t(e).parent("tr").find("input.tabledit-identifier").attr("disabled",!1);var i=n(d.buttons["delete"].action);t(e).parents("tr").find("input.tabledit-identifier").attr("disabled",!0),i!==!1&&(t(e).parent("tr").addClass("tabledit-deleted-row"),t(e).parent("tr").addClass(d.mutedClass).find(".tabledit-toolbar button:not(.tabledit-restore-button)").attr("disabled",!0),t(e).find(".tabledit-restore-button").show(),o=t(e).parent("tr"))},confirm:function(e){i.find("td.tabledit-edit-mode").each(function(){b.reset(this)}),t(e).find(".tabledit-delete-button").addClass("active"),t(e).find(".tabledit-confirm-button").show()},restore:function(e){t(e).parent("tr").find("input.tabledit-identifier").attr("disabled",!1);var i=n(d.buttons.restore.action);t(e).parents("tr").find("input.tabledit-identifier").attr("disabled",!0),i!==!1&&(t(e).parent("tr").removeClass("tabledit-deleted-row"),t(e).parent("tr").removeClass(d.mutedClass).find(".tabledit-toolbar button").attr("disabled",!1),t(e).find(".tabledit-restore-button").hide(),l=t(e).parent("tr"))}};return r.columns.identifier(),r.columns.editable(),r.columns.toolbar(),d.onDraw(),d.deleteButton&&(i.on("click","button.tabledit-delete-button",function(e){if(e.handled!==!0){e.preventDefault();var n=t(this).hasClass("active"),i=t(this).parents("td");c.reset(i),n||c.confirm(i),e.handled=!0}}),i.on("click","button.tabledit-confirm-button",function(e){if(e.handled!==!0){e.preventDefault();var n=t(this).parents("td");c.submit(n),e.handled=!0}})),d.restoreButton&&i.on("click","button.tabledit-restore-button",function(e){e.handled!==!0&&(e.preventDefault(),c.restore(t(this).parents("td")),e.handled=!0)}),d.editButton?(i.on("click","button.tabledit-edit-button",function(e){if(e.handled!==!0){e.preventDefault();var n=t(this),a=n.hasClass("active");b.reset(i.find("td.tabledit-edit-mode")),a||t(n.parents("tr").find("td.tabledit-view-mode").get().reverse()).each(function(){u.edit(this)}),e.handled=!0}}),i.on("click","button.tabledit-save-button",function(e){e.handled!==!0&&(e.preventDefault(),b.submit(t(this).parents("tr").find("td.tabledit-edit-mode")),e.handled=!0)})):(i.on(d.eventType,"tr:not(.tabledit-deleted-row) td.tabledit-view-mode",function(t){t.handled!==!0&&(t.preventDefault(),b.reset(i.find("td.tabledit-edit-mode")),u.edit(this),t.handled=!0)}),i.on("change","select.tabledit-input:visible",function(){event.handled!==!0&&(b.submit(t(this).parent("td")),event.handled=!0)}),t(document).on("click",function(t){var e=i.find(".tabledit-edit-mode");e.is(t.target)||0!==e.has(t.target).length||b.reset(i.find(".tabledit-input:visible").parent("td"))})),t(document).on("keyup",function(t){var e=i.find(".tabledit-input:visible"),n=i.find(".tabledit-confirm-button");if(e.length>0)var a=e.parents("td");else{if(!(n.length>0))return;var a=n.parents("td")}switch(t.keyCode){case 9:d.editButton||(b.submit(a),u.edit(a.closest("td").next()));break;case 13:b.submit(a);break;case 27:b.reset(a),c.reset(a)}}),this}}(jQuery); \ No newline at end of file diff --git a/public/assets/js/jquery.tabledit.js b/public/assets/js/jquery.tabledit.js new file mode 100644 index 0000000..201e0e4 --- /dev/null +++ b/public/assets/js/jquery.tabledit.js @@ -0,0 +1,611 @@ +/*! + * Tabledit v1.2.3 (https://github.com/markcell/jQuery-Tabledit) + * Copyright (c) 2015 Celso Marques + * Licensed under MIT (https://github.com/markcell/jQuery-Tabledit/blob/master/LICENSE) + */ + +/** + * @description Inline editor for HTML tables compatible with Bootstrap + * @version 1.2.3 + * @author Celso Marques + */ + +if (typeof jQuery === 'undefined') { + throw new Error('Tabledit requires jQuery library.'); +} + +(function($) { + 'use strict'; + + $.fn.Tabledit = function(options) { + if (!this.is('table')) { + throw new Error('Tabledit only works when applied to a table.'); + } + + var $table = this; + + var defaults = { + url: window.location.href, + inputClass: 'form-control input-sm', + toolbarClass: 'btn-toolbar', + groupClass: 'btn-group btn-group-sm', + dangerClass: 'danger', + warningClass: 'warning', + mutedClass: 'text-muted', + eventType: 'click', + rowIdentifier: 'id', + hideIdentifier: false, + autoFocus: true, + editButton: true, + deleteButton: true, + saveButton: true, + restoreButton: true, + buttons: { + edit: { + class: 'btn btn-sm btn-default', + html: '', + action: 'edit' + }, + delete: { + class: 'btn btn-sm btn-default', + html: '', + action: 'delete' + }, + save: { + class: 'btn btn-sm btn-success', + html: 'Save' + }, + restore: { + class: 'btn btn-sm btn-warning', + html: 'Restore', + action: 'restore' + }, + confirm: { + class: 'btn btn-sm btn-danger', + html: 'Confirm' + } + }, + onDraw: function() { return; }, + onSuccess: function() { return; }, + onFail: function() { return; }, + onAlways: function() { return; }, + onAjax: function() { return; } + }; + + var settings = $.extend(true, defaults, options); + + var $lastEditedRow = 'undefined'; + var $lastDeletedRow = 'undefined'; + var $lastRestoredRow = 'undefined'; + + /** + * Draw Tabledit structure (identifier column, editable columns, toolbar column). + * + * @type {object} + */ + var Draw = { + columns: { + identifier: function() { + // Hide identifier column. + if (settings.hideIdentifier) { + $table.find('th:nth-child(' + parseInt(settings.columns.identifier[0]) + 1 + '), tbody td:nth-child(' + parseInt(settings.columns.identifier[0]) + 1 + ')').hide(); + } + + var $td = $table.find('tbody td:nth-child(' + (parseInt(settings.columns.identifier[0]) + 1) + ')'); + + $td.each(function() { + // Create hidden input with row identifier. + var span = '' + $(this).text() + ''; + var input = ''; + + // Add elements to table cell. + $(this).html(span + input); + + // Add attribute "id" to table row. + $(this).parent('tr').attr(settings.rowIdentifier, $(this).text()); + }); + }, + editable: function() { + for (var i = 0; i < settings.columns.editable.length; i++) { + var $td = $table.find('tbody td:nth-child(' + (parseInt(settings.columns.editable[i][0]) + 1) + ')'); + + $td.each(function() { + // Get text of this cell. + var text = $(this).text(); + + // Add pointer as cursor. + if (!settings.editButton) { + $(this).css('cursor', 'pointer'); + } + + // Create span element. + var span = '' + text + ''; + + // Check if exists the third parameter of editable array. + if (typeof settings.columns.editable[i][2] !== 'undefined') { + // Create select element. + var input = ''; + } else { + // Create text input element. + var input = ''; + } + + // Add elements and class "view" to table cell. + $(this).html(span + input); + $(this).addClass('tabledit-view-mode'); + }); + } + }, + toolbar: function() { + if (settings.editButton || settings.deleteButton) { + var editButton = ''; + var deleteButton = ''; + var saveButton = ''; + var restoreButton = ''; + var confirmButton = ''; + + // Add toolbar column header if not exists. + if ($table.find('th.tabledit-toolbar-column').length === 0) { + $table.find('tr:first').append(''); + } + + // Create edit button. + if (settings.editButton) { + editButton = ''; + } + + // Create delete button. + if (settings.deleteButton) { + deleteButton = ''; + confirmButton = ''; + } + + // Create save button. + if (settings.editButton && settings.saveButton) { + saveButton = ''; + } + + // Create restore button. + if (settings.deleteButton && settings.restoreButton) { + restoreButton = ''; + } + + var toolbar = '
\n\ +
' + editButton + deleteButton + '
\n\ + ' + saveButton + '\n\ + ' + confirmButton + '\n\ + ' + restoreButton + '\n\ +
'; + + // Add toolbar column cells. + $table.find('tbody>tr').append('' + toolbar + ''); + } + } + } + }; + + /** + * Change to view mode or edit mode with table td element as parameter. + * + * @type object + */ + var Mode = { + view: function(td) { + // Get table row. + var $tr = $(td).parent('tr'); + // Disable identifier. + $(td).parent('tr').find('.tabledit-input.tabledit-identifier').prop('disabled', true); + // Hide and disable input element. + $(td).find('.tabledit-input').blur().hide().prop('disabled', true); + // Show span element. + $(td).find('.tabledit-span').show(); + // Add "view" class and remove "edit" class in td element. + $(td).addClass('tabledit-view-mode').removeClass('tabledit-edit-mode'); + // Update toolbar buttons. + if (settings.editButton) { + $tr.find('button.tabledit-save-button').hide(); + $tr.find('button.tabledit-edit-button').removeClass('active').blur(); + } + }, + edit: function(td) { + Delete.reset(td); + // Get table row. + var $tr = $(td).parent('tr'); + // Enable identifier. + $tr.find('.tabledit-input.tabledit-identifier').prop('disabled', false); + // Hide span element. + $(td).find('.tabledit-span').hide(); + // Get input element. + var $input = $(td).find('.tabledit-input'); + // Enable and show input element. + $input.prop('disabled', false).show(); + // Focus on input element. + if (settings.autoFocus) { + $input.focus(); + } + // Add "edit" class and remove "view" class in td element. + $(td).addClass('tabledit-edit-mode').removeClass('tabledit-view-mode'); + // Update toolbar buttons. + if (settings.editButton) { + $tr.find('button.tabledit-edit-button').addClass('active'); + $tr.find('button.tabledit-save-button').show(); + } + } + }; + + /** + * Available actions for edit function, with table td element as parameter or set of td elements. + * + * @type object + */ + var Edit = { + reset: function(td) { + $(td).each(function() { + // Get input element. + var $input = $(this).find('.tabledit-input'); + // Get span text. + var text = $(this).find('.tabledit-span').text(); + // Set input/select value with span text. + if ($input.is('select')) { + $input.find('option').filter(function() { + return $.trim($(this).text()) === text; + }).attr('selected', true); + } else { + $input.val(text); + } + // Change to view mode. + Mode.view(this); + }); + }, + submit: function(td) { + // Send AJAX request to server. + var ajaxResult = ajax(settings.buttons.edit.action); + + if (ajaxResult === false) { + return; + } + + $(td).each(function() { + // Get input element. + var $input = $(this).find('.tabledit-input'); + // Set span text with input/select new value. + if ($input.is('select')) { + $(this).find('.tabledit-span').text($input.find('option:selected').text()); + } else { + $(this).find('.tabledit-span').text($input.val()); + } + // Change to view mode. + Mode.view(this); + }); + + // Set last edited column and row. + $lastEditedRow = $(td).parent('tr'); + } + }; + + /** + * Available actions for delete function, with button as parameter. + * + * @type object + */ + var Delete = { + reset: function(td) { + // Reset delete button to initial status. + $table.find('.tabledit-confirm-button').hide(); + // Remove "active" class in delete button. + $table.find('.tabledit-delete-button').removeClass('active').blur(); + }, + submit: function(td) { + Delete.reset(td); + // Enable identifier hidden input. + $(td).parent('tr').find('input.tabledit-identifier').attr('disabled', false); + // Send AJAX request to server. + var ajaxResult = ajax(settings.buttons.delete.action); + // Disable identifier hidden input. + $(td).parents('tr').find('input.tabledit-identifier').attr('disabled', true); + + if (ajaxResult === false) { + return; + } + + // Add class "deleted" to row. + $(td).parent('tr').addClass('tabledit-deleted-row'); + // Hide table row. + $(td).parent('tr').addClass(settings.mutedClass).find('.tabledit-toolbar button:not(.tabledit-restore-button)').attr('disabled', true); + // Show restore button. + $(td).find('.tabledit-restore-button').show(); + // Set last deleted row. + $lastDeletedRow = $(td).parent('tr'); + }, + confirm: function(td) { + // Reset all cells in edit mode. + $table.find('td.tabledit-edit-mode').each(function() { + Edit.reset(this); + }); + // Add "active" class in delete button. + $(td).find('.tabledit-delete-button').addClass('active'); + // Show confirm button. + $(td).find('.tabledit-confirm-button').show(); + }, + restore: function(td) { + // Enable identifier hidden input. + $(td).parent('tr').find('input.tabledit-identifier').attr('disabled', false); + // Send AJAX request to server. + var ajaxResult = ajax(settings.buttons.restore.action); + // Disable identifier hidden input. + $(td).parents('tr').find('input.tabledit-identifier').attr('disabled', true); + + if (ajaxResult === false) { + return; + } + + // Remove class "deleted" to row. + $(td).parent('tr').removeClass('tabledit-deleted-row'); + // Hide table row. + $(td).parent('tr').removeClass(settings.mutedClass).find('.tabledit-toolbar button').attr('disabled', false); + // Hide restore button. + $(td).find('.tabledit-restore-button').hide(); + // Set last restored row. + $lastRestoredRow = $(td).parent('tr'); + } + }; + + /** + * Send AJAX request to server. + * + * @param {string} action + */ + function ajax(action) + { + var serialize = $table.find('.tabledit-input').serialize() + + if (!serialize) { + return false; + } + + serialize += '&action=' + action; + + var result = settings.onAjax(action, serialize); + + if (result === false) { + return false; + } + + var jqXHR = $.post(settings.url, serialize, function(data, textStatus, jqXHR) { + if (action === settings.buttons.edit.action) { + $lastEditedRow.removeClass(settings.dangerClass).addClass(settings.warningClass); + setTimeout(function() { + //$lastEditedRow.removeClass(settings.warningClass); + $table.find('tr.' + settings.warningClass).removeClass(settings.warningClass); + }, 1400); + } + + settings.onSuccess(data, textStatus, jqXHR); + }, 'json'); + + jqXHR.fail(function(jqXHR, textStatus, errorThrown) { + if (action === settings.buttons.delete.action) { + $lastDeletedRow.removeClass(settings.mutedClass).addClass(settings.dangerClass); + $lastDeletedRow.find('.tabledit-toolbar button').attr('disabled', false); + $lastDeletedRow.find('.tabledit-toolbar .tabledit-restore-button').hide(); + } else if (action === settings.buttons.edit.action) { + $lastEditedRow.addClass(settings.dangerClass); + } + + settings.onFail(jqXHR, textStatus, errorThrown); + }); + + jqXHR.always(function() { + settings.onAlways(); + }); + + return jqXHR; + } + + Draw.columns.identifier(); + Draw.columns.editable(); + Draw.columns.toolbar(); + + settings.onDraw(); + + if (settings.deleteButton) { + /** + * Delete one row. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-delete-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + // Get current state before reset to view mode. + var activated = $(this).hasClass('active'); + + var $td = $(this).parents('td'); + + Delete.reset($td); + + if (!activated) { + Delete.confirm($td); + } + + event.handled = true; + } + }); + + /** + * Delete one row (confirm). + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-confirm-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + var $td = $(this).parents('td'); + + Delete.submit($td); + + event.handled = true; + } + }); + } + + if (settings.restoreButton) { + /** + * Restore one row. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-restore-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + Delete.restore($(this).parents('td')); + + event.handled = true; + } + }); + } + + if (settings.editButton) { + /** + * Activate edit mode on all columns. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-edit-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + var $button = $(this); + + // Get current state before reset to view mode. + var activated = $button.hasClass('active'); + + // Change to view mode columns that are in edit mode. + Edit.reset($table.find('td.tabledit-edit-mode')); + + if (!activated) { + // Change to edit mode for all columns in reverse way. + $($button.parents('tr').find('td.tabledit-view-mode').get().reverse()).each(function() { + Mode.edit(this); + }); + } + + event.handled = true; + } + }); + + /** + * Save edited row. + * + * @param {object} event + */ + $table.on('click', 'button.tabledit-save-button', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + // Submit and update all columns. + Edit.submit($(this).parents('tr').find('td.tabledit-edit-mode')); + + event.handled = true; + } + }); + } else { + /** + * Change to edit mode on table td element. + * + * @param {object} event + */ + $table.on(settings.eventType, 'tr:not(.tabledit-deleted-row) td.tabledit-view-mode', function(event) { + if (event.handled !== true) { + event.preventDefault(); + + // Reset all td's in edit mode. + Edit.reset($table.find('td.tabledit-edit-mode')); + + // Change to edit mode. + Mode.edit(this); + + event.handled = true; + } + }); + + /** + * Change event when input is a select element. + */ + $table.on('change', 'select.tabledit-input:visible', function(event) { + if (event.handled !== true) { + // Submit and update the column. + Edit.submit($(this).parent('td')); + + event.handled = true; + } + }); + + /** + * Click event on document element. + * + * @param {object} event + */ + $(document).on('click', function(event) { + var $editMode = $table.find('.tabledit-edit-mode'); + // Reset visible edit mode column. + if (!$editMode.is(event.target) && $editMode.has(event.target).length === 0) { + Edit.reset($table.find('.tabledit-input:visible').parent('td')); + } + }); + } + + /** + * Keyup event on table element. + * + * @param {object} event + */ + $table.on('keyup', function(event) { + // Get input element with focus or confirmation button. + var $input = $table.find('.tabledit-input:visible'); + var $button = $table.find('.tabledit-confirm-button'); + + if ($input.length > 0) { + var $td = $input.parents('td'); + } else if ($button.length > 0) { + var $td = $button.parents('td'); + } else { + return; + } + + // Key? + switch (event.keyCode) { + case 9: // Tab. + if (!settings.editButton) { + Edit.submit($td); + Mode.edit($td.closest('td').next()); + } + break; + case 13: // Enter. + Edit.submit($td); + break; + case 27: // Escape. + Edit.reset($td); + Delete.reset($td); + break; + } + }); + + return this; + }; +}(jQuery)); diff --git a/public/assets/js/jquery.tabledit.min.js b/public/assets/js/jquery.tabledit.min.js new file mode 100644 index 0000000..2d4b259 --- /dev/null +++ b/public/assets/js/jquery.tabledit.min.js @@ -0,0 +1,6 @@ +/*! + * Tabledit v1.2.3 (https://github.com/markcell/jQuery-Tabledit) + * Copyright (c) 2015 Celso Marques + * Licensed under MIT (https://github.com/markcell/jQuery-Tabledit/blob/master/LICENSE) + */ +if("undefined"==typeof jQuery)throw new Error("Tabledit requires jQuery library.");!function(t){"use strict";t.fn.Tabledit=function(e){function n(e){var n=i.find(".tabledit-input").serialize()+"&action="+e,a=d.onAjax(e,n);if(a===!1)return!1;var l=t.post(d.url,n,function(t,n,a){e===d.buttons.edit.action&&(s.removeClass(d.dangerClass).addClass(d.warningClass),setTimeout(function(){i.find("tr."+d.warningClass).removeClass(d.warningClass)},1400)),d.onSuccess(t,n,a)},"json");return l.fail(function(t,n,i){e===d.buttons["delete"].action?(o.removeClass(d.mutedClass).addClass(d.dangerClass),o.find(".tabledit-toolbar button").attr("disabled",!1),o.find(".tabledit-toolbar .tabledit-restore-button").hide()):e===d.buttons.edit.action&&s.addClass(d.dangerClass),d.onFail(t,n,i)}),l.always(function(){d.onAlways()}),l}if(!this.is("table"))throw new Error("Tabledit only works when applied to a table.");var i=this,a={url:window.location.href,inputClass:"form-control input-sm",toolbarClass:"btn-toolbar",groupClass:"btn-group btn-group-sm",dangerClass:"danger",warningClass:"warning",mutedClass:"text-muted",eventType:"click",rowIdentifier:"id",hideIdentifier:!1,autoFocus:!0,editButton:!0,deleteButton:!0,saveButton:!0,restoreButton:!0,buttons:{edit:{"class":"btn btn-sm btn-default",html:'',action:"edit"},"delete":{"class":"btn btn-sm btn-default",html:'',action:"delete"},save:{"class":"btn btn-sm btn-success",html:"Save"},restore:{"class":"btn btn-sm btn-warning",html:"Restore",action:"restore"},confirm:{"class":"btn btn-sm btn-danger",html:"Confirm"}},onDraw:function(){},onSuccess:function(){},onFail:function(){},onAlways:function(){},onAjax:function(){}},d=t.extend(!0,a,e),s="undefined",o="undefined",l="undefined",r={columns:{identifier:function(){d.hideIdentifier&&i.find("th:nth-child("+parseInt(d.columns.identifier[0])+"1), tbody td:nth-child("+parseInt(d.columns.identifier[0])+"1)").hide();var e=i.find("tbody td:nth-child("+(parseInt(d.columns.identifier[0])+1)+")");e.each(function(){var e=''+t(this).text()+"",n='';t(this).html(e+n),t(this).parent("tr").attr(d.rowIdentifier,t(this).text())})},editable:function(){for(var e=0;e";if("undefined"!=typeof d.columns.editable[e][2]){var a='"}else var a='';t(this).html(i+a),t(this).addClass("tabledit-view-mode")})}},toolbar:function(){if(d.editButton||d.deleteButton){var t="",e="",n="",a="",s="";0===i.find("th.tabledit-toolbar-column").length&&i.find("tr:first").append(''),d.editButton&&(t='"),d.deleteButton&&(e='",s='"),d.editButton&&d.saveButton&&(n='"),d.deleteButton&&d.restoreButton&&(a='");var o='
\n
'+t+e+"
\n "+n+"\n "+s+"\n "+a+"\n
";i.find("tr:gt(0)").append(''+o+"")}}}},u={view:function(e){var n=t(e).parent("tr");t(e).parent("tr").find(".tabledit-input.tabledit-identifier").prop("disabled",!0),t(e).find(".tabledit-input").blur().hide().prop("disabled",!0),t(e).find(".tabledit-span").show(),t(e).addClass("tabledit-view-mode").removeClass("tabledit-edit-mode"),d.editButton&&(n.find("button.tabledit-save-button").hide(),n.find("button.tabledit-edit-button").removeClass("active").blur())},edit:function(e){c.reset(e);var n=t(e).parent("tr");n.find(".tabledit-input.tabledit-identifier").prop("disabled",!1),t(e).find(".tabledit-span").hide();var i=t(e).find(".tabledit-input");i.prop("disabled",!1).show(),d.autoFocus&&i.focus(),t(e).addClass("tabledit-edit-mode").removeClass("tabledit-view-mode"),d.editButton&&(n.find("button.tabledit-edit-button").addClass("active"),n.find("button.tabledit-save-button").show())}},b={reset:function(e){t(e).each(function(){var e=t(this).find(".tabledit-input"),n=t(this).find(".tabledit-span").text();e.is("select")?e.find("option").filter(function(){return t.trim(t(this).text())===n}).attr("selected",!0):e.val(n),u.view(this)})},submit:function(e){var i=n(d.buttons.edit.action);i!==!1&&(t(e).each(function(){var e=t(this).find(".tabledit-input");t(this).find(".tabledit-span").text(e.is("select")?e.find("option:selected").text():e.val()),u.view(this)}),s=t(e).parent("tr"))}},c={reset:function(t){i.find(".tabledit-confirm-button").hide(),i.find(".tabledit-delete-button").removeClass("active").blur()},submit:function(e){c.reset(e),t(e).parent("tr").find("input.tabledit-identifier").attr("disabled",!1);var i=n(d.buttons["delete"].action);t(e).parents("tr").find("input.tabledit-identifier").attr("disabled",!0),i!==!1&&(t(e).parent("tr").addClass("tabledit-deleted-row"),t(e).parent("tr").addClass(d.mutedClass).find(".tabledit-toolbar button:not(.tabledit-restore-button)").attr("disabled",!0),t(e).find(".tabledit-restore-button").show(),o=t(e).parent("tr"))},confirm:function(e){i.find("td.tabledit-edit-mode").each(function(){b.reset(this)}),t(e).find(".tabledit-delete-button").addClass("active"),t(e).find(".tabledit-confirm-button").show()},restore:function(e){t(e).parent("tr").find("input.tabledit-identifier").attr("disabled",!1);var i=n(d.buttons.restore.action);t(e).parents("tr").find("input.tabledit-identifier").attr("disabled",!0),i!==!1&&(t(e).parent("tr").removeClass("tabledit-deleted-row"),t(e).parent("tr").removeClass(d.mutedClass).find(".tabledit-toolbar button").attr("disabled",!1),t(e).find(".tabledit-restore-button").hide(),l=t(e).parent("tr"))}};return r.columns.identifier(),r.columns.editable(),r.columns.toolbar(),d.onDraw(),d.deleteButton&&(i.on("click","button.tabledit-delete-button",function(e){if(e.handled!==!0){e.preventDefault();var n=t(this).hasClass("active"),i=t(this).parents("td");c.reset(i),n||c.confirm(i),e.handled=!0}}),i.on("click","button.tabledit-confirm-button",function(e){if(e.handled!==!0){e.preventDefault();var n=t(this).parents("td");c.submit(n),e.handled=!0}})),d.restoreButton&&i.on("click","button.tabledit-restore-button",function(e){e.handled!==!0&&(e.preventDefault(),c.restore(t(this).parents("td")),e.handled=!0)}),d.editButton?(i.on("click","button.tabledit-edit-button",function(e){if(e.handled!==!0){e.preventDefault();var n=t(this),a=n.hasClass("active");b.reset(i.find("td.tabledit-edit-mode")),a||t(n.parents("tr").find("td.tabledit-view-mode").get().reverse()).each(function(){u.edit(this)}),e.handled=!0}}),i.on("click","button.tabledit-save-button",function(e){e.handled!==!0&&(e.preventDefault(),b.submit(t(this).parents("tr").find("td.tabledit-edit-mode")),e.handled=!0)})):(i.on(d.eventType,"tr:not(.tabledit-deleted-row) td.tabledit-view-mode",function(t){t.handled!==!0&&(t.preventDefault(),b.reset(i.find("td.tabledit-edit-mode")),u.edit(this),t.handled=!0)}),i.on("change","select.tabledit-input:visible",function(){event.handled!==!0&&(b.submit(t(this).parent("td")),event.handled=!0)}),t(document).on("click",function(t){var e=i.find(".tabledit-edit-mode");e.is(t.target)||0!==e.has(t.target).length||b.reset(i.find(".tabledit-input:visible").parent("td"))})),t(document).on("keyup",function(t){var e=i.find(".tabledit-input:visible"),n=i.find(".tabledit-confirm-button");if(e.length>0)var a=e.parents("td");else{if(!(n.length>0))return;var a=n.parents("td")}switch(t.keyCode){case 9:d.editButton||(b.submit(a),u.edit(a.closest("td").next()));break;case 13:b.submit(a);break;case 27:b.reset(a),c.reset(a)}}),this}}(jQuery); \ No newline at end of file diff --git a/public/include/maparticle.php b/public/include/maparticle.php index ae571b5..0f87d84 100644 --- a/public/include/maparticle.php +++ b/public/include/maparticle.php @@ -22,6 +22,8 @@
+
+ @@ -44,6 +46,16 @@ <?php echo $sixteens; ?> <?php echo $eighteens; ?> <?php echo $nineteens; ?> + <?php echo $twentys; ?> + <?php echo $twentys; ?> + + diff --git a/public/languages/en/shoesnamepart.php b/public/languages/en/shoesnamepart.php index 5cf1130..94ce7f2 100644 --- a/public/languages/en/shoesnamepart.php +++ b/public/languages/en/shoesnamepart.php @@ -1,22 +1,21 @@ +$ones = "Collar"; +$twos = "Tongue"; +$threes = "Facing"; +$fours = "Upper (vamp)"; +$fives = "Scuff cap"; +$sixs = "back strap"; +$sevens = "Upper (quarter)"; +$eights = "Upper (counter)"; +$nines = "Outsole - Heel"; +$tens = "Sole Complex"; +$elevens = "Outsole - Forepart"; +$twelves = "Vamp lining"; +$thirteens = "Safety toe cap"; +$fourteens = "Insole"; +$fifteens = "Insock or seat sock"; +$sixteens = "Perforation-resistant insert"; +$seventeens = "Counter stiffener"; +$eighteens = "Counter lining"; +$nineteens = "Quarter lining"; +$twentys = "Tongue lining"; diff --git a/public/languages/it/shoesnamepart.php b/public/languages/it/shoesnamepart.php index 4afa27d..cbbb608 100644 --- a/public/languages/it/shoesnamepart.php +++ b/public/languages/it/shoesnamepart.php @@ -1,22 +1,21 @@ \ No newline at end of file +$ones = "Collarino"; +$twos = "Linguetta"; +$threes = "Listino portaocchielli"; +$fours = "Tomaio (mascherina)"; +$fives = "Copripuntale"; +$sixs = "Tirante posteriore"; +$sevens = "Tomaio (quartiere)"; +$eights = "Tomaio (tallone) "; +$nines = "Suola - Tacco"; +$tens = "Fondo della calzatura"; +$elevens = "Suola - Pianta"; +$twelves = "Fodera della mascherina"; +$thirteens = "Puntale di sicurezza"; +$fourteens = "Sottopiede "; +$fifteens = "Plantare o tallonetta"; +$sixteens = "Inserto resistente alla perforazione"; +$seventeens = "Contrafforte"; +$eighteens = "Fodera del tallone"; +$nineteens = "Fodera del quartiere"; +$twentys = "Fodera della linguetta"; diff --git a/public/logic-edit-delete.php b/public/logic-edit-delete.php index 935b1eb..daebd4c 100644 --- a/public/logic-edit-delete.php +++ b/public/logic-edit-delete.php @@ -9,41 +9,35 @@ include('db-connect.php'); $input = filter_input_array(INPUT_POST); -if ($input['action'] === 'edit') -{ - $sqlSelect="SELECT * FROM trfstandards WHERE idtrfstandards='" . $input['id'] . "'"; - $records=mysqli_query($con,$sqlSelect); - if(mysqli_num_rows($records)>0){ - if(isset($input['idprotectioncategory'])){ - $q_idprotectioncategory = "idprotectioncategory='{$input['idprotectioncategory']}'" ; - }else{ +if ($input['action'] === 'edit') { + $sqlSelect = "SELECT * FROM trfstandards WHERE idtrfstandards='" . $input['id'] . "'"; + $records = mysqli_query($con, $sqlSelect); + if (mysqli_num_rows($records) > 0) { + if (isset($input['idprotectioncategory'])) { + $q_idprotectioncategory = "idprotectioncategory='{$input['idprotectioncategory']}'"; + } else { $q_idprotectioncategory = ""; } - if(isset($input['iddpicategory'])){ - $q_iddpicategory = "iddpicategory='{$input['iddpicategory']}'" ; - }else{ + if (isset($input['iddpicategory'])) { + $q_iddpicategory = "iddpicategory='{$input['iddpicategory']}'"; + } else { $q_iddpicategory = ""; } $sql = "UPDATE trfstandards SET {$q_idprotectioncategory} {$q_iddpicategory} WHERE idtrfstandards='" . $input['id'] . "'"; // mysqli_query($con,$sql); + } else { + $sql = "INSERT INTO trfstandards SET idtrfdetails ='" . $input['idtrfdetails'] . "', idstandards='" . $input['idstandards'] . "'" . " , idprotectioncategory='" . $input['idprotectioncategory'] . "'" . " , iddpicategory='" . $input['iddpicategory'] . "'"; } - else { - $sql = "INSERT INTO trfstandards SET idtrfdetails ='" . $input['idtrfdetails'] . "', idstandards='" . $input['idstandards'] . "'" ." , idprotectioncategory='" . $input['idprotectioncategory'] . "'" ." , iddpicategory='" . $input['iddpicategory'] . "'"; - } - - mysqli_query($con,$sql); - -} -if ($input['action'] === 'delete') -{ - mysqli_query($con,"DELETE FROM trfstandards WHERE idtrfstandards='" . $input['id'] . "'"); -} + mysqli_query($con, $sql); +} +if ($input['action'] === 'delete') { + mysqli_query($con, "DELETE FROM trfstandards WHERE idtrfstandards='" . $input['id'] . "'"); +} //mysqli_close($mysqli); echo json_encode($input); -?> diff --git a/public/pdf/1002rev0applicationform20250220075642.pdf b/public/pdf/1002rev0applicationform20250220075642.pdf new file mode 100644 index 0000000..f48fd9a Binary files /dev/null and b/public/pdf/1002rev0applicationform20250220075642.pdf differ diff --git a/public/pdf/1002rev0applicationformb20250220075642.pdf b/public/pdf/1002rev0applicationformb20250220075642.pdf new file mode 100644 index 0000000..74254c8 Binary files /dev/null and b/public/pdf/1002rev0applicationformb20250220075642.pdf differ diff --git a/public/standardstep.php b/public/standardstep.php index 0c36f4f..8c646d8 100644 --- a/public/standardstep.php +++ b/public/standardstep.php @@ -320,8 +320,8 @@ $iddpicategoryperStdJson = json_encode($iddpicategorylistRecord); - - + + diff --git a/public/standardstepbck100325.php b/public/standardstepbck100325.php new file mode 100644 index 0000000..0c36f4f --- /dev/null +++ b/public/standardstepbck100325.php @@ -0,0 +1,890 @@ + + + + + + +setQuery("SELECT * FROM standards WHERE standards.idarticlecharacteristic='$ac'"); + $stdfromartchar->execute(); + $value = $stdfromartchar->getColumnVal("idstandards"); + $dpicatsel = $stdfromartchar->getColumnVal("iddpicategory"); + + //foreach ($stds as $hobys=>$value) { + + $stdcheckpresent = new WA_MySQLi_RS("stdcheckpresent", $cmctrfdb, 1); + $stdcheckpresent->setQuery("SELECT * FROM trfstandards WHERE trfstandards.idtrfdetails='$idtrf' AND trfstandards.idstandards='$value'"); + $stdcheckpresent->execute(); + + // insert for glovces EN 420 if not present + /* if ($articletype==2) { + $stdcheckpresent420 = new WA_MySQLi_RS("stdcheckpresent420",$cmctrfdb,1); +$stdcheckpresent420->setQuery("SELECT * FROM trfstandards WHERE trfstandards.idtrfdetails='$idtrf' AND trfstandards.idstandards='129'"); +$stdcheckpresent420->execute(); + if (empty($stdcheckpresent420->getColumnVal("idtrfstandards"))) { + $InsertQuery = new WA_MySQLi_Query($cmctrfdb); + $InsertQuery->Action = "insert"; + $InsertQuery->Table = "trfstandards"; + $InsertQuery->bindColumn("idtrfdetails", "i", "$idtrf", "WA_DEFAULT"); + $InsertQuery->bindColumn("idstandards", "i", "129", "WA_DEFAULT"); + $InsertQuery->bindColumn("iddpicategory", "i", "$dpicatsel", "WA_DEFAULT"); + $InsertQuery->saveInSession(""); + $InsertQuery->execute(); + $InsertGoTo = ""; + + $InsertQuery->redirect($InsertGoTo); + }} */ + + if (empty($stdcheckpresent->getColumnVal("idtrfstandards"))) { + + $InsertQuery = new WA_MySQLi_Query($cmctrfdb); + $InsertQuery->Action = "insert"; + $InsertQuery->Table = "trfstandards"; + $InsertQuery->bindColumn("idtrfdetails", "i", "$idtrf", "WA_DEFAULT"); + $InsertQuery->bindColumn("idstandards", "i", "$value", "WA_DEFAULT"); + $InsertQuery->bindColumn("iddpicategory", "i", "$dpicatsel", "WA_DEFAULT"); + $InsertQuery->saveInSession(""); + $InsertQuery->execute(); + $InsertGoTo = ""; + + $InsertQuery->redirect($InsertGoTo); + } + } +} //} + + +?> +Action = "update"; + $UpdateQuery->Table = "`trf-details`"; + $UpdateQuery->bindColumn("sample_description", "s", "$description", "WA_DEFAULT"); + $UpdateQuery->bindColumn("measurefrom", "s", "$rangemeasuremin", "WA_DEFAULT"); + $UpdateQuery->bindColumn("measureto", "s", "$rangemeasuremax", "WA_DEFAULT"); + $UpdateQuery->bindColumn("model", "s", "$model", "WA_DEFAULT"); + $UpdateQuery->bindColumn("idarticletype", "i", "$articletype", "WA_DEFAULT"); + $UpdateQuery->bindColumn("idarticle_characteristics", "s", "$listartchar", "WA_DEFAULT"); + $UpdateQuery->bindColumn("registeredmark", "s", "$registeredmark", "WA_DEFAULT"); + $UpdateQuery->bindColumn("previousreportnumber", "s", "$previousreportnumber", "WA_DEFAULT"); + $UpdateQuery->bindColumn("toextend", "s", "$toextend", "WA_DEFAULT"); + $UpdateQuery->bindColumn("revisionfor", "s", "$revisionfor", "WA_DEFAULT"); + $UpdateQuery->bindColumn("renewdate", "s", "$renewdate", "WA_DEFAULT"); + $UpdateQuery->addFilter("idtrfdetails", "=", "i", "" . ($idtrf) . ""); + $UpdateQuery->execute(); + $UpdateGoTo = ""; + if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : ""; + $UpdateQuery->redirect($UpdateGoTo); + + $code = "3"; + $InsertQuery2 = new WA_MySQLi_Query($cmctrfdb); + $InsertQuery2->Action = "insert"; + $InsertQuery2->Table = "wheretrfstep"; + $InsertQuery2->bindColumn("idtrf", "i", "$idtrf", "WA_DEFAULT"); + $InsertQuery2->bindColumn("code", "s", "$code", "WA_DEFAULT"); + $InsertQuery2->saveInSession(""); + $InsertQuery2->execute(); + $InsertGoTo = ""; + + $InsertQuery2->redirect($InsertGoTo); + } else { + + $UpdateQuery = new WA_MySQLi_Query($cmctrfdb); + $UpdateQuery->Action = "update"; + $UpdateQuery->Table = "`trf-details`"; + $UpdateQuery->bindColumn("sample_description", "s", "$description", "WA_DEFAULT"); + $UpdateQuery->bindColumn("measurefrom", "s", "$rangemeasuremintext", "WA_DEFAULT"); + $UpdateQuery->bindColumn("measureto", "s", "$rangemeasuremaxtext", "WA_DEFAULT"); + + $UpdateQuery->bindColumn("model", "s", "$model", "WA_DEFAULT"); + $UpdateQuery->bindColumn("idarticletype", "i", "$articletype", "WA_DEFAULT"); + $UpdateQuery->bindColumn("idarticle_characteristics", "s", "$listartchar", "WA_DEFAULT"); + $UpdateQuery->bindColumn("registeredmark", "s", "$registeredmark", "WA_DEFAULT"); + $UpdateQuery->addFilter("idtrfdetails", "=", "i", "" . ($idtrf) . ""); + $UpdateQuery->execute(); + $UpdateGoTo = ""; + if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo ? rel2abs($UpdateGoTo, dirname(__FILE__)) : ""; + $UpdateQuery->redirect($UpdateGoTo); + + $code = "3"; + $InsertQuery2 = new WA_MySQLi_Query($cmctrfdb); + $InsertQuery2->Action = "insert"; + $InsertQuery2->Table = "wheretrfstep"; + $InsertQuery2->bindColumn("idtrf", "i", "$idtrf", "WA_DEFAULT"); + $InsertQuery2->bindColumn("code", "s", "$code", "WA_DEFAULT"); + $InsertQuery2->saveInSession(""); + $InsertQuery2->execute(); + $InsertGoTo = ""; + + $InsertQuery2->redirect($InsertGoTo); + } +} +?> + +setQuery("SELECT * FROM `trf-details` WHERE `trf-details`.idtrfdetails='$idtrf'"); +$trfnumberfinal->execute(); +$idcertn = $trfnumberfinal->getColumnVal("idcertification"); +$articletype = $trfnumberfinal->getColumnVal("idarticletype"); +$articlecharact = $trfnumberfinal->getColumnVal("idarticle_characteristics"); +?> +getColumnVal("idcertification") ?> +setQuery("SELECT * FROM certificationtype WHERE certificationtype.idcertificationtype='$idcert'"); +$certname->execute(); ?> +setQuery("SELECT * FROM standards WHERE standards.idarticletype='$articletype'"); +// $stdcheck->execute(); +?> +setQuery("SELECT * FROM standards WHERE standards.idarticlecharacteristic='$articlecharact' "); +$stdcheck->execute(); +$idstselect = $stdcheck->getColumnVal("idstandards"); +?> + + + + + + + <?php echo $titlepage; ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
+
+
+ +
+

+
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+
+
+
+
+ +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ +
+
+
+ + + +
+
50%
+
+ + + + + + +
+ setQuery("SELECT * FROM trfstandards LEFT JOIN standards ON trfstandards.idstandards=standards.idstandards WHERE trfstandards.idtrfdetails='$idtrf'"); + $standardselectedlist->execute(); ?> + + + + +
+
+
+ +
+

+ . +

+ +
+ + +
+ + + +
+ Attenzione: tutti i campi devono essere compilati.

'; + } + ?> + ' . $nextsteptitle . ''; + + if (($articletype == 1) || (!empty($virusstep))) { + echo ''; + } else { + echo ''; + } + + ?> + + + +
+
+
+
+ +
+ + + +
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file