Iconos de imagenes redondos, filtro de catalogo

This commit is contained in:
Juan Ferrer Toribio 2015-08-27 16:04:34 +02:00
parent d52a8a090d
commit 9309cb51b3
17 changed files with 129 additions and 43 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.201-1) stable; urgency=low hedera-web (1.205-1) stable; urgency=low
* Initial Release. * Initial Release.

2
debian/cron.d vendored
View File

@ -1,2 +1,2 @@
MAILTO=webmaster MAILTO=webmaster
*/4 * * * * root cd /usr/share/hedera-web/tpv && php5 imap.php */4 * * * * www-data php5 /usr/share/hedera-web/tpv/imap.php

View File

@ -4,7 +4,6 @@ namespace Vn;
require_once ('vn/hedera/init.php'); require_once ('vn/hedera/init.php');
require_once ('vn/db/db.php'); require_once ('vn/db/db.php');
require_once ('vn/lib/log.php');
require_once ('vn/tpv/soap-method.php'); require_once ('vn/tpv/soap-method.php');
use Vn\Lib\Log; use Vn\Lib\Log;
@ -20,6 +19,9 @@ class Tpv
{ {
global $conf; global $conf;
ini_set ('log_errors', TRUE);
ini_set ('error_log', Hedera\_LOG_DIR .'/hedera-web.log');
self::$conn = new Db\Conn (); self::$conn = new Db\Conn ();
self::$conn->open ( self::$conn->open (
$conf['db']['host'] $conf['db']['host']
@ -42,7 +44,6 @@ class Tpv
**/ **/
static function getFromMailbox () static function getFromMailbox ()
{ {
Log::init (Hedera\_LOG_DIR .'/hedera-web.log');
self::init (); self::init ();
$imap = NULL; $imap = NULL;
@ -101,14 +102,14 @@ class Tpv
$folder = sprintf ('INBOX.%s', $folder); $folder = sprintf ('INBOX.%s', $folder);
if (!imap_mail_move ($imap, $msg, $folder)) if (!imap_mail_move ($imap, $msg, $folder))
Log::write ('TPV: IMAP: Can\'t move message to %s: %s' error_log ('TPV: IMAP: Can\'t move message to %s: %s'
,$folder ,$folder
,imap_last_error () ,imap_last_error ()
); );
} }
if ($inbox && ($count = count ($inbox)) > 0) if ($inbox && ($count = count ($inbox)) > 0)
Log::write ('TPV: %d mails processed.', $count); error_log ('TPV: %d mails processed.', $count);
imap_expunge ($imap); imap_expunge ($imap);
@ -137,16 +138,15 @@ class Tpv
$deleted += count ($messages); $deleted += count ($messages);
} }
Log::write ('TPV: Cleaner: %d mails deleted.', $deleted); error_log ('TPV: Cleaner: %d mails deleted.', $deleted);
} }
imap_close ($imap); imap_close ($imap);
} }
else else
Log::write ('TPV: IMAP: %s', imap_last_error ()); error_log ('TPV: IMAP: %s', imap_last_error ());
self::deinit (); self::deinit ();
Log::close ();
} }
/** /**
@ -207,7 +207,7 @@ class Tpv
} }
catch (\Exception $e) catch (\Exception $e)
{ {
Log::write ("TPV: DB: %s", $e->getMessage ()); error_log ("TPV: DB: %s", $e->getMessage ());
} }
} }

View File

@ -30,6 +30,11 @@ Vn.Basket = new Class
this.hash.set ({'form': 'ecomerce/checkout'}); this.hash.set ({'form': 'ecomerce/checkout'});
} }
,onCatalogClick: function ()
{
this.hash.set ({'form': 'ecomerce/catalog'});
}
,onCheckoutClick: function () ,onCheckoutClick: function ()
{ {
this.hash.set ({'form': 'ecomerce/confirm'}); this.hash.set ({'form': 'ecomerce/confirm'});

View File

@ -21,6 +21,10 @@
color: white; color: white;
text-align: right; text-align: right;
} }
.basket .config
{
margin: 0;
}
/* Rows */ /* Rows */
@ -28,4 +32,12 @@
{ {
background-color: #FCC; background-color: #FCC;
} }
.basket .icon
{
width: 8em;
}
.basket .icon > img
{
border-radius: 50%;
}

View File

