2015-09-11 09:37:16 +00:00
|
|
|
|
2015-09-25 00:53:59 +00:00
|
|
|
Vn.resource ('js/hedera/gui.xml');
|
|
|
|
Vn.define (function () {
|
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
Vn.Gui = new Class
|
|
|
|
({
|
|
|
|
Extends: Htk.Widget,
|
|
|
|
Properties:
|
|
|
|
{
|
|
|
|
conn:
|
|
|
|
{
|
2015-12-10 13:48:43 +00:00
|
|
|
type: Db.Conn
|
|
|
|
,set: function (x)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
this.link ({_conn: x},
|
2015-12-15 15:22:46 +00:00
|
|
|
{'loading-changed': this._onConnLoadChange });
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-09-23 22:12:57 +00:00
|
|
|
var sql = 'SELECT default_form, image_dir, image_host FROM config;'
|
2015-09-11 09:37:16 +00:00
|
|
|
+'SELECT production_domain, test_domain FROM config;'
|
2015-12-02 17:26:58 +00:00
|
|
|
+'SELECT name FROM customer_user;'
|
2015-09-11 09:37:16 +00:00
|
|
|
+'CALL form_list ();';
|
2015-12-10 23:24:14 +00:00
|
|
|
x.execQuery (sql, this.onMainQueryDone.bind (this));
|
|
|
|
|
|
|
|
if (Vn.Cookie.check ('hedera_supplant'))
|
|
|
|
this.supplantUser (Vn.Cookie.get ('hedera_supplant'));
|
2015-12-10 13:48:43 +00:00
|
|
|
}
|
|
|
|
,get: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
return this._conn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,forms: {}
|
|
|
|
,activeForm: null
|
|
|
|
,activeCss: null
|
|
|
|
,requestedForm: null
|
|
|
|
,menuShown: false
|
|
|
|
,menuOptions: {}
|
|
|
|
,choosedOption: null
|
2015-12-19 15:42:38 +00:00
|
|
|
,_shown: false
|
|
|
|
,_scrollTimeout: null
|
|
|
|
,_navbarVisible: true
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
,initialize: function (props)
|
|
|
|
{
|
|
|
|
this.builderInit ('js/hedera/gui.xml');
|
|
|
|
|
|
|
|
this.loadingCount = 0;
|
|
|
|
|
|
|
|
this.$('background').onclick = function () {};
|
|
|
|
|
|
|
|
this.$('menu-button').addEventListener ('click', function (event)
|
|
|
|
{
|
|
|
|
event.stopPropagation ();
|
|
|
|
this.showMenu ();
|
|
|
|
}.bind (this));
|
|
|
|
|
|
|
|
this.$('left-panel').addEventListener ('click', function (event)
|
|
|
|
{
|
|
|
|
event.stopPropagation ();
|
|
|
|
});
|
2015-12-02 17:26:58 +00:00
|
|
|
|
2015-12-10 13:48:43 +00:00
|
|
|
this.parent (props);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,show: function ()
|
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = true;
|
|
|
|
|
|
|
|
Vn.includeCss ('js/hedera/gui.css');
|
2015-09-11 09:37:16 +00:00
|
|
|
document.body.appendChild (this.node);
|
2015-12-19 15:42:38 +00:00
|
|
|
|
|
|
|
if (Vn.isMobile ())
|
|
|
|
{
|
|
|
|
this._onScrollHandler = this._onScroll.bind (this);
|
|
|
|
window.addEventListener ('scroll', this._onScrollHandler );
|
|
|
|
}
|
|
|
|
|
|
|
|
this.hash = Vn.Hash;
|
|
|
|
this.formParam = new Vn.HashParam ({key: 'form'});
|
|
|
|
this.formParam.on ('changed', this._onFormChange, this);
|
|
|
|
|
|
|
|
if (!Vn.Cookie.check ('hedera_cookies'))
|
|
|
|
{
|
|
|
|
Vn.Cookie.set ('hedera_cookies', true);
|
|
|
|
Htk.Toast.showWarning (_('By using this site you accept cookies'));
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,hide: function ()
|
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._shown = false;
|
|
|
|
|
|
|
|
if (Vn.isMobile ())
|
|
|
|
window.removeEventListener ('scroll', this._onScrollHandler);
|
|
|
|
|
|
|
|
this.formParam.unref ();
|
2015-09-16 16:11:15 +00:00
|
|
|
this.closeForm ();
|
2015-12-10 23:24:14 +00:00
|
|
|
this.hideMenu ();
|
2015-09-11 09:37:16 +00:00
|
|
|
Vn.Node.remove (this.node);
|
2015-12-19 15:42:38 +00:00
|
|
|
Vn.excludeCss ('js/hedera/gui.css');
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-15 15:22:46 +00:00
|
|
|
,logout: function ()
|
|
|
|
{
|
|
|
|
this.onLogoutClick ();
|
|
|
|
}
|
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
,onLogoutClick: function ()
|
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
this._conn.close (this._onConnClose.bind (this));
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-19 15:42:38 +00:00
|
|
|
,_onConnClose: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
this.signalEmit ('logout');
|
|
|
|
}
|
|
|
|
|
2015-12-19 15:42:38 +00:00
|
|
|
,_onConnLoadChange: function (conn, isLoading)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (isLoading)
|
|
|
|
this.loaderPush ();
|
|
|
|
else
|
|
|
|
this.loaderPop ();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onMainQueryDone: function (resultSet)
|
|
|
|
{
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
|
|
|
var res = resultSet.fetchResult ();
|
|
|
|
var columns = res.columns;
|
|
|
|
|
|
|
|
if (res.next ())
|
|
|
|
for (var i = 0; i < res.columns.length; i++)
|
|
|
|
Vn.Config[columns[i].name] = res.get (columns[i].name);
|
|
|
|
|
|
|
|
// Retrieving configuration parameters
|
|
|
|
|
|
|
|
var res = resultSet.fetchResult ();
|
|
|
|
|
|
|
|
if (res.next () && res.get ('test_domain'))
|
|
|
|
{
|
|
|
|
if (location.host != res.get ('production_domain'))
|
|
|
|
{
|
|
|
|
var linkText = 'ReturnToOldWebsite';
|
|
|
|
var linkField = 'production_domain';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var linkText = 'TestTheNewWebsite';
|
|
|
|
var linkField = 'test_domain';
|
|
|
|
}
|
|
|
|
|
|
|
|
Vn.Node.setText (this.$('test-link'), _(linkText));
|
|
|
|
this.$('test-link').href = '//'+ res.get (linkField);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Vn.Node.hide (this.$('test-link'));
|
|
|
|
|
|
|
|
// Retrieving the user name
|
|
|
|
|
|
|
|
var userName = resultSet.fetchValue ();
|
|
|
|
|
|
|
|
if (userName)
|
|
|
|
{
|
|
|
|
var span = this.$('user-name');
|
|
|
|
span.appendChild (document.createTextNode (userName));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Retrieving menu sections
|
|
|
|
|
|
|
|
var res = resultSet.fetchResult ();
|
|
|
|
var sectionMap = {};
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
for (var i = 0; res.next (); i++)
|
|
|
|
{
|
|
|
|
var parent = res.get ('parent');
|
|
|
|
|
|
|
|
if (!sectionMap[parent])
|
|
|
|
sectionMap[parent] = [];
|
|
|
|
|
|
|
|
sectionMap[parent].push (i);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.createMenu (res, sectionMap, null, this.$('main-menu'));
|
|
|
|
|
|
|
|
// Loading the default form
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
this._onFormChange ();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-19 15:42:38 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Navigation bar
|
|
|
|
|
|
|
|
,_onScroll: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
if (this._scrollTimeout === null)
|
|
|
|
this._scrollTimeout = setTimeout (
|
2016-01-07 12:58:29 +00:00
|
|
|
this._scrollTimeoutFunc.bind (this), 150);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-19 15:42:38 +00:00
|
|
|
,_scrollTimeoutFunc: function ()
|
|
|
|
{
|
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var navbar = this.$('top-bar');
|
|
|
|
var yOffset = Vn.Browser.getPageYOffset ();
|
|
|
|
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
|
|
|
|
|
|
|
|
if (showNavbar !== this._navbarVisible)
|
|
|
|
{
|
|
|
|
if (showNavbar)
|
|
|
|
var translateY = 0;
|
|
|
|
else
|
|
|
|
var translateY = -navbar.offsetHeight;
|
|
|
|
|
|
|
|
navbar.style.transform =
|
|
|
|
'translateZ(0) translateY('+ translateY +'px)';
|
|
|
|
}
|
|
|
|
|
|
|
|
this._navbarVisible = showNavbar;
|
|
|
|
this._lastYOffset = yOffset;
|
|
|
|
this._scrollTimeout = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Background
|
|
|
|
|
|
|
|
,showBackground: function ()
|
|
|
|
{
|
|
|
|
Vn.Node.addClass (this.$('background'), 'show');
|
|
|
|
}
|
|
|
|
|
|
|
|
,hideBackground: function ()
|
|
|
|
{
|
|
|
|
Vn.Node.removeClass (this.$('background'), 'show');
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu
|
|
|
|
|
|
|
|
,showMenu: function ()
|
|
|
|
{
|
|
|
|
this.showBackground ();
|
|
|
|
Vn.Node.addClass (this.$('left-panel'), 'show');
|
|
|
|
this.menuShown = true;
|
|
|
|
|
|
|
|
this.hideMenuCallback = this.hideMenu.bind (this);
|
|
|
|
document.addEventListener ('click', this.hideMenuCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
,hideMenu: function ()
|
|
|
|
{
|
|
|
|
if (!this.menuShown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.hideBackground ();
|
|
|
|
Vn.Node.removeClass (this.$('left-panel'), 'show');
|
|
|
|
this.menuShown = false;
|
|
|
|
|
|
|
|
document.removeEventListener ('click', this.hideMenuCallback);
|
|
|
|
this.hideMenuCallback = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner
|
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
,loaderPush: function ()
|
|
|
|
{
|
|
|
|
this.loadingCount++;
|
|
|
|
|
|
|
|
if (this.loadingCount == 1)
|
2015-11-19 13:57:23 +00:00
|
|
|
this.$('loader').start ();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,loaderPop: function ()
|
|
|
|
{
|
|
|
|
if (this.loadingCount == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.loadingCount--;
|
|
|
|
|
|
|
|
if (this.loadingCount == 0)
|
2015-11-19 13:57:23 +00:00
|
|
|
this.$('loader').stop ();
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
,createMenu: function (res, sectionMap, parent, ul)
|
|
|
|
{
|
|
|
|
var sections = sectionMap[parent];
|
|
|
|
|
|
|
|
for (var i = 0; i < sections.length; i++)
|
|
|
|
{
|
|
|
|
res.row = sections[i];
|
|
|
|
|
|
|
|
var li = document.createElement ('li');
|
|
|
|
ul.appendChild (li);
|
|
|
|
|
|
|
|
var a = document.createElement ('a');
|
|
|
|
a.href = Vn.Hash.make ({'form': res.get ('path')});
|
|
|
|
this.menuOptions[res.get ('path')] = a;
|
|
|
|
li.appendChild (a);
|
|
|
|
|
|
|
|
var text = document.createTextNode (_(res.get ('description')));
|
|
|
|
a.appendChild (text);
|
|
|
|
|
|
|
|
var formId = res.get ('id');
|
|
|
|
|
|
|
|
if (sectionMap[formId])
|
|
|
|
{
|
|
|
|
var submenu = document.createElement ('ul');
|
|
|
|
submenu.className = 'submenu';
|
|
|
|
li.appendChild (submenu);
|
|
|
|
|
|
|
|
li.addEventListener ('mouseover',
|
2015-12-02 17:26:58 +00:00
|
|
|
this._onLiMouseHover.bind (this, submenu, a));
|
2015-09-11 09:37:16 +00:00
|
|
|
li.addEventListener ('mouseout',
|
2015-12-02 17:26:58 +00:00
|
|
|
this._onLiMouseOut.bind (this));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
this.createMenu (res, sectionMap, formId, submenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
,_onLiMouseHover: function (submenu, parent)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-09-16 16:11:15 +00:00
|
|
|
if (this.menuShown)
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
this.hideSubmenu ();
|
|
|
|
this.activeSubmenu = submenu;
|
|
|
|
|
|
|
|
var rect = parent.getBoundingClientRect ();
|
2015-09-16 16:11:15 +00:00
|
|
|
Vn.Node.addClass (submenu, 'show');
|
2015-09-11 09:37:16 +00:00
|
|
|
submenu.style.left = rect.right +'px';
|
|
|
|
submenu.style.top = rect.top +'px';
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
,_onLiMouseOut: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
|
|
|
this.timeout = setTimeout (this.hideSubmenu.bind (this), 160);
|
|
|
|
}
|
|
|
|
|
|
|
|
,hideSubmenu: function ()
|
|
|
|
{
|
|
|
|
var submenu = this.activeSubmenu;
|
|
|
|
|
|
|
|
if (submenu)
|
|
|
|
{
|
2015-09-16 16:11:15 +00:00
|
|
|
Vn.Node.removeClass (submenu, 'show');
|
|
|
|
submenu.style.left = 'initial';
|
|
|
|
submenu.style.top = 'initial';
|
2015-09-11 09:37:16 +00:00
|
|
|
clearTimeout (this.timeout);
|
|
|
|
this.activeSubmenu = null;
|
|
|
|
this.timeout = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,_onFormChange: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-12-19 15:42:38 +00:00
|
|
|
var formPath = this.formParam.value;
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
if (!formPath)
|
|
|
|
formPath = Vn.Config['default_form'];
|
|
|
|
|
|
|
|
this.openForm (formPath,
|
|
|
|
this._onFormLoad.bind (this));
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,openForm: function (formPath, callback)
|
|
|
|
{
|
|
|
|
this.hideMenu ();
|
|
|
|
this.loaderPush ();
|
2015-09-16 16:11:15 +00:00
|
|
|
|
|
|
|
this.closeForm ();
|
2015-09-11 09:37:16 +00:00
|
|
|
this.requestedForm = formPath;
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
var newChoosedOption = this.menuOptions[formPath];
|
|
|
|
|
|
|
|
if (newChoosedOption)
|
|
|
|
{
|
|
|
|
Vn.Node.addClass (newChoosedOption, 'selected');
|
|
|
|
this.choosedOption = newChoosedOption;
|
|
|
|
}
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
this.activeCss = 'forms/'+ formPath +'/style.css';
|
|
|
|
Vn.includeCss (this.activeCss);
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
var formInfo = this.forms[formPath];
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (!formInfo)
|
|
|
|
{
|
2015-11-17 10:34:33 +00:00
|
|
|
formInfo = new Vn.Module ('forms', formPath);
|
2015-09-11 09:37:16 +00:00
|
|
|
this.forms[formPath] = formInfo;
|
|
|
|
}
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
formInfo.addCallback (callback);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,_onFormLoad: function (formInfo)
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-11-17 10:34:33 +00:00
|
|
|
this.loaderPop ();
|
2015-09-11 09:37:16 +00:00
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
if (formInfo.error)
|
|
|
|
{
|
|
|
|
Htk.Toast.showError (_('Error loading form'));
|
2015-09-11 09:37:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
this.activeForm = new formInfo.klass (this, formInfo);
|
|
|
|
this.activeForm.open ();
|
2015-12-15 15:22:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
,setForm: function (form)
|
|
|
|
{
|
|
|
|
Vn.Node.removeChilds (this.$('form-holder'));
|
|
|
|
|
|
|
|
if (form)
|
|
|
|
{
|
|
|
|
this.$('form-holder').appendChild (form);
|
|
|
|
setTimeout (this._onSetFormTimeout.bind (this), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_onSetFormTimeout: function ()
|
|
|
|
{
|
|
|
|
Vn.Node.addClass (this.$('form-holder'), 'show');
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,setTitle: function (title)
|
|
|
|
{
|
|
|
|
Vn.Node.removeChilds (this.$('title'));
|
|
|
|
|
|
|
|
if (title)
|
|
|
|
this.$('title').appendChild (title);
|
|
|
|
}
|
|
|
|
|
|
|
|
,setActions: function (actions)
|
|
|
|
{
|
2015-09-16 16:11:15 +00:00
|
|
|
Vn.Node.removeChilds (this.$('action-bar'));
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
if (actions)
|
2015-09-16 16:11:15 +00:00
|
|
|
this.$('action-bar').appendChild (actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
,closeForm: function ()
|
|
|
|
{
|
|
|
|
if (this.activeForm)
|
|
|
|
{
|
2015-12-15 15:22:46 +00:00
|
|
|
Vn.Node.removeClass (this.$('form-holder'), 'show');
|
2015-09-16 16:11:15 +00:00
|
|
|
this.activeForm.close ();
|
|
|
|
this.activeForm.unref ();
|
|
|
|
this.activeForm = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.activeCss)
|
|
|
|
{
|
2015-11-17 10:34:33 +00:00
|
|
|
Vn.excludeCss (this.activeCss);
|
2015-09-16 16:11:15 +00:00
|
|
|
this.activeCss = null;
|
|
|
|
}
|
2015-11-17 10:34:33 +00:00
|
|
|
|
|
|
|
if (this.choosedOption)
|
|
|
|
{
|
|
|
|
Vn.Node.removeClass (this.choosedOption, 'selected');
|
|
|
|
this.choosedOption = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Reports
|
|
|
|
|
2015-11-17 10:34:33 +00:00
|
|
|
,openReport: function (reportName, batch)
|
|
|
|
{
|
|
|
|
this.loaderPush ();
|
|
|
|
|
|
|
|
var module = new Vn.Module ('reports', reportName);
|
|
|
|
module.addCallback (this._onReportLoad.bind (this, batch));
|
|
|
|
}
|
|
|
|
|
|
|
|
,_onReportLoad: function (batch, module)
|
|
|
|
{
|
|
|
|
this.loaderPop ();
|
|
|
|
|
|
|
|
if (module.error)
|
|
|
|
{
|
|
|
|
Htk.Toast.showError (_('Error loading report'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var report = new module.klass (module, this);
|
|
|
|
report.open (batch);
|
2015-09-11 09:37:16 +00:00
|
|
|
}
|
2015-11-30 16:46:24 +00:00
|
|
|
|
2015-12-02 17:26:58 +00:00
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Supplant
|
|
|
|
|
2015-11-30 16:46:24 +00:00
|
|
|
,supplantUser: function (userId, callback)
|
|
|
|
{
|
|
|
|
var batch = new Sql.Batch ();
|
|
|
|
batch.addValue ('user', userId);
|
|
|
|
|
|
|
|
var query = 'UPDATE user_session_view SET user_id = #user;'+
|
|
|
|
'SELECT Cliente FROM vn2008.Clientes WHERE Id_cliente = #user';
|
2015-12-10 23:24:14 +00:00
|
|
|
this._conn.execQuery (query,
|
2015-11-30 16:46:24 +00:00
|
|
|
this._onUserSupplant.bind (this, userId, callback), batch);
|
|
|
|
}
|
|
|
|
|
|
|
|
,_onUserSupplant: function (userId, callback, resultSet)
|
|
|
|
{
|
|
|
|
this._supplantClear ();
|
2015-12-02 17:26:58 +00:00
|
|
|
Vn.Cookie.set ('hedera_supplant', userId);
|
2015-11-30 16:46:24 +00:00
|
|
|
|
|
|
|
resultSet.fetchResult ();
|
|
|
|
var userName = resultSet.fetchValue ();
|
|
|
|
|
|
|
|
Vn.Node.setText (this.$('supplanted'), userName);
|
|
|
|
Vn.Node.show (this.$('supplant'));
|
|
|
|
|
|
|
|
if (callback)
|
|
|
|
callback ();
|
|
|
|
}
|
|
|
|
|
|
|
|
,_supplantClear: function ()
|
|
|
|
{
|
2015-12-02 17:26:58 +00:00
|
|
|
if (Vn.Cookie.check ('hedera_supplant'))
|
2015-11-30 16:46:24 +00:00
|
|
|
{
|
|
|
|
Vn.Node.hide (this.$('supplant'));
|
2015-12-02 17:26:58 +00:00
|
|
|
Vn.Cookie.unset ('hedera_supplant');
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2015-11-30 16:46:24 +00:00
|
|
|
,onSupplantExitClick: function ()
|
|
|
|
{
|
|
|
|
var query = 'UPDATE user_session_view SET user_id = account.user_get_id ()'
|
2015-12-10 23:24:14 +00:00
|
|
|
this._conn.execQuery (query, this.supplantExit.bind (this));
|
2015-11-30 16:46:24 +00:00
|
|
|
}
|
2015-12-19 15:42:38 +00:00
|
|
|
|
2015-11-30 16:46:24 +00:00
|
|
|
,supplantExit: function ()
|
|
|
|
{
|
|
|
|
this._supplantClear ();
|
|
|
|
this._onFormChange ();
|
|
|
|
}
|
2015-12-02 17:26:58 +00:00
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Destroy
|
2015-09-11 09:37:16 +00:00
|
|
|
|
|
|
|
,_destroy: function ()
|
|
|
|
{
|
2015-09-16 16:11:15 +00:00
|
|
|
this.hide ();
|
2015-09-11 09:37:16 +00:00
|
|
|
this.parent ();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-09-25 00:53:59 +00:00
|
|
|
});
|
|
|
|
|