diff --git a/forms/admin/items/items.js b/forms/admin/items/items.js index 240a7de3..96c5e973 100644 --- a/forms/admin/items/items.js +++ b/forms/admin/items/items.js @@ -2,20 +2,5 @@ Hedera.Items = new Class ({ Extends: Hedera.Form - - ,activate: function () - { - this.$('lot').assign ({ - warehouse: 7, - realm: null - }); - } - - ,onShowClick: function () - { - var lot = this.$('lot'); - lot.assign ({rate: this.$('rate').value}); - this.gui.openReport ('items-report', lot.params); - } }); diff --git a/forms/admin/items/locale/ca.json b/forms/admin/items/locale/ca.json new file mode 100755 index 00000000..eab281b3 --- /dev/null +++ b/forms/admin/items/locale/ca.json @@ -0,0 +1,4 @@ +{ + "Items": "Artícles", + "Enter a search term": "Introdueix un terme de cerca" +} diff --git a/forms/admin/items/locale/en.json b/forms/admin/items/locale/en.json old mode 100644 new mode 100755 index d87369f0..b4b30d66 --- a/forms/admin/items/locale/en.json +++ b/forms/admin/items/locale/en.json @@ -1,9 +1,4 @@ { - "Item list": "Item list" - - ,"Store": "Store" - ,"Realm": "Realm" - ,"Rate": "Rate" - - ,"Show": "Show" + "Items": "Items", + "Enter a search term": "Enter a search term" } diff --git a/forms/admin/items/locale/es.json b/forms/admin/items/locale/es.json old mode 100644 new mode 100755 index fa098f43..649219de --- a/forms/admin/items/locale/es.json +++ b/forms/admin/items/locale/es.json @@ -1,9 +1,4 @@ { - "Item list": "Listado de artículos" - - ,"Store": "Almacén" - ,"Realm": "Reino" - ,"Rate": "Tarifa" - - ,"Show": "Mostrar" + "Items": "Artículos", + "Enter a search term": "Introduce un término de búsqueda" } diff --git a/forms/admin/items/locale/fr.json b/forms/admin/items/locale/fr.json new file mode 100755 index 00000000..bf70e9ab --- /dev/null +++ b/forms/admin/items/locale/fr.json @@ -0,0 +1,4 @@ +{ + "Items": "Articles", + "Enter a search term": "Entrez un terme de recherche" +} \ No newline at end of file diff --git a/forms/admin/items/locale/mn.json b/forms/admin/items/locale/mn.json old mode 100644 new mode 100755 index d87369f0..b4b30d66 --- a/forms/admin/items/locale/mn.json +++ b/forms/admin/items/locale/mn.json @@ -1,9 +1,4 @@ { - "Item list": "Item list" - - ,"Store": "Store" - ,"Realm": "Realm" - ,"Rate": "Rate" - - ,"Show": "Show" + "Items": "Items", + "Enter a search term": "Enter a search term" } diff --git a/forms/admin/items/locale/pt.json b/forms/admin/items/locale/pt.json index 67e01480..8533ed6b 100644 --- a/forms/admin/items/locale/pt.json +++ b/forms/admin/items/locale/pt.json @@ -1,9 +1,4 @@ { - "Item list": "Lista de Ítens" - - ,"Store": "Armazém" - ,"Realm": "Reino" - ,"Rate": "Tarifa" - - ,"Show": "Mostrar" + "Items": "Artigos", + "Enter a search term": "Digite um termo de pesquisa" } diff --git a/forms/admin/items/style.css b/forms/admin/items/style.css index e69de29b..51960ccd 100644 --- a/forms/admin/items/style.css +++ b/forms/admin/items/style.css @@ -0,0 +1,23 @@ + +/* Row */ + +.items .list-row > .photo +{ + margin-right: 1em; + float: left; + border-radius: 50%; + height: 3.2em; + width: 3.2em; +} +.items .list-row > p +{ + margin: .1em 0; + margin-left: 5em; +} + +/* Topbar */ + +.action-bar .htk-search-entry +{ + margin: .8em .6em; +} diff --git a/forms/admin/items/ui.xml b/forms/admin/items/ui.xml index fda8e084..3737ebff 100755 --- a/forms/admin/items/ui.xml +++ b/forms/admin/items/ui.xml @@ -1,42 +1,47 @@ -

