diff --git a/.eslintrc.yml b/.eslintrc.yml index 0fe49c2b..cbeacb9c 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,4 +1,8 @@ extends: eslint:recommended +env: + es6: true +parserOptions: + sourceType: module rules: no-undef: 0 no-redeclare: 0 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/conf/apache.conf b/conf/apache.conf index e550f557..c502e40a 100644 --- a/conf/apache.conf +++ b/conf/apache.conf @@ -2,33 +2,24 @@ # Alias /image-db /var/lib/hedera-web/image-db/ - Options -Indexes -FollowSymLinks AllowOverride None - - Order Allow,Deny - Allow From All - + Require all granted + SetOutputFilter DEFLATE - + Header set Access-Control-Allow-Origin "*" - - Options Indexes FollowSymLinks MultiViews AllowOverride FileInfo Options - - Order Allow,Deny - Allow From All Require all granted - diff --git a/conf/config.php b/conf/config.php old mode 100755 new mode 100644 diff --git a/debian/control b/debian/control index 8fc4d6c1..ba284ed5 100644 --- a/debian/control +++ b/debian/control @@ -5,13 +5,14 @@ Build-Depends: build-essential, debhelper, nodejs Standards-Version: 3.9.3 Section: misc Homepage: http://www.verdnatura.es -Vcs-Git: git://www.verdnatura.es/var/git/hedera-web +Vcs-Git: https://git.verdnatura.es/hedera-web Package: hedera-web Architecture: all -Depends: apache2, php5-mysql, php5-mcrypt, php5-ldap, php5-ssh2, php5-apcu, php-vn-lib, nodejs +Depends: apache2 | httpd, nodejs, php5-cli, php5-mysql, php5-mcrypt, php5-ldap, php5-ssh2, php5-apcu, php-vn-lib Suggests: php-text-captcha, php5-imap Section: misc Priority: optional Description: Verdnatura's web page - Verdnatura's web page. + Web page used by Verdnatura, it includes user authetication, a simple CMS and + a webpshop. diff --git a/debian/cron.d b/debian/cron.d old mode 100644 new mode 100755 diff --git a/debian/install b/debian/install index 4d5b3760..2af389db 100644 --- a/debian/install +++ b/debian/install @@ -10,8 +10,7 @@ reports usr/share/hedera-web rest usr/share/hedera-web index.php usr/share/hedera-web package.json usr/share/hedera-web -manifest.json usr/share/hedera-web -LICENSE usr/share/hedera-web +build usr/share/hedera-web README.md usr/share/hedera-web webpack.config.json usr/share/hedera-web build usr/share/hedera-web diff --git a/debian/postinst b/debian/postinst index 13608102..536e6b82 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,8 +1,15 @@ #!/bin/bash -cd /usr/share/hedera-web && npm install --production -a2enconf hedera-web -service apache2 reload +set -e + +(cd /usr/share/hedera-web && npm install --production) + +if [ -e /usr/share/apache2/apache2-maintscript-helper ] +then + . /usr/share/apache2/apache2-maintscript-helper + apache2_invoke enconf hedera-web.conf +fi + service php5-fpm restart service cron restart diff --git a/debian/postrm b/debian/postrm index d2d54aca..cf986935 100755 --- a/debian/postrm +++ b/debian/postrm @@ -1,5 +1,12 @@ #!/bin/bash +set -e + +if [ -e /usr/share/apache2/apache2-maintscript-helper ] +then + . /usr/share/apache2/apache2-maintscript-helper + apache2_invoke disconf hedera-web.conf +fi + rm -rf /usr/share/hedera-web/node_modules -service apache2 reload service cron restart diff --git a/forms/account/address-list/address-list.js b/forms/account/address-list/address-list.js index 74f7ed81..97a2974e 100644 --- a/forms/account/address-list/address-list.js +++ b/forms/account/address-list/address-list.js @@ -5,8 +5,8 @@ Hedera.AddressList = new Class ,activate: function () { - this.$.userModel.setInfo ('c', 'customer_view', 'hedera'); - this.$.addresses.setInfo ('a', 'address_view', 'hedera'); + this.$.userModel.setInfo ('c', 'myClient', 'hedera'); + this.$.addresses.setInfo ('a', 'myAddress', 'hedera'); } ,onAddAddressClick: function () diff --git a/forms/account/address-list/locale/ca.json b/forms/account/address-list/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/account/address-list/locale/en.json b/forms/account/address-list/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/account/address-list/locale/es.json b/forms/account/address-list/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/account/address-list/locale/fr.json b/forms/account/address-list/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/account/address-list/locale/mn.json b/forms/account/address-list/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/account/address-list/ui.xml b/forms/account/address-list/ui.xml old mode 100755 new mode 100644 index 92681601..9c39d1e7 --- a/forms/account/address-list/ui.xml +++ b/forms/account/address-list/ui.xml @@ -2,17 +2,17 @@ - SELECT user_id, default_address - FROM customer_view c + SELECT id, defaultAddressFk + FROM myClient - SELECT a.id, a.consignee, p.name province, a.zip_code, - a.city, a.name, a.active, c.Pais country - FROM address_view a - LEFT JOIN vn2008.province p ON a.province_id = p.province_id - JOIN vn2008.Paises c ON c.Id = p.Paises_Id - WHERE active != FALSE + SELECT a.id, a.nickname, p.name province, a.postalCode, + a.city, a.street, a.active, c.country + FROM myAddress a + LEFT JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + WHERE a.active

@@ -29,7 +29,7 @@ + name="defaultAddressFk"/>

- {{consignee}} + {{nickname}}

- {{name}} + {{street}}

- {{zip_code}}, {{city}} + {{postalCode}}, {{city}}