@ -4,9 +4,12 @@
<div class="header"> <div class="header">
<h1><t>ShoppingBasket</t></h1> <h1><t>ShoppingBasket</t></h1>
<div class="action-bar"> <div class="action-bar">
<button on-click="onConfigureClick"> <button on-click="onConfigureClick" title="_ConfigureOrder">
<img src="image/dark/preferences.svg" alt=""/> <img class="config" src="image/dark/preferences.svg" alt=""/>
<t>ConfigureOrder</t> </button>
<button on-click="onCatalogClick">
<img src="image/dark/menu.svg" alt=""/>
<t>Catalog</t>
</button> </button>
<button on-click="onCheckoutClick"> <button on-click="onCheckoutClick">
<img src="image/dark/ok.svg" alt=""/> <img src="image/dark/ok.svg" alt=""/>
@ -24,7 +27,13 @@
INNER JOIN vn2008.Articles a ON a.Id_Article = i.item_id INNER JOIN vn2008.Articles a ON a.Id_Article = i.item_id
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id; LEFT JOIN vn2008.Origen o ON a.id_origen = o.id;
</db-model> </db-model>
<htk-column-image column="Foto" directory="catalog" subdir="50x50" show-full="true"/> <htk-column-image
column="Foto"
directory="catalog"
subdir="50x50"
show-full="true"
full-dir="900x900"
class="icon"/>
<htk-column-text title="_Item" column="Article"/> <htk-column-text title="_Item" column="Article"/>
<htk-column-text renderer="featuresRender"/> <htk-column-text renderer="featuresRender"/>
<htk-column-text title="_Amount" column="amount" renderer="stemsRender"/> <htk-column-text title="_Amount" column="amount" renderer="stemsRender"/>

View File

@ -103,7 +103,7 @@ Vn.Catalog = new Class
,onSearch: function (event) ,onSearch: function (event)
{ {
var searchTags = this.$('search-entry').value; var searchTags = this.$('search-entry').value;
searchTags = searchTags != '' ? searchTags : null; searchTags = searchTags != '' ? searchTags : undefined;
var batch = this.$('batch'); var batch = this.$('batch');
batch.block (); batch.block ();
@ -112,8 +112,8 @@ Vn.Catalog = new Class
if (searchTags) if (searchTags)
{ {
this.$('type').value = null; this.$('type').value = undefined;
this.$('realm').value = null; this.$('realm').value = undefined;
} }
batch.unblock (); batch.unblock ();
@ -189,7 +189,7 @@ Vn.Catalog = new Class
var itemId = this.$('items-model').get (row, 'item_id') var itemId = this.$('items-model').get (row, 'item_id')
this.$('lots-batch').addValue ('item', itemId); this.$('lots-batch').addValue ('item', itemId);
this.itemId = itemId; this.itemRow = row;
this.onEraseClick (); this.onEraseClick ();
this.popup.show (button); this.popup.show (button);
} }
@ -224,21 +224,33 @@ Vn.Catalog = new Class
,onConfirmClick: function () ,onConfirmClick: function ()
{ {
var model = this.$('items-model');
var sql = ''; var sql = '';
var batch = new Sql.Batch (); var batch = new Sql.Batch ();
var query = new Sql.String ({query: 'CALL basket_item_add (#warehouse, #item, #amount);'}); var query = new Sql.String ({query: 'CALL basket_item_add (#warehouse, #item, #amount);'});
var amountSum = 0;
for (var warehouse in this.items) for (var warehouse in this.items)
{ {
var amount = this.items[warehouse];
amountSum += amount;
batch.addValue ('warehouse', warehouse); batch.addValue ('warehouse', warehouse);
batch.addValue ('item', this.itemId); batch.addValue ('item', model.get (this.itemRow, 'item_id'));
batch.addValue ('amount', this.items[warehouse]); batch.addValue ('amount', amount);
sql += query.render (batch); sql += query.render (batch);
} }
if (sql != '') if (amountSum > 0)
{
this.conn.execQuery (sql); this.conn.execQuery (sql);
var itemName = model.get (this.itemRow, 'Article');
Htk.Toast.showMessage (
sprintf (_('Added%dOf%s'), amountSum, itemName));
}
this.popup.hide (); this.popup.hide ();
} }

View File

