0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2017-10-16 09:58:12 +02:00
parent 125686307f
commit e178c74f25
9 changed files with 85 additions and 76 deletions

View File

@ -18,7 +18,7 @@ Hedera.Catalog = new Class
if (!localStorage.getItem ('hederaGuest'))
{
Hedera.BasketChecker.check (this.conn, this.params,
Hedera.BasketChecker.check (this.conn, this.hash,
this.onBasketCheck.bind (this));
}
else
@ -46,6 +46,7 @@ Hedera.Catalog = new Class
this.onRealmChange ();
this.refreshTitle ();
this.onParamsChange ();
}
,deactivate: function ()
@ -108,28 +109,26 @@ Hedera.Catalog = new Class
this.hideMenu ();
}
,onLotChange: function ()
,onParamsChange: function ()
{
function shouldRefresh (params)
{
return params.search ||
params.realm && (
params.type ||
params.color ||
params.origin ||
params.category ||
params.producer
);
}
var params = this.params.$;
var shouldRefresh = params.search ||
params.realm && (
params.type ||
params.color ||
params.origin ||
params.category ||
params.producer
);
function refreshItems ()
if (shouldRefresh)
{
this.$('items').refresh ();
}
var filterSql = this.$('filter').render (params);
var modelParams = {
filter: new Sql.String ({query: filterSql})
};
this.$('items').refresh (modelParams);
if (shouldRefresh (this.params.$))
{
refreshItems ();
this.hideMenu ();
this.$('order').style.display = 'block';
}

View File

@ -275,15 +275,15 @@
position: relative;
width: 100%;
margin: 0;
height: 5.5em;
height: 6.5em;
overflow: visible;
border-bottom: 1px solid #DDD;
}
.list-view .item-box > .htk-image
{
margin: 1em;
width: 3.5em;
height: 3.5em;
width: 4.5em;
height: 4.5em;
float: left;
overflow: hidden;
}
@ -294,7 +294,7 @@
.list-view .item-info
{
position: absolute;
left: 5.5em;
left: 6.5em;
right: 0;
top: 0;
bottom: 0;

View File

@ -1,6 +1,6 @@
<vn>
<vn-group>
<vn-lot-query id="params" on-change="onLotChange">
<vn-lot-query id="params" on-change="onParamsChange">
<vn-spec name="realm" type="Number"/>
<vn-spec name="type" type="Number"/>
<vn-spec name="search" type="String"/>
@ -41,8 +41,6 @@
<db-model
id="items"
result-index="2"
filter="filter"
lot="lot"
auto-load="false">
CREATE TEMPORARY TABLE tmp.bionic_calc
(INDEX (item_id))
@ -151,6 +149,9 @@
<p class="producer">
<htk-text lot="item" name="producer"/>
</p>
<p>
<htk-text lot="item" name="item_id"/>
</p>
<p>
<t>Size</t> <htk-text lot="item" name="Medida"/>,
<t>Category</t> <htk-text lot="item" name="Categoria"/>
@ -211,44 +212,6 @@
<div class="clear"/>
</div>
</div>
<div id="order" class="order">
<h2><t>Order by</t></h2>
<select on-change="onOrderChange">
<option value="D|relevancy" selected="true">
<t>Relevancy</t>
</option>
<option value="A|Article">
<t>Name</t>
</option>
<option value="A|price">
<t>Lower price</t>
</option>
<option value="D|price">
<t>Higher price</t>
</option>
<option value="A|available">
<t>Available</t>
</option>
<option value="A|Medida">
<t>Lower size</t>
</option>
<option value="D|Medida">
<t>Higher size</t>
</option>
<option value="A|color">
<t>Color</t>
</option>
<option value="A|producer">
<t>Producer</t>
</option>
<option value="A|Abreviatura">
<t>Origin</t>
</option>
<option value="A|Categoria">
<t>Category</t>
</option>
</select>
</div>
<div id="realm-msg" class="realm-msg">
<h1><t>Choose a realm</t></h1>
</div>
@ -342,6 +305,44 @@
</db-model>
</vn-filter>
</div>
<div id="order" class="order">
<h2><t>Order by</t></h2>
<select on-change="onOrderChange">
<option value="D|relevancy" selected="true">
<t>Relevancy</t>
</option>
<option value="A|Article">
<t>Name</t>
</option>
<option value="A|price">
<t>Lower price</t>
</option>
<option value="D|price">
<t>Higher price</t>
</option>
<option value="A|available">
<t>Available</t>
</option>
<option value="A|Medida">
<t>Lower size</t>
</option>
<option value="D|Medida">
<t>Higher size</t>
</option>
<option value="A|color">
<t>Color</t>
</option>
<option value="A|producer">
<t>Producer</t>
</option>
<option value="A|Abreviatura">
<t>Origin</t>
</option>
<option value="A|Categoria">
<t>Category</t>
</option>
</select>
</div>
</div>
</div>
<htk-popup id="desc-popup">

View File

@ -47,6 +47,9 @@ Connection.implement
*/
,execSql: function (sql, callback)
{
if (enableDebug)
console.log (sql);
this.send ('core/query', {'sql': sql},
this._onExec.bind (this, callback));
}

View File

@ -22,6 +22,6 @@ module.exports =
if (callback)
callback (isOk);
if (!isOk)
this.hash.setAll ({'form': 'ecomerce/checkout'});
this.hash.$ = {form: 'ecomerce/checkout'};
}
};