diff --git a/forms/account/address/address.js b/forms/account/address/address.js index 4c295c0b..3307b5cd 100644 --- a/forms/account/address/address.js +++ b/forms/account/address/address.js @@ -5,8 +5,8 @@ Hedera.Address = new Class ,activate: function () { - this.$.model.setInfo ('a', 'address_view', 'hedera', ['id'], 'id'); - this.$.model.setDefault ('customer_id', 'a', + this.$.model.setInfo ('a', 'myAddress', 'hedera', ['id'], 'id'); + this.$.model.setDefault ('clientFk', 'a', new Sql.Function ({schema: 'account', name: 'userGetId'})); } diff --git a/forms/account/address/locale/ca.json b/forms/account/address/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/account/address/locale/en.json b/forms/account/address/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/account/address/locale/es.json b/forms/account/address/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/account/address/locale/fr.json b/forms/account/address/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/account/address/locale/mn.json b/forms/account/address/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/account/address/ui.xml b/forms/account/address/ui.xml old mode 100755 new mode 100644 index 1bae850e..fc67af1b --- a/forms/account/address/ui.xml +++ b/forms/account/address/ui.xml @@ -11,11 +11,12 @@ mode="ON_DEMAND" lot="params" on-operations-done="onOperationsDone"> - SELECT a.id, a.name, a.consignee, a.city, a.zip_code, a.province_id, c.Id country - FROM address_view a - LEFT JOIN vn2008.province p ON p.province_id = a.province_id - JOIN vn2008.Paises c ON c.Id = p.Paises_Id - WHERE active != FALSE AND a.id = #address + SELECT a.id, a.street, a.nickname, a.city, + a.postalCode, a.provinceFk, c.id countryFk + FROM myAddress a + LEFT JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + WHERE a.active AND a.id = #address @@ -36,11 +37,11 @@
- +
- +
@@ -48,7 +49,7 @@
- +
@@ -60,8 +61,8 @@ name="country" one-way="true"/> - SELECT Id, Pais FROM vn2008.Paises - ORDER BY Pais + SELECT id, country FROM vn.country + ORDER BY country
@@ -69,8 +70,8 @@ - SELECT province_id, name FROM vn2008.province - WHERE Paises_Id = #country + SELECT id, name FROM vn.province + WHERE countryFk = #country ORDER BY name diff --git a/forms/account/conf/conf.js b/forms/account/conf/conf.js index ad3e4b7b..6cceaa0e 100644 --- a/forms/account/conf/conf.js +++ b/forms/account/conf/conf.js @@ -5,7 +5,7 @@ Hedera.Conf = new Class ,activate: function () { - this.$.userModel.setInfo ('c', 'customer_view', 'hedera'); + this.$.userModel.setInfo ('c', 'myClient', 'hedera'); if (this.hash.$.changePass) this.onPassChangeClick (); diff --git a/forms/account/conf/locale/ca.json b/forms/account/conf/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/account/conf/locale/en.json b/forms/account/conf/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/account/conf/locale/es.json b/forms/account/conf/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/account/conf/locale/fr.json b/forms/account/conf/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/account/conf/locale/mn.json b/forms/account/conf/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/account/conf/ui.xml b/forms/account/conf/ui.xml old mode 100755 new mode 100644 index b5730408..9e83248b --- a/forms/account/conf/ui.xml +++ b/forms/account/conf/ui.xml @@ -7,10 +7,10 @@ SELECT u.id, u.name, u.email, u.recoverPass, - u.nickname, u.lang, c.mail, c.user_id + u.nickname, u.lang, c.isToBeMailed, c.id clientFk FROM account.userView u - LEFT JOIN customer_view c - ON u.id = c.user_id + LEFT JOIN myClient c + ON u.id = c.id @@ -52,7 +52,7 @@
- +
diff --git a/forms/admin/access-log/ui.xml b/forms/admin/access-log/ui.xml old mode 100755 new mode 100644 diff --git a/forms/admin/connections/locale/ca.json b/forms/admin/connections/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/connections/locale/en.json b/forms/admin/connections/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/connections/locale/es.json b/forms/admin/connections/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/connections/locale/fr.json b/forms/admin/connections/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/connections/locale/mn.json b/forms/admin/connections/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/connections/locale/pt.json b/forms/admin/connections/locale/pt.json old mode 100755 new mode 100644 diff --git a/forms/admin/connections/ui.xml b/forms/admin/connections/ui.xml old mode 100755 new mode 100644 diff --git a/forms/admin/items/locale/ca.json b/forms/admin/items/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/items/locale/en.json b/forms/admin/items/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/items/locale/es.json b/forms/admin/items/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/items/locale/fr.json b/forms/admin/items/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/items/locale/mn.json b/forms/admin/items/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/items/ui.xml b/forms/admin/items/ui.xml old mode 100755 new mode 100644 diff --git a/forms/admin/links/locale/ca.json b/forms/admin/links/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/links/locale/en.json b/forms/admin/links/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/links/locale/es.json b/forms/admin/links/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/links/locale/fr.json b/forms/admin/links/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/links/locale/mn.json b/forms/admin/links/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/links/ui.xml b/forms/admin/links/ui.xml old mode 100755 new mode 100644 diff --git a/forms/admin/photos/locale/ca.json b/forms/admin/photos/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/photos/locale/en.json b/forms/admin/photos/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/photos/locale/es.json b/forms/admin/photos/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/photos/locale/fr.json b/forms/admin/photos/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/photos/locale/mn.json b/forms/admin/photos/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/photos/ui.xml b/forms/admin/photos/ui.xml old mode 100755 new mode 100644 index bdb34f95..e10f7552 --- a/forms/admin/photos/ui.xml +++ b/forms/admin/photos/ui.xml @@ -8,7 +8,7 @@ - SELECT name, `desc` FROM image_schema ORDER BY `desc` + SELECT name, `desc` FROM imageCollection ORDER BY `desc` diff --git a/forms/admin/queries/locale/ca.json b/forms/admin/queries/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/queries/locale/en.json b/forms/admin/queries/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/queries/locale/es.json b/forms/admin/queries/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/queries/locale/fr.json b/forms/admin/queries/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/queries/locale/mn.json b/forms/admin/queries/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/queries/locale/pt.json b/forms/admin/queries/locale/pt.json old mode 100755 new mode 100644 diff --git a/forms/admin/queries/ui.xml b/forms/admin/queries/ui.xml old mode 100755 new mode 100644 diff --git a/forms/admin/users/locale/ca.json b/forms/admin/users/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/users/locale/en.json b/forms/admin/users/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/users/locale/es.json b/forms/admin/users/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/users/locale/fr.json b/forms/admin/users/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/users/locale/mn.json b/forms/admin/users/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/users/ui.xml b/forms/admin/users/ui.xml old mode 100755 new mode 100644 diff --git a/forms/admin/visits/locale/ca.json b/forms/admin/visits/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/admin/visits/locale/en.json b/forms/admin/visits/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/admin/visits/locale/es.json b/forms/admin/visits/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/admin/visits/locale/fr.json b/forms/admin/visits/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/admin/visits/locale/mn.json b/forms/admin/visits/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/admin/visits/locale/pt.json b/forms/admin/visits/locale/pt.json old mode 100755 new mode 100644 diff --git a/forms/admin/visits/ui.xml b/forms/admin/visits/ui.xml old mode 100755 new mode 100644 diff --git a/forms/agencies/packages/locale/ca.json b/forms/agencies/packages/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/agencies/packages/locale/en.json b/forms/agencies/packages/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/agencies/packages/locale/es.json b/forms/agencies/packages/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/agencies/packages/locale/fr.json b/forms/agencies/packages/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/agencies/packages/locale/mn.json b/forms/agencies/packages/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/agencies/packages/ui.xml b/forms/agencies/packages/ui.xml old mode 100755 new mode 100644 diff --git a/forms/agencies/provinces/locale/ca.json b/forms/agencies/provinces/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/agencies/provinces/locale/en.json b/forms/agencies/provinces/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/agencies/provinces/locale/es.json b/forms/agencies/provinces/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/agencies/provinces/locale/fr.json b/forms/agencies/provinces/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/agencies/provinces/locale/mn.json b/forms/agencies/provinces/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/agencies/provinces/ui.xml b/forms/agencies/provinces/ui.xml old mode 100755 new mode 100644 diff --git a/forms/cms/about/locale/ca.json b/forms/cms/about/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/cms/about/locale/en.json b/forms/cms/about/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/cms/about/locale/es.json b/forms/cms/about/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/cms/about/locale/fr.json b/forms/cms/about/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/cms/about/locale/mn.json b/forms/cms/about/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/cms/about/ui.xml b/forms/cms/about/ui.xml old mode 100755 new mode 100644 diff --git a/forms/cms/contact/locale/ca.json b/forms/cms/contact/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/cms/contact/locale/en.json b/forms/cms/contact/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/cms/contact/locale/es.json b/forms/cms/contact/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/cms/contact/locale/fr.json b/forms/cms/contact/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/cms/contact/locale/mn.json b/forms/cms/contact/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/cms/contact/ui.xml b/forms/cms/contact/ui.xml old mode 100755 new mode 100644 diff --git a/forms/cms/home/locale/ca.json b/forms/cms/home/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/cms/home/locale/en.json b/forms/cms/home/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/cms/home/locale/es.json b/forms/cms/home/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/cms/home/locale/fr.json b/forms/cms/home/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/cms/home/locale/mn.json b/forms/cms/home/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/cms/home/ui.xml b/forms/cms/home/ui.xml old mode 100755 new mode 100644 index d3d81edc..6fb6332a --- a/forms/cms/home/ui.xml +++ b/forms/cms/home/ui.xml @@ -15,7 +15,7 @@ SELECT title, text, image, id FROM news WHERE tag != 'course' - ORDER BY priority, date_time DESC + ORDER BY priority, created DESC
diff --git a/forms/cms/location/locale/ca.json b/forms/cms/location/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/cms/location/locale/en.json b/forms/cms/location/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/cms/location/locale/es.json b/forms/cms/location/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/cms/location/locale/fr.json b/forms/cms/location/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/cms/location/locale/mn.json b/forms/cms/location/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/cms/location/ui.xml b/forms/cms/location/ui.xml old mode 100755 new mode 100644 diff --git a/forms/cms/training/locale/ca.json b/forms/cms/training/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/cms/training/locale/en.json b/forms/cms/training/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/cms/training/locale/es.json b/forms/cms/training/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/cms/training/locale/fr.json b/forms/cms/training/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/cms/training/locale/mn.json b/forms/cms/training/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/cms/training/ui.xml b/forms/cms/training/ui.xml old mode 100755 new mode 100644 index 1536f436..c08916a0 --- a/forms/cms/training/ui.xml +++ b/forms/cms/training/ui.xml @@ -6,9 +6,9 @@
- SELECT title, date_time, text, image, id FROM news + SELECT title, created, text, image, id FROM news WHERE tag = 'course' - ORDER BY priority, date_time DESC + ORDER BY priority, created DESC
@@ -16,7 +16,7 @@

{{title}}

- +

diff --git a/forms/cms/why/locale/ca.json b/forms/cms/why/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/cms/why/locale/en.json b/forms/cms/why/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/cms/why/locale/es.json b/forms/cms/why/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/cms/why/locale/fr.json b/forms/cms/why/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/cms/why/locale/mn.json b/forms/cms/why/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/cms/why/ui.xml b/forms/cms/why/ui.xml old mode 100755 new mode 100644 diff --git a/forms/ecomerce/basket/locale/ca.json b/forms/ecomerce/basket/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/basket/locale/en.json b/forms/ecomerce/basket/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/basket/locale/es.json b/forms/ecomerce/basket/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/basket/locale/fr.json b/forms/ecomerce/basket/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/basket/locale/mn.json b/forms/ecomerce/basket/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/basket/ui.xml b/forms/ecomerce/basket/ui.xml old mode 100755 new mode 100644 diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 272d47b4..b240ad53 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -489,7 +489,7 @@ Hedera.Catalog = new Class ,onConfirmClick: function () { var sql = ''; - var query = 'CALL basket_item_add (#warehouse, #item, #amount);'; + var query = 'CALL basketAddItem (#warehouse, #item, #amount);'; var amountSum = 0; for (var warehouse in this.items) diff --git a/forms/ecomerce/catalog/locale/ca.json b/forms/ecomerce/catalog/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/catalog/locale/en.json b/forms/ecomerce/catalog/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/catalog/locale/es.json b/forms/ecomerce/catalog/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/catalog/locale/fr.json b/forms/ecomerce/catalog/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/catalog/locale/mn.json b/forms/ecomerce/catalog/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml old mode 100755 new mode 100644 diff --git a/forms/ecomerce/checkout/locale/ca.json b/forms/ecomerce/checkout/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/checkout/locale/en.json b/forms/ecomerce/checkout/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/checkout/locale/es.json b/forms/ecomerce/checkout/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/checkout/locale/fr.json b/forms/ecomerce/checkout/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/checkout/locale/mn.json b/forms/ecomerce/checkout/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/checkout/ui.xml b/forms/ecomerce/checkout/ui.xml old mode 100755 new mode 100644 diff --git a/forms/ecomerce/confirm/confirm.js b/forms/ecomerce/confirm/confirm.js index 63594a2c..23cd59a5 100644 --- a/forms/ecomerce/confirm/confirm.js +++ b/forms/ecomerce/confirm/confirm.js @@ -29,7 +29,7 @@ Hedera.Confirm = new Class Vn.Node.display (this.$.address, !isPickup); Vn.Node.setText (this.$.address, _(isPickup ? 'Warehouse' : 'Agency')); - var total = order.taxBase + order.vat; + var total = order.taxBase + order.tax; if (total === null) total = 0; diff --git a/forms/ecomerce/confirm/locale/ca.json b/forms/ecomerce/confirm/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/confirm/locale/en.json b/forms/ecomerce/confirm/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/confirm/locale/es.json b/forms/ecomerce/confirm/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/confirm/locale/fr.json b/forms/ecomerce/confirm/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/confirm/locale/mn.json b/forms/ecomerce/confirm/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/confirm/ui.xml b/forms/ecomerce/confirm/ui.xml old mode 100755 new mode 100644 index 1e06b6d8..d1f051e8 --- a/forms/ecomerce/confirm/ui.xml +++ b/forms/ecomerce/confirm/ui.xml @@ -3,11 +3,11 @@ - CALL basket_get_vat (); - SELECT o.id, o.date_send sendDate, o.note, o.company_id company, + CALL basketGetTax; + SELECT o.id, o.date_send, o.note, o.company_id, ag.description agency, v.code method, - ad.consignee, ad.zip_code zipCode, ad.city, ad.name address, - t.*, c.credit, clientGetDebt() debt + ad.consignee, ad.zip_code, ad.city, ad.name address, + t.*, c.credit, clientGetDebt(NULL) debt FROM basket o JOIN vn2008.Agencias ag ON ag.Id_Agencia = o.agency_id LEFT JOIN address_view ad ON ad.id = o.address_id @@ -15,15 +15,15 @@ JOIN customer_view c JOIN ( SELECT - IFNULL(SUM(tax_base), 0) taxBase, - IFNULL(SUM(vat + surcharge), 0) vat - FROM t_order_vat + IFNULL(SUM(taxBase), 0) taxBase, + IFNULL(SUM(tax + equalizationTax), 0) tax + FROM tmp.orderTax ) t; - DROP TEMPORARY TABLE t_order_vat; + DROP TEMPORARY TABLE tmp.orderTax; - CALL basket_confirm () + CALL basketConfirm

@@ -79,7 +79,7 @@ _Order VAT - + diff --git a/forms/ecomerce/invoices/locale/ca.json b/forms/ecomerce/invoices/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/invoices/locale/en.json b/forms/ecomerce/invoices/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/invoices/locale/es.json b/forms/ecomerce/invoices/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/invoices/locale/fr.json b/forms/ecomerce/invoices/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/invoices/locale/mn.json b/forms/ecomerce/invoices/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/ecomerce/invoices/ui.xml b/forms/ecomerce/invoices/ui.xml old mode 100755 new mode 100644 diff --git a/forms/ecomerce/orders/locale/ca.json b/forms/ecomerce/orders/locale/ca.json old mode 100755 new mode 100644 index 27e5ec66..ff5452e5 --- a/forms/ecomerce/orders/locale/ca.json +++ b/forms/ecomerce/orders/locale/ca.json @@ -27,7 +27,6 @@ ,"Consignee": "Consignatari" ,"Boxes": "Caixes" ,"TotalWithVAT": "Total amb IVA" - ,"Pending": "Pendent" ,"PayOrder": "Pagar encàrrec" ,"An error has been in the payment": "Sembla que hi ha hagut un error en el pagament" diff --git a/forms/ecomerce/orders/locale/en.json b/forms/ecomerce/orders/locale/en.json old mode 100755 new mode 100644 index 473884b9..a5241d45 --- a/forms/ecomerce/orders/locale/en.json +++ b/forms/ecomerce/orders/locale/en.json @@ -27,7 +27,6 @@ ,"Consignee": "Consignee" ,"Boxes": "Bundles" ,"TotalWithVAT": "Total with VAT" - ,"Pending": "Pending" ,"PayOrder": "Pay order" ,"An error has been in the payment": "It seems that there has been an error in the payment" diff --git a/forms/ecomerce/orders/locale/es.json b/forms/ecomerce/orders/locale/es.json old mode 100755 new mode 100644 index 35942d97..8366f53b --- a/forms/ecomerce/orders/locale/es.json +++ b/forms/ecomerce/orders/locale/es.json @@ -27,7 +27,6 @@ ,"Consignee": "Consignatario" ,"Boxes": "Bultos" ,"TotalWithVAT": "Total con IVA" - ,"Pending": "Pendiente" ,"PayOrder": "Pagar pedido" ,"An error has been in the payment": "Parece que ha habido un error en el pago" diff --git a/forms/ecomerce/orders/locale/fr.json b/forms/ecomerce/orders/locale/fr.json old mode 100755 new mode 100644 index 2f8c4df7..a4d08f66 --- a/forms/ecomerce/orders/locale/fr.json +++ b/forms/ecomerce/orders/locale/fr.json @@ -21,13 +21,12 @@ ,"ShoppingBasket": "Panier" ,"SeeOrder": "Votre panier" - ,"Delivery": "Accouchement" + ,"Delivery": "Livraison" ,"TicketNumber": "Numéro ticket" ,"SentAddress": "Adresse de livraison" ,"Consignee": "Destinataire" ,"Boxes": "Colis" ,"TotalWithVAT": "Total avec TVA" - ,"Pending": "En attente" ,"PayOrder": "Payer la commande" ,"An error has been in the payment": "Il semble qu'il ya eu une erreur dans le paiement" diff --git a/forms/ecomerce/orders/locale/mn.json b/forms/ecomerce/orders/locale/mn.json old mode 100755 new mode 100644 index 9cdd66eb..4648b67e --- a/forms/ecomerce/orders/locale/mn.json +++ b/forms/ecomerce/orders/locale/mn.json @@ -27,7 +27,6 @@ ,"Consignee": "Consignee" ,"Boxes": "Bundles" ,"TotalWithVAT": "Total with VAT" - ,"Pending": "Pending" ,"PayOrder": "Pay order" ,"An error has been in the payment": "It seems that there has been an error in the payment" diff --git a/forms/ecomerce/orders/locale/pt.json b/forms/ecomerce/orders/locale/pt.json index 82476967..ea675dd9 100644 --- a/forms/ecomerce/orders/locale/pt.json +++ b/forms/ecomerce/orders/locale/pt.json @@ -27,7 +27,6 @@ ,"Consignee": "Consignatario" ,"Boxes": "Bultos" ,"TotalWithVAT": "Total com IVA" - ,"Pending": "Pendente" ,"PayOrder": "Pagar pedido" ,"An error has been in the payment": "Parece que não houve um erro no pagamento" diff --git a/forms/ecomerce/orders/orders.js b/forms/ecomerce/orders/orders.js index 9c88b647..a859b205 100644 --- a/forms/ecomerce/orders/orders.js +++ b/forms/ecomerce/orders/orders.js @@ -45,7 +45,7 @@ Hedera.Orders = new Class ,onPayButtonClick: function () { - var amount = -this.$.debt.$.debt; + var amount = -this.$.debt.value; amount = amount <= 0 ? null : amount; @@ -53,7 +53,7 @@ Hedera.Orders = new Class if (amount !== null) defaultAmountStr = Vn.Value.format (amount, '%.2d'); - + amount = prompt (_('AmountToPay:'), defaultAmountStr); if (amount != null) diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml old mode 100755 new mode 100644 index 818f2ba4..4be6bf23 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -2,11 +2,6 @@ - - - SELECT clientGetDebt() debt - -

_LastOrders

@@ -31,7 +26,13 @@ lot="debt" name="debt" format="%.2d€" - conditional-func="balanceConditionalFunc"/> + conditional-func="balanceConditionalFunc"> + + + SELECT clientGetDebt(NULL) debt + + +
- CALL clientTicketList (#from, NULL) + CALL myTicketList (#from, NULL) -

- +

-

@{{ticket_id}}

-

{{consignee}}

-

{{type}}

+

@{{id}}

+

{{nickname}}

+

{{agency}}

diff --git a/forms/ecomerce/ticket/locale/ca.json b/forms/ecomerce/ticket/locale/ca.json old mode 100755 new mode 100644 index d76c9907..1b4f9f4d --- a/forms/ecomerce/ticket/locale/ca.json +++ b/forms/ecomerce/ticket/locale/ca.json @@ -5,6 +5,7 @@ ,"Delivery": "Entrega" ,"Total": "Total" + ,"Total + tax": "Total + IVA" ,"Tax base": "Base imposable" ,"VAT": "IVA" diff --git a/forms/ecomerce/ticket/locale/en.json b/forms/ecomerce/ticket/locale/en.json old mode 100755 new mode 100644 index 637bc6d1..aaa6cdad --- a/forms/ecomerce/ticket/locale/en.json +++ b/forms/ecomerce/ticket/locale/en.json @@ -5,6 +5,7 @@ ,"Delivery": "Delivery" ,"Total": "Total" + ,"Total + tax": "Total + tax" ,"Tax base": "Tax base" ,"VAT": "VAT" diff --git a/forms/ecomerce/ticket/locale/es.json b/forms/ecomerce/ticket/locale/es.json old mode 100755 new mode 100644 index 3127cd32..7e1abc68 --- a/forms/ecomerce/ticket/locale/es.json +++ b/forms/ecomerce/ticket/locale/es.json @@ -5,6 +5,7 @@ ,"Delivery": "Entrega" ,"Total": "Total" + ,"Total + tax": "Total + IVA" ,"Tax base": "Base imponible" ,"VAT": "IVA" ,"Total + VAT": "Total + IVA" diff --git a/forms/ecomerce/ticket/locale/fr.json b/forms/ecomerce/ticket/locale/fr.json old mode 100755 new mode 100644 index e55f885f..3d79d182 --- a/forms/ecomerce/ticket/locale/fr.json +++ b/forms/ecomerce/ticket/locale/fr.json @@ -5,6 +5,7 @@ ,"Delivery": "Livraison" ,"Total": "Total" + ,"Total + tax": "Total + impôt" ,"Tax base": "Imposable" ,"VAT": "TVA" diff --git a/forms/ecomerce/ticket/locale/mn.json b/forms/ecomerce/ticket/locale/mn.json old mode 100755 new mode 100644 index 637bc6d1..aaa6cdad --- a/forms/ecomerce/ticket/locale/mn.json +++ b/forms/ecomerce/ticket/locale/mn.json @@ -5,6 +5,7 @@ ,"Delivery": "Delivery" ,"Total": "Total" + ,"Total + tax": "Total + tax" ,"Tax base": "Tax base" ,"VAT": "VAT" diff --git a/forms/ecomerce/ticket/locale/pt.json b/forms/ecomerce/ticket/locale/pt.json index 2aa40fc9..9671aa48 100644 --- a/forms/ecomerce/ticket/locale/pt.json +++ b/forms/ecomerce/ticket/locale/pt.json @@ -5,6 +5,7 @@ ,"Delivery": "Entrega" ,"Total": "Total" + ,"Total + tax": "Total + imposto" ,"Tax base": "Tributável" ,"VAT": "IVA" diff --git a/forms/ecomerce/ticket/ticket.js b/forms/ecomerce/ticket/ticket.js index f2c12e7b..335205d9 100644 --- a/forms/ecomerce/ticket/ticket.js +++ b/forms/ecomerce/ticket/ticket.js @@ -10,7 +10,7 @@ Hedera.Ticket = new Class var batch = new Sql.Batch (); batch.addValue ('ticket', ticket.value); - this.conn.execQuery ('CALL clientTicketLog (#ticket)', null, batch); + this.conn.execQuery ('CALL myTicketLogAccess (#ticket)', null, batch); } ,onPrintClick: function () @@ -32,11 +32,7 @@ Hedera.Ticket = new Class ,subtotal: function (form) { var row = form.$; - - if (row.price && row.fixed) - return row.amount * row.price * ((100 - row.discount) / 100); - else - return null; + return row.quantity * row.price * ((100 - row.discount) / 100); } }); diff --git a/forms/ecomerce/ticket/ui.xml b/forms/ecomerce/ticket/ui.xml old mode 100755 new mode 100644 index d46a8a5e..fb9da468 --- a/forms/ecomerce/ticket/ui.xml +++ b/forms/ecomerce/ticket/ui.xml @@ -3,7 +3,7 @@ - CALL clientTicketGet(#ticket) + CALL myTicketGet(#ticket)

_OrderDetail @@ -22,37 +22,37 @@ @{{ticket.id}}

- +

- _Delivery {{ticket.Agencia}} + _Delivery {{ticket.agency}}

- {{ticket.consignee}} + {{ticket.nickname}}

- {{ticket.name}} + {{ticket.street}}

- {{ticket.consignee}} {{ticket.city}} ({{ticket.province}}) + {{ticket.postalCode}} {{ticket.city}} ({{ticket.province}})

_Total - +

- _Total + VAT - + _Total + tax +

- CALL clientTicketRowGet(#ticket) + CALL myTicketGetRows(#ticket)
@@ -63,10 +63,10 @@ subdir="200x200" full-dir="900x900"/>

- {{concept}} {{Medida}} {{Categoria}} + {{concept}} {{size}} {{category}}

- {{amount}} x + {{quantity}} x diff --git a/forms/news/new/locale/ca.json b/forms/news/new/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/news/new/locale/en.json b/forms/news/new/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/news/new/locale/es.json b/forms/news/new/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/news/new/locale/fr.json b/forms/news/new/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/news/new/locale/mn.json b/forms/news/new/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/news/new/new.js b/forms/news/new/new.js index e05c387a..4a0811b8 100644 --- a/forms/news/new/new.js +++ b/forms/news/new/new.js @@ -11,7 +11,7 @@ Hedera.New = new Class ,activate: function () { this.$.model.mode = Db.Model.Mode.ON_DEMAND; - this.$.model.setDefault ('user_id', 'news', + this.$.model.setDefault ('userFk', 'news', new Sql.Function ({schema: 'account', name: 'userGetId'})); tinymce.init ({ diff --git a/forms/news/new/ui.xml b/forms/news/new/ui.xml old mode 100755 new mode 100644 index f963d889..578d3721 --- a/forms/news/new/ui.xml +++ b/forms/news/new/ui.xml @@ -36,7 +36,7 @@ - SELECT name, description FROM news_tag + SELECT name, description FROM newsTag ORDER BY description diff --git a/forms/news/news/locale/ca.json b/forms/news/news/locale/ca.json old mode 100755 new mode 100644 diff --git a/forms/news/news/locale/en.json b/forms/news/news/locale/en.json old mode 100755 new mode 100644 diff --git a/forms/news/news/locale/es.json b/forms/news/news/locale/es.json old mode 100755 new mode 100644 diff --git a/forms/news/news/locale/fr.json b/forms/news/news/locale/fr.json old mode 100755 new mode 100644 diff --git a/forms/news/news/locale/mn.json b/forms/news/news/locale/mn.json old mode 100755 new mode 100644 diff --git a/forms/news/news/ui.xml b/forms/news/news/ui.xml old mode 100755 new mode 100644 index 17d037e7..455c6c29 --- a/forms/news/news/ui.xml +++ b/forms/news/news/ui.xml @@ -14,8 +14,8 @@ SELECT n.id, u.nickname, priority, image, title FROM news n - JOIN account.user u ON u.id = n.user_id - ORDER BY priority, n.date_time DESC + JOIN account.user u ON u.id = n.userFk + ORDER BY priority, n.created DESC diff --git a/forms/reports/items-form/ui.xml b/forms/reports/items-form/ui.xml old mode 100755 new mode 100644 diff --git a/forms/reports/shelves/ui.xml b/forms/reports/shelves/ui.xml old mode 100755 new mode 100644 diff --git a/index.php b/index.php old mode 100755 new mode 100644 diff --git a/js/hedera/gui.js b/js/hedera/gui.js index 23488cca..d7f02780 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -140,8 +140,7 @@ module.exports = new Class // Retrieving configuration parameters Object.assign (Vn.Config, resultSet.fetchRow ()); - - // Retrieving configuration parameters + Vn.Config.imageUrl = resultSet.fetchValue (); var row = resultSet.fetchRow (); @@ -173,7 +172,7 @@ module.exports = new Class ,loadMenu: function () { - var sql = 'CALL formList ()'; + var sql = 'SELECT * FROM myMenu'; this._conn.execQuery (sql, this._onMenuLoad.bind (this)); } @@ -186,7 +185,7 @@ module.exports = new Class if (sections) sections.forEach (function (section) { - var parent = section.parent; + var parent = section.parentFk; if (!sectionMap[parent]) sectionMap[parent] = []; diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml old mode 100755 new mode 100644 diff --git a/js/hedera/login.xml b/js/hedera/login.xml old mode 100755 new mode 100644 diff --git a/js/hedera/tpv.js b/js/hedera/tpv.js index 285ce3e5..e20d4061 100644 --- a/js/hedera/tpv.js +++ b/js/hedera/tpv.js @@ -13,7 +13,7 @@ module.exports = new Class if (this.tpvStatus) { - var query = 'CALL transactionEnd (#transaction, #status)'; + var query = 'CALL tpvTransactionEnd (#transaction, #status)'; var params = { transaction: this.tpvOrder, status: this.tpvStatus @@ -27,11 +27,11 @@ module.exports = new Class ,pay: function (amount, company) { - this._realPpay (amount * 100, company); + this._realPay (amount * 100, company); } - ,_realPpay: function (amount, company) - { + ,_realPay: function (amount, company) + { if (isNumeric (amount) && amount > 0) { var params = { @@ -55,7 +55,7 @@ module.exports = new Class var postValues = json.postValues; var form = document.createElement ('form'); - form.method = 'post'; + form.method = 'POST'; form.action = json.url; document.body.appendChild (form); @@ -66,7 +66,7 @@ module.exports = new Class input.name = field; form.appendChild (input); - if (postValues[field]) + if (postValues[field]) input.value = postValues[field]; } @@ -78,9 +78,9 @@ module.exports = new Class ,retryPay: function () { - var query = 'SELECT t.amount, m.company_id ' - +'FROM tpv_transaction_view t ' - +'JOIN tpv_merchant m ON t.merchant_id = m.id ' + var query = 'SELECT t.amount, m.companyFk ' + +'FROM myTpvTransaction t ' + +'JOIN tpvMerchant m ON m.id = t.merchantFk ' +'WHERE t.id = #transaction'; var params = {transaction: parseInt (this.tpvOrder)}; this.conn.execQuery (query, @@ -92,7 +92,7 @@ module.exports = new Class var row = resultSet.fetchRow (); if (row) - this._realPpay (row.amount, row.company_id); + this._realPay (row.amount, row.companyFk); else Htk.Toast.showError (_('AmountError')); } diff --git a/js/htk/field/image.js b/js/htk/field/image.js index 2022afee..667fb99f 100644 --- a/js/htk/field/image.js +++ b/js/htk/field/image.js @@ -130,7 +130,7 @@ module.exports = new Class ,_makeSrc: function (subdir) { - var src = Vn.Config['image_dir'] +'/'; + var src = Vn.Config.imageUrl +'/'; if (this._directory) src += this._directory +'/'; diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js index 1441531b..af09257c 100644 --- a/js/vn/json-connection.js +++ b/js/vn/json-connection.js @@ -199,7 +199,7 @@ module.exports = new Class formData.append ('token', this.token); var request = new XMLHttpRequest (); - request.open ('post', '', true); + request.open ('POST', '', true); request.onreadystatechange = this._onStateChange.bind (this, request, callback); request.send (formData); diff --git a/package.json b/package.json index 28d7ebf3..788a9121 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,14 @@ "url": "https://git.verdnatura.es/hedera-web" }, "devDependencies": { + "archiver": "^2.1.0", "assets-webpack-plugin": "^3.5.1", "bundle-loader": "^0.5.4", "css-loader": "^0.25.0", "eslint": "^3.16.1", "file-loader": "^0.9.0", + "fs-extra": "^5.0.0", + "glob": "^7.1.2", "json-loader": "^0.5.4", "raw-loader": "^0.5.1", "style-loader": "^0.19.0", diff --git a/manifest.json b/pages/main/manifest.json similarity index 57% rename from manifest.json rename to pages/main/manifest.json index e1b6b274..ccfa40bb 100644 --- a/manifest.json +++ b/pages/main/manifest.json @@ -2,10 +2,10 @@ "name": "Verdnatura", "icons": [ { - "src": "image\/favicon\/favicon.png", + "src": "\/image\/favicon\/favicon.png", "sizes": "512x512" } ], - "start_url": "index.php", + "start_url": "/index.php", "display": "standalone" } diff --git a/pages/main/ui.php b/pages/main/ui.php old mode 100755 new mode 100644 index 65a7a283..9d842d74 --- a/pages/main/ui.php +++ b/pages/main/ui.php @@ -14,7 +14,7 @@ $result = $db->query ('SELECT name, content FROM metatag'); - + diff --git a/pages/production/main.js b/pages/production/main.js new file mode 100644 index 00000000..3cbb71b3 --- /dev/null +++ b/pages/production/main.js @@ -0,0 +1,146 @@ + +/** + * Time in seconds between every request. + */ +var INTERVAL = 10; + +var requestInterval = INTERVAL; +var failedRequests = 0; +var timeoutId = null; +var request = null; +var lastText = null; +var lastError = null; + +function onBodyLoad () +{ + updateText (); +} + +function onSettingsClick () +{ + var deviceId = localStorage.getItem ('hederaDeviceId'); + + if (deviceId == null) + deviceId = ''; + + deviceId = prompt ('Enter the device identifier', deviceId); + + if (deviceId) + localStorage.setItem ('hederaDeviceId', deviceId); + else if (deviceId === '') + localStorage.removeItem ('hederaDeviceId'); + + if (timeoutId != null) + { + clearTimeout (timeoutId); + timeoutId = null; + } + if (request) + { + request.abort (); + request = null; + } + + updateText (); +} + +function updateText () +{ + var deviceId = localStorage.getItem ('hederaDeviceId'); + + if (!deviceId) + { + display ('Device id not set', true); + return; + } + + var formData = new FormData (); + formData.append ('srv', 'json:misc/production'); + formData.append ('deviceId', deviceId); + + request = new XMLHttpRequest(); + request.open ('POST', '', true); + request.onreadystatechange = + onRequestChange.bind (null, request); + request.send (formData); +} + +function onRequestChange (request) +{ + if (request.readyState !== 4) + return; + + try { + switch (request.status) + { + case 200: + var json = JSON.parse (request.responseText); + display (json.data); + requestInterval = INTERVAL; + failedRequests = 0; + break; + case 400: + var json = JSON.parse (request.responseText); + throw new Error (json.data.message); + default: + throw new Error ('HTTP '+ request.status +': '+ request.statusText); + } + } + catch (e) + { + display (e.message, true); + console.error (e.message); + failedRequests++; + + if (failedRequests > 10 && requestInterval < 60) + { + requestInterval += parseInt (Math.random() * 10) + 1; + console.warn ('Request interval increased to %d seconds.', requestInterval); + } + } + + timeoutId = setTimeout (updateText, requestInterval * 1000); + request = null; +} + +function display (text, error) +{ + var bgColor; + + if (!error) + { + $('text').textContent = text; + $('error').textContent = ''; + $('error').style.display = 'none'; + bgColor = 'green'; + } + else + { + $('text').textContent = 'Er'; + $('error').textContent = text; + $('error').style.display = 'block'; + bgColor = 'red'; + } + + if (text != lastText || lastError != error) + { + var body = document.body; + body.addEventListener ('transitionend', onTransitionEnd); + body.style.backgroundColor = bgColor; + } + + lastText = text; + lastError = error; +} + +function onTransitionEnd () +{ + var body = document.body; + body.removeEventListener ('transitionend', onTransitionEnd); + body.style.backgroundColor = ''; +} + +function $ (elementId) +{ + return document.getElementById (elementId); +} diff --git a/pages/production/manifest.json b/pages/production/manifest.json new file mode 100644 index 00000000..95c5a691 --- /dev/null +++ b/pages/production/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "Production", + "icons": [ + { + "src": "\/image\/favicon\/favicon.png", + "sizes": "512x512" + } + ], + "start_url": "/index.php?method=production", + "display": "standalone" +} diff --git a/pages/production/style.css b/pages/production/style.css new file mode 100644 index 00000000..d5beb353 --- /dev/null +++ b/pages/production/style.css @@ -0,0 +1,62 @@ +body +{ + background-color: #333; + position: absolute; + height: 100%; + width: 100%; + margin: 0; + font-family: Sans; + transition: background-color 500ms ease-in; +} +#container +{ + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} +#child +{ + max-width: 90%; + text-align: center; +} +#text +{ + color: white; + font-size: 24em; + font-weight: bold; + text-align: center; + white-space: nowrap; + overflow: hidden; + line-height: 1em; +} +#error +{ + color: red; + font-size: 3em; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} +button +{ + position: fixed; + margin: 1em; + padding: 1em; + top: 0; + right: 0; + background-color: transparent; + border: none; + cursor: pointer; +} +button:hover +{ + background-color: rgba(0, 0, 0, 0.4); + border-radius: .2em; +} +button > img +{ + height: 3em; + display: block; +} \ No newline at end of file diff --git a/pages/production/ui.php b/pages/production/ui.php new file mode 100644 index 00000000..249f9603 --- /dev/null +++ b/pages/production/ui.php @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + Production + + + +

+ + \ No newline at end of file diff --git a/pages/update-browser/locale/ca.json b/pages/update-browser/locale/ca.json old mode 100755 new mode 100644 diff --git a/pages/update-browser/locale/en.json b/pages/update-browser/locale/en.json old mode 100755 new mode 100644 diff --git a/pages/update-browser/locale/es.json b/pages/update-browser/locale/es.json old mode 100755 new mode 100644 diff --git a/pages/update-browser/locale/fr.json b/pages/update-browser/locale/fr.json old mode 100755 new mode 100644 diff --git a/pages/update-browser/locale/mn.json b/pages/update-browser/locale/mn.json old mode 100755 new mode 100644 diff --git a/pages/update-browser/style.css b/pages/update-browser/style.css old mode 100755 new mode 100644 diff --git a/pages/update-browser/ui.php b/pages/update-browser/ui.php old mode 100755 new mode 100644 index 62f59301..49e6e1f5 --- a/pages/update-browser/ui.php +++ b/pages/update-browser/ui.php @@ -3,8 +3,9 @@ - - + + + Verdnatura diff --git a/pages/version-menu/locale/ca.json b/pages/version-menu/locale/ca.json old mode 100755 new mode 100644 diff --git a/pages/version-menu/locale/en.json b/pages/version-menu/locale/en.json old mode 100755 new mode 100644 diff --git a/pages/version-menu/locale/es.json b/pages/version-menu/locale/es.json old mode 100755 new mode 100644 diff --git a/pages/version-menu/locale/fr.json b/pages/version-menu/locale/fr.json old mode 100755 new mode 100644 diff --git a/pages/version-menu/locale/mn.json b/pages/version-menu/locale/mn.json old mode 100755 new mode 100644 diff --git a/pages/version-menu/style.css b/pages/version-menu/style.css old mode 100755 new mode 100644 diff --git a/pages/version-menu/ui.php b/pages/version-menu/ui.php old mode 100755 new mode 100644 index 2e8c5a41..12be46ae --- a/pages/version-menu/ui.php +++ b/pages/version-menu/ui.php @@ -3,8 +3,9 @@ + - + Verdnatura diff --git a/reports/delivery-note/delivery-note.js b/reports/delivery-note/delivery-note.js index ead9ba53..3a708bdc 100644 --- a/reports/delivery-note/delivery-note.js +++ b/reports/delivery-note/delivery-note.js @@ -12,10 +12,6 @@ Hedera.DeliveryNote = new Class { var price = form.get ('price'); var discount = form.get ('discount'); - - if (price && form.get ('fixed')) - return form.get ('amount') * price * ((100 - discount) / 100); - else - return null; + return form.get ('quantity') * price * ((100 - discount) / 100); } }); diff --git a/reports/delivery-note/style.css b/reports/delivery-note/style.css index d480ff85..10707b22 100644 --- a/reports/delivery-note/style.css +++ b/reports/delivery-note/style.css @@ -22,5 +22,4 @@ font-weight: bold; border-top: 1px solid #333; padding-top: .3em; - text-align: right; } diff --git a/reports/delivery-note/ui.xml b/reports/delivery-note/ui.xml old mode 100755 new mode 100644 index 79c01d3a..3b548b8e --- a/reports/delivery-note/ui.xml +++ b/reports/delivery-note/ui.xml @@ -2,7 +2,7 @@ - CALL clientTicketGet(#ticket) + CALL myTicketGet(#ticket) @@ -12,44 +12,44 @@

- +

- +

- +

- + ()

- _Delivery + _Delivery

- CALL clientTicketRowGet(#ticket) + CALL myTicketGetRows(#ticket) - - + + - - - + + + diff --git a/reports/items-report/ui.xml b/reports/items-report/ui.xml old mode 100755 new mode 100644 diff --git a/reports/recover-password/ui.php b/reports/recover-password/ui.php old mode 100755 new mode 100644 diff --git a/reports/shelves-report/ui.xml b/reports/shelves-report/ui.xml old mode 100755 new mode 100644 diff --git a/rest/core/IndieFlower.ttf b/rest/core/IndieFlower.ttf old mode 100755 new mode 100644 diff --git a/rest/core/account.php b/rest/core/account.php old mode 100755 new mode 100644 index 23ad5488..76efaf79 --- a/rest/core/account.php +++ b/rest/core/account.php @@ -42,9 +42,6 @@ class Account */ static function ldapSync ($db, $userName, $password) { - if (empty ($password)) - return; - // Gets LDAP configuration parameters $conf = $db->getObject ( @@ -58,81 +55,114 @@ class Account if (!$ds) throw new Exception ("Can't connect to LDAP server: ". ldapError ($ds)); - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - $bind = ldap_bind ($ds, $conf->rdn, base64_decode ($conf->password)); + try { + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + $bind = ldap_bind ($ds, $conf->rdn, base64_decode ($conf->password)); - if (!$bind) - throw new Exception ("Authentication failed on LDAP server: ". ldapError ($ds)); + if (!$bind) + throw new Exception ("Authentication failed on LDAP server: ". ldapError ($ds)); - // Prepares the data + // Prepares the data - $domain = $db->getValue ('SELECT domain FROM account.mailConfig'); + $domain = $db->getValue ('SELECT domain FROM account.mailConfig'); - $user = $db->getObject ( - 'SELECT id, nickname, lang - FROM account.user - WHERE name = #', - [$userName] - ); + $user = $db->getObject ( + 'SELECT id, nickname, lang + FROM account.user + WHERE name = #', + [$userName] + ); - $nameArgs = explode (' ', $user->nickname); - $givenName = $nameArgs[0]; + $cn = empty ($user->nickname) ? $userName : $user->nickname; - if (count ($nameArgs) > 1) - $sn = $nameArgs[1]; - if (empty ($sn)) - $sn = 'Empty'; + $nameArgs = explode (' ', $user->nickname); + $givenName = $nameArgs[0]; - $info = [ - 'cn' => $user->nickname, - 'displayName' => $user->nickname, - 'givenName' => $givenName, - 'sn' => $sn, - 'mail' => "$userName@{$domain}", - 'userPassword' => sshaEncode ($password), - 'preferredLanguage' => $user->lang - ]; + if (count ($nameArgs) > 1) + $sn = $nameArgs[1]; + if (empty ($sn)) + $sn = 'Empty'; - // Search the user entry + $attrs = [ + 'cn' => $cn, + 'displayName' => $user->nickname, + 'givenName' => $givenName, + 'sn' => $sn, + 'mail' => "$userName@{$domain}", + 'userPassword' => sshaEncode ($password), + 'preferredLanguage' => $user->lang + ]; - $filter = "uid=$userName"; + // Search the user entry - if (!empty($conf->filter)) - $filter = "(&($filter)($conf->filter))"; + $filter = "uid=$userName"; - $res = ldap_search ($ds, $conf->baseDn, $filter); + if (!empty($conf->filter)) + $filter = "(&($filter)($conf->filter))"; - if (!$res) - throw new Exception ("Can't get the LDAP entry: ". ldapError ($ds)); + $res = ldap_search ($ds, $conf->baseDn, $filter); - $dn = "uid=$userName,{$conf->baseDn}"; - $entry = ldap_first_entry ($ds, $res); + if (!$res) + throw new Exception ("Can't get the LDAP entry: ". ldapError ($ds)); - $classes = ldap_get_values ($ds, $entry, 'objectClass'); + $dn = "uid=$userName,{$conf->baseDn}"; + $entry = ldap_first_entry ($ds, $res); - if (!in_array ('inetOrgPerson', $classes)) - { - ldap_delete ($ds, $dn); - $entry = NULL; + $classes = ldap_get_values ($ds, $entry, 'objectClass'); + + if (!in_array ('inetOrgPerson', $classes)) + { + ldap_delete ($ds, $dn); + $entry = NULL; + } + + if ($entry) + { + $modifs = []; + $curAttrs = ldap_get_attributes ($ds, $entry); + + foreach ($attrs as $attribute => $value) + if (!empty ($value)) + { + $modifs[] = [ + 'attrib' => $attribute, + 'modtype' => LDAP_MODIFY_BATCH_REPLACE, + 'values' => [$value] + ]; + } + elseif (isset ($curAttrs[$attribute])) + { + $modifs[] = [ + 'attrib' => $attribute, + 'modtype' => LDAP_MODIFY_BATCH_REMOVE_ALL + ]; + } + + $updated = ldap_modify_batch ($ds, $dn, $modifs); + } + else + { + $addAttrs = []; + + foreach ($attrs as $attribute => $value) + if (!empty ($value)) + $addAttrs[$attribute] = $value; + + $addAttrs = array_merge ($addAttrs, [ + 'objectClass' => ['inetOrgPerson'], + 'uid' => $userName + ]); + $updated = ldap_add ($ds, $dn, $addAttrs); + } + + if (!$updated) + throw new Exception ("Can't update the LDAP entry: ". ldapError ($ds)); } - - if ($entry) + catch (Exception $e) { - $updated = ldap_modify ($ds, $dn, $info); + ldap_unbind ($ds); + throw $e; } - else - { - $info = array_merge ($info, [ - 'objectClass' => ['inetOrgPerson'], - 'uid' => $userName - ]); - $updated = ldap_add ($ds, $dn, $info); - } - - if (!$updated) - throw new Exception ("Can't update the LDAP entry: ". ldapError ($ds)); - - ldap_unbind ($ds); } /** @@ -233,7 +263,6 @@ class SshConnection $args[$i] = self::escape ($args[$i]); $command = call_user_func_array ('sprintf', $args); - error_log ($command); return ssh2_exec ($this->connection, $command); } diff --git a/rest/core/captcha.php b/rest/core/captcha.php old mode 100755 new mode 100644 diff --git a/rest/core/change-password.php b/rest/core/change-password.php old mode 100755 new mode 100644 diff --git a/rest/core/locale/ca.json b/rest/core/locale/ca.json old mode 100755 new mode 100644 diff --git a/rest/core/locale/en.json b/rest/core/locale/en.json new file mode 100644 index 00000000..75f9e384 --- /dev/null +++ b/rest/core/locale/en.json @@ -0,0 +1,5 @@ +{ + "InvalidAction": "Invalid action" + + ,"EmptyQuery": "Empty query" +} diff --git a/rest/core/locale/es.json b/rest/core/locale/es.json old mode 100755 new mode 100644 diff --git a/rest/core/locale/fr.json b/rest/core/locale/fr.json old mode 100755 new mode 100644 diff --git a/rest/core/locale/mn.json b/rest/core/locale/mn.json old mode 100755 new mode 100644 diff --git a/rest/core/log.php b/rest/core/log.php old mode 100755 new mode 100644 diff --git a/rest/core/login.php b/rest/core/login.php old mode 100755 new mode 100644 diff --git a/rest/core/logout.php b/rest/core/logout.php old mode 100755 new mode 100644 diff --git a/rest/core/query.php b/rest/core/query.php old mode 100755 new mode 100644 index a61c372f..197f6ae0 --- a/rest/core/query.php +++ b/rest/core/query.php @@ -34,16 +34,16 @@ class Query extends Vn\Web\JsonRequest if ($db->checkWarnings () && ($result = $db->query ('SHOW WARNINGS'))) { - $sql = 'SELECT description, @warn code '. - 'FROM sql_message WHERE code = @warn'; + $sql = 'SELECT `description`, @warn `code` + FROM `message` WHERE `code` = @warn'; - while ($row = $result->fetch_assoc ()) + while ($row = $result->fetch_object ()) { - if ($row['Code'] == 1265 - && ($warning = $db->getRow ($sql))) - trigger_error ("{$warning['code']}: {$warning['description']}", E_USER_WARNING); + if ($row->Code == 1265 + && ($warning = $db->getObject ($sql))) + trigger_error ("{$warning->code}: {$warning->description}", E_USER_WARNING); else - trigger_error ("{$row['Code']}: {$row['Message']}", E_USER_WARNING); + trigger_error ("{$row->Code}: {$row->Message}", E_USER_WARNING); } } @@ -56,7 +56,7 @@ class Query extends Vn\Web\JsonRequest if ($e->getCode () == 1644) { $dbMessage = $e->getMessage (); - $sql = 'SELECT description FROM sql_message WHERE code = #'; + $sql = 'SELECT `description` FROM `message` WHERE `code` = #'; $message = $db->getValue ($sql, [$dbMessage]); if ($message) diff --git a/rest/core/recover-password.php b/rest/core/recover-password.php old mode 100755 new mode 100644 diff --git a/rest/core/set-password.php b/rest/core/set-password.php old mode 100755 new mode 100644 diff --git a/rest/core/supplant.php b/rest/core/supplant.php old mode 100755 new mode 100644 diff --git a/rest/core/sync-user.php b/rest/core/sync-user.php old mode 100755 new mode 100644 diff --git a/rest/dms/add.php b/rest/dms/add.php index 695c1001..13f9a662 100644 --- a/rest/dms/add.php +++ b/rest/dms/add.php @@ -33,7 +33,7 @@ class Add extends Vn\Web\JsonRequest $maxSize = $db->getValue ('SELECT max_size FROM dms_config'); if ($_FILES['doc']['size'] > $maxSize * 1048576) - throw new Lib\UserException (sprintf ('File size exceeds size: %d MB', $maxSize))); + throw new Lib\UserException (sprintf ('File size exceeds size: %d MB', $maxSize)); try { // Registers the document in the database diff --git a/rest/dms/invoice.php b/rest/dms/invoice.php index 78548d38..1b2e9cad 100644 --- a/rest/dms/invoice.php +++ b/rest/dms/invoice.php @@ -2,6 +2,7 @@ use Vn\Web\Security; use Vn\Web\Util; +use Vn\Lib; class Invoice extends Vn\Web\RestRequest { @@ -14,7 +15,7 @@ class Invoice extends Vn\Web\RestRequest ['invoice' => (int) $_GET['invoice']]); if (!$pdfPath) - throw new Exception (s('Invoice id not found')); + throw new Lib\UserException (s('Invoice id not found')); Util::printFile ($pdfPath); } diff --git a/rest/dms/invoice.sql b/rest/dms/invoice.sql index 71e43303..f3249727 100644 --- a/rest/dms/invoice.sql +++ b/rest/dms/invoice.sql @@ -1,5 +1,5 @@ -SELECT CONCAT_WS('/', c.pdfs_dir, invoice_get_path (#invoice)) +SELECT CONCAT_WS('/', c.pdfs_dir, invoiceGetPath(#invoice)) FROM config c JOIN invoice_view i WHERE i.invoice_id = #invoice diff --git a/rest/image/image.php b/rest/image/image.php old mode 100755 new mode 100644 diff --git a/rest/image/locale/en.json b/rest/image/locale/en.json old mode 100755 new mode 100644 diff --git a/rest/image/locale/es.json b/rest/image/locale/es.json old mode 100755 new mode 100644 diff --git a/rest/image/resize.php b/rest/image/resize.php index b5d43f16..a813c25e 100644 --- a/rest/image/resize.php +++ b/rest/image/resize.php @@ -14,10 +14,10 @@ require_once (__DIR__.'/lib.php'); class Resize extends Vn\Lib\Method { const PARAMS = [ - 'src_dir' - ,'dst_dir' - ,'max_height' - ,'max_Width' + 'srcDir' + ,'dstDir' + ,'maxHeight' + ,'maxWidth' ,'rewrite' ,'crop' ,'symbolic' @@ -28,13 +28,13 @@ class Resize extends Vn\Lib\Method $options = getopt ('', $params); - if (!$this->checkParams ($options, self::PARAMS) + if (!$this->checkParams ($options, self::PARAMS)) $this->usage (); - $srcDir = $options['src_dir']; - $dstDir = $options['dst_dir']; - $maxHeight = $options['max_height']; - $maxWidth = $options['max_Width']; + $srcDir = $options['srcDir']; + $dstDir = $options['dstDir']; + $maxHeight = $options['maxHeight']; + $maxWidth = $options['maxWidth']; $rewrite = isset ($options['rewrite']); $crop = isset ($options['crop']); $symbolic = isset ($options['symbolic']); diff --git a/rest/image/thumb.php b/rest/image/thumb.php index 77db5872..2fad4584 100644 --- a/rest/image/thumb.php +++ b/rest/image/thumb.php @@ -52,8 +52,8 @@ class Thumb extends Vn\Web\RestRequest $row = $db->getValue ( 'SELECT crop - FROM image_schema s - JOIN image_schema_size z ON z.image_schema_id = s.id + FROM imageCollection s + JOIN imageCollectionSize z ON z.collectionFk = s.id WHERE s.name = #schema AND z.width = #width AND z.height = #height' @@ -82,7 +82,7 @@ class Thumb extends Vn\Web\RestRequest // Sends the thumb to the client - $useXsendfile = $db->getValue ('SELECT use_xsendfile FROM image_config'); + $useXsendfile = $db->getValue ('SELECT useXsendfile FROM imageConfig'); if ($useXsendfile) { diff --git a/rest/image/upload.php b/rest/image/upload.php old mode 100755 new mode 100644 index 6f81ec07..2d88cf18 --- a/rest/image/upload.php +++ b/rest/image/upload.php @@ -72,7 +72,7 @@ class Upload extends Vn\Web\JsonRequest throw new Lib\Exception (s($message)); } - $maxSize = $db->getValue ('SELECT max_size FROM image_config'); + $maxSize = $db->getValue ('SELECT maxSize FROM imageConfig'); if ($_FILES['image']['size'] > $maxSize * 1048576) throw new UserException (sprintf (s('File size error'), $maxSize)); @@ -86,7 +86,7 @@ class Upload extends Vn\Web\JsonRequest $symbolicSrc = "../full/$fileName"; $image = Image::create ($tmpName); - Image::resizeSave ($image, $fullFile, $info['max_height'], $info['max_width']); + Image::resizeSave ($image, $fullFile, $info['maxHeight'], $info['maxWidth']); foreach ($info['sizes'] as $size => $i) { diff --git a/rest/image/util.php b/rest/image/util.php old mode 100755 new mode 100644 index 7cea4292..a3d2de2b --- a/rest/image/util.php +++ b/rest/image/util.php @@ -26,8 +26,8 @@ class Util $db = $this->app->getSysConn (); $info = $db->getRow ( - 'SELECT id, max_width, max_height, `schema`, `table`, `column` - FROM image_schema WHERE name = #schema' + 'SELECT id, maxWidth, maxHeight, `schema`, `table`, `column` + FROM imageCollection WHERE name = #schema' ,['schema' => $schema] ); @@ -36,7 +36,7 @@ class Util $res = $db->query ( 'SELECT width, height, crop - FROM image_schema_size WHERE image_schema_id = #id' + FROM imageCollectionSize WHERE collectionFk = #id' ,['id' => $info['id']] ); diff --git a/rest/misc/access-version.php b/rest/misc/access-version.php old mode 100755 new mode 100644 diff --git a/rest/misc/contact.php b/rest/misc/contact.php old mode 100755 new mode 100644 index 87109b3b..15d8a87a --- a/rest/misc/contact.php +++ b/rest/misc/contact.php @@ -31,32 +31,32 @@ class Contact extends Vn\Web\JsonRequest //$db->queryFromFile (__DIR__.'/contact', $_REQUEST); //$customerId = $db->getValue ('SELECT @id'); - $conf = $db->getRow ( + $conf = $db->getObject ( 'SELECT m.host, m.port, m.secure, m.sender, m.user, m.password, c.recipient - FROM mail_config m JOIN contact c' + FROM mailConfig m JOIN contact c' ); $mail = new PHPMailer (); $mail->isSMTP (); - $mail->Host = $conf['host']; + $mail->Host = $conf->host; - if (!empty ($conf['user'])) + if (!empty ($conf->user)) { $mail->SMTPAuth = TRUE; - $mail->Username = $conf['user']; - $mail->Password = base64_decode ($conf['password']); + $mail->Username = $conf->user; + $mail->Password = base64_decode ($conf->password); } else $mail->SMTPAuth = FALSE; - if ($conf['secure']) + if ($conf->secure) { $mail->SMTPSecure = 'ssl'; $mail->Port = 465; } - $mail->setFrom ($conf['sender'], 'Web'); - $mail->addAddress ($conf['recipient']); + $mail->setFrom ($conf->sender, 'Web'); + $mail->addAddress ($conf->recipient); $mail->isHTML (TRUE); $mail->Subject = s('New customer request'); $mail->Body = '
'. print_r ($_REQUEST, TRUE) .'
'; diff --git a/rest/misc/exchange-rate.php b/rest/misc/exchange-rate.php old mode 100755 new mode 100644 diff --git a/rest/misc/mail.php b/rest/misc/mail.php old mode 100755 new mode 100644 index c6da11d5..3fb0c6f5 --- a/rest/misc/mail.php +++ b/rest/misc/mail.php @@ -23,7 +23,7 @@ class Mail extends Vn\Lib\Method try { $mail = $mailer->createObject ($row->to, $row->text, $row->subject); - $mail->AddReplyTo ($row->reply_to, $conf->sender_name); + $mail->AddReplyTo ($row->reply_to, $row->reply_to); if (!empty ($row->path)) { @@ -47,7 +47,7 @@ class Mail extends Vn\Lib\Method } $db->query ('UPDATE mail SET sent = #, error = # WHERE id = #', - [$sent, $status, $row['id']]); + [$sent, $status, $row->id]); } $db->query ('COMMIT'); diff --git a/rest/misc/production.php b/rest/misc/production.php new file mode 100644 index 00000000..62ee72b4 --- /dev/null +++ b/rest/misc/production.php @@ -0,0 +1,19 @@ +getObject ( + 'SELECT displayText FROM vn.routeGate WHERE deviceId = #', + [$_REQUEST['deviceId']] + ); + + if (!isset($row)) + throw new Vn\Lib\UserException ('Device not found'); + + return $row->displayText; + } +} diff --git a/rest/misc/sms.php b/rest/misc/sms.php index 17f000cc..9361a94c 100644 --- a/rest/misc/sms.php +++ b/rest/misc/sms.php @@ -5,45 +5,49 @@ use Vn\Lib; class Sms extends Vn\Web\JsonRequest { const PARAMS = [ - 'to' - ,'text' + 'destination' + ,'message' + ]; + + const OK_STATES = [ + 0, // Ok + 200 // Processing ]; function run ($db) { - $smsConfig = $db->getRow ('SELECT uri, user, password, title FROM sms_config'); + $smsConfig = $db->getObject ('SELECT uri, user, password, title FROM vn.smsConfig'); - $sClient = new SoapClient ($smsConfig['uri']); + $sClient = new SoapClient ($smsConfig->uri); $xmlString = $sClient->sendSMS ( - $smsConfig['user'] - ,$smsConfig['password'] - ,$smsConfig['title'] - ,$_REQUEST['to'] - ,$_REQUEST['text'] + $smsConfig->user + ,$smsConfig->password + ,$smsConfig->title + ,$_REQUEST['destination'] + ,$_REQUEST['message'] ); $xmlResponse = new SimpleXMLElement ($xmlString); + $res = $xmlResponse->sms; - $customer = empty ($_REQUEST['customer']) ? NULL : $_REQUEST['customer']; + $db->query ( + 'INSERT INTO vn.sms SET + `senderFk` = account.userGetId(), + `destinationFk` = #, + `destination` = #, + `message` = #, + `statusCode` = #, + `status` = #', + [ + empty ($_REQUEST['destinationId']) ? NULL : $_REQUEST['destinationId'] + ,$_REQUEST['destination'] + ,$_REQUEST['message'] + ,$res->codigo + ,$res->descripcion + ] + ); - try { - $sms = $xmlResponse->sms; - $db->query ( - 'INSERT INTO vn2008.sms (Id_trabajador, `text`, `to`, `from`, sent, response, Id_Cliente) - VALUES (account.userGetId(), #, #, #, #, #, #)', - [ - $_REQUEST['text'] - ,$_REQUEST['to'] - ,$_REQUEST['to'] - ,$sms->codigo - ,$sms->descripcion - ,$customer - ] - ); - } - catch (Exception $e) - { - trigger_error ($e->getMessage (), E_USER_WARNING); - } + if (!in_array ((int) $res->codigo, self::OK_STATES)) + throw new Lib\UserException ($res->descripcion); return TRUE; } diff --git a/rest/tpv/confirm-mail.php b/rest/tpv/confirm-mail.php index 0c9f1bf4..dbbb8255 100644 --- a/rest/tpv/confirm-mail.php +++ b/rest/tpv/confirm-mail.php @@ -10,17 +10,17 @@ class ConfirmMail extends Vn\Lib\Method function run ($db) { $imap = NULL; - $imapConf = $db->getRow ( - 'SELECT host, user, pass, clean_period, success_folder, error_folder - FROM tpv_imap_config' + $imapConf = $db->getObject ( + 'SELECT host, user, pass, cleanPeriod, successFolder, errorFolder + FROM tpvImapConfig' ); $mailbox = sprintf ('{%s/imap/ssl/novalidate-cert}', - $imapConf['host']); + $imapConf->host); $imap = imap_open ($mailbox - ,$imapConf['user'] - ,base64_decode ($imapConf['pass']) + ,$imapConf->user + ,base64_decode ($imapConf->pass) ); if (!$imap) @@ -61,9 +61,9 @@ class ConfirmMail extends Vn\Lib\Method // Moves the processed mail to another folder if ($success) - $folder = $imapConf['success_folder']; + $folder = $imapConf->successFolder; else - $folder = $imapConf['error_folder']; + $folder = $imapConf->errorFolder; if (!imap_mail_move ($imap, $msg, "$folder")) trigger_error (imap_last_error (), E_USER_WARNING); @@ -80,12 +80,12 @@ class ConfirmMail extends Vn\Lib\Method if (rand (1, 20) == 1) { $folders = array ( - $imapConf['success_folder'] - ,$imapConf['error_folder'] + $imapConf->successFolder + ,$imapConf->errorFolder ); $date = new \DateTime (NULL); - $date->sub (new \DateInterval ($imapConf['clean_period'])); + $date->sub (new \DateInterval ($imapConf->cleanPeriod)); $filter = sprintf ('BEFORE "%s"', $date->format('D, j M Y')); foreach ($folders as $folder) diff --git a/rest/tpv/confirm-soap.php b/rest/tpv/confirm-soap.php index 06eeb900..5126ad88 100644 --- a/rest/tpv/confirm-soap.php +++ b/rest/tpv/confirm-soap.php @@ -50,7 +50,7 @@ function procesaNotificacionSIS ($XML) $shaString = substr ($requestString, $start, $end - $start + 10); $key = $db->getValue ( - 'SELECT secret_key FROM tpv_merchant WHERE id = #' + 'SELECT secretKey FROM tpvMerchant WHERE id = #' ,[$params['Ds_MerchantCode']] ); diff --git a/rest/tpv/tpv.php b/rest/tpv/tpv.php old mode 100755 new mode 100644 index 9907e77b..5b4e35f5 --- a/rest/tpv/tpv.php +++ b/rest/tpv/tpv.php @@ -20,7 +20,7 @@ class Tpv $error = NULL; return $db->query ( - 'CALL transactionConfirm (#, #, #, #, #, #)', + 'CALL tpvTransactionConfirm (#, #, #, #, #, #)', [ $params['Ds_Amount'] ,$params['Ds_Order'] diff --git a/rest/tpv/transaction.php b/rest/tpv/transaction.php old mode 100755 new mode 100644 index 0cdb1c00..293edf65 --- a/rest/tpv/transaction.php +++ b/rest/tpv/transaction.php @@ -12,7 +12,7 @@ class Transaction extends Vn\Web\JsonRequest $amount = (int) $_REQUEST['amount']; $companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company']; - $row = $db->getObject ('CALL transactionStart (#, #)', + $row = $db->getObject ('CALL tpvTransactionStart (#, #)', [$amount, $companyId]); if (!isset ($row)) @@ -58,4 +58,3 @@ class Transaction extends Vn\Web\JsonRequest ]; } } - diff --git a/utils/extract-locale.js b/utils/extract-locale.js new file mode 100644 index 00000000..620f900b --- /dev/null +++ b/utils/extract-locale.js @@ -0,0 +1,87 @@ +var glob = require('glob'); +var fs = require('fs-extra'); +var path = require('path'); +var archiver = require('archiver'); + +let lang = process.argv[2]; + +if (lang == null) +{ + let baseName = path.basename(process.argv[1]); + console.log(`Usage: ${baseName} language_code`); + process.exit(1); +} + +let nTasks; +let projectDir; + +fs.remove(lang, () => { + fs.realpath(`${__dirname}/..`, (err, realPath) => { + projectDir = realPath; + let len = projectDir.length + 1; + + glob(`${projectDir}/**/locale/`, (err, localeDirs) => { + for (let localeDir of localeDirs) { + localeDir = localeDir.substr(len) + + if (/^node_modules\//.test (localeDir)) + continue; + + exportLocale(localeDir); + } + + nTasks = localeDirs.length; + }); + }); +}); + +function exportLocale (localeDir) { + let dstDir = `${lang}/${localeDir}`; + + fs.mkdirp(dstDir, err => { + if (err) { + console.log(err); + onTaskEnd(); + return; + } + + let src, dst; + + src = `${projectDir}/${localeDir}/en.json`; + dst = `${dstDir}/en.json`; + fs.copy(src, dst, onTaskEnd); + + src = `${projectDir}/${localeDir}/${lang}.json`; + dst = `${dstDir}/${lang}.json`; + fs.copy(src, dst, onTaskEnd); + + nTasks += 2; + onTaskEnd(); + }); +} + +let output; +let archive; + +function onTaskEnd() { + nTasks--; + if (nTasks > 0) return; + + output = fs.createWriteStream(`${lang}.zip`); + output.on ('close', onArchiveClose); + + archive = archiver('zip', { + zlib: { level: 9 } + }); + archive.on ('error', err => { + throw err; + }); + archive.pipe(output); + archive.directory(lang); + archive.finalize(); +} + +function onArchiveClose() { + fs.remove(lang); + console.log ('Export finalized!'); +} diff --git a/web/db-session-handler.php b/web/db-session-handler.php old mode 100755 new mode 100644 diff --git a/web/html-service.php b/web/html-service.php index 1600ee7d..1497e8b0 100644 --- a/web/html-service.php +++ b/web/html-service.php @@ -2,8 +2,6 @@ namespace Vn\Web; -require_once __DIR__.'/html.php'; - use Vn\Lib\Locale; /** @@ -92,6 +90,7 @@ class HtmlService extends Service $this->printHeader (); $dir = $basePath; + include_once __DIR__.'/html.php'; include ("./$basePath/ui.php"); } else diff --git a/web/html.php b/web/html.php index 5f1df6dc..f18b6e1b 100644 --- a/web/html.php +++ b/web/html.php @@ -1,13 +1,16 @@ getVersion(); + function getUrl ($fileName) { if (file_exists ($fileName)) - $mTime = '?'. strftime ('%G%m%d%H%M%S', filemtime ($fileName)); + $fileVersion = strftime ('%G%m%d%H%M%S', filemtime ($fileName)); else - $mTime = '?'. $this->getVersion (); + $fileVersion = $version; - return $fileName.$mTime; + return "$fileName?$fileVersion"; } function js ($fileName) diff --git a/web/json-exception.php b/web/json-exception.php old mode 100755 new mode 100644 diff --git a/web/json-reply.php b/web/json-reply.php old mode 100755 new mode 100644 diff --git a/web/jwt.php b/web/jwt.php old mode 100755 new mode 100644 diff --git a/web/locale/en.json b/web/locale/en.json old mode 100755 new mode 100644 diff --git a/web/locale/es.json b/web/locale/es.json old mode 100755 new mode 100644 diff --git a/web/mailer.php b/web/mailer.php old mode 100755 new mode 100644 index 0b6b5f20..aeaba74c --- a/web/mailer.php +++ b/web/mailer.php @@ -13,8 +13,8 @@ class Mailer function __construct ($db) { $this->conf = $db->getObject ( - 'SELECT host, port, secure, sender, sender_name, user, password - FROM hedera.mail_config' + 'SELECT host, port, secure, sender, senderName, user, password + FROM hedera.mailConfig' ); } @@ -41,7 +41,7 @@ class Mailer $mail->Port = 465; } - $mail->setFrom ($conf->sender, $conf->sender_name); + $mail->setFrom ($conf->sender, $conf->senderName); $mail->IsHTML (TRUE); $mail->Subject = $subject; $mail->Body = $body; diff --git a/web/report.php b/web/report.php old mode 100755 new mode 100644 diff --git a/web/service.php b/web/service.php old mode 100755 new mode 100644 index a74d4193..14fc9093 --- a/web/service.php +++ b/web/service.php @@ -87,7 +87,8 @@ abstract class Service if (isset ($_COOKIE['PHPSESSID']) || isset ($_SESSION['access']) - || isset ($_SESSION['skipVisit'])) + || isset ($_SESSION['skipVisit']) + || !isset ($_SERVER['HTTP_USER_AGENT'])) return; $agent = $_SERVER['HTTP_USER_AGENT']; diff --git a/web/unavailable.html b/web/unavailable.html old mode 100755 new mode 100644 diff --git a/webpack.config.js b/webpack.config.js index e3a19003..9139ef47 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,12 @@ -var path = require ('path'); -var webpack = require ('webpack'); -var AssetsWebpackPlugin = require ('assets-webpack-plugin'); -var WebpackChunkHash = require ('webpack-chunk-hash'); -var merge = require ('webpack-merge'); -var wpConfig = require ('./webpack.config.json'); +var path = require('path'); +var webpack = require('webpack'); +var AssetsWebpackPlugin = require('assets-webpack-plugin'); +var WebpackChunkHash = require('webpack-chunk-hash'); +var merge = require('webpack-merge'); +var wpConfig = require('./webpack.config.json'); var devMode = process.env.NODE_ENV !== 'production'; -var outputPath = path.join (__dirname, wpConfig.buildDir); +var outputPath = path.join(__dirname, wpConfig.buildDir); var publicPath = wpConfig.buildDir +'/'; var baseConfig = { @@ -34,12 +34,12 @@ var baseConfig = { __dirname: true }, plugins: [ - new webpack.DefinePlugin ({ + new webpack.DefinePlugin({ _DEV_MODE: devMode, _DEV_SERVER_PORT: wpConfig.devServerPort, _PUBLIC_PATH: JSON.stringify (publicPath) }), - new webpack.optimize.CommonsChunkPlugin ({ + new webpack.optimize.CommonsChunkPlugin({ names: ['vendor', 'manifest'] }) ], @@ -54,15 +54,15 @@ var prodConfig = { chunkFilename: 'chunk.[id].[chunkhash].js' }, plugins: [ - new webpack.optimize.UglifyJsPlugin ({ + new webpack.optimize.UglifyJsPlugin({ minimize: true, compress: { warnings: false } }), - new AssetsWebpackPlugin ({ + new AssetsWebpackPlugin({ path: outputPath }), - new webpack.HashedModuleIdsPlugin (), - new WebpackChunkHash () + new webpack.HashedModuleIdsPlugin(), + new WebpackChunkHash() ], devtool: 'source-map' }; @@ -73,7 +73,7 @@ var devConfig = { chunkFilename: 'chunk.[id].js' }, plugins: [ - new webpack.NamedModulesPlugin () + new webpack.NamedModulesPlugin() ], devServer: { host: '0.0.0.0', @@ -85,4 +85,4 @@ var devConfig = { }; var mrgConfig = devMode ? devConfig : prodConfig; -module.exports = merge (baseConfig, mrgConfig); +module.exports = merge(baseConfig, mrgConfig);