@ -242,8 +242,15 @@ button.confirm > img
} }
.items > tbody img .items > tbody img
{ {
max-height: 5em; max-height: 6em;
max-width: 5em; max-width: 6em;
border-radius: 50%;
}
.items .icon
{
width: 6em;
padding: .2em;
padding-right: .5em;
} }
td.second-category td.second-category
{ {

View File

@ -22,26 +22,31 @@
FROM basket_item FROM basket_item
GROUP BY warehouse_id GROUP BY warehouse_id
</db-query> </db-query>
<db-model result-index="1" id="items-model"> <db-model result-index="2" id="items-model">
CALL bionic_from_type (#type); CREATE TEMPORARY TABLE tmp.bionic_calc
(INDEX (item_id))
ENGINE=MEMORY
SELECT Id_Article item_id FROM vn2008.Articles
WHERE #filter
LIMIT 400;
CALL bionic_calc ();
SELECT t.item_id, t.available, t.price, SELECT t.item_id, t.available, t.price,
a.Foto, a.Article, a.Categoria, a.Medida, a.Tallos, a.Color, o.Abreviatura a.Foto, a.Article, a.Categoria, a.Medida, a.Tallos, a.Color, o.Abreviatura
FROM vn2008.t_bionic_item t FROM tmp.bionic_item t
JOIN vn2008.Articles a ON a.Id_Article = t.item_id JOIN vn2008.Articles a ON a.Id_Article = t.item_id
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id LEFT JOIN vn2008.Origen o ON a.id_origen = o.id
WHERE t.available > 0 WHERE t.available > 0
ORDER BY a.Article, a.Medida ORDER BY a.Article, a.Medida;
LIMIT 400;
<sql-batch property="batch" id="batch"> <sql-batch property="batch" id="batch">
<item name="type" param="type"/> <item name="filter" object="filter"/>
</sql-batch> </sql-batch>
</db-model> </db-model>
<db-model id="item-lots" result-index="1" on-status-changed-after="onStatusChange"> <db-model id="item-lots" result-index="1" on-status-changed-after="onStatusChange">
CALL bionic_from_item (#item); CALL bionic_from_item (#item);
SELECT p.warehouse_id, p.grouping, p.price, p.rate, SELECT p.warehouse_id, p.grouping, p.price, p.rate,
t.amount, l.available - IFNULL(t.amount, 0) available t.amount, l.available - IFNULL(t.amount, 0) available
FROM vn2008.t_bionic_lot l FROM tmp.bionic_lot l
JOIN vn2008.t_bionic_price p JOIN tmp.bionic_price p
ON p.warehouse_id = l.warehouse_id ON p.warehouse_id = l.warehouse_id
LEFT JOIN ( LEFT JOIN (
SELECT warehouse_id, SUM(amount) amount SELECT warehouse_id, SUM(amount) amount
@ -74,6 +79,7 @@
<htk-grid empty-message="_SelectSubtype" id="items-grid" class="items" model="items-model"> <htk-grid empty-message="_SelectSubtype" id="items-grid" class="items" model="items-model">
<htk-column-image <htk-column-image
title="*" title="*"
class="icon"
column="Foto" column="Foto"
directory="catalog" directory="catalog"
subdir="200x200" subdir="200x200"

View File

@ -19,15 +19,19 @@ Vn.Checkout = new Class
if (!(orderForm.ready && defaultsForm.ready)) if (!(orderForm.ready && defaultsForm.ready))
return; return;
var date;
if (orderForm.numRows > 0) if (orderForm.numRows > 0)
{ {
var i = orderForm; var i = orderForm;
var date = i.get ('date_send'); date = i.get ('date_send');
} }
else else
{
var i = defaultsForm; var i = defaultsForm;
var date = new Date ();
if (!date || date.getTime () < (new Date ()).getTime ())
{
date = new Date ();
if (i.get('delivery_method') != 'PICKUP') if (i.get('delivery_method') != 'PICKUP')
date.setTime (date.getTime () + 86400000); date.setTime (date.getTime () + 86400000);

View File

@ -450,8 +450,8 @@ img.icon
} }
.htk-grid > tbody td .htk-grid > tbody td
{ {
padding-right: 0.7em; margin: 0;
padding-left: 0.3em; padding: 0 0.5em;
} }
.htk-grid > tbody td:first-child, .htk-grid > tbody td:first-child,
.htk-grid > thead th:first-child .htk-grid > thead th:first-child
@ -483,11 +483,15 @@ img.icon
.cell-button img .cell-button img
{ {
height: 1.5em; height: 1.5em;
display: block;
margin: auto;
} }
.cell-image > img .cell-image > img
{ {
max-width: 2.5em; max-width: 2.5em;
max-height: 2.5em; max-height: 2.5em;
display: block;
margin: auto;
} }
/* Repater */ /* Repater */

View File

@ -65,7 +65,13 @@ Htk.ColumnImage = new Class
,render: function (tr) ,render: function (tr)
{ {
var td = this.parent (tr); var td = this.parent (tr);
td.className = 'cell-image';
var className = 'cell-image';
if (td.className)
className = td.className +' '+ className;
td.className = className;
var img = document.createElement ('img'); var img = document.createElement ('img');
img.alt = '' img.alt = ''

View File

@ -46,3 +46,18 @@ Vn.Value =
return value; return value;
} }
}; };
function sprintf (formatString)
{
var args = arguments;
if (args.length <= 1)
return formatString;
var i = 1;
return formatString.replace (/%[s|d]/g, function ()
{
return args[i++];
});
}

View File

@ -6,7 +6,6 @@
,"SelectSubtype": "Selecciona un subtipus en el menú de la dreta" ,"SelectSubtype": "Selecciona un subtipus en el menú de la dreta"
,"ArticleNotFound": "Artcle no trobat" ,"ArticleNotFound": "Artcle no trobat"
,"ArticleNotAvailable": "Article no disponible" ,"ArticleNotAvailable": "Article no disponible"
,"NoMoreAmountAvailable": "No hi ha més quantitat disponible"
,"StartOrder": "Començar encàrrec" ,"StartOrder": "Començar encàrrec"
,"ShoppingBasket": "Cistella de la compra" ,"ShoppingBasket": "Cistella de la compra"
@ -36,4 +35,7 @@
,"Confirm": "Confirmar" ,"Confirm": "Confirmar"
,"IndicativePhotos": "* Les fotos són orientatives" ,"IndicativePhotos": "* Les fotos són orientatives"
,"Added%dOf%s": "Afegits %d de %s"
,"NoMoreAmountAvailable": "No hi ha més quantitat disponible"
} }

View File

@ -6,7 +6,6 @@
,"SelectSubtype": "Selecciona un subtipo en el menú de la derecha" ,"SelectSubtype": "Selecciona un subtipo en el menú de la derecha"
,"ArticleNotFound": "Artículo no encontrado" ,"ArticleNotFound": "Artículo no encontrado"
,"ArticleNotAvailable": "Artículo no disponible" ,"ArticleNotAvailable": "Artículo no disponible"
,"NoMoreAmountAvailable": "No hay más cantidad disponible"
,"StartOrder": "Empezar pedido" ,"StartOrder": "Empezar pedido"
,"ShoppingBasket": "Cesta de la compra" ,"ShoppingBasket": "Cesta de la compra"
@ -36,4 +35,7 @@
,"Confirm": "Confirmar" ,"Confirm": "Confirmar"
,"IndicativePhotos": "* Las fotos son orientativas" ,"IndicativePhotos": "* Las fotos son orientativas"
,"Added%dOf%s": "Añadidos %d de %s"
,"NoMoreAmountAvailable": "No hay más cantidad disponible"
} }

View File

@ -6,7 +6,6 @@
,"SelectSubtype": "Sélectionnez le sous-menu sur la droite" ,"SelectSubtype": "Sélectionnez le sous-menu sur la droite"
,"ArticleNotFound": "Article pas trouvé" ,"ArticleNotFound": "Article pas trouvé"
,"ArticleNotAvailable": "Article pas disponible" ,"ArticleNotAvailable": "Article pas disponible"
,"NoMoreAmountAvailable": "Pas plus de quantité disponible"
,"StartOrder": "Acheter" ,"StartOrder": "Acheter"
,"ShoppingBasket": "Mon panier" ,"ShoppingBasket": "Mon panier"
@ -36,4 +35,7 @@
,"Confirm": "Confirmer" ,"Confirm": "Confirmer"
,"IndicativePhotos": "* Photos sont indicatifs" ,"IndicativePhotos": "* Photos sont indicatifs"
,"Added%dOf%s": "Ajouté %d %s"
,"NoMoreAmountAvailable": "Pas plus de quantité disponible"
} }