- Item list + Items

-
- +
+
-
-
- - - - SELECT id, name FROM vn2008.warehouse - WHERE reserve ORDER BY name - - -
-
- - - - SELECT id, reino FROM vn2008.reinos - WHERE display != FALSE ORDER BY reino - - -
-
- - -
+
+ + + SELECT Id_Article, Article, Medida, Categoria, Foto + FROM vn2008.Articles + WHERE Article LIKE CONCAT('%', #filter, '%') + OR Id_Article = #filter + ORDER BY Article LIMIT 50 + + +
+ +

+ + + +

+

+ +

+

+ +

+
+
+ +
diff --git a/forms/admin/photos/locale/ca.json b/forms/admin/photos/locale/ca.json index 33d37b50..704fe00c 100755 --- a/forms/admin/photos/locale/ca.json +++ b/forms/admin/photos/locale/ca.json @@ -1,12 +1,13 @@ { - "Photos": "Fotos" + "Images": "Imatges" - ,"Collection": "Colección" - ,"ImageName": "Nom de la imatge" - ,"Id": "Id" - ,"ImageFile": "Arxiu d'imatge" + ,"Collection": "Col·lecció" + ,"Click or drop files here": "Prem o deixa anar els arxius aquí" - ,"Upload": "Enviar" + ,"Clear all": "Netejar tot" + ,"Upload files": "Pujar arxius" - ,"ImageUploaded": "Imatge pujada correctament" + ,"Upload finished successfully": "Imatges pujades correctament" + ,"Some errors happened on upload": "Van ocórrer errors en pujar alguna de les imatges" + ,"There are no files to upload": "No s'ha seleccionat arxius per pujar" } diff --git a/forms/admin/photos/locale/en.json b/forms/admin/photos/locale/en.json index 402722b4..c160093c 100755 --- a/forms/admin/photos/locale/en.json +++ b/forms/admin/photos/locale/en.json @@ -1,12 +1,13 @@ { - "Photos": "Photos" + "Images": "Images" ,"Collection": "Collection" - ,"ImageName": "Image name" - ,"Id": "Id" - ,"ImageFile": "Image file" + ,"Click or drop files here": "Click or drop files here" - ,"Upload": "Upload" + ,"Clear all": "Clear all" + ,"Upload files": "Upload files" - ,"ImageUploaded": "Image uploaded successfully" -} + ,"Upload finished successfully": "Upload finished successfully" + ,"Some errors happened on upload": "Some errors happened on upload" + ,"There are no files to upload": "There are no files to upload" +} \ No newline at end of file diff --git a/forms/admin/photos/locale/es.json b/forms/admin/photos/locale/es.json index 65031e5f..841acff0 100755 --- a/forms/admin/photos/locale/es.json +++ b/forms/admin/photos/locale/es.json @@ -1,12 +1,13 @@ { - "Photos": "Fotos" + "Images": "Imágenes" ,"Collection": "Colección" - ,"ImageName": "Nombre de la imagen" - ,"Id": "Id" - ,"ImageFile": "Archivo de imagen" + ,"Click or drop files here": "Pulsa o suelta los archivos aquí" - ,"Upload": "Enviar" + ,"Clear all": "Limpiar todo" + ,"Upload files": "Subir archivos" - ,"ImageUploaded": "Imagen subida correctamente" + ,"Upload finished successfully": "Imágenes subidas correctamente" + ,"Some errors happened on upload": "Ocurrieron errores al subir alguna de las imágenes" + ,"There are no files to upload": "No se han seleccionado archivos para subir" } diff --git a/forms/admin/photos/locale/fr.json b/forms/admin/photos/locale/fr.json index b6be33d7..c2b17151 100755 --- a/forms/admin/photos/locale/fr.json +++ b/forms/admin/photos/locale/fr.json @@ -1,12 +1,13 @@ { - "Photos": "Photos" + "Images": "Images" ,"Collection": "Collection" - ,"ImageName": "Nom de l'image" - ,"Id": "Id" - ,"ImageFile": "Fichier image" + ,"Click or drop files here": "Cliquez ici ou déposer des fichiers" - ,"Upload": "Télécharger" + ,"Clear all": "Tout effacer" + ,"Upload files": "Upload Files" - ,"ImageUploaded": "téléchargement correct" -} + ,"Upload finished successfully": "Les images téléchargées correctement" + ,"Some errors happened on upload": "Des erreurs sont survenues lors du téléchargement des images" + ,"There are no files to upload": "Aucun fichier sélectionné pour télécharger" +} \ No newline at end of file diff --git a/forms/admin/photos/locale/mn.json b/forms/admin/photos/locale/mn.json index f40f409e..c160093c 100755 --- a/forms/admin/photos/locale/mn.json +++ b/forms/admin/photos/locale/mn.json @@ -1,12 +1,13 @@ { - "Photos": "Photos" + "Images": "Images" - ,"Collection": "цуглуулга" - ,"ImageName": "Image name" - ,"Id": "Id" - ,"ImageFile": "Image file" + ,"Collection": "Collection" + ,"Click or drop files here": "Click or drop files here" - ,"Upload": "Upload" + ,"Clear all": "Clear all" + ,"Upload files": "Upload files" - ,"ImageUploaded": "Image uploaded successfully" -} + ,"Upload finished successfully": "Upload finished successfully" + ,"Some errors happened on upload": "Some errors happened on upload" + ,"There are no files to upload": "There are no files to upload" +} \ No newline at end of file diff --git a/forms/admin/photos/locale/pt.json b/forms/admin/photos/locale/pt.json index 28ad4bb6..728f208e 100644 --- a/forms/admin/photos/locale/pt.json +++ b/forms/admin/photos/locale/pt.json @@ -1,12 +1,13 @@ { - "Photos": "Fotos" + "Images": "Imagens" ,"Collection": "Coleção" - ,"ImageName": "Nome da imagem" - ,"Id": "Id" - ,"ImageFile": "Arquivo de imagem" + ,"Click or drop files here": "Clique ou soltar arquivos aqui" - ,"Upload": "Enviar" + ,"Clear all": "Clear All" + ,"Upload files": "Fazer upload de arquivos" - ,"ImageUploaded": "Imagem subida correctamente" -} + ,"Upload finished successfully": "Upload concluído com sucesso" + ,"Some errors happened on upload": "Ocurrieron erros ao subir alguma das imagens" + ,"There are no files to upload": "Não há arquivos selecionados para upload" +} \ No newline at end of file diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/photos.js index 9da93fe3..7fab2c61 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/photos.js @@ -2,36 +2,203 @@ Hedera.Photos = new Class ({ Extends: Hedera.Form + ,filesData: [] + ,uploadCount: 0 + ,errors: false ,activate: function () { this.$('schema').value = 'catalog'; - this.$('photo-id').focus (); - - var self = this; - this.$('html-form').onsubmit = function () - { self._onSubmit (); return false; }; } - - ,_onSubmit: function () - { - this.$('schema-field').value = this.$('schema').value; - this.$('submit').disabled = true; - this.conn.sendFormMultipart (this.$('html-form'), - this._onResponse.bind (this)); + ,addFiles: function (files) + { + if (!files) + return; + + for (var i = 0; i < files.length; i++) + this.addFile (files[i]); } - - ,_onResponse: function (json, error) + + ,addFile: function (file) { - this.$('submit').disabled = false; + var doc = document; + var div = doc.createElement ('div'); - if (error) - throw error; + var button = new Htk.Button ({ + tip: 'Remove', + icon: 'delete' + }); + button.on ('click', this.onFileRemove, this); + div.appendChild (button.node); - this.$('photo-id').value = ''; - this.$('photo-id').focus (); - Htk.Toast.showMessage (_('ImageAdded')); + var thumb = doc.createElement ('img'); + thumb.file = file; + thumb.className = 'thumb'; + div.appendChild (thumb); + + var reader = new FileReader (); + reader.onload = function (e) { thumb.src = e.target.result; }; + reader.readAsDataURL(file); + + var name = doc.createElement ('input'); + name.type = 'text'; + name.value = getFileName (file.name); + div.appendChild (name); + + var status = doc.createElement ('span'); + status.className = 'status'; + div.appendChild (status); + + var fileData = { + div: div, + file: file, + name: name, + status: status, + sent: false, + loading : false + }; + this.filesData.push (fileData); + button.value = fileData; + + this.$('file-list').appendChild (div); + } + + ,onUploadClick: function () + { + var filesData = this.filesData; + var formData = new FormData(); + var count = 0; + + for (var i = 0; i < filesData.length; i++) + { + var fileData = filesData[i]; + + if (!(fileData.sent || fileData.loading)) + { + formData.append ('image', fileData.file); + formData.append ('name', fileData.name.value); + formData.append ('schema', this.$('schema').value); + formData.append ('srv', 'json:image/upload'); + this.conn.sendFormData (formData, + this.onFileUpload.bind (this, fileData)); + + fileData.loading = true; + this.uploadCount++; + count++; + } + } + + if (count === 0) + Htk.Toast.showWarning (_('There are no files to upload')); + } + + ,onFileUpload: function (fileData, data, error) + { + fileData.loading = false; + + if (data) + { + var iconName = 'ok'; + var title = _('ImageAdded'); + fileData.sent = true; + fileData.name.disabled = true; + } + else + { + var iconName = 'error'; + var title = error.message; + this.errors = true; + } + + var status = fileData.status; + Vn.Node.removeChilds (status); + + var icon = new Htk.Icon ({icon: iconName}); + status.appendChild (icon.node); + status.title = title; + + this.uploadCount--; + + if (this.uploadCount === 0) + { + if (!this.errors) + Htk.Toast.showMessage (_('Upload finished successfully')); + else + Htk.Toast.showError (_('Some errors happened on upload')); + + this.errors = false; + } + } + + ,onFileRemove: function (button) + { + var fileData = button.value; + this.$('file-list').removeChild (fileData.div); + + for (var i = 0; i < this.filesData.length; i++) + if (this.filesData[i] === fileData) + { + this.filesData.splice (i, 1); + break; + } + } + + ,onClearClick: function () + { + this.filesData = []; + Vn.Node.removeChilds (this.$('file-list')); + } + + ,onDropzoneClick: function () + { + this.$('file').click (); + } + + ,onFileChange: function () + { + this.addFiles (this.$('file').files); + } + + ,onDragEnter: function (event) + { + Vn.Node.addClass (this.$('dropzone'), 'dragover'); + } + + ,onDragLeave: function (event) + { + Vn.Node.removeClass (this.$('dropzone'), 'dragover'); + } + + ,onDragOver: function (event) + { + event.preventDefault (); + } + + ,onDragEnd: function (event) + { + Vn.Node.removeClass (this.$('dropzone'), 'dragover'); + event.dataTransfer.clearData (); + } + + ,onDrop: function (event) + { + event.preventDefault (); + this.addFiles (event.dataTransfer.files); } }); +function getFileName (path) +{ + var barIndex = path.lastIndexOf ('/'); + if (barIndex === -1) + barIndex = path.lastIndexOf ('\\'); + if (barIndex === -1) + barIndex = 0; + + var dotIndex = path.lastIndexOf ('.'); + if (dotIndex === -1) + dotIndex = 0; + + return path.substr (barIndex, dotIndex); +} diff --git a/forms/admin/photos/style.css b/forms/admin/photos/style.css index b6049c24..54a7ee8d 100644 --- a/forms/admin/photos/style.css +++ b/forms/admin/photos/style.css @@ -1,17 +1,63 @@ -.photos iframe +/* Dropzone */ + +.photos .dropzone +{ + background-color: white; + border-style: dashed; + border-radius: .4em; + border-color: #2196F3; + padding: 2em 1em; + text-align: center; + color: #666; + cursor: pointer; +} +.photos .dropzone.dragover +{ + color: #CCC; + border-style: solid; +} +.photos input[type=file] { display: none; } -/* Footer */ +/* File list */ -.photos input[type=submit] +.photos .file-list { - display: block; - margin-top: 1.5em; - margin-left: auto; - margin-right: auto; - font-size: 1.2em; + margin-top: 1em; +} +.photos .file-list > div +{ + height: 2.5em; +} +.photos .file-list .thumb +{ + max-height: 2em; + max-width: 2em; + vertical-align: middle; + margin: 0 1em; +} +.photos .file-list input +{ + max-width: 10em; +} +.photos .file-list .status +{ + margin-left: .5em; + cursor: pointer; } +/* Footer */ + +.photos .footer +{ + margin-top: 1.5em; + text-align: center; +} +.photos .footer > button +{ + font-size: 1.2em; + margin-left: 1em; +} diff --git a/forms/admin/photos/ui.xml b/forms/admin/photos/ui.xml index 175673eb..e4000aaf 100755 --- a/forms/admin/photos/ui.xml +++ b/forms/admin/photos/ui.xml @@ -1,33 +1,41 @@

- Photos + Images

-
-
- -
- - -
-
- - -
-
+
+
SELECT name, `desc` FROM image_schema ORDER BY `desc` -
-
- - +
+ Click or drop files here +
+ +
+
diff --git a/forms/reports/items-form/items-form.js b/forms/reports/items-form/items-form.js new file mode 100644 index 00000000..34a2b2bb --- /dev/null +++ b/forms/reports/items-form/items-form.js @@ -0,0 +1,23 @@ + +Hedera.ItemsForm = new Class +({ + Extends: Hedera.Form + + ,activate: function () + { + this.$('warehouse').value = 7; + this.$('realm').value = null; + } + + ,onPreviewClick: function () + { + var batch = new Sql.Batch (); + batch.addValues ({ + 'warehouse': this.$('warehouse').value + ,'realm': this.$('realm').value + ,'rate': this.$('rate').value + }); + this.gui.openReport ('items-report', batch); + } +}); + diff --git a/forms/reports/items-form/locale/en.json b/forms/reports/items-form/locale/en.json new file mode 100644 index 00000000..53a2579c --- /dev/null +++ b/forms/reports/items-form/locale/en.json @@ -0,0 +1,9 @@ +{ + "Item list": "Item list" + + ,"Store": "Store" + ,"Realm": "Realm" + ,"Rate": "Rate" + + ,"Preview": "Preview" +} diff --git a/forms/reports/items-form/locale/es.json b/forms/reports/items-form/locale/es.json new file mode 100644 index 00000000..68eee4ef --- /dev/null +++ b/forms/reports/items-form/locale/es.json @@ -0,0 +1,9 @@ +{ + "Item list": "Listado de artículos" + + ,"Store": "Almacén" + ,"Realm": "Reino" + ,"Rate": "Tarifa" + + ,"Preview": "Mostrar" +} diff --git a/forms/reports/items-form/locale/mn.json b/forms/reports/items-form/locale/mn.json new file mode 100644 index 00000000..53a2579c --- /dev/null +++ b/forms/reports/items-form/locale/mn.json @@ -0,0 +1,9 @@ +{ + "Item list": "Item list" + + ,"Store": "Store" + ,"Realm": "Realm" + ,"Rate": "Rate" + + ,"Preview": "Preview" +} diff --git a/forms/reports/items-form/locale/pt.json b/forms/reports/items-form/locale/pt.json new file mode 100644 index 00000000..8bf6f7f2 --- /dev/null +++ b/forms/reports/items-form/locale/pt.json @@ -0,0 +1,9 @@ +{ + "Item list": "Lista de Ítens" + + ,"Store": "Armazém" + ,"Realm": "Reino" + ,"Rate": "Tarifa" + + ,"Preview": "Mostrar" +} diff --git a/forms/admin/shelves/style.css b/forms/reports/items-form/style.css similarity index 100% rename from forms/admin/shelves/style.css rename to forms/reports/items-form/style.css diff --git a/forms/reports/items-form/ui.xml b/forms/reports/items-form/ui.xml new file mode 100755 index 00000000..fda8e084 --- /dev/null +++ b/forms/reports/items-form/ui.xml @@ -0,0 +1,42 @@ + + +

+ Item list +

+
+ +
+
+
+
+ + + + SELECT id, name FROM vn2008.warehouse + WHERE reserve ORDER BY name + + +
+
+ + + + SELECT id, reino FROM vn2008.reinos + WHERE display != FALSE ORDER BY reino + + +
+
+ + +
+
+
+
diff --git a/forms/admin/shelves/locale/ca.json b/forms/reports/shelves/locale/ca.json similarity index 100% rename from forms/admin/shelves/locale/ca.json rename to forms/reports/shelves/locale/ca.json diff --git a/forms/admin/shelves/locale/en.json b/forms/reports/shelves/locale/en.json similarity index 100% rename from forms/admin/shelves/locale/en.json rename to forms/reports/shelves/locale/en.json diff --git a/forms/admin/shelves/locale/es.json b/forms/reports/shelves/locale/es.json similarity index 100% rename from forms/admin/shelves/locale/es.json rename to forms/reports/shelves/locale/es.json diff --git a/forms/admin/shelves/locale/fr.json b/forms/reports/shelves/locale/fr.json similarity index 100% rename from forms/admin/shelves/locale/fr.json rename to forms/reports/shelves/locale/fr.json diff --git a/forms/admin/shelves/locale/mn.json b/forms/reports/shelves/locale/mn.json similarity index 100% rename from forms/admin/shelves/locale/mn.json rename to forms/reports/shelves/locale/mn.json diff --git a/forms/admin/shelves/locale/pt.json b/forms/reports/shelves/locale/pt.json similarity index 100% rename from forms/admin/shelves/locale/pt.json rename to forms/reports/shelves/locale/pt.json diff --git a/forms/admin/shelves/shelves.js b/forms/reports/shelves/shelves.js similarity index 100% rename from forms/admin/shelves/shelves.js rename to forms/reports/shelves/shelves.js diff --git a/forms/reports/shelves/style.css b/forms/reports/shelves/style.css new file mode 100644 index 00000000..e69de29b diff --git a/forms/admin/shelves/ui.xml b/forms/reports/shelves/ui.xml similarity index 100% rename from forms/admin/shelves/ui.xml rename to forms/reports/shelves/ui.xml diff --git a/js/hedera/gui.js b/js/hedera/gui.js index 4c355e11..b284d21e 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -191,7 +191,7 @@ module.exports = new Class ,loadMenu: function () { - var sql = 'CALL form_list ()'; + var sql = 'CALL formList ()'; this._conn.execQuery (sql, this._onMenuLoad.bind (this)); } diff --git a/js/hedera/locale/ca.json b/js/hedera/locale/ca.json index 6e8a99f0..4e07c231 100644 --- a/js/hedera/locale/ca.json +++ b/js/hedera/locale/ca.json @@ -50,6 +50,7 @@ ,"Visits": "Visites" ,"News": "Noticies" ,"Photos": "Fotos" + ,"Items": "Artícles" ,"Reports": "Informes" ,"Shelves": "Estanterías" ,"Items list": "Llistat articles" diff --git a/js/hedera/locale/en.json b/js/hedera/locale/en.json index ea6d9e3f..2f599146 100644 --- a/js/hedera/locale/en.json +++ b/js/hedera/locale/en.json @@ -50,6 +50,7 @@ ,"Visits": "Visits" ,"News": "News" ,"Photos": "Photos" + ,"Items": "Items" ,"Reports": "Reports" ,"Shelves": "Shelves" ,"Items list": "Items list" diff --git a/js/hedera/locale/es.json b/js/hedera/locale/es.json index 93a365f5..6efbf899 100644 --- a/js/hedera/locale/es.json +++ b/js/hedera/locale/es.json @@ -50,6 +50,7 @@ ,"Visits": "Visitas" ,"News": "Noticias" ,"Photos": "Fotos" + ,"Items": "Artículos" ,"Reports": "Informes" ,"Shelves": "Estanterías" ,"Items list": "Listado artículos" diff --git a/js/hedera/locale/fr.json b/js/hedera/locale/fr.json index 9ff1e6fb..e3c46d25 100644 --- a/js/hedera/locale/fr.json +++ b/js/hedera/locale/fr.json @@ -50,6 +50,7 @@ ,"Visits": "Visites" ,"News": "Nouvelles" ,"Photos": "Photos" + ,"Items": "Articles" ,"Reports": "Rapport" ,"Shelves": "Etagères" ,"Items list": "Liste des articles" diff --git a/js/hedera/locale/mn.json b/js/hedera/locale/mn.json index 425a379b..53ada016 100644 --- a/js/hedera/locale/mn.json +++ b/js/hedera/locale/mn.json @@ -50,6 +50,7 @@ ,"Visits": "уулзалт" ,"News": "мэдээ" ,"Photos": "Фото зураг" + ,"Items": "зүйл" ,"Reports": "мэдээ" ,"Shelves": "тавиур" ,"Items list": "зүйлс жагсаалт" diff --git a/js/hedera/locale/pt.json b/js/hedera/locale/pt.json index 55356558..e8fe2c92 100644 --- a/js/hedera/locale/pt.json +++ b/js/hedera/locale/pt.json @@ -50,6 +50,7 @@ ,"Visits": "Visitas" ,"News": "Noticias" ,"Photos": "Fotos" + ,"Items": "Artigos" ,"Reports": "Relatórios" ,"Shelves": "Estantes" ,"Items list": "Lista de Itens" diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js index f7ef477e..d9b9b15c 100644 --- a/js/vn/json-connection.js +++ b/js/vn/json-connection.js @@ -183,7 +183,7 @@ module.exports = new Class if (this.token) formData.append ('token', this.token); - + var request = new XMLHttpRequest (); request.open ('POST', form.action, true); request.onreadystatechange = @@ -193,6 +193,20 @@ module.exports = new Class this._addRequest (); } + ,sendFormData: function (formData, callback) + { + if (this.token) + formData.append ('token', this.token); + + var request = new XMLHttpRequest (); + request.open ('post', '', true); + request.onreadystatechange = + this._onStateChange.bind (this, request, callback); + request.send (formData); + + this._addRequest (); + } + /* * Called when REST response is received. */ diff --git a/rest/image/sync.php b/rest/image/sync.php index 7b02355d..9ffeec70 100644 --- a/rest/image/sync.php +++ b/rest/image/sync.php @@ -20,7 +20,7 @@ class Sync extends Vn\Lib\Method function run () { - $db = $this->getSysConn () + $db = $this->getSysConn (); set_time_limit (0); $this->$trashSubdir = date ('YmdHis'); diff --git a/rest/image/thumb.php b/rest/image/thumb.php index eb6b1501..77db5872 100644 --- a/rest/image/thumb.php +++ b/rest/image/thumb.php @@ -64,7 +64,6 @@ class Thumb extends Vn\Web\RestRequest throw new Exception ('Size not allowed'); // Creates the thumb. - $util = new Util ($this->app); $baseDir = "{$util->dataDir}/$schema"; diff --git a/rest/image/upload.php b/rest/image/upload.php index 7dbed63c..6f81ec07 100755 --- a/rest/image/upload.php +++ b/rest/image/upload.php @@ -10,77 +10,31 @@ use Vn\Lib\UserException; */ class Upload extends Vn\Web\JsonRequest { + const PARAMS = [ + 'name', + 'schema' + ]; + function run ($db) { $util = new Util ($this->app); - // Checks schema. - - $regexp = '/[^a-z0-9_]/'; - - if (empty ($_REQUEST['schema']) || preg_match ($regexp, $_REQUEST['schema']) !== 0) - throw new UserException (s('Bad schema name')); - $schema = $_REQUEST['schema']; + $name = $_REQUEST['name']; + + // Checks schema + $info = $util->loadInfo ($schema); if (!$info) throw new UserException (s('Schema not exists')); - // Checks file name and identifier. + // Checks file name - $query = sprintf ( - 'SHOW INDEX FROM `%1$s`.`%2$s` WHERE Key_name = \'PRIMARY\'' - ,$info['schema'] - ,$info['table'] - ); - $pk = $db->getRow ($query); - - if (!empty ($_REQUEST['id']) && empty ($_REQUEST['name'])) - { - $query = sprintf ( - 'SELECT `%3$s` FROM `%1$s`.`%2$s` WHERE `%4$s` = #id' - ,$info['schema'] - ,$info['table'] - ,$info['column'] - ,$pk['Column_name'] - ); - $_REQUEST['name'] = $db->getValue ($query, - ['id' => $_REQUEST['id']]); - } - - if (empty ($_REQUEST['name']) || preg_match ($regexp, $_REQUEST['name']) !== 0) + if (preg_match ('/[^a-z0-9_]/', $_REQUEST['name']) !== 0) throw new UserException (s('Bad file name')); - // Checks permissions. - - if (!empty ($_REQUEST['id'])) - { - $filterColumn = $pk['Column_name']; - $filterValue = $_REQUEST['id']; - } - else - { - $filterColumn = $info['column']; - $filterValue = $_REQUEST['name']; - } - - $query = sprintf ( - 'UPDATE `%1$s`.`%2$s` SET `%3$s` = #name WHERE `%4$s` = #filter LIMIT 1' - ,$info['schema'] - ,$info['table'] - ,$info['column'] - ,$filterColumn - ); - $params = [ - 'name' => $_REQUEST['name'], - 'filter' => $filterValue - ]; - - if (!$db->query ($query, $params)) - throw new UserException (s('Permission denied')); - - // Checks for file errors. + // Checks for file errors if (empty ($_FILES['image']['name'])) throw new UserException (s('File not choosed')); @@ -123,14 +77,15 @@ class Upload extends Vn\Web\JsonRequest if ($_FILES['image']['size'] > $maxSize * 1048576) throw new UserException (sprintf (s('File size error'), $maxSize)); - // Resizes and saves the image. + // Resizes and saves the image - $fileName = "{$_REQUEST['name']}.png"; + $tmpName = $_FILES['image']['tmp_name']; + $fileName = "{$name}.png"; $schemaPath = "{$util->dataDir}/$schema"; $fullFile = "$schemaPath/full/$fileName"; $symbolicSrc = "../full/$fileName"; - $image = Image::create ($_FILES['image']['tmp_name']); + $image = Image::create ($tmpName); Image::resizeSave ($image, $fullFile, $info['max_height'], $info['max_width']); foreach ($info['sizes'] as $size => $i) @@ -140,7 +95,7 @@ class Upload extends Vn\Web\JsonRequest } imagedestroy ($image); - unlink ($_FILES['image']['tmp_name']); + unlink ($tmpName); return TRUE; } }