[ADD] kernel of wefra for Odoo 11.0

This commit is contained in:
David Drapeau 2019-10-02 23:28:58 +02:00
parent 5c1a32dcce
commit d5899e0a6c
2013 changed files with 218661 additions and 1 deletions

10
.htaccess Normal file
View File

@ -0,0 +1,10 @@
Options +FollowSymlinks
RewriteEngine on
#RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !index.php
#RewriteRule ^install$ custom/__private/install/install.php [L]
RewriteRule ^([a-z\-]+)-([0-9\.]+)$ index.php?page=$1&reference=$2 [L]
RewriteRule ^([a-z\-]+)$ index.php?page=$1 [L]

View File

@ -1,2 +1,2 @@
# wefra-odoo11 # globsi-admin

10
__private/.htaccess Normal file
View File

@ -0,0 +1,10 @@
Options +FollowSymlinks
RewriteEngine on
#RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !index.php
#RewriteRule ^install$ custom/__private/install/install.php [L]
RewriteRule ^([a-z\-]+)-([0-9\.]+)$ index.php?page=$1&reference=$2 [L]
RewriteRule ^([a-z\-]+)$ index.php?page=$1 [L]

View File

@ -0,0 +1,936 @@
--access to backend database
DROP TABLE IF EXISTS erp_config;
-- user_user.sql
DROP TABLE IF EXISTS useruser_corefeature_rel;
DROP TABLE IF EXISTS user_confirm;
DROP TABLE IF EXISTS user_detail;
DROP TABLE IF EXISTS user_user;
-- core.sql
DROP TABLE IF EXISTS core_feature;
DROP TABLE IF EXISTS core_feature_translation;
DROP TABLE IF EXISTS core_config;
DROP TABLE IF EXISTS core_translation;
DROP TABLE IF EXISTS core_country;
DROP TABLE IF EXISTS core_lang;
DROP TABLE IF EXISTS core_currency;
DROP TABLE IF EXISTS core_theme;
CREATE TABLE core_theme (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
code VARCHAR(16) NOT NULL,
name VARCHAR(128) NOT NULL,
is_prod_available BOOLEAN NOT NULL DEFAULT FALSE,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
CONSTRAINT coreTheme_id_pk PRIMARY KEY(id),
CONSTRAINT coreTheme_code_uk UNIQUE(id)
);
CREATE TABLE core_currency (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
code VARCHAR(16) NOT NULL,
name VARCHAR(128) NOT NULL,
symbol VARCHAR(16) NOT NULL,
rounding DECIMAL(12,8) NOT NULL,
priority INTEGER NOT NULL DEFAULT 100,
decimal_precision INTEGER NOT NULL DEFAULT 2,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
CONSTRAINT coreCurrency_id_pk PRIMARY KEY(id),
CONSTRAINT coreCurrency_name_uk UNIQUE(name),
CONSTRAINT coreCurrency_name_chk CHECK(name !='')
);
CREATE TABLE core_lang (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
code VARCHAR(16) NOT NULL,
name VARCHAR(128) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT FALSE,
comment TEXT NOT NULL DEFAULT '',
CONSTRAINT coreLang_id_pk PRIMARY KEY(id),
CONSTRAINT coreLang_name_uk UNIQUE(name)
);
CREATE TABLE core_country (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
code VARCHAR(16) NOT NULL,
name VARCHAR(128) NOT NULL,
core_currency_id INTEGER,
priority INTEGER NOT NULL DEFAULT 100,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
CONSTRAINT coreCountry_id_pk PRIMARY KEY(id),
CONSTRAINT coreCountry_code_uk UNIQUE(code),
CONSTRAINT coreCountry_code_chk CHECK(code !=''),
CONSTRAINT coreCountry_name_chk CHECK(name !=''),
CONSTRAINT coreCountry_coreCurrencyId_fk FOREIGN KEY(core_currency_id) REFERENCES core_currency(id)
);
CREATE TABLE core_translation (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
code VARCHAR(128) NOT NULL,
source TEXT NOT NULL,
ab_RU TEXT NOT NULL DEFAULT '',
am_ET TEXT NOT NULL DEFAULT '',
ar_SY TEXT NOT NULL DEFAULT '',
bg_BG TEXT NOT NULL DEFAULT '',
bs_BS TEXT NOT NULL DEFAULT '',
ca_ES TEXT NOT NULL DEFAULT '',
cs_CZ TEXT NOT NULL DEFAULT '',
da_DK TEXT NOT NULL DEFAULT '',
de_DE TEXT NOT NULL DEFAULT '',
el_GR TEXT NOT NULL DEFAULT '',
en_CA TEXT NOT NULL DEFAULT '',
en_gb TEXT NOT NULL DEFAULT '',
en_US TEXT NOT NULL DEFAULT '',
es_AR TEXT NOT NULL DEFAULT '',
es_BO TEXT NOT NULL DEFAULT '',
es_CL TEXT NOT NULL DEFAULT '',
es_CO TEXT NOT NULL DEFAULT '',
es_CR TEXT NOT NULL DEFAULT '',
es_DO TEXT NOT NULL DEFAULT '',
es_EC TEXT NOT NULL DEFAULT '',
es_ES TEXT NOT NULL DEFAULT '',
es_GT TEXT NOT NULL DEFAULT '',
es_HN TEXT NOT NULL DEFAULT '',
es_MX TEXT NOT NULL DEFAULT '',
es_NI TEXT NOT NULL DEFAULT '',
es_PA TEXT NOT NULL DEFAULT '',
es_PE TEXT NOT NULL DEFAULT '',
es_PR TEXT NOT NULL DEFAULT '',
es_PY TEXT NOT NULL DEFAULT '',
es_SV TEXT NOT NULL DEFAULT '',
es_UY TEXT NOT NULL DEFAULT '',
es_VE TEXT NOT NULL DEFAULT '',
et_EE TEXT NOT NULL DEFAULT '',
fa_IR TEXT NOT NULL DEFAULT '',
fi_FI TEXT NOT NULL DEFAULT '',
fr_BE TEXT NOT NULL DEFAULT '',
fr_CA TEXT NOT NULL DEFAULT '',
fr_CH TEXT NOT NULL DEFAULT '',
fr_fr TEXT NOT NULL DEFAULT '',
gl_ES TEXT NOT NULL DEFAULT '',
gu_IN TEXT NOT NULL DEFAULT '',
he_IL TEXT NOT NULL DEFAULT '',
hi_IN TEXT NOT NULL DEFAULT '',
hr_HR TEXT NOT NULL DEFAULT '',
hu_HU TEXT NOT NULL DEFAULT '',
id_ID TEXT NOT NULL DEFAULT '',
it_IT TEXT NOT NULL DEFAULT '',
iu_CA TEXT NOT NULL DEFAULT '',
ja_JP TEXT NOT NULL DEFAULT '',
ko_KP TEXT NOT NULL DEFAULT '',
ko_KR TEXT NOT NULL DEFAULT '',
lt_LT TEXT NOT NULL DEFAULT '',
lv_LV TEXT NOT NULL DEFAULT '',
ml_IN TEXT NOT NULL DEFAULT '',
mn_MN TEXT NOT NULL DEFAULT '',
nb_NO TEXT NOT NULL DEFAULT '',
nl_NL TEXT NOT NULL DEFAULT '',
nl_BE TEXT NOT NULL DEFAULT '',
oc_FR TEXT NOT NULL DEFAULT '',
pl_PL TEXT NOT NULL DEFAULT '',
pt_BR TEXT NOT NULL DEFAULT '',
pt_PT TEXT NOT NULL DEFAULT '',
ro_RO TEXT NOT NULL DEFAULT '',
ru_RU TEXT NOT NULL DEFAULT '',
si_LK TEXT NOT NULL DEFAULT '',
sl_SI TEXT NOT NULL DEFAULT '',
sk_SK TEXT NOT NULL DEFAULT '',
sq_AL TEXT NOT NULL DEFAULT '',
sr_RS TEXT NOT NULL DEFAULT '',
sr_latin TEXT NOT NULL DEFAULT '',
sv_SE TEXT NOT NULL DEFAULT '',
te_IN TEXT NOT NULL DEFAULT '',
tr_TR TEXT NOT NULL DEFAULT '',
vi_VN TEXT NOT NULL DEFAULT '',
uk_UA TEXT NOT NULL DEFAULT '',
ur_PK TEXT NOT NULL DEFAULT '',
zh_CN TEXT NOT NULL DEFAULT '',
zh_HK TEXT NOT NULL DEFAULT '',
zh_TW TEXT NOT NULL DEFAULT '',
th_TH TEXT NOT NULL DEFAULT '',
tlh_TLH TEXT NOT NULL DEFAULT '',
is_active BOOLEAN NOT NULL DEFAULT TRUE,
comment TEXT NOT NULL DEFAULT '',
CONSTRAINT coreTranslation_id_pk PRIMARY KEY(id),
CONSTRAINT coreTranslation_code_uk UNIQUE(code)
);
CREATE TABLE core_config (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
k VARCHAR(128) NOT NULL,
v VARCHAR(128) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
comment TEXT NOT NULL DEFAULT '',
CONSTRAINT coreConfig_id_pk PRIMARY KEY(id),
CONSTRAINT coreConfig_k_uk UNIQUE(k)
);
--FIX bug core_feature with core_translation for menu and using models and views
CREATE TABLE core_feature_translation (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
code VARCHAR(128) NOT NULL,
source TEXT NOT NULL,
ab_RU TEXT NOT NULL DEFAULT '',
am_ET TEXT NOT NULL DEFAULT '',
ar_SY TEXT NOT NULL DEFAULT '',
bg_BG TEXT NOT NULL DEFAULT '',
bs_BS TEXT NOT NULL DEFAULT '',
ca_ES TEXT NOT NULL DEFAULT '',
cs_CZ TEXT NOT NULL DEFAULT '',
da_DK TEXT NOT NULL DEFAULT '',
de_DE TEXT NOT NULL DEFAULT '',
el_GR TEXT NOT NULL DEFAULT '',
en_CA TEXT NOT NULL DEFAULT '',
en_gb TEXT NOT NULL DEFAULT '',
en_US TEXT NOT NULL DEFAULT '',
es_AR TEXT NOT NULL DEFAULT '',
es_BO TEXT NOT NULL DEFAULT '',
es_CL TEXT NOT NULL DEFAULT '',
es_CO TEXT NOT NULL DEFAULT '',
es_CR TEXT NOT NULL DEFAULT '',
es_DO TEXT NOT NULL DEFAULT '',
es_EC TEXT NOT NULL DEFAULT '',
es_ES TEXT NOT NULL DEFAULT '',
es_GT TEXT NOT NULL DEFAULT '',
es_HN TEXT NOT NULL DEFAULT '',
es_MX TEXT NOT NULL DEFAULT '',
es_NI TEXT NOT NULL DEFAULT '',
es_PA TEXT NOT NULL DEFAULT '',
es_PE TEXT NOT NULL DEFAULT '',
es_PR TEXT NOT NULL DEFAULT '',
es_PY TEXT NOT NULL DEFAULT '',
es_SV TEXT NOT NULL DEFAULT '',
es_UY TEXT NOT NULL DEFAULT '',
es_VE TEXT NOT NULL DEFAULT '',
et_EE TEXT NOT NULL DEFAULT '',
fa_IR TEXT NOT NULL DEFAULT '',
fi_FI TEXT NOT NULL DEFAULT '',
fr_BE TEXT NOT NULL DEFAULT '',
fr_CA TEXT NOT NULL DEFAULT '',
fr_CH TEXT NOT NULL DEFAULT '',
fr_fr TEXT NOT NULL DEFAULT '',
gl_ES TEXT NOT NULL DEFAULT '',
gu_IN TEXT NOT NULL DEFAULT '',
he_IL TEXT NOT NULL DEFAULT '',
hi_IN TEXT NOT NULL DEFAULT '',
hr_HR TEXT NOT NULL DEFAULT '',
hu_HU TEXT NOT NULL DEFAULT '',
id_ID TEXT NOT NULL DEFAULT '',
it_IT TEXT NOT NULL DEFAULT '',
iu_CA TEXT NOT NULL DEFAULT '',
ja_JP TEXT NOT NULL DEFAULT '',
ko_KP TEXT NOT NULL DEFAULT '',
ko_KR TEXT NOT NULL DEFAULT '',
lt_LT TEXT NOT NULL DEFAULT '',
lv_LV TEXT NOT NULL DEFAULT '',
ml_IN TEXT NOT NULL DEFAULT '',
mn_MN TEXT NOT NULL DEFAULT '',
nb_NO TEXT NOT NULL DEFAULT '',
nl_NL TEXT NOT NULL DEFAULT '',
nl_BE TEXT NOT NULL DEFAULT '',
oc_FR TEXT NOT NULL DEFAULT '',
pl_PL TEXT NOT NULL DEFAULT '',
pt_BR TEXT NOT NULL DEFAULT '',
pt_PT TEXT NOT NULL DEFAULT '',
ro_RO TEXT NOT NULL DEFAULT '',
ru_RU TEXT NOT NULL DEFAULT '',
si_LK TEXT NOT NULL DEFAULT '',
sl_SI TEXT NOT NULL DEFAULT '',
sk_SK TEXT NOT NULL DEFAULT '',
sq_AL TEXT NOT NULL DEFAULT '',
sr_RS TEXT NOT NULL DEFAULT '',
sr_latin TEXT NOT NULL DEFAULT '',
sv_SE TEXT NOT NULL DEFAULT '',
te_IN TEXT NOT NULL DEFAULT '',
tr_TR TEXT NOT NULL DEFAULT '',
vi_VN TEXT NOT NULL DEFAULT '',
uk_UA TEXT NOT NULL DEFAULT '',
ur_PK TEXT NOT NULL DEFAULT '',
zh_CN TEXT NOT NULL DEFAULT '',
zh_HK TEXT NOT NULL DEFAULT '',
zh_TW TEXT NOT NULL DEFAULT '',
th_TH TEXT NOT NULL DEFAULT '',
tlh_TLH TEXT NOT NULL DEFAULT '',
is_active BOOLEAN NOT NULL DEFAULT TRUE,
comment TEXT NOT NULL DEFAULT '',
CONSTRAINT coreFeatureTranslation_id_pk PRIMARY KEY(id),
CONSTRAINT coreFeatureTranslation_code_uk UNIQUE(code)
);
CREATE TABLE core_feature (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_parent boolean NOT NULL DEFAULT FALSE,
parent_id INTEGER,
model VARCHAR(250) NOT NULL,
code VARCHAR(64) NOT NULL,
url_feature_translation_id INTEGER,
label_feature_translation_id INTEGER,
menu_icon VARCHAR(128),
is_menu_display BOOLEAN NOT NULL DEFAULT FALSE,
is_available_for_guest BOOLEAN NOT NULL DEFAULT FALSE,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
priority INTEGER NOT NULL DEFAULT 100,
CONSTRAINT coreFeatures_id_pk PRIMARY KEY(id),
CONSTRAINT coreFeatures_parentId_fk FOREIGN KEY(parent_id) REFERENCES core_feature(id),
CONSTRAINT coreFeature_urlFeatureTranslationId_fk FOREIGN KEY(url_feature_translation_id) REFERENCES core_feature_translation(id),
CONSTRAINT coreFeature_labelFeatureTranslationId_fk FOREIGN KEY(label_feature_translation_id) REFERENCES core_feature_translation(id),
CONSTRAINT coreFeatures_code_uk UNIQUE(code)
);
/* OFFICIAL DATA */
INSERT INTO core_theme(code, name, is_prod_available) VALUES('materialize', 'Materialize', TRUE);
INSERT INTO core_currency(code, name, symbol, rounding, priority) VALUES ('usd', 'USD', '$', '0.01', 3);
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vef', 'VEF', 'Bs.F', '0.0001');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cad', 'CAD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding, priority) VALUES ('chf', 'CHF', 'CHF', '0.01', 1);
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('brl', 'BRL', 'R$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cny', 'CNY', '¥', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cop', 'COP', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('czk', 'CZK', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('dkk', 'DKK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('huf', 'HUF', 'Ft', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('idr', 'IDR', 'Rp', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lvl', 'LVL', 'Ls', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nok', 'NOK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xpf', 'XPF', 'XPF', '1.00');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pab', 'PAB', 'B/.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pln', 'PLN', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sek', 'SEK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ars', 'ARS', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('inr', 'INR', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('aud', 'AUD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uah', 'UAH', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vnd', 'VND', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('hkd', 'HKD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('jpy', 'JPY', '¥', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bgn', 'BGN', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ltl', 'LTL', 'Lt', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ron', 'RON', 'lei', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('hrk', 'HRK', 'kn', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rub', 'RUB', 'руб', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('try', 'TRY', 'TL', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('krw', 'KRW', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mxn', 'MXN', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('myr', 'MYR', 'RM', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nzd', 'NZD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('php', 'PHP', 'Php', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sgd', 'SGD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zar', 'ZAR', 'R', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('crc', 'CRC', '¢', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mur', 'MUR', 'Rs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xof', 'XOF', 'CFA', '1');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xaf', 'XAF', 'FCFA', '1');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ugx', 'UGX', 'USh', '1');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('hnl', 'HNL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('clp', 'CLP', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uyu', 'UYU', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('afn', 'AFN', 'Afs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('aoa', 'AOA', 'Kz', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xcd', 'XCD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('amd', 'AMD', 'դր..', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('awg', 'AWG', 'Afl.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('azn', 'AZN', 'm', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bsd', 'BSD', 'B$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bhd', 'BHD', 'BD', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bdt', 'BDT', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bbd', 'BBD', 'Bds$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('byr', 'BYR', 'BR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bzd', 'BZD', 'BZ$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bmd', 'BMD', 'BD$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('btn', 'BTN', 'Nu.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bob', 'BOB', 'Bs.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bam', 'BAM', 'KM', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bwp', 'BWP', 'P', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bif', 'BIF', 'FBu', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('khr', 'KHR', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kyd', 'KYD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kmf', 'KMF', 'CF', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cdf', 'CDF', 'Fr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cup', 'CUP', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ang', 'ANG', 'ƒ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cyp', 'CYP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('djf', 'DJF', 'Fdj', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('dop', 'DOP', 'RD$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tpe', 'TPE', 'RD$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ecs', 'ECS', 'S/.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('egp', 'EGP', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('svc', 'SVC', '¢', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ern', 'ERN', 'Nfk', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('eek', 'EEK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('etb', 'ETB', 'Br', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('fkp', 'FKP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('fjd', 'FJD', 'FJ$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gel', 'GEL', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gip', 'GIP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('qtq', 'QTQ', 'Q', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gnf', 'GNF', 'FG', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gwp', 'GWP', 'FG', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gyd', 'GYD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('htg', 'HTG', 'G', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('isk', 'ISK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('irr', 'IRR', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('iqd', 'IQD', 'ع.د', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ils', 'ILS', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('jmd', 'JMD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('jod', 'JOD', ' د.ا ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kzt', 'KZT', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kes', 'KES', 'KSh', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kwd', 'KWD', ' د.ك ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kgs', 'KGS', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lak', 'LAK', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lbp', 'LBP', 'ل.ل', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lsl', 'LSL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lrd', 'LRD', 'L$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lyd', 'LYD', ' ل.د ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mop', 'MOP', 'MOP$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mkd', 'MKD', 'ден', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mga', 'MGA', 'Ar', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mwk', 'MWK', 'MK', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mvr', 'MVR', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mro', 'MRO', 'UM', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mdl', 'MDL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mnt', 'MNT', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mad', 'MAD', ' د.م. ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bnd', 'BND', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('dzd', 'DZD', 'DZ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ghs', 'GHS', 'GH¢', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gmd', 'GMD', 'D', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zrz', 'ZRZ', 'Ƶ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mzn', 'MZN', 'MT', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mmk', 'MMK', 'K', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nad', 'NAD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('npr', 'NPR', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('all', 'ALL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nio', 'NIO', 'C$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ngn', 'NGN', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kpw', 'KPW', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zwd', 'ZWD', 'Z$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zmk', 'ZMK', 'ZK', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('yer', 'YER', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vub', 'VUB', 'Bs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding, priority) VALUES ('eur', 'EUR', '', '0.01', 2);
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vuv', 'VUV', 'VT', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uzs', 'UZS', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uyp', 'UYP', '$U', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('aed', 'AED', 'د.إ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uag', 'UAG', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tmm', 'TMM', 'm', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('trl', 'TRL', 'TL', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tnd', 'TND', 'DT', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ttd', 'TTD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('top', 'TOP', 'T$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('thb', 'THB', '฿', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tzs', 'TZS', 'x/y', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tjr', 'TJR', 'x/y', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('twd', 'TWD', 'NT$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('syp', 'SYP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('szl', 'SZL', 'E', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('srg', 'SRG', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sdd', 'SDD', '£Sd', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lkr', 'LKR', 'Rs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ssp', 'SSP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gbp', 'GBP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sod', 'SOD', 'Sh.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sbd', 'SBD', 'SI$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sll', 'SLL', 'Le', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('scr', 'SCR', 'SR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rsd', 'RSD', 'din.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sar', 'SAR', 'SR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('std', 'STD', 'Db', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('itl', 'ITL', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('wst', 'WST', 'WS$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('shp', 'SHP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rwf', 'RWF', 'RF', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rur', 'RUR', 'R', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rol', 'ROL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('qar', 'QAR', 'QR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('plz', 'PLZ', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pen', 'PEN', 'S/.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pyg', 'PYG', '', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pgk', 'PGK', 'K', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pkr', 'PKR', 'Rs.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('omr', 'OMR', 'ر.ع.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cve', 'CVE', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('skk', 'SKK', 'Sk', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sit', 'SIT', 'Sk', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('yum', 'YUM', 'дин.', '0.01');
UPDATE core_currency SET decimal_precision=4 WHERE rounding=0.0001;
UPDATE core_currency SET decimal_precision=0 WHERE rounding=1.0;
INSERT INTO core_lang(code, name) VALUES ('ab_ru', 'Abkhazian / аҧсуа');
INSERT INTO core_lang(code, name) VALUES ('am_et', 'Amharic / አምሃርኛ');
INSERT INTO core_lang(code, name) VALUES ('ar_sy', 'Arabic / الْعَرَبيّة');
INSERT INTO core_lang(code, name) VALUES ('bg_bg', 'Bulgarian / български език');
INSERT INTO core_lang(code, name) VALUES ('bs_bs', 'Bosnian / bosanski jezik');
INSERT INTO core_lang(code, name) VALUES ('ca_es', 'Catalan / Català');
INSERT INTO core_lang(code, name) VALUES ('cs_cz', 'Czech / Čeština');
INSERT INTO core_lang(code, name) VALUES ('da_dk', 'Danish / Dansk');
INSERT INTO core_lang(code, name) VALUES ('de_de', 'German / Deutsch');
INSERT INTO core_lang(code, name) VALUES ('el_gr', 'Greek / Ελληνικά');
INSERT INTO core_lang(code, name) VALUES ('en_ca', 'English (CA)');
INSERT INTO core_lang(code, name, is_active) VALUES ('en_gb', 'English (UK)', TRUE);
INSERT INTO core_lang(code, name) VALUES ('en_us', 'English (US)');
INSERT INTO core_lang(code, name) VALUES ('es_ar', 'Spanish (AR) / Español (AR)');
INSERT INTO core_lang(code, name) VALUES ('es_bo', 'Spanish (BO) / Español (BO)');
INSERT INTO core_lang(code, name) VALUES ('es_cl', 'Spanish (CL) / Español (CL)');
INSERT INTO core_lang(code, name) VALUES ('es_co', 'Spanish (CO) / Español (CO)');
INSERT INTO core_lang(code, name) VALUES ('es_cr', 'Spanish (CR) / Español (CR)');
INSERT INTO core_lang(code, name) VALUES ('es_do', 'Spanish (DO) / Español (DO)');
INSERT INTO core_lang(code, name) VALUES ('es_ec', 'Spanish (EC) / Español (EC)');
INSERT INTO core_lang(code, name) VALUES ('es_es', 'Español');
INSERT INTO core_lang(code, name) VALUES ('es_gt', 'Spanish (GT) / Español (GT)');
INSERT INTO core_lang(code, name) VALUES ('es_hn', 'Spanish (HN) / Español (HN)');
INSERT INTO core_lang(code, name) VALUES ('es_mx', 'Spanish (MX) / Español (MX)');
INSERT INTO core_lang(code, name) VALUES ('es_ni', 'Spanish (NI) / Español (NI)');
INSERT INTO core_lang(code, name) VALUES ('es_pa', 'Spanish (PA) / Español (PA)');
INSERT INTO core_lang(code, name) VALUES ('es_pe', 'Spanish (PE) / Español (PE)');
INSERT INTO core_lang(code, name) VALUES ('es_pr', 'Spanish (PR) / Español (PR)');
INSERT INTO core_lang(code, name) VALUES ('es_py', 'Spanish (PY) / Español (PY)');
INSERT INTO core_lang(code, name) VALUES ('es_sv', 'Spanish (SV) / Español (SV)');
INSERT INTO core_lang(code, name) VALUES ('es_uy', 'Spanish (UY) / Español (UY)');
INSERT INTO core_lang(code, name) VALUES ('es_ve', 'Spanish (VE) / Español (VE)');
INSERT INTO core_lang(code, name) VALUES ('et_ee', 'Estonian / Eesti keel');
INSERT INTO core_lang(code, name) VALUES ('fa_ir', 'Persian / افارس');
INSERT INTO core_lang(code, name) VALUES ('fi_fi', 'Finnish / Suomi');
INSERT INTO core_lang(code, name) VALUES ('fr_be', 'French (BE) / Français (BE)');
INSERT INTO core_lang(code, name) VALUES ('fr_ca', 'French (CA) / Français (CA)');
INSERT INTO core_lang(code, name) VALUES ('fr_ch', 'French (CH) / Français (CH)');
INSERT INTO core_lang(code, name, is_active) VALUES ('fr_fr', 'Français', TRUE);
INSERT INTO core_lang(code, name) VALUES ('gl_es', 'Galician / Galego');
INSERT INTO core_lang(code, name) VALUES ('gu_in', 'Gujarati / ગુજરાતી');
INSERT INTO core_lang(code, name) VALUES ('he_il', 'Hebrew / עִבְרִי');
INSERT INTO core_lang(code, name) VALUES ('hi_in', 'Hindi / हिंदी');
INSERT INTO core_lang(code, name) VALUES ('hr_hr', 'Croatian / hrvatski jezik');
INSERT INTO core_lang(code, name) VALUES ('hu_hu', 'Hungarian / Magyar');
INSERT INTO core_lang(code, name) VALUES ('id_id', 'Indonesian / Bahasa Indonesia');
INSERT INTO core_lang(code, name) VALUES ('it_it', 'Italian / Italiano');
INSERT INTO core_lang(code, name) VALUES ('iu_ca', 'Inuktitut / ᐃᓄᒃᑎᑐᑦ');
INSERT INTO core_lang(code, name) VALUES ('ja_jp', 'Japanese / 日本語');
INSERT INTO core_lang(code, name) VALUES ('ko_kp', 'Korean (KP) / 한국어 (KP)');
INSERT INTO core_lang(code, name) VALUES ('ko_kr', '한국어 (KR)');
INSERT INTO core_lang(code, name) VALUES ('lt_lt', 'Lithuanian / Lietuvių kalba');
INSERT INTO core_lang(code, name) VALUES ('lv_lv', 'Latvian / latviešu valoda');
INSERT INTO core_lang(code, name) VALUES ('ml_in', 'Malayalam / മലയാളം');
INSERT INTO core_lang(code, name) VALUES ('mn_mn', 'Mongolian / монгол');
INSERT INTO core_lang(code, name) VALUES ('nb_no', 'Norwegian Bokmål / Norsk bokmål');
INSERT INTO core_lang(code, name) VALUES ('nl_nl', 'Dutch / Nederlands');
INSERT INTO core_lang(code, name) VALUES ('nl_be', 'Flemish (BE) / Vlaams (BE)');
INSERT INTO core_lang(code, name) VALUES ('oc_fr', 'Occitan (FR, post 1500) / Occitan');
INSERT INTO core_lang(code, name) VALUES ('pl_pl', 'Polish / Język polski');
INSERT INTO core_lang(code, name) VALUES ('pt_br', 'Portuguese (BR) / Português (BR)');
INSERT INTO core_lang(code, name) VALUES ('pt_pt', 'Portuguese / Português');
INSERT INTO core_lang(code, name) VALUES ('ro_ro', 'Romanian / română');
INSERT INTO core_lang(code, name) VALUES ('ru_ru', 'Russian / русский язык');
INSERT INTO core_lang(code, name) VALUES ('si_lk', 'Sinhalese / සිංහල');
INSERT INTO core_lang(code, name) VALUES ('sl_si', 'Slovenian / slovenščina');
INSERT INTO core_lang(code, name) VALUES ('sk_sk', 'Slovak / Slovenský jazyk');
INSERT INTO core_lang(code, name) VALUES ('sq_al', 'Albanian / Shqip');
INSERT INTO core_lang(code, name) VALUES ('sr_rs', 'Serbian (Cyrillic) / српски');
INSERT INTO core_lang(code, name) VALUES ('sr_latin', 'Serbian (Latin) / srpski');
INSERT INTO core_lang(code, name) VALUES ('sv_se', 'Swedish / svenska');
INSERT INTO core_lang(code, name) VALUES ('te_in', 'Telugu / తెలుగు');
INSERT INTO core_lang(code, name) VALUES ('tr_tr', 'Turkish / Türkçe');
INSERT INTO core_lang(code, name) VALUES ('vi_vn', 'Vietnamese / Tiếng Việt');
INSERT INTO core_lang(code, name) VALUES ('uk_ua', 'Ukrainian / українська');
INSERT INTO core_lang(code, name) VALUES ('ur_pk', 'Urdu / اردو');
INSERT INTO core_lang(code, name) VALUES ('zh_cn', 'Chinese (CN) / 简体中文');
INSERT INTO core_lang(code, name) VALUES ('zh_hk', 'Chinese (HK)');
INSERT INTO core_lang(code, name) VALUES ('zh_tw', 'Chinese (TW) / 正體字');
INSERT INTO core_lang(code, name) VALUES ('th_th', 'Thai / ภาษาไทย');
INSERT INTO core_lang(code, name) VALUES ('tlh_tlh', 'Klingon');
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ad', 'Andorra, Principality of', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ae', 'United Arab Emirates', (SELECT id FROM core_currency WHERE code='aed' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('af', 'Afghanistan, Islamic State of', (SELECT id FROM core_currency WHERE code='afn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ag', 'Antigua and Barbuda', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ai', 'Anguilla', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('al', 'Albania', (SELECT id FROM core_currency WHERE code='all' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('am', 'Armenia', (SELECT id FROM core_currency WHERE code='amd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('an', 'Netherlands Antilles', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ao', 'Angola', (SELECT id FROM core_currency WHERE code='aoa' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('aq', 'Antarctica', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ar', 'Argentina', (SELECT id FROM core_currency WHERE code='ars' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('as', 'American Samoa', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('at', 'Austria', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('au', 'Australia', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('aw', 'Aruba', (SELECT id FROM core_currency WHERE code='awg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ax', 'Åland Islands', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('az', 'Azerbaijan', (SELECT id FROM core_currency WHERE code='azn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ba', 'Bosnia-Herzegovina', (SELECT id FROM core_currency WHERE code='bam' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bb', 'Barbados', (SELECT id FROM core_currency WHERE code='bbd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bd', 'Bangladesh', (SELECT id FROM core_currency WHERE code='bdt' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('be', 'Belgium', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bf', 'Burkina Faso', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bg', 'Bulgaria', (SELECT id FROM core_currency WHERE code='bgn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bh', 'Bahrain', (SELECT id FROM core_currency WHERE code='bhd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bi', 'Burundi', (SELECT id FROM core_currency WHERE code='bif' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bj', 'Benin', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bl', 'Saint Barthélémy', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bm', 'Bermuda', (SELECT id FROM core_currency WHERE code='bmd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bn', 'Brunei Darussalam', (SELECT id FROM core_currency WHERE code='bnd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bo', 'Bolivia', (SELECT id FROM core_currency WHERE code='bob' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bq', 'Bonaire, Sint Eustatius and Saba', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('br', 'Brazil', (SELECT id FROM core_currency WHERE code='brl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bs', 'Bahamas', (SELECT id FROM core_currency WHERE code='bsd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bt', 'Bhutan', (SELECT id FROM core_currency WHERE code='btn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bv', 'Bouvet Island', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bw', 'Botswana', (SELECT id FROM core_currency WHERE code='bwp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('by', 'Belarus', (SELECT id FROM core_currency WHERE code='byr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bz', 'Belize', (SELECT id FROM core_currency WHERE code='bzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ca', 'Canada', (SELECT id FROM core_currency WHERE code='cad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cc', 'Cocos (Keeling) Islands', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cf', 'Central African Republic', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cd', 'Congo, Democratic Republic of the', (SELECT id FROM core_currency WHERE code='cdf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cg', 'Congo', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('ch', 'Switzerland', (SELECT id FROM core_currency WHERE code='chf' LIMIT 1), 1);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ci', 'Ivory Coast (Cote D''Ivoire)', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ck', 'Cook Islands', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cl', 'Chile', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cm', 'Cameroon', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cn', 'China', (SELECT id FROM core_currency WHERE code='cny' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('co', 'Colombia', (SELECT id FROM core_currency WHERE code='cop' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cr', 'Costa Rica', (SELECT id FROM core_currency WHERE code='crc' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cu', 'Cuba', (SELECT id FROM core_currency WHERE code='cup' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cv', 'Cape Verde', (SELECT id FROM core_currency WHERE code='cve' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cw', 'Curaçao', (SELECT id FROM core_currency WHERE code='ang' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cx', 'Christmas Island', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cy', 'Cyprus', (SELECT id FROM core_currency WHERE code='cyp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cz', 'Czech Republic', (SELECT id FROM core_currency WHERE code='czk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('de', 'Germany', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1), 3);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dj', 'Djibouti', (SELECT id FROM core_currency WHERE code='djf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dk', 'Denmark', (SELECT id FROM core_currency WHERE code='dkk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dm', 'Dominica', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('do', 'Dominican Republic', (SELECT id FROM core_currency WHERE code='dop' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dz', 'Algeria', (SELECT id FROM core_currency WHERE code='dzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ec', 'Ecuador', (SELECT id FROM core_currency WHERE code='ecs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ee', 'Estonia', (SELECT id FROM core_currency WHERE code='eek' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('eg', 'Egypt', (SELECT id FROM core_currency WHERE code='egp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('eh', 'Western Sahara', (SELECT id FROM core_currency WHERE code='mad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('er', 'Eritrea', (SELECT id FROM core_currency WHERE code='ern' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('es', 'Spain', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('et', 'Ethiopia', (SELECT id FROM core_currency WHERE code='etb' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fi', 'Finland', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fj', 'Fiji', (SELECT id FROM core_currency WHERE code='fjd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fk', 'Falkland Islands', (SELECT id FROM core_currency WHERE code='fkp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fm', 'Micronesia', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fo', 'Faroe Islands', (SELECT id FROM core_currency WHERE code='dkk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('fr', 'France', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1), 2);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ga', 'Gabon', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gd', 'Grenada', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ge', 'Georgia', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gf', 'French Guyana', (SELECT id FROM core_currency WHERE code='gel' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gh', 'Ghana', (SELECT id FROM core_currency WHERE code='ghs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gi', 'Gibraltar', (SELECT id FROM core_currency WHERE code='gip' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gg', 'Guernsey', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gl', 'Greenland', (SELECT id FROM core_currency WHERE code='dkk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gm', 'Gambia', (SELECT id FROM core_currency WHERE code='gmd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gn', 'Guinea', (SELECT id FROM core_currency WHERE code='gnf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gp', 'Guadeloupe (French)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gq', 'Equatorial Guinea', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gr', 'Greece', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gs', 'South Georgia and the South Sandwich Islands', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gt', 'Guatemala', (SELECT id FROM core_currency WHERE code='qtq' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gu', 'Guam (USA)', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gw', 'Guinea Bissau', (SELECT id FROM core_currency WHERE code='gwp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gy', 'Guyana', (SELECT id FROM core_currency WHERE code='gyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hk', 'Hong Kong', (SELECT id FROM core_currency WHERE code='hkd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hm', 'Heard and McDonald Islands', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hn', 'Honduras', (SELECT id FROM core_currency WHERE code='hnl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hr', 'Croatia', (SELECT id FROM core_currency WHERE code='hrk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ht', 'Haiti', (SELECT id FROM core_currency WHERE code='htg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hu', 'Hungary', (SELECT id FROM core_currency WHERE code='huf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('id', 'Indonesia', (SELECT id FROM core_currency WHERE code='idr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ie', 'Ireland', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('il', 'Israel', (SELECT id FROM core_currency WHERE code='ils' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('im', 'Isle of Man', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('in', 'India', (SELECT id FROM core_currency WHERE code='inr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('io', 'British Indian Ocean Territory', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('iq', 'Iraq', (SELECT id FROM core_currency WHERE code='iqd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ir', 'Iran', (SELECT id FROM core_currency WHERE code='irr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('is', 'Iceland', (SELECT id FROM core_currency WHERE code='isk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('it', 'Italy', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('je', 'Jersey', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('jm', 'Jamaica', (SELECT id FROM core_currency WHERE code='jmd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('jo', 'Jordan', (SELECT id FROM core_currency WHERE code='jod' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('jp', 'Japan', (SELECT id FROM core_currency WHERE code='jpy' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ke', 'Kenya', (SELECT id FROM core_currency WHERE code='kes' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kg', 'Kyrgyz Republic (Kyrgyzstan)', (SELECT id FROM core_currency WHERE code='kgs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kh', 'Cambodia, Kingdom of', (SELECT id FROM core_currency WHERE code='khr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ki', 'Kiribati', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('km', 'Comoros', (SELECT id FROM core_currency WHERE code='kmf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kn', 'Saint Kitts & Nevis Anguilla', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kp', 'North Korea', (SELECT id FROM core_currency WHERE code='kpw' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kr', 'South Korea', (SELECT id FROM core_currency WHERE code='krw' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kw', 'Kuwait', (SELECT id FROM core_currency WHERE code='kwd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ky', 'Cayman Islands', (SELECT id FROM core_currency WHERE code='kyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kz', 'Kazakhstan', (SELECT id FROM core_currency WHERE code='kzt' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('la', 'Laos', (SELECT id FROM core_currency WHERE code='lak' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lb', 'Lebanon', (SELECT id FROM core_currency WHERE code='lbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lc', 'Saint Lucia', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('li', 'Liechtenstein', (SELECT id FROM core_currency WHERE code='chf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lk', 'Sri Lanka', (SELECT id FROM core_currency WHERE code='lkr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lr', 'Liberia', (SELECT id FROM core_currency WHERE code='lrd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ls', 'Lesotho', (SELECT id FROM core_currency WHERE code='lsl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lt', 'Lithuania', (SELECT id FROM core_currency WHERE code='ltl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lu', 'Luxembourg', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lv', 'Latvia', (SELECT id FROM core_currency WHERE code='lvl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ly', 'Libya', (SELECT id FROM core_currency WHERE code='lyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ma', 'Morocco', (SELECT id FROM core_currency WHERE code='mad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mc', 'Monaco', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('md', 'Moldavia', (SELECT id FROM core_currency WHERE code='mdl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('me', 'Montenegro', (SELECT id FROM core_currency WHERE code='lyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mf', 'Saint Martin (French part)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mg', 'Madagascar', (SELECT id FROM core_currency WHERE code='mga' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mh', 'Marshall Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mk', 'Macedonia, the former Yugoslav Republic of', (SELECT id FROM core_currency WHERE code='mkd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ml', 'Mali', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mm', 'Myanmar', (SELECT id FROM core_currency WHERE code='mmk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mn', 'Mongolia', (SELECT id FROM core_currency WHERE code='mnt' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mo', 'Macau', (SELECT id FROM core_currency WHERE code='mop' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mp', 'Northern Mariana Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mq', 'Martinique (French)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mr', 'Mauritania', (SELECT id FROM core_currency WHERE code='mro' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ms', 'Montserrat', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mt', 'Malta', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mu', 'Mauritius', (SELECT id FROM core_currency WHERE code='mur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mv', 'Maldives', (SELECT id FROM core_currency WHERE code='mvr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mw', 'Malawi', (SELECT id FROM core_currency WHERE code='mwk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mx', 'Mexico', (SELECT id FROM core_currency WHERE code='mxn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('my', 'Malaysia', (SELECT id FROM core_currency WHERE code='mxn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mz', 'Mozambique', (SELECT id FROM core_currency WHERE code='mzn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('na', 'Namibia', (SELECT id FROM core_currency WHERE code='nad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nc', 'New Caledonia (French)', (SELECT id FROM core_currency WHERE code='xpf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ne', 'Niger', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nf', 'Norfolk Island', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ng', 'Nigeria', (SELECT id FROM core_currency WHERE code='ngn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ni', 'Nicaragua', (SELECT id FROM core_currency WHERE code='nio' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nl', 'Netherlands', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('no', 'Norway', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('np', 'Nepal', (SELECT id FROM core_currency WHERE code='npr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nr', 'Nauru', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nt', 'Neutral Zone', (SELECT id FROM core_currency WHERE code='iqd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nu', 'Niue', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nz', 'New Zealand', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('om', 'Oman', (SELECT id FROM core_currency WHERE code='omr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pa', 'Panama', (SELECT id FROM core_currency WHERE code='pab' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pe', 'Peru', (SELECT id FROM core_currency WHERE code='pen' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pf', 'Polynesia (French)', (SELECT id FROM core_currency WHERE code='xpf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pg', 'Papua New Guinea', (SELECT id FROM core_currency WHERE code='pgk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ph', 'Philippines', (SELECT id FROM core_currency WHERE code='php' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pk', 'Pakistan', (SELECT id FROM core_currency WHERE code='pkr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pl', 'Poland', (SELECT id FROM core_currency WHERE code='plz' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pm', 'Saint Pierre and Miquelon', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pn', 'Pitcairn Island', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pr', 'Puerto Rico', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ps', 'Palestinian Territory, Occupied', (SELECT id FROM core_currency WHERE code='ils' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pt', 'Portugal', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pw', 'Palau', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('py', 'Paraguay', (SELECT id FROM core_currency WHERE code='pyg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('qa', 'Qatar', (SELECT id FROM core_currency WHERE code='qar' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('re', 'Reunion (French)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ro', 'Romania', (SELECT id FROM core_currency WHERE code='rol' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('rs', 'Serbia', (SELECT id FROM core_currency WHERE code='rsd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('ru', 'Russian Federation', (SELECT id FROM core_currency WHERE code='rub' LIMIT 1), 100);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('rw', 'Rwanda', (SELECT id FROM core_currency WHERE code='rwf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sa', 'Saudi Arabia', (SELECT id FROM core_currency WHERE code='sar' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sb', 'Solomon Islands', (SELECT id FROM core_currency WHERE code='sbd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sc', 'Seychelles', (SELECT id FROM core_currency WHERE code='scr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sd', 'Sudan', (SELECT id FROM core_currency WHERE code='sdd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('se', 'Sweden', (SELECT id FROM core_currency WHERE code='sek' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sg', 'Singapore', (SELECT id FROM core_currency WHERE code='sgd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sh', 'Saint Helena', (SELECT id FROM core_currency WHERE code='shp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('si', 'Slovenia', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sj', 'Svalbard and Jan Mayen Islands', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sk', 'Slovakia', (SELECT id FROM core_currency WHERE code='skk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sl', 'Sierra Leone', (SELECT id FROM core_currency WHERE code='sll' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sm', 'San Marino', (SELECT id FROM core_currency WHERE code='itl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sn', 'Senegal', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('so', 'Somalia', (SELECT id FROM core_currency WHERE code='sod' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sr', 'Suriname', (SELECT id FROM core_currency WHERE code='srg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ss', 'South Sudan', (SELECT id FROM core_currency WHERE code='ssp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('st', 'Saint Tome (Sao Tome) and Principe', (SELECT id FROM core_currency WHERE code='std' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sv', 'El Salvador', (SELECT id FROM core_currency WHERE code='svc' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sx', 'Sint Maarten (Dutch part)', (SELECT id FROM core_currency WHERE code='ang' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sy', 'Syria', (SELECT id FROM core_currency WHERE code='syp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sz', 'Swaziland', (SELECT id FROM core_currency WHERE code='szl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tc', 'Turks and Caicos Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('td', 'Chad', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tf', 'French Southern Territories', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tg', 'Togo', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('th', 'Thailand', (SELECT id FROM core_currency WHERE code='thb' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tj', 'Tajikistan', (SELECT id FROM core_currency WHERE code='tjr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tk', 'Tokelau', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tm', 'Turkmenistan', (SELECT id FROM core_currency WHERE code='tmm' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tn', 'Tunisia', (SELECT id FROM core_currency WHERE code='tnd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('to', 'Tonga', (SELECT id FROM core_currency WHERE code='top' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tp', 'East Timor', (SELECT id FROM core_currency WHERE code='tpe' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tr', 'Turkey', (SELECT id FROM core_currency WHERE code='trl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tt', 'Trinidad and Tobago', (SELECT id FROM core_currency WHERE code='ttd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tv', 'Tuvalu', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tw', 'Taiwan', (SELECT id FROM core_currency WHERE code='twd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tz', 'Tanzania', (SELECT id FROM core_currency WHERE code='tzs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ua', 'Ukraine', (SELECT id FROM core_currency WHERE code='uag' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ug', 'Uganda', (SELECT id FROM core_currency WHERE code='ugx' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('gb', 'United Kingdom', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1), 4);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('um', 'USA Minor Outlying Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('us', 'United States', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('uy', 'Uruguay', (SELECT id FROM core_currency WHERE code='uyp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('uz', 'Uzbekistan', (SELECT id FROM core_currency WHERE code='uzs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('va', 'Holy See (Vatican City State)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vc', 'Saint Vincent & Grenadines', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ve', 'Venezuela', (SELECT id FROM core_currency WHERE code='vub' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vg', 'Virgin Islands (British)', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vi', 'Virgin Islands (USA)', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vn', 'Vietnam', (SELECT id FROM core_currency WHERE code='vnd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vu', 'Vanuatu', (SELECT id FROM core_currency WHERE code='vuv' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('wf', 'Wallis and Futuna Islands', (SELECT id FROM core_currency WHERE code='xpf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ws', 'Samoa', (SELECT id FROM core_currency WHERE code='wst' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ye', 'Yemen', (SELECT id FROM core_currency WHERE code='yer' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('yt', 'Mayotte', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('yu', 'Yugoslavia', (SELECT id FROM core_currency WHERE code='yum' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('za', 'South Africa', (SELECT id FROM core_currency WHERE code='zar' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('zm', 'Zambia', (SELECT id FROM core_currency WHERE code='zmk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('zr', 'Zaire', (SELECT id FROM core_currency WHERE code='zrz' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('zw', 'Zimbabwe', (SELECT id FROM core_currency WHERE code='zwd' LIMIT 1) );
---- general translations
--INSERT INTO core_translation(code, source, en_gb, fr_fr, en_us) VALUES('dateFormat', 'd/m/Y', 'd/m/Y', 'd/m/Y', 'm/d/Y');
/* config constants in database */
INSERT INTO core_config(k, v) VALUES('framework_environment', 'prod');
INSERT INTO core_config(k, v) VALUES('email_active', 'false');
INSERT INTO core_config(k, v) VALUES('theme', 'materialize');
INSERT INTO core_config(k, v) VALUES('default_lang_code', (SELECT code FROM core_lang WHERE code='en_gb' LIMIT 1));
INSERT INTO core_config(k, v) VALUES('default_country_code', (SELECT code FROM core_country WHERE code='ch' LIMIT 1));
INSERT INTO core_config(k, v) VALUES('default_currency_code', (SELECT code FROM core_currency WHERE code='chf' LIMIT 1));
INSERT INTO core_config(k, v) VALUES('email_info', 'info@localhost');
INSERT INTO core_config(k, v) VALUES('email_noreply', 'no-reply@localhost');
CREATE TABLE user_user (
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
email VARCHAR(128) NOT NULL,
password VARCHAR(128) NOT NULL,
firstname VARCHAR(128) NOT NULL DEFAULT '',
lastname VARCHAR(128) NOT NULL DEFAULT '',
phone VARCHAR(32) NOT NULL DEFAULT '',
postcode VARCHAR(32) NOT NULL DEFAULT '',
city VARCHAR(128) NOT NULL DEFAULT '',
core_lang_id INTEGER,
core_country_id INTEGER,
core_currency_id INTEGER,
core_theme_id INTEGER,
is_active BOOLEAN NOT NULL DEFAULT FALSE,
comment TEXT NOT NULL DEFAULT '',
activation_code VARCHAR(128) NOT NULL,
CONSTRAINT userUser_id_pk PRIMARY KEY(id),
CONSTRAINT userUser_email_uk UNIQUE(email),
CONSTRAINT userUser_coreLangId_fk FOREIGN KEY(core_lang_id) REFERENCES core_lang(id),
CONSTRAINT userUser_coreCountryId_fk FOREIGN KEY(core_country_id) REFERENCES core_country(id),
CONSTRAINT userUser_coreCurrencyId_fk FOREIGN KEY(core_currency_id) REFERENCES core_currency(id),
CONSTRAINT userUser_coreThemeId_fk FOREIGN KEY(core_theme_id) REFERENCES core_theme(id)
);
CREATE TABLE user_detail (
id SERIAL,
user_id INTEGER NOT NULL,
ext_id INTEGER NOT NULL,
CONSTRAINT coreUserDetail_id_pk PRIMARY KEY(id),
CONSTRAINT coreUserDetail_coreUserId_fk FOREIGN KEY(user_id) REFERENCES user_user(id)
);
CREATE TABLE user_confirm (
id SERIAL,
user_id VARCHAR(128) NOT NULL DEFAULT '',
key_confirmation VARCHAR(128) NOT NULL DEFAULT '',
email VARCHAR(250) DEFAULT NULL,
CONSTRAINT coreUserConfirm_pk PRIMARY KEY(id)
);
CREATE TABLE useruser_corefeature_rel (
user_id INTEGER,
core_feature_id INTEGER,
CONSTRAINT userUserCoreFeatureRel_coreUserId_fk FOREIGN KEY(user_id) REFERENCES user_user(id),
CONSTRAINT userUserCoreFeatureRel_coreMenuId_fk FOREIGN KEY(core_feature_id) REFERENCES core_feature(id),
CONSTRAINT userUserCoreFeatureRel_userId_menuId_uk UNIQUE(user_id, core_feature_id)
);
-- core_feature: home
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_home_url', 'home', 'home', 'accueil');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_home_label', 'Home', 'Home', 'Accueil');
INSERT INTO core_feature(model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest
) VALUES('home', 'home',
(SELECT id FROM core_feature_translation WHERE code='menu_home_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_home_label' LIMIT 1),
TRUE, TRUE
);
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_login_url', 'login', 'login', 'connexion');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_login_label', 'Login', 'Login', 'Connexion');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest
) VALUES ('login', 'login',
(SELECT id FROM core_feature_translation WHERE code='menu_login_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_login_label' LIMIT 1),
TRUE, TRUE
);
-- logout: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr, ko_kr) VALUES ('menu_logout_url', 'logout', 'logout', 'logout', '');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr, ko_kr) VALUES ('menu_logout_label', 'Logout', 'Logout', 'Déconnexion', '');
-- logout: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest
) VALUES('logout', 'logout',
(SELECT id FROM core_feature_translation WHERE code='menu_logout_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_logout_label' LIMIT 1),
TRUE, FALSE
);
-- my-profile: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_myProfile_url', 'my-profile', 'my-profile', 'mon-compte');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_myProfile_label', 'My Profile', 'My Profile', 'Mon Compte');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest
) VALUES ('my-profile', 'my-profile',
(SELECT id FROM core_feature_translation WHERE code='menu_myProfile_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_myProfile_label' LIMIT 1),
TRUE, FALSE
);
CREATE TABLE erp_config(
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
k VARCHAR(128) NOT NULL,
v VARCHAR(128) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
comment TEXT NOT NULL DEFAULT '',
CONSTRAINT erpConfig_id_pk PRIMARY KEY(id),
CONSTRAINT erpConfig_k_uk UNIQUE(k)
);
INSERT INTO erp_config(k, v)
VALUES('url', 'http://localhost:8069/'),
('db', 'odoo_wefra'),
('admin_user', 'admin'),
('admin_password', 'admin');
--reorganise the priority of the menu tags
UPDATE core_feature SET priority=10 WHERE code='home';
UPDATE core_feature SET priority=900 WHERE code='my-profile';
UPDATE core_feature SET priority=1000 WHERE code='login';
UPDATE core_feature SET priority=1000 WHERE code='logout';

View File

@ -0,0 +1,103 @@
<?php
session_start();
unset($_SESSION);
// Import Core Interfaces
require_once('../../modules/InterfaceConfig.php');
require_once('../../modules/InterfacePostgreSQL.php');
// Import Core Classes
require_once('../../modules/ClassConfig.php');
require_once('../../modules/ClassUser.php');
require_once('../../modules/ClassCountry.php');
require_once('../../modules/ClassCurrency.php');
require_once('../../modules/ClassLang.php');
// Import Custom Classes
require_once('../../custom/modules/ClassUserCustom.php');
require_once('../../custom/modules/ClassERP.php');
require_once('../../custom/modules/ripcord.php');
echo "test";
$oConf = new ClassConfig();
$oUser = new ClassUserCustom();
$oCountry = new ClassCountry();
$oCurrency = new ClassCurrency();
$oLang = new ClassLang();
$oERP = new ClassERP();
// Create session arrays
if (!isset($_SESSION['config'])) {
$_SESSION['config'] = $oConf->getConfig();
$_SESSION['erp'] = $oERP->getConfig();
//$_SESSION['translations'] = $oTrans->listTranslations($_SESSION['config']['default_lang_code']);
//$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
//$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
//$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
//$_SESSION['languages'] = $oLang->listLanguages();
//$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
}
// Open connection with Odoo
$url = $_SESSION['erp']['url'];
$db = $_SESSION['erp']['db'];
$username = $_SESSION['erp']['admin_user'];
$password = $_SESSION['erp']['admin_password'];
$common = ripcord::client($url."xmlrpc/2/common");
$uid = $common->authenticate($db, $username, $password, array());
$models = ripcord::client($url."xmlrpc/2/object");
// Step 1. Create user admin@wefra
$data = array('formRegisterFieldPassword'=>'admin', 'formRegisterFieldConfirmPassword'=>'admin', 'formRegisterFieldFirstname'=>'Admin', 'formRegisterFieldLastname'=>'Wefra',
'formRegisterFieldEmail'=>'admin@wefra', 'formRegisterFieldCountry'=>44);
$name = $data['formRegisterFieldFirstname'].' '.$data['formRegisterFieldLastname'];
//create user in ERP
$ext_id = $models->execute_kw($db, $uid, $password, 'res.users', 'create',
array(array('name'=>$name,
'email'=>$data['formRegisterFieldEmail'],
'login'=>$data['formRegisterFieldEmail'], //yes, the login IS the email, there is no mistake here
'country_id'=>(integer) $models->execute_kw($db, $uid, $password, 'res.country', 'search', array(array(array('code', '=', 'CH'))))[0],
'project_task_level_id'=>(integer) $models->execute_kw($db, $uid, $password, 'project.task.level', 'search', array(array(array('name', '=', 'White Belt'))))[0]
)));
echo "ext_id has value: ";
print_r($ext_id);
echo "<br><br>";
//if user created in ERP, then create it in Wefra with password linked
if(isset($ext_id) and !is_array($ext_id)){
//create user in Wefra and link the user to ERP
$user = $oUser->createUserForWefraAdmin($data, $ext_id);
echo "Wefra user status: ";
print_r($user);
echo "<br><br>";
if($user){
//update the password for user in ERP
//..
$getUser = $oUser->getUser($user['user_id']);
$models->execute_kw($db, $uid, $password, 'res.users', 'write', array(array($ext_id), array('password'=>$getUser['password'], 'password_uncrypted'=>$data['formRegisterFieldPassword'])));
//..
//that way, ERP rights will be checked everytime Wefra will use ORM to allow user to to actions which will have an influence in the ERP (ie. get a task which will be assigned to his ERP's user related)
$message['content'] = '<span style="color:green"><b>Success: </b><p>User Admin Wefra has been created in globsi-admin</p>';
} else {
echo '<span style="color:red"><b>Failure: </b><p>User Admin Wefra could not been created in globsi-admin</p>';
}
//display a confirmation message that everything went well
$message['content'] = '<span style="color:green"><b>Success: </b><p>User Admin Wefra has been created in globsi-backend</p>';
} else {
//if user not created in ERP, displaying a warning message to ask for a new try
$message['content'] = '<span style="color:red"><b>Failure: </b><p>User Admin Wefra could not been created in globsi-backend</p>';
}
echo $message['content'];
echo "<br><br>Session Config<br>";
print_r($_SESSION['config']);
echo "<br><br>Session ERP<br>";
print_r($_SESSION['erp']);

View File

@ -0,0 +1,22 @@
-- core_feature: register
INSERT INTO core_feature_translation (code, source, en_gb) VALUES('menu_register_url', 'register', 'register');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES('menu_register_label', 'Register', 'Register');
INSERT INTO core_feature(model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, is_active, priority
) VALUES('register', 'register',
(SELECT id FROM core_feature_translation WHERE code='menu_register_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_register_label' LIMIT 1),
TRUE, TRUE, TRUE, 100
);
-- core_feature: terms-of-use
INSERT INTO core_feature_translation (code, source, en_gb) VALUES('menu_termsOfUse_url', 'terms-of-use', 'terms-of-use');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES('menu_termsOfUse_label', 'Terms Of Use', 'Terms Of Use');
INSERT INTO core_feature(model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, is_active, priority
) VALUES('terms-of-use', 'terms-of-use',
(SELECT id FROM core_feature_translation WHERE code='menu_termsOfUse_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_termsOfUse_label' LIMIT 1),
FALSE, TRUE, TRUE, 200
);

View File

@ -0,0 +1,231 @@
-- list-projects: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_listProjects_url', 'list-projects', 'list-projects');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_listProjects_label', 'Projects', 'Projects');
-- list-projects: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id, is_menu_display, is_menu_backend, is_available_for_guest, priority
) VALUES('list-projects', 'list-projects',
(SELECT id FROM core_feature_translation WHERE code='menu_listProjects_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_listProjects_label' LIMIT 1),
TRUE, FALSE, FALSE, 102
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES (
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='list-projects')
);
-- create-project
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_createProject_url', 'create-project', 'create-project', 'creer-projet');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_createProject_label', 'Create Project', 'Create Project', 'Créer Projet');
INSERT INTO core_feature (
model, code, url_feature_translation_id, label_feature_translation_id, is_menu_display, is_available_for_guest, priority
) VALUES ('create-project', 'create-project',
(SELECT id FROM core_feature_translation WHERE code='menu_createProject_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_createProject_label' LIMIT 1),
TRUE, FALSE, 20
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id)
VALUES(
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='create-project')
);
-- list-clients: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_listClients_url', 'list-clients', 'list-clients');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_listClients_label', 'Clients', 'Clients');
-- list-clients: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, priority
) VALUES('list-clients', 'list-clients',
(SELECT id FROM core_feature_translation WHERE code='menu_listClients_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_listClients_label' LIMIT 1),
FALSE, FALSE, 102
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES (
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='list-clients')
);
-- edit-client: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_editClient_url', 'edit-client', 'edit-client');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_editClient_label', 'Edit', 'Edit');
-- edit-client: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, priority
) VALUES('edit-client', 'edit-client',
(SELECT id FROM core_feature_translation WHERE code='menu_editClient_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_editClient_label' LIMIT 1),
FALSE, FALSE, 102
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES (
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='edit-client')
);
-- list-providers: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_listProviders_url', 'list-providers', 'list-providers');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_listProviders_label', 'Providers', 'Providers');
-- list-providers: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, priority
) VALUES('list-providers', 'list-providers',
(SELECT id FROM core_feature_translation WHERE code='menu_listProviders_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_listProviders_label' LIMIT 1),
FALSE, FALSE, 102
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES (
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='list-providers')
);
-- edit-provider: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_editProvider_url', 'edit-provider', 'edit-provider');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_editProvider_label', 'Edit', 'Edit');
-- edit-provider: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, priority
) VALUES('edit-provider', 'edit-provider',
(SELECT id FROM core_feature_translation WHERE code='menu_editProvider_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_editProvider_label' LIMIT 1),
FALSE, FALSE, 102
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES (
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='edit-provider')
);
-- create-provider: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_createProvider_url', 'create-provider', 'create-provider');
INSERT INTO core_feature_translation (code, source, en_gb) VALUES ('menu_createProvider_label', 'Edit', 'Edit');
-- create-provider: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_available_for_guest, priority
) VALUES('create-provider', 'create-provider',
(SELECT id FROM core_feature_translation WHERE code='menu_createProvider_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_createProvider_label' LIMIT 1),
FALSE, FALSE, 102
);
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id) VALUES (
(SELECT id FROM user_user WHERE email='admin@globsi-admin'),
(SELECT id FROM core_feature WHERE code='create-provider')
);
--reorganise the priority of the menu tags
UPDATE core_feature SET priority=10 WHERE code='home';
UPDATE core_feature SET priority=50 WHERE code='list-projects';
UPDATE core_feature SET priority=100 WHERE code='list-tasks';
UPDATE core_feature SET priority=150 WHERE code='list-clients';
UPDATE core_feature SET priority=200 WHERE code='list-providers';
UPDATE core_feature SET priority=250 WHERE code='list-isp';
UPDATE core_feature SET priority=900 WHERE code='my-profile';
UPDATE core_feature SET priority=1000 WHERE code='login';
UPDATE core_feature SET priority=1000 WHERE code='logout';
UPDATE core_feature_translation SET source='Tasks', en_gb='Tasks' WHERE code='menu_listTasks_label';
UPDATE core_feature SET is_menu_display=TRUE WHERE code IN ('list-projects', 'list-tasks', 'list-clients', 'list-isp', 'list-providers', 'list-users', 'list-translations');
UPDATE core_feature SET is_menu_display=FALSE WHERE code IN ('edit-projects', 'edit-tasks', 'edit-clients', 'edit-isp', 'edit-providers', 'edit-users', 'edit-translations');
UPDATE core_feature SET is_menu_display=FALSE WHERE code IN ('create-projects', 'create-tasks', 'create-clients', 'create-isp', 'create-providers', 'create-users', 'create-translations');
DROP TABLE IF EXISTS globsi_providers_config;
CREATE TABLE globsi_providers_config(
id SERIAL,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
k VARCHAR(128) NOT NULL,
v VARCHAR(128) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
comment TEXT NOT NULL DEFAULT '',
CONSTRAINT globsiProvidersConfig_id_pk PRIMARY KEY(id),
CONSTRAINT globsiProvidersConfig_k_uk UNIQUE(k)
);
INSERT INTO globsi_providers_config(k, v)
VALUES('db_server', 'localhost'),
('db_name', 'globsi_providers'),
('db_user', 'odoo11'),
('db_password', 'odoo11');
-- core_feature: list-translations
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_listTranslations_url', 'list-translations', 'list-translations', 'lister-traductions');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_listTranslations_label', 'List Translations', 'List Translations', 'Lister Traductions');
INSERT INTO core_feature (
model, code, url_feature_translation_id, label_feature_translation_id, is_menu_display, is_menu_backend, is_available_for_guest, priority
) VALUES ('list-translations', 'list-translations',
(SELECT id FROM core_feature_translation WHERE code='menu_listTranslations_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_listTranslations_label' LIMIT 1),
TRUE, FALSE, FALSE, 30
);
-- core_feature: edit-translation
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_editTranslation_url', 'edit-translation', 'edit-translation', 'editer-traduction');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_editTranslation_label', 'Edit Translation', 'Edit Translation', 'Éditer Traduction');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_menu_backend, is_available_for_guest
) VALUES ('edit-translation', 'edit-translation',
(SELECT id FROM core_feature_translation WHERE code='menu_editTranslation_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_editTranslation_label' LIMIT 1),
FALSE, FALSE, FALSE
);
-- core_feature: list-users
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_listUsers_url', 'list-users', 'list-users', 'lister-utilisateurs');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_listUsers_label', 'List Users', 'List Users', 'Lister Users');
INSERT INTO core_feature (
model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_menu_backend, is_available_for_guest, priority
) VALUES ('list-users', 'list-users',
(SELECT id FROM core_feature_translation WHERE code='menu_listUsers_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_listUsers_label' LIMIT 1),
TRUE, FALSE, FALSE, 30
);
-- core_feature: edit-user
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_editUser_url', 'edit-user', 'edit-user', 'editer-traduction');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_editUser_label', 'Edit User', 'Edit User', 'Éditer User');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_menu_backend, is_available_for_guest
) VALUES ('edit-user', 'edit-user',
(SELECT id FROM core_feature_translation WHERE code='menu_editUser_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_editUser_label' LIMIT 1),
FALSE, FALSE, FALSE
);
-- core_feature: list-tasks
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_listTasks_url', 'list-tasks', 'list-tasks', 'lister-taches');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_listTasks_label', 'List Tasks', 'List Tasks', 'Lister Tâches');
INSERT INTO core_feature (
model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_menu_backend, is_available_for_guest, priority
) VALUES ('list-tasks', 'list-tasks',
(SELECT id FROM core_feature_translation WHERE code='menu_listTasks_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_listTasks_label' LIMIT 1),
TRUE, FALSE, FALSE, 30
);
-- core_feature: edit-task
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_editTask_url', 'edit-task', 'edit-task', 'editer-tache');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_editTask_label', 'Edit Task', 'Edit Task', 'Éditer Tâche');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
is_menu_display, is_menu_backend, is_available_for_guest
) VALUES ('edit-task', 'edit-task',
(SELECT id FROM core_feature_translation WHERE code='menu_editTask_url' LIMIT 1),
(SELECT id FROM core_feature_translation WHERE code='menu_editTask_label' LIMIT 1),
FALSE, FALSE, FALSE
);

12
custom/modules.php Normal file
View File

@ -0,0 +1,12 @@
<?php
//require_once('./custom/modules/InterfaceForeignDB.php');
//require_once('./custom/modules/ClassForeignDB.php');
//require_once('./custom/modules/ClassDMKPI.php');
require_once('./custom/modules/ClassUserCustom.php');
require_once('./custom/modules/ClassERP.php');
require_once('./custom/modules/ClassGlobsiClients.php');
require_once('./custom/modules/ClassGlobsiISP.php');
require_once('./custom/modules/ClassGlobsiProvider.php');
require_once('./custom/modules/ClassXMLRPC.php');
require_once('./custom/modules/ClassPlay.php');
require_once('./custom/modules/ripcord.php');

View File

@ -0,0 +1,22 @@
<?php
class ClassERP {
public function __construct(){}
public function __destruct(){}
public function getConfig(){
$oPDOLink = ClassConfig::databaseConnect();
$rowsConfig = array();
$sql="
SELECT *
FROM erp_config
WHERE is_active=TRUE
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array());
$rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $k=>$v){
$erpConfig[$rows[$k]['k']] = $rows[$k]['v'];
}
return $erpConfig;
}
}

View File

@ -0,0 +1,127 @@
<?php
class ClassGlobsiClients extends ClassConfig {
public function __construct(){}
public function __destruct(){}
public function getConfig(){
$oPDOLink = ClassConfig::databaseConnect();
$rowsConfig = array();
$sql="
SELECT *
FROM globsi_clients_config
WHERE is_active=TRUE
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array());
$rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $k=>$v){
$erpConfig[$rows[$k]['k']] = $rows[$k]['v'];
}
return $erpConfig;
}
public function createClient($data, $ext_id){
$this->_data = $data;
$this->_extId = $ext_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_clients']['db_server'], $_SESSION['globsi_clients']['db_name'], $_SESSION['globsi_clients']['db_user'], $_SESSION['globsi_clients']['db_password']);
//IF password and confirmPassword are not identical, displaying an error message
if($this->_data['formCreateClientFieldPassword'] != $this->_data['formCreateClientFieldConfirmPassword']){
$message['state']='failed';
$message['css_class']='failed';
$message['translation_code'] = 'checkRegisterForm_notSamePassword';
return $message;
}
else {
$activation_code = rand();
$sql="
INSERT INTO user_user(email, password, activation_code, firstname, lastname,
core_lang_id, core_country_id, core_currency_id, core_theme_id,
is_active, comment
)VALUES(
:email, :password, :activation_code,
:firstname, :lastname,
12, 44, 4, 1,
true, 'user created during installation process')
";
$execSQL = $oPDOLink->prepare($sql);
if($execSQL->execute(array(
':email'=>$this->_data['formCreateClientFieldEmail'],
':password'=>sha1($this->_data['formCreateClientFieldPassword'].'-k3P[8x&'),
':activation_code'=>$activation_code,
':firstname'=>$this->_data['formCreateClientFieldFirstname'],
':lastname'=>$this->_data['formCreateClientFieldLastname']
))){
$newUserId = $oPDOLink->lastInsertId('user_user_id_seq');
//$isVipOfferActive = $this->_checkIfVipOfferActive();
//$isEverythingForFreeActive = $this->_checkIfEverythingForFreeActive();
// core user detail
$sql="
INSERT INTO user_detail(user_id, ext_id)
VALUES (:user_id, :ext_id)
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$newUserId, ':ext_id'=>$this->_extId));
// features for user
$sql="
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id)
VALUES (
(SELECT id FROM user_user WHERE email=:email LIMIT 1),
(SELECT id FROM core_feature WHERE code=:core_feature_code LIMIT 1)
);
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'home'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'list-tasks'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'edit-task'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'create-task'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'list-partners'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'edit-partner'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'create-partner'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'list-projects'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'edit-project'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'create-project'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'my-profile'));
$execSQL->execute(array(':email'=>$this->_data['formCreateClientFieldEmail'], ':core_feature_code'=>'logout'));
$message['user_id'] = $newUserId;
$message['activation_code'] = $activation_code;
$message['status'] = "green";
$message['content'] = 'User created with success';
//TODO change confirmation_registration by register_form_success when registrations will need an activation by clic on link in an email
//$message['translation_code'] = 'register_form_success'; //'confirmation_registration';
//TODO send an email to admin to indicate that there is a new registration
return $message;
} else {
$message['status']='red';
$message['content'] = 'User has not been created';
//$message['translation_code'] = 'register_form_failed';
return $message;
}
}
}
public function getClient($user_id){
$this->_userId = $user_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_clients']['db_server'], $_SESSION['globsi_clients']['db_name'], $_SESSION['globsi_clients']['db_user'], $_SESSION['globsi_clients']['db_password']);
$sql="
SELECT ud.ext_id, uu.*
FROM user_user uu
LEFT JOIN user_detail ud
ON uu.id=ud.user_id
WHERE uu.id=:user_id;
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$this->_userId));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
return $row;
}
}

View File

@ -0,0 +1,118 @@
<?php
class ClassGlobsiISP extends ClassConfig {
public function __construct(){}
public function __destruct(){}
public function getConfig(){
$oPDOLink = ClassConfig::databaseConnect();
$rowsConfig = array();
$sql="
SELECT *
FROM globsi_sales_config
WHERE is_active=TRUE
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array());
$rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $k=>$v){
$erpConfig[$rows[$k]['k']] = $rows[$k]['v'];
}
return $erpConfig;
}
public function createISP($data, $ext_id){
$this->_data = $data;
$this->_extId = $ext_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_sales']['db_server'], $_SESSION['globsi_sales']['db_name'], $_SESSION['globsi_sales']['db_user'], $_SESSION['globsi_sales']['db_password']);
//IF password and confirmPassword are not identical, displaying an error message
if($this->_data['formCreateISPFieldPassword'] != $this->_data['formCreateISPFieldConfirmPassword']){
$message['state']='failed';
$message['css_class']='failed';
$message['translation_code'] = 'checkRegisterForm_notSamePassword';
return $message;
}
else {
$activation_code = rand();
$sql="
INSERT INTO user_user(email, password, activation_code, firstname, lastname,
core_lang_id, core_country_id, core_currency_id, core_theme_id,
is_active, comment
)VALUES(
:email, :password, :activation_code,
:firstname, :lastname,
12, 44, 4, 1,
true, 'user created during installation process')
";
$execSQL = $oPDOLink->prepare($sql);
if($execSQL->execute(array(
':email'=>$this->_data['formCreateISPFieldEmail'],
':password'=>sha1($this->_data['formCreateISPFieldPassword'].'-k3P[8x&'),
':activation_code'=>$activation_code,
':firstname'=>$this->_data['formCreateISPFieldFirstname'],
':lastname'=>$this->_data['formCreateISPFieldLastname']
))){
$newUserId = $oPDOLink->lastInsertId('user_user_id_seq');
//$isVipOfferActive = $this->_checkIfVipOfferActive();
//$isEverythingForFreeActive = $this->_checkIfEverythingForFreeActive();
// core user detail
$sql="
INSERT INTO user_detail(user_id, ext_id)
VALUES (:user_id, :ext_id)
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$newUserId, ':ext_id'=>$this->_extId));
// features for user
$sql="
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id)
VALUES (
(SELECT id FROM user_user WHERE email=:email LIMIT 1),
(SELECT id FROM core_feature WHERE code=:core_feature_code LIMIT 1)
);
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':email'=>$this->_data['formCreateISPFieldEmail'], ':core_feature_code'=>'home'));
$execSQL->execute(array(':email'=>$this->_data['formCreateISPFieldEmail'], ':core_feature_code'=>'my-profile'));
$execSQL->execute(array(':email'=>$this->_data['formCreateISPFieldEmail'], ':core_feature_code'=>'logout'));
$message['user_id'] = $newUserId;
$message['activation_code'] = $activation_code;
$message['status'] = "green";
$message['content'] = 'User created with success';
//TODO change confirmation_registration by register_form_success when registrations will need an activation by clic on link in an email
//$message['translation_code'] = 'register_form_success'; //'confirmation_registration';
//TODO send an email to admin to indicate that there is a new registration
return $message;
} else {
$message['status']='red';
$message['content'] = 'User has not been created';
//$message['translation_code'] = 'register_form_failed';
return $message;
}
}
}
public function getISP($user_id){
$this->_userId = $user_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_isp']['db_server'], $_SESSION['globsi_isp']['db_name'], $_SESSION['globsi_isp']['db_user'], $_SESSION['globsi_isp']['db_password']);
$sql="
SELECT ud.ext_id, uu.*
FROM user_user uu
LEFT JOIN user_detail ud
ON uu.id=ud.user_id
WHERE uu.id=:user_id;
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$this->_userId));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
return $row;
}
}

View File

@ -0,0 +1,118 @@
<?php
class ClassGlobsiProvider extends ClassConfig {
public function __construct(){}
public function __destruct(){}
public function getConfig(){
$oPDOLink = ClassConfig::databaseConnect();
$rowsConfig = array();
$sql="
SELECT *
FROM globsi_providers_config
WHERE is_active=TRUE
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array());
$rows = $execSQL->fetchAll(PDO::FETCH_ASSOC);
foreach($rows as $k=>$v){
$erpConfig[$rows[$k]['k']] = $rows[$k]['v'];
}
return $erpConfig;
}
public function createProvider($data, $ext_id){
$this->_data = $data;
$this->_extId = $ext_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_providers']['db_server'], $_SESSION['globsi_providers']['db_name'], $_SESSION['globsi_providers']['db_user'], $_SESSION['globsi_providers']['db_password']);
//IF password and confirmPassword are not identical, displaying an error message
if($this->_data['formCreateProviderFieldPassword'] != $this->_data['formCreateProviderFieldConfirmPassword']){
$message['state']='failed';
$message['css_class']='failed';
$message['translation_code'] = 'checkRegisterForm_notSamePassword';
return $message;
}
else {
$activation_code = rand();
$sql="
INSERT INTO user_user(email, password, activation_code, firstname, lastname,
core_lang_id, core_country_id, core_currency_id, core_theme_id,
is_active, comment
)VALUES(
:email, :password, :activation_code,
:firstname, :lastname,
12, 44, 4, 1,
true, 'user created during installation process')
";
$execSQL = $oPDOLink->prepare($sql);
if($execSQL->execute(array(
':email'=>$this->_data['formCreateProviderFieldEmail'],
':password'=>sha1($this->_data['formCreateProviderFieldPassword'].'-k3P[8x&'),
':activation_code'=>$activation_code,
':firstname'=>$this->_data['formCreateProviderFieldFirstname'],
':lastname'=>$this->_data['formCreateProviderFieldLastname']
))){
$newUserId = $oPDOLink->lastInsertId('user_user_id_seq');
//$isVipOfferActive = $this->_checkIfVipOfferActive();
//$isEverythingForFreeActive = $this->_checkIfEverythingForFreeActive();
// core user detail
$sql="
INSERT INTO user_detail(user_id, ext_id)
VALUES (:user_id, :ext_id)
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$newUserId, ':ext_id'=>$this->_extId));
// features for user
$sql="
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id)
VALUES (
(SELECT id FROM user_user WHERE email=:email LIMIT 1),
(SELECT id FROM core_feature WHERE code=:core_feature_code LIMIT 1)
);
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':email'=>$this->_data['formCreateProviderFieldEmail'], ':core_feature_code'=>'home'));
$execSQL->execute(array(':email'=>$this->_data['formCreateProviderFieldEmail'], ':core_feature_code'=>'my-profile'));
$execSQL->execute(array(':email'=>$this->_data['formCreateProviderFieldEmail'], ':core_feature_code'=>'logout'));
$message['user_id'] = $newUserId;
$message['activation_code'] = $activation_code;
$message['status'] = "green";
$message['content'] = 'User created with success';
//TODO change confirmation_registration by register_form_success when registrations will need an activation by clic on link in an email
//$message['translation_code'] = 'register_form_success'; //'confirmation_registration';
//TODO send an email to admin to indicate that there is a new registration
return $message;
} else {
$message['status']='red';
$message['content'] = 'User has not been created';
//$message['translation_code'] = 'register_form_failed';
return $message;
}
}
}
public function getClient($user_id){
$this->_userId = $user_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::foreignDatabaseConnect($_SESSION['globsi_providers']['db_server'], $_SESSION['globsi_providers']['db_name'], $_SESSION['globsi_providers']['db_user'], $_SESSION['globsi_providers']['db_password']);
$sql="
SELECT ud.ext_id, uu.*
FROM user_user uu
LEFT JOIN user_detail ud
ON uu.id=ud.user_id
WHERE uu.id=:user_id;
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$this->_userId));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
return $row;
}
}

View File

@ -0,0 +1,96 @@
<?php
class ClassPlay extends ripcord {
public function __construct(){}
public function __destruct(){}
private function _getStageId($models, $db, $uid, $password, $stage){
return $models->execute_kw($db, $uid, $password, 'project.task.type', 'search', array(array(array('name', '=', $stage))))[0];
}
public function codePushed($models, $db, $uid, $password, $task_id){
# Check if upload have no error, then encode to base64.
if ($_FILES['input_file_code_form']['error'] == UPLOAD_ERR_OK
&& is_uploaded_file($_FILES['input_file_code_form']['tmp_name'])) {
$file_content = file_get_contents($_FILES['input_file_code_form']['tmp_name']);
$file_base64 = base64_encode($file_content);
}
else{
$res['status'] = 'warning';
$res['message'] = 'Something went wrong with the file you try to upload. Please try again. If problem persist, <a href="mailto:contact@jmdn-solutions.com">contact us</a>';
return $res;
}
//assign task to user in ERP
$stage_id = $this->_getStageId($models, $db, $uid, $password, "Approval");
$res['erp'] = $models->execute_kw(
$db, $uid, $password, 'project.task', 'write', array(
array((integer) $task_id),
array(
'stage_id'=>$stage_id,
'file_base64'=>$file_base64,
'file_name'=>$_FILES['input_file_code_form']['name'],
)
)); //the (integer) casting before $task_id is required
$res['status'] = 'success';
$res['message'] = 'Well done and thank you for your work. We will review it as soon as possible and let you know if it is approved or if a part of your work needs to be fixed.';
return $res;
}
public function getUnassignedTask($models, $db, $uid, $password, $task_id){
//assign task to user in ERP
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'get_task', array(array((integer) $task_id))); //the (integer) casting before $task_id is required
return $res;
}
public function listMyCurrentTasks($models, $db, $uid, $password){
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search_read', array(array(array('user_id', '=', $uid))), array('fields'=>array()));
return $res;
}
public function getMyCurrentTask($models, $db, $uid, $password){
$stage_id = $this->_getStageId($models, $db, $uid, $password, "Current");
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search_read', array(array(array('user_id', '=', $uid), array('stage_id', '=', $stage_id))), array('fields'=>array()));
return $res;
}
public function listMyTasksOnApproval($models, $db, $uid, $password){
$stage_id = $this->_getStageId($models, $db, $uid, $password, "Approval");
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search_read', array(array(array('user_id', '=', $uid), array('stage_id', '=', $stage_id))), array('fields'=>array()));
return $res;
}
public function listTasksToFix($models, $db, $uid, $password){
$stage_id = $this->_getStageId($models, $db, $uid, $password, "To Fix");
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search_read', array(array(array('user_id', '=', $uid), array('stage_id', '=', $stage_id))), array('fields'=>array()));
return $res;
}
public function listMyTasksDone($models, $db, $uid, $password){
$stage_id = $this->_getStageId($models, $db, $uid, $password, "Done");
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search_read', array(array(array('user_id', '=', $uid), array('stage_id', '=', $stage_id))), array('fields'=>array()));
return $res;
}
public function listUnassignedTasks($models, $db, $uid, $password){
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search_read', array(array(array('user_id', '=', false),array('published', '=', true))), array('fields'=>array()));
return $res;
}
public function listFixTasks($models, $db, $uid, $password){
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'list_to_fix_tasks', array());
return $res;
}
public function taskGaveUp($models, $db, $uid, $password, $task_id){
//unassign task from user in ERP
$stage_id = $this->_getStageId($models, $db, $uid, $password, "Current");
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'write', array(array((integer) $task_id), array('stage_id'=>$stage_id, 'user_id'=>false))); //the (integer) casting before $task_id is required
return $res;
}
public function taskGetAttachment($models, $db, $uid, $password, $attachment_id){
$res = $models->execute_kw($db, $uid, $password, 'ir.attachment', 'read', array((integer) $attachment_id), array('fields'=>["datas", "name"])); //the (integer) casting before $attachment_id is required
return $res;
}
}

View File

@ -0,0 +1,203 @@
<?php
class ClassUserCustom extends ClassUser {
public function createUserForWefraAdmin($data, $ext_id){
$this->_data = $data;
$this->_extId = $ext_id;
$config = ClassConfig::getConfig();
$oPDOLink = ClassConfig::databaseConnect();
//IF password and confirmPassword are not identical, displaying an error message
if($this->_data['formRegisterFieldPassword'] != $this->_data['formRegisterFieldConfirmPassword']){
$message['state']='failed';
$message['css_class']='failed';
$message['translation_code'] = 'checkRegisterForm_notSamePassword';
return $message;
}
else {
$activation_code = rand();
$sql="
INSERT INTO user_user(email, password, activation_code, firstname, lastname,
core_lang_id, core_country_id, core_currency_id, core_theme_id,
is_active, comment
)VALUES(
:email, :password, :activation_code,
:firstname, :lastname,
12, 44, 4, 1,
true, 'user created during installation process')
";
$execSQL = $oPDOLink->prepare($sql);
if($execSQL->execute(array(
':email'=>$this->_data['formRegisterFieldEmail'],
':password'=>sha1($this->_data['formRegisterFieldPassword'].'-k3P[8x&'),
':activation_code'=>$activation_code,
':firstname'=>$this->_data['formRegisterFieldFirstname'],
':lastname'=>$this->_data['formRegisterFieldLastname']
))){
$newUserId = $oPDOLink->lastInsertId('user_user_id_seq');
//$isVipOfferActive = $this->_checkIfVipOfferActive();
//$isEverythingForFreeActive = $this->_checkIfEverythingForFreeActive();
// core user detail
$sql="
INSERT INTO user_detail(user_id, ext_id)
VALUES (:user_id, :ext_id)
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$newUserId, ':ext_id'=>$this->_extId));
// features for user
$sql="
INSERT INTO useruser_corefeature_rel(user_id, core_feature_id)
VALUES (
(SELECT id FROM user_user WHERE email=:email LIMIT 1),
(SELECT id FROM core_feature WHERE code=:core_feature_code LIMIT 1)
);
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':email'=>$this->_data['formRegisterFieldEmail'], ':core_feature_code'=>'home'));
$execSQL->execute(array(':email'=>$this->_data['formRegisterFieldEmail'], ':core_feature_code'=>'my-profile'));
$execSQL->execute(array(':email'=>$this->_data['formRegisterFieldEmail'], ':core_feature_code'=>'logout'));
$message['user_id'] = $newUserId;
$message['activation_code'] = $activation_code;
$message['status'] = "success";
$message['css_class'] = 'success-message';
//TODO change confirmation_registration by register_form_success when registrations will need an activation by clic on link in an email
//$message['translation_code'] = 'register_form_success'; //'confirmation_registration';
//TODO send an email to admin to indicate that there is a new registration
return $message;
} else {
$message['status']='failed';
$message['css_class'] = 'failed-message';
//$message['translation_code'] = 'register_form_failed';
return $message;
}
}
}
public function array_values_recursive($array){
$arrayValues = array();
foreach ($array as $value){
if (is_scalar($value) OR is_resource($value)){
$arrayValues[] = $value;
}
elseif (is_array($value)){
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
//ENDOF array_values_recursive()
public function getUser($user_id){
$this->_userId = $user_id;
$oPDOLink = ClassConfig::databaseConnect();
$sql="
SELECT ud.ext_id, uu.*
FROM user_user uu
LEFT JOIN user_detail ud
ON uu.id=ud.user_id
WHERE uu.id=:user_id;
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$this->_userId));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
return $row;
}
public function login($post_datas=array()){
$this->_postDatas = $post_datas;
$oPDOLink = ClassConfig::databaseConnect();
if($this->_postDatas['formLoginFieldEmail']=='' || $this->_postDatas['formLoginFieldPassword']==''){
$message['state'] = 'no_required_fields_filled';
$message['css_class'] = 'failed-message';
$message['translation_code'] = "message_requiredFieldsNotFilled";
return $message;
}
$sql="
SELECT uu.id, uu.email, uu.password, uu.firstname, uu.lastname, uu.phone,
uu.core_lang_id, uu.core_country_id, uu.core_currency_id,
uu.is_active,
(SELECT code FROM core_lang WHERE id=core_lang_id) AS lang_code,
(SELECT code FROM core_country WHERE id=core_country_id) AS country_code,
(SELECT code FROM core_currency WHERE id=core_currency_id) AS currency_code
FROM user_user uu
INNER JOIN user_detail ud
ON uu.id=ud.user_id
WHERE uu.email=:email AND uu.password=:password
LIMIT 1
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(
':email'=>$this->_postDatas['formLoginFieldEmail'],
':password'=>sha1($this->_postDatas['formLoginFieldPassword'].'-k3P[8x&')
));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
if(isset($row['is_active']) and $row['is_active']==false){
$message['state'] = 'account_not_activated';
$message['css_class'] = 'warning-message';
$message['translation_code'] = 'messageLogin_accountNotActivated';
return $message;
} else if(isset($row['email'])){
unset($_SESSION['features']);
$_SESSION['features'] = $this->getFeatures($row['id']);
$row['state'] = 'success';
return $row;
} else{
$message['state'] = 'bad_login_or_password';
$message['css_class'] = 'failed-message';
//FIX translate this message
$message['translation_code'] = "messageLogin_badLoginOrPassword";
return $message;
}
}
//ENDOF login()
public function changePassword($user_id, $data){
$this->_userId = $user_id;
$this->_data = $data;
$oPDOLink = ClassConfig::databaseConnect();
$sql="
SELECT password
FROM user_user
WHERE id=:user_id;
";
$execSQL = $oPDOLink->prepare($sql);
$execSQL->execute(array(':user_id'=>$this->_userId));
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
if(isset($row['password']) && sha1($this->_data['oldPassword'].'-k3P[8x&') != $row['password']){
$message['state'] = 'failed_bad_password';
} else if($this->_data['newPassword'] != $this->_data['confirmPassword']){
$message['state'] = 'failed_password_confirm';
} else{
$sql="
UPDATE user_user
SET password=:password
WHERE id=:user_id;
";
$execSQL = $oPDOLink->prepare($sql);
if($execSQL->execute(array(
':user_id'=>$this->_userId,
':password'=>sha1($this->_data['newPassword'].'-k3P[8x&')
))){
$message['state'] = 'success';
} else{
$message['state'] = 'failed';
}
}
return $message;
}
}

View File

@ -0,0 +1,21 @@
<?php
require_once('ripcord_client.php');
class ClassXMLRPC {
public function __construct($url, $database, $user, $password){
$this->_url = $url;
$this->_database = $database;
$this->_user = $user;
$this->_password = $password;
$this->_common = ripcord::client($this->_url."xmlrpc/2/common");
$this->_uid = $this->_common->authenticate($this->_database, $this->_user, $this->_password, array());
$this->_models = ripcord::client($this->_url."xmlrpc/2/object");
}
public function __destruct(){}
public function execute($model, $method, $args, $kwargs){
return $this->_models->execute_kw($this->_database, $this->_uid, $this->_password, $model, $method, $args, $kwargs);
}
}

356
custom/modules/ripcord.php Normal file
View File

@ -0,0 +1,356 @@
<?php
/**
* Ripcord is an easy to use XML-RPC library for PHP.
* @package Ripcord
* @author Auke van Slooten <auke@muze.nl>
* @copyright Copyright (C) 2010, Muze <www.muze.nl>
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
* @version Ripcord 0.9 - PHP 5
*/
/**
* The ripcord class contains a number of useful static methods. This makes it a bit easier to create a server or client, convert types
* and check for errors.
* @package Ripcord
*/
class ripcord
{
/**
* This method checks whether the given argument is an XML-RPC fault.
* @param mixed $fault
* @return bool
*/
public static function isFault($fault)
{
if ( isset($fault) && is_array($fault) ) {
return xmlrpc_is_fault($fault);
} else {
return false;
}
}
/**
* This method generates an XML-RPC fault with the given code and message.
* @param int $code
* @param string $message
* @return array
*/
public static function fault($code, $message)
{
return array('faultCode' => $code, 'faultString' => $message);
}
/**
* This method returns a new Ripcord server, which by default implements XML-RPC, Simple RPC and SOAP 1.1.
* The server will publish any methods passed through the $services argument. It can be configured through
* the $options argument.
* @param mixed $services Optional. Either an object or an array of objects. If the array has non-numeric keys, the key will be used as a namespace for the methods in the object.
* @param array $options Optional. An array of options to set for the Ripcord server.
* @see Ripcord_Server
*/
public static function server($services = null, $options = null, $documentor = null)
{
self::load('Ripcord_Server');
if ( !isset($documentor) )
{
$doc = array('name', 'css', 'wsdl', 'wsdl2');
$docOptions = array();
foreach ( $doc as $key )
{
if ( isset($options[$key]) )
{
$docOptions[$key] = $options[$key];
unset( $options[$key] );
}
}
$docOptions['version'] = $options['version'];
$documentor = self::documentor( $docOptions );
}
return new Ripcord_Server($services, $options, $documentor);
}
/**
* This method returns a new Ripcord client. By default this will be an XML-RPC client, but you can change this
* through the $options argument.
* @param string $url The url of the RPC server to connect with
* @param array $options Optional. An array of options to set for the Ripcord client.
* @see Ripcord_Client
*/
public static function client($url, $options = null, $transport = null )
{
self::load('Ripcord_Client');
if ( !isset($transport) )
{
$transport = new Ripcord_Transport_Stream();
}
return new Ripcord_Client($url, $options, $transport);
}
/**
* This method returns a new Ripcord documentor object.
* @param array $options Optional. An array of options to set for the Ripcord documentor.
* @param object docCommentParser Optional. An object that parses a docComment block. Must
* implement the Ripcord_Documentor_CommentParser interface.
* @see Ripcord_Client
*/
public static function documentor( $options = null, $docCommentParser = null )
{
self::load('Ripcord_Documentor');
if (!$docCommentParser) {
$docCommentParser = new Ripcord_Documentor_Parser_phpdoc();
}
return new Ripcord_Documentor( $options, $docCommentParser );
}
/**
* This method returns an XML-RPC datetime object from a given unix timestamp.
* @param int $timestamp
* @return object
*/
public static function datetime($timestamp)
{
$datetime = date("Ymd\TH:i:s", $timestamp);
xmlrpc_set_type($datetime, 'datetime');
return $datetime;
}
/**
* This method returns a unix timestamp from a given XML-RPC datetime object.
* It will throw a 'Variable is not of type datetime' Ripcord_Exception (code -6)
* if the given argument is not of the correct type.
* @param object $datetime
* @return int
*/
public static function timestamp($datetime)
{
if (xmlrpc_get_type($datetime)=='datetime')
{
return $datetime->timestamp;
} else {
throw Ripcord_Exception('Variable is not of type datetime', -6);
}
}
/**
* This method returns an XML-RPC base64 object from a given binary string.
* @param string $binary
* @return object
*/
public static function base64($binary)
{
xmlrpc_set_type($binary, 'base64');
return $binary;
}
/**
* This method returns a (binary) string from a given XML-RPC base64 object.
* It will throw a 'Variable is not of type base64' Ripcord_Exception (code -7)
* if the given argument is not of the correct type.
* @param object $base64
* @return string
*/
public static function binary($base64)
{
if (xmlrpc_get_type($base64)=='base64')
{
return $base64->scalar;
} else {
throw Ripcord_Exception('Variable is not of type base64', -7);
}
}
/**
* This method returns the type of the given parameter. This can be any of the XML-RPC data types, e.g.
* 'struct', 'int', 'string', 'base64', 'boolean', 'double', 'array' or 'datetime'.
* @param mixed $param
* @return string
*/
public static function getType($param)
{
return xmlrpc_get_type($param);
}
/**
* This method returns a new Ripcord client, configured to access a SOAP 1.1 server.
* @param string $url
* @param array $options Optional.
* @see Ripcord_Client
*/
public static function soapClient($url, $options = null, $transport = null)
{
$options['version'] = 'soap 1.1';
return self::client($url, $options, $transport);
}
/**
* This method returns a new Ripcord client, configured to access an XML-RPC server.
* @param string $url
* @param array $options Optional.
* @return object
* @see Ripcord_Client
*/
public static function xmlrpcClient($url, $options = null, $transport = null)
{
$options['version'] = 'xmlrpc';
return self::client($url, $options, $transport);
}
/**
* This method returns a new Ripcord client, configured to access a Simple RPC server.
* @param string $url
* @param array $options Optional.
* @return object
* @see Ripcord_Client
*/
public static function simpleClient($url, $options = null, $transport = null)
{
$options['version'] = 'simple';
return self::client($url, $options, $transport);
}
/**
* This method includes a ripcord class, using require_once. Used for autoloading ripcord classes.
* @param string $class The name of the class to load.
* @return boolean
*/
public static function load($class)
{
if (substr($class, 0, 8)=='Ripcord_')
{
$root = dirname(__FILE__).'/ripcord_';
$class = substr($class, 8);
$file = str_replace('.', '', $class);
$file = str_replace('_', '/', $file);
$file = strtolower($file);
while ($file && $file!='.')
{
if ( file_exists($root.$file.'.php') )
{
require_once($root.$file.'.php');
return true;
} else {
$file = dirname($file);
}
}
}
return false;
}
/**
* This method creates a new Ripcord_Client_Call object, which encodes the information needed for
* a method call to an rpc server. This is mostly used for the system.multiCall method.
* @param string $method The name of the method call to encode
* @param mixed $args,... The remainder of the arguments are encoded as parameters to the call
* @return object
*/
public static function encodeCall()
{
self::load('Ripcord_Client');
$params = func_get_args();
$method = array_shift($params);
return new Ripcord_Client_Call( $method, $params );
}
/*
* This method binds the first parameter to the output of a Ripcord client call. If
* the second argument is a Ripcord_Client_Call object, it binds the parameter to it,
* if not it simply assigns the second parameter to the first parameter.
* This means that doing:
* > ripcord::bind( $result, $client->someMethod() )
* will always result in $result eventually containing the return value of $client->someMethod().
* Whether multiCall mode has been enabled or not.
*/
public function bind(&$bound, $call)
{
if ( is_a( $call, 'Ripcord_Client_Call' ) )
{
$call->bound =& $bound;
} else {
$bound = $call;
}
return null;
}
/**
* Method {method} not found. - Thrown by the ripcord server when a requested method isn't found.
*/
const methodNotFound = -1;
/**
* Argument {index} is not a valid Ripcord call - Thrown by the client when passing incorrect arguments to system.multiCall.
*/
const notRipcordCall = -2;
/**
* Cannot recurse system.multiCall - Thrown by the ripcord server when system.multicall is called within itself.
*/
const cannotRecurse = -3;
/**
* Could not access {url} - Thrown by the transport object when unable to access the given url.
*/
const cannotAccessURL = -4;
/**
* PHP XMLRPC library is not installed - Thrown by the ripcord server and client when the xmlrpc library is not installed.
*/
const xmlrpcNotInstalled = -5;
/**
* Variable is not of type datetime - Thrown by the ripcord timestamp method.
*/
const notDatetime = -6;
/**
* Variable is not of type base64 - Thrown by the ripcord binary method.
*/
const notBase64 = -7;
/**
* Variable is not a classname or an object - Thrown by the ripcord server.
*/
const unknownServiceType = -8;
}
/**
* This interface is implemented by all exceptions thrown by Ripcord.
* @package Ripcord
*/
interface Ripcord_Exception {}
/**
* This class is used whenever an when a method passed to the server is invalid.
* - ripcord::methodNotFound (-1) Method {method} not found. - Thrown by the ripcord server when a requested method isn't found.
* @package Ripcord
*/
class Ripcord_BadMethodCallException extends BadMethodCallException implements Ripcord_Exception { }
/**
* This class is used whenever prerequisite requirements are not met.
* - ripcord::xmlrpcNotInstalled (-5) PHP XMLRPC library is not installed - Thrown by the ripcord server and client when the xmlrpc library is not installed.
* @package Ripcord
*/
class Ripcord_ConfigurationException extends Exception implements Ripcord_Exception { }
/**
* This class is used whenever an argument passed to a Ripcord method is invalid for any reason. Possible exceptions thrown are:
* - ripcord::notRipcordCall (-2) Argument {index} is not a valid Ripcord call - Thrown by the client when passing incorrect arguments to system.multiCall.
* - ripcord::cannotRecurse (-3) Cannot recurse system.multiCall - Thrown by the ripcord server when system.multicall is called within itself.
* - ripcord::notDateTime (-6) Variable is not of type datetime - Thrown by the ripcord timestamp method.
* - ripcord::notBase64 (-7) Variable is not of type base64 - Thrown by the ripcord binary method.
* - ripcord::unknownServiceType (-8) Variable is not a classname or an object - Thrown by the ripcord server.
* @package Ripcord
*/
class Ripcord_InvalidArgumentException extends InvalidArgumentException implements Ripcord_Exception { }
/**
* This class is used whenever something goes wrong in sending / receiving data. Possible exceptions thrown are:
* - ripcord::cannotAccessURL (-4) Could not access {url} - Thrown by the transport object when unable to access the given url.
* @package Ripcord
*/
class Ripcord_TransportException extends RuntimeException implements Ripcord_Exception { }
/**
* This class is used for exceptions generated from xmlrpc faults returned by the server. The code and message correspond
* to the code and message from the xmlrpc fault.
* @package Ripcord
*/
class Ripcord_RemoteException extends Exception implements Ripcord_Exception { }
if (function_exists('spl_autoload_register')) {
spl_autoload_register('ripcord::load');
}
?>

View File

@ -0,0 +1,579 @@
<?php
/**
* Ripcord is an easy to use XML-RPC library for PHP.
* @package Ripcord
* @author Auke van Slooten <auke@muze.nl>
* @copyright Copyright (C) 2010, Muze <www.muze.nl>
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
* @version Ripcord 0.9 - PHP 5
*/
/**
* Includes the static ripcord factory class and exceptions
*/
require_once(dirname(__FILE__).'/ripcord.php');
/**
* This class implements a simple RPC client, for XML-RPC, (simplified) SOAP 1.1 or Simple RPC. The client abstracts
* the entire RPC process behind native PHP methods. Any method defined by the rpc server can be called as if it was
* a native method of the rpc client.
*
* E.g.
* <code>
* <?php
* $client = ripcord::client( 'http://www.moviemeter.nl/ws' );
* $score = $client->film->getScore( 'e3dee9d19a8c3af7c92f9067d2945b59', 500 );
* ?>
* </code>
*
* The client has a simple interface for the system.multiCall method:
* <code>
* <?php
* $client = ripcord::client( 'http://ripcord.muze.nl/ripcord.php' );
* $client->system->multiCall()->start();
* ripcord::bind( $methods, $client->system->listMethods() );
* ripcord::bind( $foo, $client->getFoo() );
* $client->system->multiCall()->execute();
* ?>
* </code>
*
* The soap client can only handle the basic php types and doesn't understand xml namespaces. Use PHP's SoapClient
* for complex soap calls. This client cannot parse wsdl.
* If you want to skip the ripcord::client factory method, you _must_ provide a transport object explicitly.
*
* @link http://wiki.moviemeter.nl/index.php/API Moviemeter API documentation
* @package Ripcord
*/
class Ripcord_Client
{
/**
* The url of the rpc server
*/
private $_url = '';
/**
* The transport object, used to post requests.
*/
private $_transport = null;
/**
* A list of output options, used with the xmlrpc_encode_request method.
* @see Ripcord_Server::setOutputOption()
*/
private $_outputOptions = array(
"output_type" => "xml",
"verbosity" => "pretty",
"escaping" => array("markup"),
"version" => "xmlrpc",
"encoding" => "utf-8"
);
/**
* The namespace to use when calling a method.
*/
private $_namespace = null;
/**
* A reference to the root client object. This is so when you use namespaced sub clients, you can always
* find the _response and _request data in the root client.
*/
private $_rootClient = null;
/**
* A flag to indicate whether or not to preemptively clone objects passed as arguments to methods, see
* php bug #50282. Only correctly set in the rootClient.
*/
private $_cloneObjects = false;
/**
* A flag to indicate if we are in a multiCall block. Start this with $client->system->multiCall()->start()
*/
protected $_multiCall = false;
/**
* A list of deferred encoded calls.
*/
protected $_multiCallArgs = array();
/**
* The exact response from the rpc server. For debugging purposes.
*/
public $_response = '';
/**
* The exact request from the client. For debugging purposes.
*/
public $_request = '';
/**
* Whether or not to throw exceptions when an xml-rpc fault is returned by the server. Default is false.
*/
public $_throwExceptions = false;
/**
* Whether or not to decode the XML-RPC datetime and base64 types to unix timestamp and binary string
* respectively.
*/
public $_autoDecode = true;
/**
* The constructor for the RPC client.
* @param string $url The url of the rpc server
* @param array $options Optional. A list of outputOptions. See {@link Ripcord_Server::setOutputOption()}
* @param object $rootClient Optional. Used internally when using namespaces.
* @throws Ripcord_ConfigurationException (ripcord::xmlrpcNotInstalled) when the xmlrpc extension is not available.
*/
public function __construct( $url, array $options = null, $transport = null, $rootClient = null )
{
if ( !isset($rootClient) ) {
$rootClient = $this;
if ( !function_exists( 'xmlrpc_encode_request' ) )
{
throw new Ripcord_ConfigurationException('PHP XMLRPC library is not installed',
ripcord::xmlrpcNotInstalled);
}
$version = explode('.', phpversion() );
if ( (0 + $version[0]) == 5) {
if ( ( 0 + $version[1]) < 2 ) {
$this->_cloneObjects = true; // workaround for bug #50282
}
}
}
$this->_rootClient = $rootClient;
$this->_url = $url;
if ( isset($options) )
{
if ( isset($options['namespace']) )
{
$this->_namespace = $options['namespace'];
unset( $options['namespace'] );
}
$this->_outputOptions = $options;
}
if ( isset($transport) ) {
$this->_transport = $transport;
}
}
/**
* This method catches any native method called on the client and calls it on the rpc server instead. It automatically
* parses the resulting xml and returns native php type results.
* @throws Ripcord_InvalidArgumentException (ripcord::notRipcordCall) when handling a multiCall and the
* arguments passed do not have the correct method call information
* @throws Ripcord_RemoteException when _throwExceptions is true and the server returns an XML-RPC Fault.
*/
public function __call($name, $args)
{
if ( isset($this->_namespace) )
{
$name = $this->_namespace . '.' . $name;
}
if ( $name === 'system.multiCall' || $name == 'system.multicall' )
{
if ( !$args || ( is_array($args) && count($args)==0 ) )
{
// multiCall is called without arguments, so return the fetch interface object
return new Ripcord_Client_MultiCall( $this->_rootClient, $name );
} else if ( is_array( $args ) && (count( $args ) == 1) &&
is_array( $args[0] ) && !isset( $args[0]['methodName'] ) )
{
// multicall is called with a simple array of calls.
$args = $args[0];
}
$this->_rootClient->_multiCall = false;
$params = array();
$bound = array();
foreach ( $args as $key => $arg )
{
if ( !is_a( $arg, 'Ripcord_Client_Call' ) &&
(!is_array($arg) || !isset($arg['methodName']) ) )
{
throw new Ripcord_InvalidArgumentException(
'Argument '.$key.' is not a valid Ripcord call',
ripcord::notRipcordCall);
}
if ( is_a( $arg, 'Ripcord_Client_Call' ) )
{
$arg->index = count( $params );
$params[] = $arg->encode();
}
else
{
$arg['index'] = count( $params );
$params[] = array(
'methodName' => $arg['methodName'],
'params' => isset($arg['params']) ?
(array) $arg['params'] : array()
);
}
$bound[$key] = $arg;
}
$args = array( $params );
$this->_rootClient->_multiCallArgs = array();
}
if ( $this->_rootClient->_multiCall ) {
$call = new Ripcord_Client_Call( $name, $args );
$this->_rootClient->_multiCallArgs[] = $call;
return $call;
}
if ($this->_rootClient->_cloneObjects) { //workaround for php bug 50282
foreach( $args as $key => $arg) {
if (is_object($arg)) {
$args[$key] = clone $arg;
}
}
}
$request = xmlrpc_encode_request( $name, $args, $this->_outputOptions );
$response = $this->_transport->post( $this->_url, $request );
$result = xmlrpc_decode( $response, $this->_outputOptions['encoding'] );
$this->_rootClient->_request = $request;
$this->_rootClient->_response = $response;
if ( ripcord::isFault( $result ) && $this->_throwExceptions )
{
throw new Ripcord_RemoteException($result['faultString'], $result['faultCode']);
}
if ( isset($bound) && is_array( $bound ) )
{
foreach ( $bound as $key => $callObject )
{
if ( is_a( $callObject, 'Ripcord_Client_Call' ) )
{
$returnValue = $result[$callObject->index];
}
else
{
$returnValue = $result[$callObject['index']];
}
if ( is_array( $returnValue ) && count( $returnValue ) == 1 )
{
// XML-RPC specification says that non-fault results must be in a single item array
$returnValue = current($returnValue);
}
if ($this->_autoDecode)
{
$type = xmlrpc_get_type($returnValue);
switch ($type)
{
case 'base64' :
$returnValue = ripcord::binary($returnValue);
break;
case 'datetime' :
$returnValue = ripcord::timestamp($returnValue);
break;
}
}
if ( is_a( $callObject, 'Ripcord_Client_Call' ) ) {
$callObject->bound = $returnValue;
}
$bound[$key] = $returnValue;
}
$result = $bound;
}
return $result;
}
/**
* This method catches any reference to properties of the client and uses them as a namespace. The
* property is automatically created as a new instance of the rpc client, with the name of the property
* as a namespace.
* @param string $name The name of the namespace
* @return object A Ripcord Client with the given namespace set.
*/
public function __get($name)
{
$result = null;
if ( !isset($this->{$name}) )
{
$result = new Ripcord_Client(
$this->_url,
array_merge($this->_outputOptions, array(
'namespace' => $this->_namespace ?
$this->_namespace . '.' . $name : $name
) ),
$this->_transport,
$this->_rootClient
);
$this->{$name} = $result;
}
return $result;
}
}
/**
* This class provides the fetch interface for system.multiCall. It is returned
* when calling $client->system->multiCall() with no arguments. Upon construction
* it puts the originating client into multiCall deferred mode. The client will
* gather the requested method calls instead of executing them immediately. It
* will them execute all of them, in order, when calling
* $client->system->multiCall()->fetch().
* This class extends Ripcord_Client only so it has access to its protected _multiCall
* property.
*/
class Ripcord_Client_MultiCall extends Ripcord_Client
{
/*
* The reference to the originating client to put into multiCall mode.
*/
private $client = null;
/*
* This method creates a new multiCall fetch api object.
*/
public function __construct( $client, $methodName = 'system.multiCall' )
{
$this->client = $client;
$this->methodName = $methodName;
}
/*
* This method puts the client into multiCall mode. While in this mode all
* method calls are collected as deferred calls (Ripcord_Client_Call).
*/
public function start()
{
$this->client->_multiCall = true;
}
/*
* This method finally calls the clients multiCall method with all deferred
* method calls since multiCall mode was enabled.
*/
public function execute()
{
if ($this->methodName=='system.multiCall') {
return $this->client->system->multiCall( $this->client->_multiCallArgs );
} else { // system.multicall
return $this->client->system->multicall( $this->client->_multiCallArgs );
}
}
}
/**
* This class is used with the Ripcord_Client when calling system.multiCall. Instead of immediately calling the method on the rpc server,
* a Ripcord_Client_Call object is created with all the information needed to call the method using the multicall parameters. The call object is
* returned immediately and is used as input parameter for the multiCall call. The result of the call can be bound to a php variable. This
* variable will be filled with the result of the call when it is available.
* @package Ripcord
*/
class Ripcord_Client_Call
{
/**
* The method to call on the rpc server
*/
public $method = null;
/**
* The arguments to pass on to the method.
*/
public $params = array();
/**
* The index in the multicall request array, if any.
*/
public $index = null;
/**
* A reference to the php variable to fill with the result of the call, if any.
*/
public $bound = null;
/**
* The constructor for the Ripcord_Client_Call class.
* @param string $method The name of the rpc method to call
* @param array $params The parameters for the rpc method.
*/
public function __construct($method, $params)
{
$this->method = $method;
$this->params = $params;
}
/**
* This method allows you to bind a php variable to the result of this method call.
* When the method call's result is available, the php variable will be filled with
* this result.
* @param mixed $bound The variable to bind the result from this call to.
* @return object Returns this object for chaining.
*/
public function bind(&$bound)
{
$this->bound =& $bound;
return $this;
}
/**
* This method returns the correct format for a multiCall argument.
* @return array An array with the methodName and params
*/
public function encode() {
return array(
'methodName' => $this->method,
'params' => (array) $this->params
);
}
}
/**
* This interface describes the minimum interface needed for the transport object used by the
* Ripcord_Client
* @package Ripcord
*/
interface Ripcord_Transport
{
/**
* This method must post the request to the given url and return the results.
* @param string $url The url to post to.
* @param string $request The request to post.
* @return string The server response
*/
public function post( $url, $request );
}
/**
* This class implements the Ripcord_Transport interface using PHP streams.
* @package Ripcord
*/
class Ripcord_Transport_Stream implements Ripcord_Transport
{
/**
* A list of stream context options.
*/
private $options = array();
/**
* Contains the headers sent by the server.
*/
public $responseHeaders = null;
/**
* This is the constructor for the Ripcord_Transport_Stream class.
* @param array $contextOptions Optional. An array with stream context options.
*/
public function __construct( $contextOptions = null )
{
if ( isset($contextOptions) )
{
$this->options = $contextOptions;
}
}
/**
* This method posts the request to the given url.
* @param string $url The url to post to.
* @param string $request The request to post.
* @return string The server response
* @throws Ripcord_TransportException (ripcord::cannotAccessURL) when the given URL cannot be accessed for any reason.
*/
public function post( $url, $request )
{
$options = array_merge(
$this->options,
array(
'http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)
)
);
$context = stream_context_create( $options );
$result = @file_get_contents( $url, false, $context );
$this->responseHeaders = $http_response_header;
if ( !$result )
{
throw new Ripcord_TransportException( 'Could not access ' . $url,
ripcord::cannotAccessURL );
}
return $result;
}
}
/**
* This class implements the Ripcord_Transport interface using CURL.
* @package Ripcord
*/
class Ripcord_Transport_CURL implements Ripcord_Transport
{
/**
* A list of CURL options.
*/
private $options = array();
/**
* A flag that indicates whether or not we can safely pass the previous exception to a new exception.
*/
private $skipPreviousException = false;
/**
* Contains the headers sent by the server.
*/
public $responseHeaders = null;
/**
* This is the constructor for the Ripcord_Transport_CURL class.
* @param array $curlOptions A list of CURL options.
*/
public function __construct( $curlOptions = null )
{
if ( isset($curlOptions) )
{
$this->options = $curlOptions;
}
$version = explode('.', phpversion() );
if ( ( (0 + $version[0]) == 5) && ( 0 + $version[1]) < 3 ) { // previousException supported in php >= 5.3
$this->_skipPreviousException = true;
}
}
/**
* This method posts the request to the given url
* @param string $url The url to post to.
* @param string $request The request to post.
* @throws Ripcord_TransportException (ripcord::cannotAccessURL) when the given URL cannot be accessed for any reason.
* @return string The server response
*/
public function post( $url, $request)
{
$curl = curl_init();
$options = (array) $this->options + array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $request,
CURLOPT_HEADER => true
);
curl_setopt_array( $curl, $options );
$contents = curl_exec( $curl );
$headerSize = curl_getinfo( $curl, CURLINFO_HEADER_SIZE );
$this->responseHeaders = substr( $contents, 0, $headerSize );
$contents = substr( $contents, $headerSize );
if ( curl_errno( $curl ) )
{
$errorNumber = curl_errno( $curl );
$errorMessage = curl_error( $curl );
curl_close( $curl );
$version = explode('.', phpversion() );
if (!$this->_skipPreviousException) { // previousException supported in php >= 5.3
$exception = new Ripcord_TransportException( 'Could not access ' . $url
, ripcord::cannotAccessURL
, new Exception( $errorMessage, $errorNumber )
);
} else {
$exception = new Ripcord_TransportException( 'Could not access ' . $url
. ' ( original CURL error: ' . $errorMessage . ' ) ',
ripcord::cannotAccessURL
);
}
throw $exception;
}
curl_close($curl);
return $contents;
}
}
?>

View File

@ -0,0 +1,17 @@
<?php
session_start();
require('../../../modules/InterfacePostgreSQL.php');
require('../../../modules/InterfaceConfig.php');
require('../../../modules/ClassConfig.php');
require('../../modules/ClassXMLRPC.php');
$url = $_SESSION['erp']['url'];
$db_name = $_SESSION['erp']['db'];
//$username = $_SESSION['user']['email'];
//$password = $_SESSION['user']['password'];
$xmlrpc = new ClassXMLRPC($url, $db_name, "admin", "admin");
$user_id = $_SESSION['user']['ext_id'];
$current_real_gain = $xmlrpc->execute("globsi.stats", "get_current_currency_gauge", [$user_id], []);
echo json_encode($current_real_gain);

View File

@ -0,0 +1,18 @@
<?php
session_start();
require_once('../modules/ripcord.php');
$url = $_SESSION['erp']['url'];
$db = $_SESSION['erp']['db'];
$username = $_SESSION['user']['email'];
$password = $_SESSION['user']['password'];
$common = ripcord::client($url."xmlrpc/2/common");
$uid = $common->authenticate($db, $username, $password, array());
$models = ripcord::client($url."xmlrpc/2/object");
$res = $models->execute_kw($db, $uid, $password, 'project.task', 'search', [[['user_id', '=', false],['published', '=', true]]]);
echo implode(",", $res);

158
custom/scripts/d3js/chart/area_chart.js vendored Normal file
View File

@ -0,0 +1,158 @@
var AreaChart = {
margin: {top: 20, right: 0, bottom: 40, left: 80},
init: function(svg, html_tag_attr, dataset, xTimeParse, xAxisFormat, yTicks){
this.html_tag_attr = html_tag_attr;
//var div = d3.select(this.html_tag_attr).append("div")
d3.select(this.html_tag_attr).append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// set the dimensions and margins of the graph
var width = $(this.html_tag_attr).width() - this.margin.left - this.margin.right,
height = $(this.html_tag_attr).height() - this.margin.top - this.margin.bottom;
// parse the date / time
var parseTime = d3.timeParse(xTimeParse);
// set the ranges
var x = d3.scaleTime().range([0, width]);
var y = d3.scaleLinear().range([(height), this.margin.top]);
// define the area
var area = d3.area()
.x(function(d) { return x(d.x); })
.y0(height)
.y1(function(d) { return y(+d.y); });
// define the line
var valueline = d3.line()
.x(function(d) { return x(d.x); })
.y(function(d) { return y(+d.y); });
//.y(function(d) { return y(d.y); });
//var svg = this.svg(html_tag_attr, width, height, this.margin);
// format the dataset
dataset.forEach(function(d) {
d.x = parseTime(d.x);
d.y = +d.y;
});
// Scale the range of the dataset
x.domain(d3.extent(dataset, function(d) { return d.x; }));
y.domain([0, d3.max(dataset, function(d) { return +d.y + 10; })]).ticks(2);
// set the gradient
//svg.append("linearGradient") <== THIS ONE WORKS
// .attr("id", "area-gradient")
// .attr("gradientUnits", "userSpaceOnUse")
// .attr("x1", 0).attr("y1", y(0))
// .attr("x2", 0).attr("y2", y(20000))
// .selectAll("stop")
// .data([
// {offset: "40%", color: "#efffef"},
// {offset: "80%", color: "#efffef", opacity:0.8}
// ])
// .enter().append("stop")
// .attr("offset", function(d) { return d.offset; })
// .attr("stop-color", function(d) { return d.color; });
var max = d3.max(dataset, function(d) { return +d.y + 10; });
svg.append("linearGradient") //<== THIS ONE IS FOR TEST
.attr("id", "area-gradient")
.attr("gradientUnits", "userSpaceOnUse")
.attr("x1", 0).attr("y1", y(0))
.attr("x2", 0).attr("y2", y(max))
//.attr("x3", 0).attr("y3", y(17000))
//.attr("x4", 0).attr("y4", y(18000))
.selectAll("stop")
.data([
{offset: "20%", color: "red", opacity:0.5},
{offset: "40%", color: "orange", opacity:0.2},
{offset: "80%", color: "yellow", opacity:0.2},
{offset: "100%", color: "green", opacity:0.5}
])
.enter().append("stop")
.attr("offset", function(d) { return d.offset; })
.attr("stop-color", function(d) { return d.color; });
// add the area
svg.append("path")
.data([dataset])
.attr("class", "area")
.attr("d", area);
// Add the valueline path.
svg.append("path")
.data([dataset])
.attr("fill", "none")
.attr("class", "line")
//.attr("stroke", "green")
.attr("stroke-width", "1.5px")
.attr("d", valueline);
// Add the X Axis
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x)
.tickFormat(d3.timeFormat(xAxisFormat)))
.selectAll("text")
.attr("dx", "-.8em")
.attr("dy", ".95em");
// Add the Y Axis
svg.append("g")
.attr("class", "axis")
.call(d3.axisLeft(y).ticks(yTicks))
.selectAll("text")
.style("text-anchor", "end")
;
}, //ENDOF init: function()
addLine: function(svg, html_tag_attr, dataset, xTimeParse, color){
// set the dimensions and margins of the graph
var width = $(this.html_tag_attr).width() - this.margin.left - this.margin.right,
height = $(this.html_tag_attr).height() - this.margin.top - this.margin.bottom;
// parse the date / time
var parseTime = d3.timeParse(xTimeParse);
// set the ranges
var x = d3.scaleTime().range([0, width]);
var y = d3.scaleLinear().range([height, 0]);
// define the line
var valueline = d3.line()
.x(function(d) { return x(d.x); })
.y(function(d) { return y(+d.y); });
//.y(function(d) { return y(d.y); });
//var svg = this.svg(html_tag_attr, width, height, this.margin);
// format the dataset
dataset.forEach(function(d) {
d.x = parseTime(d.x);
d.y = +d.y;
});
// Scale the range of the dataset
x.domain(d3.extent(dataset, function(d) { return d.x; }));
y.domain([0, d3.max(dataset, function(d) { return +d.y + 10; })]).ticks(2);
// Add the valueline path.
svg.append("path")
.data([dataset])
.attr("fill", "none")
.attr("stroke", color)
.attr("stroke-width", "2px")
.attr("d", valueline)
;
}, //ENDOG addLine: function()
}; //ENDOF LineChart

27
custom/scripts/d3js/chart/axis.js vendored Normal file
View File

@ -0,0 +1,27 @@
Axis = {
addAxis: function(svg, axis, xTranslate, yTranslate){
return svg.append("g")
.attr("transform", "translate("+xTranslate+", "+yTranslate+")")
.call(axis);
},
addTop: function(svg, scale, xTranslate, yTranslate){
var axis = d3.axisTop(scale);
return this.addAxis(svg, axis, xTranslate, yTranslate);
},
addRight: function(svg, scale, xTranslate, yTranslate){
var axis = d3.axisRight(scale);
return this.addAxis(svg, axis, xTranslate, yTranslate);
},
addBottom: function(svg, scale, xTranslate, yTranslate){
var axis = d3.axisBottom(scale);
return this.addAxis(svg, axis, xTranslate, yTranslate);
},
addLeft: function(svg, scale, xTranslate, yTranslate){
var axis = d3.axisLeft(scale);
return this.addAxis(svg, axis, xTranslate, yTranslate);
}
};

92
custom/scripts/d3js/chart/bar_chart.js vendored Normal file
View File

@ -0,0 +1,92 @@
HorizontalBarChart = {
init: function(svg, html_tag_attr, dataset, xBar, yBar, wBar, hBar, color, yScale){
this.xBar = xBar;
this.yBar = yBar;
this.wBar = wBar;
this.hBar = hBar;
this.color = color;
this.yScale = yScale;
svg.selectAll("rect")
.data(dataset)
.enter()
.append("rect")
.attr("x", this.xBar)
.attr("y", this.yBar)
.attr("width", this.wBar)
.attr("height", this.hBar)
.attr("fill", this.color);
}
};
//VerticalBarChart = {
// init: function(svg, dataset, xBar, yBar, wBar, hBar){ //, is_tooltip=false, tooltipXPosition=false, tooltipYPosition=false
// svg.selectAll("rect")
// .data(dataset)
// .enter()
// .append("rect")
// .attr("x", xBar)
// .attr("y", yBar)
// .attr("width", wBar)
// .attr("height", hBar)
// .attr("fill", "grey");
// } //ENDOF init()
//
//};
VerticalBarChart = {
margin: {top: 20, right: 0, bottom: 0, left: 80},
init: function(svg, html_tag_attr, dataset, xBar, yBar, wBar, hBar, color, xScale){ //, is_tooltip=false, tooltipXPosition=false, tooltipYPosition=false
this.xBar = xBar;
this.yBar = yBar;
this.wBar = wBar;
this.hBar = hBar;
this.color = color;
this.xScale = xScale;
var height = $(html_tag_attr).height();
svg.selectAll("rect")
.data(dataset)
.enter()
.append("rect")
.attr("x", this.xBar)
.attr("y", this.yBar)
.attr("width", this.wBar)
.attr("height", this.hBar)
.attr("fill", this.color)
.classed("hidden", true)
.on("mouseover", function(d){
var xPosition = d3.select(this).attr("x"); // + xScale.bandwidth() / 2
var yPosition = parseFloat(d3.select(this).attr("y")); // / 2 + height / 2
d3.select("#tooltip")
.style("left", xPosition + "px")
.style("top", yPosition + "px")
//.style("position", "absolute")
.select("#value")
.text(d.x +": CHF"+ d.y);
d3.select("#tooltip").classed("hidden", false);
})
.on("mouseout", function(){
d3.select("#tooltip").classed("hidden", true);
})
;
var y = d3.scaleLinear().range([(height), this.margin.top]);
y.domain([0, d3.max(dataset, function(d){ return +d.y + 0; })]);
// Add the Y Axis
svg.append("g")
.attr("class", "axis")
.call(d3.axisLeft(y))
.selectAll("text")
.style("text-anchor", "end")
;
} //ENDOF init()
};

14
custom/scripts/d3js/chart/circle.js vendored Normal file
View File

@ -0,0 +1,14 @@
Circle = {
init: function(svg, values, cxAccessor, cyAccessor){
return svg.selectAll("circle")
.data(values)
.enter()
.append("circle")
.attr("cx", cxAccessor)
.attr("cy", cyAccessor)
.attr("r", "5px")
.style("fill", "pink")
.attr("stroke", "blue")
.attr("stroke-width", "2px");
}
};

View File

@ -0,0 +1,150 @@
CollapsibleIndentedTree = {
init: function(url, selection){
//var selection = "#finance_get_profit_and_loss";
var margin = {top: 30, right: 20, bottom: 30, left: 20},
width = $(selection).width(),
barHeight = 20,
barWidth = (width - margin.left - margin.right) * 0.8;
var i = 0,
duration = 400,
root;
var diagonal = d3.linkHorizontal()
.x(function(d) { return d.y; })
.y(function(d) { return d.x; });
var svg = d3.select(selection).append("svg")
.attr("width", width) // + margin.left + margin.right)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
//d3.json(urlRoot+"custom/scripts/data/collapsible_indented_tree.json").then(function(flare){
d3.json(url).then(function(flare){
//if (error) throw error;
root = d3.hierarchy(flare);
root.x0 = 0;
root.y0 = 0;
update(root);
});
function update(source) {
// Compute the flattened node list.
var nodes = root.descendants();
var height = Math.max(500, nodes.length * barHeight + margin.top + margin.bottom);
d3.select("svg").transition()
.duration(duration)
.attr("height", height);
d3.select(self.frameElement).transition()
.duration(duration)
.style("height", height + "px");
// Compute the "layout". TODO https://github.com/d3/d3-hierarchy/issues/67
var index = -1;
root.eachBefore(function(n) {
n.x = ++index * barHeight;
n.y = n.depth * 20;
});
// Update the nodes…
var node = svg.selectAll(".node")
.data(nodes, function(d) { return d.id || (d.id = ++i); });
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.style("opacity", 0);
// Enter any new nodes at the parent's previous position.
nodeEnter.append("rect")
.attr("y", -barHeight / 2)
.attr("height", barHeight)
.attr("width", barWidth)
.style("fill", color)
.on("click", click);
nodeEnter.append("text")
.attr("dy", 3.5)
.attr("dx", 5.5)
.text(function(d) { var value = d.data.size; return d.data.name+" "+value; });
// Transition nodes to their new position.
nodeEnter.transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
.style("opacity", 1);
node.transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
.style("opacity", 1)
.select("rect")
.style("fill", color);
// Transition exiting nodes to the parent's new position.
node.exit().transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
.style("opacity", 0)
.remove();
// Update the links…
var link = svg.selectAll(".link")
.data(root.links(), function(d) { return d.target.id; });
// Enter any new links at the parent's previous position.
link.enter().insert("path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
})
.transition()
.duration(duration)
.attr("d", diagonal);
// Transition links to their new position.
link.transition()
.duration(duration)
.attr("d", diagonal);
// Transition exiting nodes to the parent's new position.
link.exit().transition()
.duration(duration)
.attr("d", function(d) {
var o = {x: source.x, y: source.y};
return diagonal({source: o, target: o});
})
.remove();
// Stash the old positions for transition.
root.each(function(d) {
d.x0 = d.x;
d.y0 = d.y;
});
}
// Toggle children on click.
function click(d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
update(d);
}
function color(d) {
return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c";
}
}
};

View File

@ -0,0 +1,83 @@
'use strict';
var DonutChart = {
init: function(url, html_tag_attr, label_accessor, value_accessor, color_accessor, inner_radius=80){
this.url = url;
this.html_tag_attr = html_tag_attr;
this.label_accessor = label_accessor;
this.value_accessor = value_accessor;
this.color_accessor = color_accessor;
this.inner_radius = inner_radius;
this.render();
this.update();
},
prepare_data: function(){
var self = this;
return d3.json(urlRoot+this.url, config_requestArguments).then(function(dataset){
self.data = [];
var total_val = d3.sum(dataset, self.value_accessor);
dataset.forEach(function(d){
self.data.push({
label: self.label_accessor(d),
value: self.value_accessor(d) / total_val * 100,
value_raw: self.value_accessor(d),
color: self.color_accessor(d)
})
});
});
},
render: function(){
this.svg = d3.select(this.html_tag_attr).append("svg");
this.pie_group = this.svg
.append("g");
},
update: function(){
var self = this;
this.prepare_data().then(function(){
var width = $(self.svg.node()).width();
var height = $(self.svg.node()).height();
var mini_dim = d3.min([width, height]);
var margin = mini_dim * 0.05;
var outerRadius = (mini_dim / 2) - margin;
var innerRadius = outerRadius * self.inner_radius / 100;
var group_vertical_position = height / 2
var group_horizontal_position = width / 2
var pie = d3.pie()
.value(function(d){ return d.value; });
var arc = d3.arc()
.outerRadius(outerRadius)
.innerRadius(innerRadius);
self.pie_group
.attr("transform", "translate(" + group_horizontal_position + "," + group_vertical_position + ")")
.selectAll("path")
.data(pie(self.data))
.enter()
.append("path");
self.pie_group
.selectAll("path")
.attr("d", function(d){ return arc(d); })
.attr("fill", function(d){ return self.color_accessor(d.data); });
});
},
}
// Exemple d'utilisation :
// get_donut_chart(
// "custom/script/ajax/my_kpi.php",
// "my_html_tag_attr",
// function(d){ return d.label; },
// function(d){ return d.value; },
// function(d){ return d.color; },
// 0.75
// );
var get_donut_chart = function(url, html_tag_attr, label_accessor, value_accessor, color_accessor, inner_radius=80){
var my_donut = {};
Object.assign(my_donut, DonutChart);
my_donut.init(url, html_tag_attr, label_accessor, value_accessor, color_accessor, inner_radius);
return my_donut;
};

146
custom/scripts/d3js/chart/gauge_chart.js vendored Normal file
View File

@ -0,0 +1,146 @@
//'use strict';
GaugeChart = {
init: function(url, html_tag_attr, current_accessor, min_accessor, max_accessor, width=200, height=145, colors=["#d7191c", "#efef5d", "#1a9641"]){
//var self = this;
this.url = url;
this.html_tag_attr = html_tag_attr;
this.width = 200;
this.height = 145;
this.current_accessor = current_accessor;
this.min_accessor = min_accessor;
this.max_accessor = max_accessor;
this.arcMin = -Math.PI/2;
this.arcMax = Math.PI/2;
this.innerRadius = 60;
this.outerRadius = 90;
this.labelPad = 10;
this.dataValue = function(d) { return +d; };
this.colorOptions = colors;
this.arc = d3.arc();
this.render();
this.update();
setInterval(this.update.bind(this), 30 * 1000);
},
prepare_data: function(){
var self = this;
return d3.json(urlRoot+this.url, config_requestArguments).then(function(dataset){
self.min = self.min_accessor(dataset);
self.max = (self.max_accessor(dataset)>0)?self.max_accessor(dataset):1;
self.current = self.current_accessor(dataset);
self.ave_min_max = ( Number(self.min) + Number(self.max) ) / 2;
self.dataDomain = [self.min, self.ave_min_max, self.max];
self.svg.datum([self.current]);
});
},
render: function(){
this.svg = d3.select(this.html_tag_attr).append("svg");
},
update: function(){
var self = this;
this.prepare_data().then(function(){
self.svg.each(function(data) {
// Convert data to standard representation greedily;
// this is needed for nondeterministic accessors.
data = data.map(function(d) { return self.dataValue(d); });
var arcScale = d3.scaleLinear().domain(self.dataDomain).range([self.arcMin, 0, self.arcMax]);
var colorScale = d3.scaleLinear().domain(self.dataDomain).range(self.colorOptions);
var arc = d3.arc().innerRadius(self.innerRadius)
.outerRadius(self.outerRadius)
.startAngle(self.arcMin);
// Select the svg element, if it exists.
var svg = d3.select(this).selectAll("svg").data([data]);
// Otherwise, create the skeletal chart.
var gEnter = svg.enter().append("svg").append("g");
var arcGEnter = gEnter.append("g").attr("class", "arc");
arcGEnter.append("path").attr("class", "bg-arc");
arcGEnter.append("path").attr("class", "data-arc")
.datum({endAngle: self.arcMin, startAngle: self.arcMin, score: self.dataDomain[0]})
.attr("d", arc)
.style("fill", colorScale(self.dataDomain[0]))
.each(function(d) { this._current = d; });
arcGEnter.append("text").attr("class", "arc-label");
arcGEnter.append("text").attr("class", "arc-min-label");
arcGEnter.append("text").attr("class", "arc-max-label");
// Update the outer dimensions.
//svg = self.svg.select("svg").attr("viewBox", '0 0 ' + self.width + ' ' + self.height);
svg = self.svg.select("svg");
svg.attr("viewBox", '0 0 ' + self.width + ' ' + self.height);
svg.select("g.arc").attr("transform", "translate(" + (self.width / 2) + "," + (self.outerRadius + ((self.outerRadius * 2) - self.height) / 2) + ")");
svg.select("g.arc .bg-arc")
.datum({endAngle: self.arcMax})
//.style("fill", "#ddd")
.attr("d", arc);
// https://bl.ocks.org/mbostock/1346410
function arcTween(a) {
var i = d3.interpolate(this._current, a);
this._current = i(0);
return function(t) {
return arc(i(t));
};
}
svg.select("g.arc .data-arc")
.datum({score: data[0], startAngle: self.arcMin, endAngle: arcScale(data[0])})
.transition()
.duration(750)
.style("fill", function(d) { return colorScale(d.score); })
.style("opacity", function(d) { return d.score < self.dataDomain[0] ? 0 : 1; })
.attrTween("d", arcTween);
var label_radius = (self.innerRadius + (self.outerRadius - self.innerRadius) / 2);
var angle_min_label = self.arcMin - (Math.PI/15);
var angle_max_label = self.arcMax + (Math.PI/15);
svg.select("text.arc-min-label")
.attr('x', (label_radius * Math.sin(angle_min_label)))
.attr('y', -(label_radius * Math.cos(angle_min_label)))
.style("alignment-baseline", "central")
.style("text-anchor", "middle")
.attr('font-size', '10px')
.attr('stroke', 'white')
.text(d3.format(".2s")(self.min));
svg.select("text.arc-max-label")
.attr('x', (label_radius * Math.sin(angle_max_label)))
.attr('y', -(label_radius * Math.cos(angle_max_label)))
.style("alignment-baseline", "central")
.style("text-anchor", "middle")
.attr('font-size', '10px')
.attr('stroke', 'white')
.text(d3.format(".2s")(self.max));
svg.select("text.arc-label")
.datum({score: data[0]})
.attr("x", 0)
.attr("y", 0)
.style("alignment-baseline", "central")
.style("text-anchor", "middle")
.style("font-size", "20px")
.attr('stroke', 'white')
.text(function(d) { return d3.format(",.2f")(d.score); });
});
});
},
};
get_gauge = function(url, html_tag_attr, current_accessor, min_accessor, max_accessor, colors=["#d7191c", "#efef5d", "#1a9641"], width=300, height=145){ //FIX width et height n'ont aucune influence sur le graphic
var my_gauge = {};
Object.assign(my_gauge, GaugeChart);
my_gauge.init(url, html_tag_attr, current_accessor, min_accessor, max_accessor, width, height, colors);
return my_gauge;
};
//1. Bringing D3JS, what prices for training Giliana, find a small business case
//2. What kind of synergie can be with Microsoft Dynamics?
//3. If definitely to visit their at

122
custom/scripts/d3js/chart/line_chart.js vendored Normal file
View File

@ -0,0 +1,122 @@
LineChart = {
init: function(svg, dataset, valueline){
svg.append("path")
.data([dataset])
.attr("fill", "none")
.attr("stroke", "green")
.attr("stroke-width", "2px")
.attr("d", valueline);
}
};
//
//LineChart = {
// margin: {top: 20, right: 0, bottom: 40, left: 80},
//
// init: function(svg, html_tag_attr, dataset, xTimeParse, xAxisFormat, xTicks, yTicks){
// this.html_tag_attr = html_tag_attr;
//
// //var div = d3.select(this.html_tag_attr).append("div")
// d3.select(this.html_tag_attr).append("div")
// .attr("class", "tooltip")
// .style("opacity", 0);
//
// // set the dimensions and margins of the graph
// var width = $(this.html_tag_attr).width() - this.margin.left - this.margin.right,
// height = $(this.html_tag_attr).height() - this.margin.top - this.margin.bottom;
//
// // parse the date / time
// var parseTime = d3.timeParse(xTimeParse);
//
// // set the ranges
// var x = d3.scaleTime().range([0, width]);
// var y = d3.scaleLinear().range([(height), this.margin.top]);
//
// // define the line
// var valueline = d3.line()
// .x(function(d) { return x(d.x); })
// .y(function(d) { return y(+d.y); });
// //.y(function(d) { return y(d.y); });
//
// // format the dataset
// dataset.forEach(function(d) {
// d.x = parseTime(d.x);
// d.y = +d.y;
// });
//
// // Scale the range of the dataset
// x.domain(d3.extent(dataset, function(d) { return d.x; }));
// y.domain([0, d3.max(dataset, function(d) { return +d.y + 10; })]).ticks(2);
// //var max = d3.max(dataset, function(d) { return +d.y + 10; });
//
// // Add the valueline path.
// svg.append("path")
// .data([dataset])
// .attr("fill", "none")
// .attr("stroke", "green")
// .attr("stroke-width", "2px")
// .attr("d", valueline);
//
// // Add the X Axis
// svg.append("g")
// .attr("class", "axis")
// .attr("transform", "translate(0," + height + ")")
// .call(d3.axisBottom(x).tickFormat(d3.timeFormat(xAxisFormat)).ticks(xTicks))
// .selectAll("text")
// .attr("dx", "-.8em")
// .attr("dy", ".95em");
//
// // Add the Y Axis
// svg.append("g")
// .attr("class", "axis")
// .call(d3.axisLeft(y).ticks(yTicks))
// .selectAll("text")
// .style("text-anchor", "end")
// ;
//
// }, //ENDOF init: function()
//
// addLine: function(svg, html_tag_attr, dataset, xTimeParse, color){
// // set the dimensions and margins of the graph
// var width = $(this.html_tag_attr).width() - this.margin.left - this.margin.right,
// height = $(this.html_tag_attr).height() - this.margin.top - this.margin.bottom;
//
// // parse the date / time
// var parseTime = d3.timeParse(xTimeParse);
//
// // set the ranges
// var x = d3.scaleTime().range([0, width]);
// var y = d3.scaleLinear().range([height, 0]);
//
// // define the line
// var valueline = d3.line()
// .x(function(d) { return x(d.x); })
// .y(function(d) { return y(+d.y); });
// //.y(function(d) { return y(d.y); });
//
// //var svg = this.svg(html_tag_attr, width, height, this.margin);
//
// // format the dataset
// dataset.forEach(function(d) {
// d.x = parseTime(d.x);
// d.y = +d.y;
// });
//
// // Scale the range of the dataset
// x.domain(d3.extent(dataset, function(d) { return d.x; }));
// y.domain([0, d3.max(dataset, function(d) { return +d.y + 10; })]).ticks(2);
//
// // Add the valueline path.
// svg.append("path")
// .data([dataset])
// .attr("fill", "none")
// .attr("stroke", color)
// .attr("stroke-width", "2px")
// .attr("d", valueline)
// ;
//
// }, //ENDOG addLine: function()
//
//}; //ENDOF LineChart

View File

@ -0,0 +1,63 @@
var MapChart = {
init: function(svg, html_tag_attr, projection, map){
var wSvg = $(html_tag_attr).width(),
hSvg = $(html_tag_attr).height();
var path = d3.geoPath().projection(projection);
Promise.all([map]).then(values => {
createMap(values[0]);
});
// Code for map zooming
var zoomSettings = d3.zoomIdentity
.translate(wSvg / 2, hSvg / 2)
.scale(hSvg / 2);
var mapZoom = d3.zoom().on("zoom", zoomed);
function zoomed(){
var e = d3.event;
projection.translate([e.transform.x, e.transform.y]).scale(e.transform.k);
d3.selectAll("path.countries").attr("d", path);
}
function zoomButton(zoomDirection) {
var width = 500;
var height = 500;
if (zoomDirection == "in") {
var newZoom = projection.scale() * 1.5;
var newX =
((projection.translate()[0] - (width / 2)) * 1.5) + width / 2;
var newY =
((projection.translate()[1] - (height / 2)) * 1.5) + height / 2;
}
else if (zoomDirection == "out") {
var newZoom = projection.scale() * .75;
var newX = ((projection.translate()[0] - (width / 2)) * .75) + width / 2;
var newY = ((projection.translate()[1] - (height / 2)) * .75) + height / 2;
}
var newZoomSettings = d3.zoomIdentity.translate(newX, newY).scale(newZoom);
svg.transition().duration(500).call(mapZoom.transform, newZoomSettings);
}
d3.select(html_tag_attr).select(html_tag_attr+"_controls").append("button").attr("classed", "btn btn-success").on("click", () => {
zoomButton("in")}).html("Zoom In");
d3.select(html_tag_attr).select(".controls").append("button").on("click", () => {
zoomButton("out")}).html("Zoom Out");
function createMap(countries){
svg.selectAll("path")
.data(countries.features)
.enter()
.append("path")
.attr("d", path)
.attr("class", "countries");
svg.call(mapZoom).call(mapZoom.transform, zoomSettings);
}
}
};

12
custom/scripts/d3js/chart/map_chart.js vendored Normal file
View File

@ -0,0 +1,12 @@
MapChart = {
init: function(svg, dataset, path){
return svg.selectAll("path")
.data(dataset)
.enter()
.append("path")
.attr("d", path)
.attr("fill", "#dedede")
.attr("stroke", "steelblue")
.attr("stroke-width", "0.7px");
}
}

7
custom/scripts/d3js/chart/svg.js vendored Normal file
View File

@ -0,0 +1,7 @@
SVG = {
init: function(selection, svgW, svgH){
return d3.select(selection).append("svg")
.attr("viewBox", "-20 0 "+ svgW +" "+ svgH)
.attr("perserveAspectRatio", "xMinYMid");
},
};

129
custom/scripts/d3js/chart/test_chart.js vendored Normal file
View File

@ -0,0 +1,129 @@
var TestChart = {
init: function(){
var svg = d3.select("svg"),
margin = {top: 20, right: 20, bottom: 110, left: 40},
margin2 = {top: 430, right: 20, bottom: 30, left: 40},
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - margin.top - margin.bottom,
height2 = +svg.attr("height") - margin2.top - margin2.bottom;
var parseDate = d3.timeParse("%b %Y");
var x = d3.scaleTime().range([0, width]),
x2 = d3.scaleTime().range([0, width]),
y = d3.scaleLinear().range([height, 0]),
y2 = d3.scaleLinear().range([height2, 0]);
var xAxis = d3.axisBottom(x),
xAxis2 = d3.axisBottom(x2),
yAxis = d3.axisLeft(y);
var brush = d3.brushX()
.extent([[0, 0], [width, height2]])
.on("brush end", brushed);
var zoom = d3.zoom()
.scaleExtent([1, Infinity])
.translateExtent([[0, 0], [width, height]])
.extent([[0, 0], [width, height]])
.on("zoom", zoomed);
var area = d3.area()
.curve(d3.curveMonotoneX)
.x(function(d) { return x(d.date); })
.y0(height)
.y1(function(d) { return y(d.price); });
var area2 = d3.area()
.curve(d3.curveMonotoneX)
.x(function(d) { return x2(d.date); })
.y0(height2)
.y1(function(d) { return y2(d.price); });
svg.append("defs").append("clipPath")
.attr("id", "clip")
.append("rect")
.attr("width", width)
.attr("height", height);
var focus = svg.append("g")
.attr("class", "focus")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var context = svg.append("g")
.attr("class", "context")
.attr("transform", "translate(" + margin2.left + "," + margin2.top + ")");
d3.csv("sp500.csv", type, function(error, data) {
if (error) throw error;
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain([0, d3.max(data, function(d) { return d.price; })]);
x2.domain(x.domain());
y2.domain(y.domain());
focus.append("path")
.datum(data)
.attr("class", "area")
.attr("d", area);
focus.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
focus.append("g")
.attr("class", "axis axis--y")
.call(yAxis);
context.append("path")
.datum(data)
.attr("class", "area")
.attr("d", area2);
context.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height2 + ")")
.call(xAxis2);
context.append("g")
.attr("class", "brush")
.call(brush)
.call(brush.move, x.range());
svg.append("rect")
.attr("class", "zoom")
.attr("width", width)
.attr("height", height)
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.call(zoom);
});
function brushed() {
if (d3.event.sourceEvent && d3.event.sourceEvent.type === "zoom") return; // ignore brush-by-zoom
var s = d3.event.selection || x2.range();
x.domain(s.map(x2.invert, x2));
focus.select(".area").attr("d", area);
focus.select(".axis--x").call(xAxis);
svg.select(".zoom").call(zoom.transform, d3.zoomIdentity
.scale(width / (s[1] - s[0]))
.translate(-s[0], 0));
}
function zoomed() {
if (d3.event.sourceEvent && d3.event.sourceEvent.type === "brush") return; // ignore zoom-by-brush
var t = d3.event.transform;
x.domain(t.rescaleX(x2).domain());
focus.select(".area").attr("d", area);
focus.select(".axis--x").call(xAxis);
context.select(".brush").call(brush.move, x.range().map(t.invertX, t));
}
function type(d) {
d.date = parseDate(d.date);
d.price = +d.price;
return d;
}
}, //ENDOF TestChart()
}

View File

@ -0,0 +1,32 @@
var GaugeChart = {
init: function(svg, html_tag_attr, min, current, max){
console.log(min, current, max);
var startAngle = -Math.PI/2,
tau = Math.PI/2,
C = tau/max;
console.log(tau, max, C, (current*C));
var width = $(html_tag_attr).width(),
height = $(html_tag_attr).height(),
coeff = height / 2,
size = 15,
g = svg.append("g").attr("transform", "translate(" + ((width / 2) - size) + "," + (height - height/2) + ")");
var arc = d3.arc()
.innerRadius(height - coeff)
.outerRadius(height - coeff - size)
.startAngle(startAngle);
// Add the background arc, from 0 to 100% (tau).
var background = g.append("path")
.datum({endAngle: tau})
.style("fill", "#ddd")
.attr("d", arc);
// Add the foreground arc in orange, currently showing 12.7%.
var foreground = g.append("path")
.datum({endAngle: (current/max*C)/startAngle })
.style("fill", "orange")
.attr("d", arc);
},
};

18
custom/scripts/d3js/chart/text_chart.js vendored Normal file
View File

@ -0,0 +1,18 @@
TextChart = {
init: function(url, svg, textAccessor){
d3.json(url, config_requestArguments).then(function(dataset){
console.log(dataset);
svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.attr("x", 20)
.attr("y", function(d, i){ return 20 + i *20; })
.text( textAccessor )
.attr("font-family", "sans-serif")
//.attr("font-size", "10px")
.attr("fill", "black");
});
}
};

View File

@ -0,0 +1,8 @@
//var svg = SVG.init("#current_real_gain", 600, 400);
get_gauge(
"custom/scripts/ajax/current_real_gain.php",
"#current_real_gain",
function(dataset){ return dataset.current; }, //current
function(){ return 0; }, //min
function(dataset){ return dataset.max; } //max
);

View File

@ -0,0 +1,36 @@
function grey_tasks(freetasks_ids){
$(".task_todo").each(function(){
var button = $(this).find("button[name='submit_getUnassignedTask_form']");
if(!freetasks_ids.includes(this.id) && !button.prop('disabled')){
button.prop('disabled', true);
button.text("Task assigned");
}
else if(freetasks_ids.includes(this.id) && button.prop('disabled')){
button.prop('disabled', false);
button.html("<i class='material-icons'>lock</i>");
}
})
}
function reatime_task_update(){
var self = reatime_task_update;
$.ajax({
type: "GET",
url: urlRoot + "custom/scripts/checkFreeTasks.php",
success: function(values)
{
var freetasks_ids = values.split(",");
freetasks_ids = $.map(freetasks_ids, function(id){
return "task_todo_" + id;
});
grey_tasks(freetasks_ids);
setTimeout(self, 5000);
},
error: function()
{
setTimeout(self, 5000);
}
});
}
$(document).ready(reatime_task_update);

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

BIN
images/binary-euros.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 MiB

BIN
images/branding.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
images/channels.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
images/flags/default/en_gb.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
images/flags/default/et_ee.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

BIN
images/flags/default/fr_fr.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

BIN
images/flags/world/ad.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
images/flags/world/ae.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

BIN
images/flags/world/af.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
images/flags/world/ag.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
images/flags/world/al.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/flags/world/am.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

BIN
images/flags/world/ao.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/flags/world/ar.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
images/flags/world/at.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

BIN
images/flags/world/au.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
images/flags/world/az.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/flags/world/ba.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/flags/world/bb.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/flags/world/bd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

BIN
images/flags/world/be.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

BIN
images/flags/world/bf.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
images/flags/world/bg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/flags/world/bh.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

BIN
images/flags/world/bi.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
images/flags/world/bj.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

BIN
images/flags/world/bn.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
images/flags/world/bo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
images/flags/world/br.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
images/flags/world/bs.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/flags/world/bt.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
images/flags/world/bw.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

BIN
images/flags/world/by.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
images/flags/world/bz.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
images/flags/world/ca.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
images/flags/world/cd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
images/flags/world/cf.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

BIN
images/flags/world/cg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/flags/world/ch.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

BIN
images/flags/world/ci.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

BIN
images/flags/world/cl.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

BIN
images/flags/world/cm.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/flags/world/cn.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
images/flags/world/co.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

BIN
images/flags/world/cr.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

BIN
images/flags/world/cu.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
images/flags/world/cv.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
images/flags/world/cy.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/flags/world/cz.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/flags/world/de.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

BIN
images/flags/world/dj.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/flags/world/dk.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/flags/world/dm.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
images/flags/world/do.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
images/flags/world/dz.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/flags/world/ec.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
images/flags/world/ee.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

BIN
images/flags/world/eg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
images/flags/world/eh.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
images/flags/world/er.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
images/flags/world/es.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Some files were not shown because too many files have changed in this diff Show More