View File

@ -40,7 +40,8 @@ module.exports = new Class
builder.add ('hash', this.hash);
builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
var res = this.builderResultInit (builder);
var res = this.builder = builder.load ();
this._node = res.$('main');
var paramsLot = res.$('params');
@ -50,6 +51,8 @@ module.exports = new Class
this.params = paramsLot;
}
res.link ();
var models = res.getByTagName ('db-model');
for (var i = 0; i < models.length; i++)
@ -79,10 +82,10 @@ module.exports = new Class
if (this.node)
{
this.deactivate ();
this.builder.unref ();
this.gui.setTitle (null);
this.gui.setActions (null);
this.gui.setForm (null);
this.deactivate ();
this.node = null;
this.params = null;
}

View File

@ -55,6 +55,7 @@ module.exports = new Class
throw new Error ('VnLotQuery: Child must be a Vn.Spec instance');
this._specs[child.name] = child;
this._onSourceChange ();
}
,_onSourceChange: function ()

View File

@ -3,6 +3,8 @@ require ('mootools');
require ('./mutators');
require ('./polyfills');
enableDebug = false;
Vn = module.exports = {
Locale : require ('./locale')
,Enum : require ('./enum')

View File

@ -12,24 +12,24 @@ class Transaction extends Vn\Web\JsonRequest
$amount = (int) $_REQUEST['amount'];
$companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company'];
$row = $db->getRow ('CALL transactionStart (#, #)',
$row = $db->getObject ('CALL transactionStart (#, #)',
[$amount, $companyId]);
if (!isset ($row))
throw new Exception ('Transaction error');
$transactionId = str_pad ($row['transactionId'], 12, '0', STR_PAD_LEFT);
$transactionId = str_pad ($row->transactionId, 12, '0', STR_PAD_LEFT);
$urlOk = empty ($_REQUEST['urlOk']) ? '' : sprintf ($_REQUEST['urlOk'], $transactionId);
$urlKo = empty ($_REQUEST['urlKo']) ? '' : sprintf ($_REQUEST['urlKo'], $transactionId);
$merchantUrl = $row['merchantUrl'] ? $row['merchantUrl'] : '';
$merchantUrl = $row->merchantUrl ? $row->merchantUrl : '';
$params = [
'Ds_Merchant_Amount' => $amount
,'Ds_Merchant_Order' => $transactionId
,'Ds_Merchant_MerchantCode' => $row['merchant']
,'Ds_Merchant_Currency' => $row['currency']
,'Ds_Merchant_TransactionType' => $row['transactionType']
,'Ds_Merchant_Terminal' => $row['terminal']
,'Ds_Merchant_MerchantCode' => $row->merchant
,'Ds_Merchant_Currency' => $row->currency
,'Ds_Merchant_TransactionType' => $row->transactionType
,'Ds_Merchant_Terminal' => $row->terminal
,'Ds_Merchant_MerchantURL' => $merchantUrl
,'Ds_Merchant_UrlOK' => $urlOk
,'Ds_Merchant_UrlKO' => $urlKo
@ -37,7 +37,7 @@ class Transaction extends Vn\Web\JsonRequest
$encodedParams = base64_encode (json_encode ($params));
$key = base64_decode ($row['secretKey']);
$key = base64_decode ($row->secretKey);
$bytes = [0, 0, 0, 0, 0, 0, 0, 0];
$iv = implode (array_map ('chr', $bytes));
@ -45,7 +45,7 @@ class Transaction extends Vn\Web\JsonRequest
$signature = base64_encode (hash_hmac ('sha256', $encodedParams, $key, TRUE));
$url = $row['url'];
$url = $row->url;
$postValues = [
'Ds_SignatureVersion' => 'HMAC_SHA256_V1'
,'Ds_MerchantParameters' => $encodedParams