invoice module

This commit is contained in:
roshelrao committed 2021-07-01 15:51:04 +05:30
1 parent 9f47df5613
commit 1332448d72
21 files changed
+422992 -34133

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["node_modules/browser-pack/_prelude.js","extensions/invoices/web/js/index.js","extensions/invoices/web/js/lib.js","node_modules/process/browser.js","web/api-common/RequestCache.js","web/api/AdapterBase.js","web/api/FormValidation.js","web/api/IceApiClient.js","web/api/IceDataPipe.js","web/api/MasterDataReader.js","web/api/ModuleBase.js","web/api/ReactModalAdapterBase.js","web/components/IceColorPick.js","web/components/IceDataGroup.js","web/components/IceForm.js","web/components/IceFormModal.js","web/components/IceLabel.js","web/components/IceSelect.js","web/components/IceSignature.js","web/components/IceStepForm.js","web/components/IceStepFromModal.js","web/components/IceTable.js","web/components/IceUpload.js","web/node_modules/@icons/material/CheckIcon.js","web/node_modules/@icons/material/UnfoldMoreHorizontalIcon.js","web/node_modules/axios/index.js","web/node_modules/axios/lib/adapters/xhr.js","web/node_modules/axios/lib/axios.js","web/node_modules/axios/lib/cancel/Cancel.js","web/node_modules/axios/lib/cancel/CancelToken.js","web/node_modules/axios/lib/cancel/isCancel.js","web/node_modules/axios/lib/core/Axios.js","web/node_modules/axios/lib/core/InterceptorManager.js","web/node_modules/axios/lib/core/buildFullPath.js","web/node_modules/axios/lib/core/createError.js","web/node_modules/axios/lib/core/dispatchRequest.js","web/node_modules/axios/lib/core/enhanceError.js","web/node_modules/axios/lib/core/mergeConfig.js","web/node_modules/axios/lib/core/settle.js","web/node_modules/axios/lib/core/transformData.js","web/node_modules/axios/lib/defaults.js","web/node_modules/axios/lib/helpers/bind.js","web/node_modules/axios/lib/helpers/buildURL.js","web/node_modules/axios/lib/helpers/combineURLs.js","web/node_modules/axios/lib/helpers/cookies.js","web/node_modules/axios/lib/helpers/isAbsoluteURL.js","web/node_modules/axios/lib/helpers/isURLSameOrigin.js","web/node_modules/axios/lib/helpers/normalizeHeaderName.js","web/node_modules/axios/lib/helpers/parseHeaders.js","web/node_modules/axios/lib/helpers/spread.js","web/node_modules/axios/lib/utils.js","web/node_modules/lodash/_DataView.js","web/node_modules/lodash/_Hash.js","web/node_modules/lodash/_ListCache.js","web/node_modules/lodash/_Map.js","web/node_modules/lodash/_MapCache.js","web/node_modules/lodash/_Promise.js","web/node_modules/lodash/_Set.js","web/node_modules/lodash/_SetCache.js","web/node_modules/lodash/_Stack.js","web/node_modules/lodash/_Symbol.js","web/node_modules/lodash/_Uint8Array.js","web/node_modules/lodash/_WeakMap.js","web/node_modules/lodash/_apply.js","web/node_modules/lodash/_arrayEach.js","web/node_modules/lodash/_arrayFilter.js","web/node_modules/lodash/_arrayLikeKeys.js","web/node_modules/lodash/_arrayMap.js","web/node_modules/lodash/_arrayPush.js","web/node_modules/lodash/_arraySome.js","web/node_modules/lodash/_assignMergeValue.js","web/node_modules/lodash/_assignValue.js","web/node_modules/lodash/_assocIndexOf.js","web/node_modules/lodash/_baseAssign.js","web/node_modules/lodash/_baseAssignIn.js","web/node_modules/lodash/_baseAssignValue.js","web/node_modules/lodash/_baseClone.js","web/node_modules/lodash/_baseCreate.js","web/node_modules/lodash/_baseEach.js","web/node_modules/lodash/_baseFor.js","web/node_modules/lodash/_baseForOwn.js","web/node_modules/lodash/_baseGet.js","web/node_modules/lodash/_baseGetAllKeys.js","web/node_modules/lodash/_baseGetTag.js","web/node_modules/lodash/_baseHasIn.js","web/node_modules/lodash/_baseIsArguments.js","web/node_modules/lodash/_baseIsEqual.js","web/node_modules/lodash/_baseIsEqualDeep.js","web/node_modules/lodash/_baseIsMap.js","web/node_modules/lodash/_baseIsMatch.js","web/node_modules/lodash/_baseIsNative.js","web/node_modules/lodash/_baseIsSet.js","web/node_modules/lodash/_baseIsTypedArray.js","web/node_modules/lodash/_baseIteratee.js","web/node_modules/lodash/_baseKeys.js","web/node_modules/lodash/_baseKeysIn.js","web/node_modules/lodash/_baseMap.js","web/node_modules/lodash/_baseMatches.js","web/node_modules/lodash/_baseMatchesProperty.js","web/node_modules/lodash/_baseMerge.js","web/node_modules/lodash/_baseMergeDeep.js","web/node_modules/lodash/_baseProperty.js","web/node_modules/lodash/_basePropertyDeep.js","web/node_modules/lodash/_baseRest.js","web/node_modules/lodash/_baseSetToString.js","web/node_modules/lodash/_baseTimes.js","web/node_modules/lodash/_baseToString.js","web/node_modules/lodash/_baseUnary.js","web/node_modules/lodash/_cacheHas.js","web/node_modules/lodash/_castFunction.js","web/node_modules/lodash/_castPath.js","web/node_modules/lodash/_cloneArrayBuffer.js","web/node_modules/lodash/_cloneBuffer.js","web/node_modules/lodash/_cloneDataView.js","web/node_modules/lodash/_cloneRegExp.js","web/node_modules/lodash/_cloneSymbol.js","web/node_modules/lodash/_cloneTypedArray.js","web/node_modules/lodash/_copyArray.js","web/node_modules/lodash/_copyObject.js","web/node_modules/lodash/_copySymbols.js","web/node_modules/lodash/_copySymbolsIn.js","webLine truncated
+5
View File
@@ -0,0 +1,5 @@
<?php
require_once __DIR__.'/src/Invoices/Extension.php';
require_once __DIR__.'/src/Invoices/Migration.php';
require_once __DIR__.'/src/Invoices/Model/Invoice.php';
+13
View File
@@ -0,0 +1,13 @@
{
"label": "Invoices",
"menu": ["Invoices", "fa-file"],
"icon": "fa-files",
"user_levels": [
"Admin",
"Manager",
"User"
],
"model_namespace": "\\Invoices\\Model",
"manager": "\\Invoices\\Extension",
"headless": false
}
@@ -0,0 +1,30 @@
<?php
namespace Invoices;
use Classes\IceExtension;
class Extension extends IceExtension
{
public function install() {
$migration = new Migration();
return $migration->up();
}
public function uninstall() {
$migration = new Migration();
return $migration->down();
}
public function setupModuleClassDefinitions()
{
}
public function setupRestEndPoints()
{
}
}
@@ -0,0 +1,51 @@
<?php
namespace Invoices;
use Classes\Migration\AbstractMigration;
class Migration extends AbstractMigration
{
public function up()
{
$sql = <<<'SQL'
create table Invoices
(
id bigint auto_increment primary key,
paymentId bigint not null,
invoiceId bigint not null,
description varchar(500) charset utf8 not null,
buyerName varchar(200) charset utf8 not null,
buyerAddress varchar(200) charset utf8 not null,
buyerPostalCode varchar(200) charset utf8 not null,
buyerCountry varchar(200) charset utf8 not null,
buyerVatId varchar(50) charset utf8 not null,
sellerName varchar(200) charset utf8 not null,
sellerAddress varchar(200) null,
sellerCountry varchar(200) charset utf8 not null,
sellerVatId varchar(50) charset utf8 not null,
amount decimal(10,2) default 0.00 null,
vat decimal(10,2) default 0.00 null,
vatRate decimal(10,2) default 0.00 null,
issuedDate datetime null,
paidDate datetime null,
created datetime null,
updated datetime null,
status enum('Pending', 'Paid', 'Processing', 'Draft', 'Sent', 'Canceled') collate utf8_unicode_ci default 'Pending' null,
acceptPayments tinyint default 0 null,
buyerEmail varchar(125) charset utf8 null,
constraint invoiceId
unique (invoiceId)
)
collate=utf8mb4_unicode_ci;
SQL;
return $this->executeQuery($sql);
}
public function down()
{
$sql = <<<'SQL'
DROP TABLE IF EXISTS `Invoices`;
SQL;
return $this->executeQuery($sql);
}
}
@@ -0,0 +1,23 @@
<?php
namespace Invoices\Model;
use Classes\ModuleAccess;
use Model\BaseModel;
class Invoice extends BaseModel
{
public $table = 'Invoices';
public function getAdminAccess()
{
return array("get","element","save","delete");
}
public function getModuleAccess()
{
return [
new ModuleAccess('employees', 'admin'),
];
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
/*$user = \Classes\BaseService::getInstance()->getCurrentUser();
echo "Welcome ".$user->username."<br/>";
echo "Invoices <br/>";
*/
use Classes\PermissionManager;
use Invoices\Model\Invoice;
?><div class="span9">
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
<li class="active"><a id="tabInvoices" href="#tabPageInvoices"><?=t('Invoices')?></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageInvoices">
<div id="InvoicesTable" class="reviewBlock" data-content="List" style="padding-left:5px;"></div>
<div id="InvoicesForm"></div>
<div id="InvoicesFilterForm"></div>
</div>
</div>
</div>
<div id="dataGroup"></div>
<?php
$moduleData = [
'user_level' => $user->user_level,
'permissions' => [
'Invoice' => PermissionManager::checkGeneralAccess(new Invoice()),
]
];
?>
<script>
initAdminInvoices(<?=json_encode($moduleData)?>);
</script>
+17
View File
@@ -0,0 +1,17 @@
import InvoiceAdapter from './lib';
import IceDataPipe from '../../../../web/api/IceDataPipe';
function init(data) {
const modJsList = [];
modJsList.tabInvoices =new InvoiceAdapter('Invoices', 'Invoices','','');
modJsList.tabInvoices.setObjectTypeName('Invoices');
modJsList.tabInvoices.setDataPipe(new IceDataPipe(modJsList.tabVInvoices));
modJsList.tabInvoices.setAccess(data.permissions.Invoices);
window.modJs = modJsList.tabInvoices;
window.modJsList = modJsList;
}
window.initAdminInvoices = init;
+119
View File
@@ -0,0 +1,119 @@
import ReactModalAdapterBase from '../../../../web/api/ReactModalAdapterBase';
/**
* VatInvoiceAdapter
*/
class InvoiceAdapter extends ReactModalAdapterBase {
/*constructor(endPoint, tab, filter, orderBy) {
super(endPoint, tab, filter, orderBy);
this.fieldNameMap = {};
this.hiddenFields = {};
this.tableFields = {};
this.formOnlyFields = {};
}*/
getDataMapping() {
return [
'id',
'paymentId',
'invoiceId',
'description',
'buyerName',
'buyerAddress',
'buyerPostalAddress',
'buyerVatId',
'buyerEmail',
'sellerName',
'sellerAddress',
'sellerVatId',
'amount',
'vat',
'vatRate',
'issuedDate',
'paidDate',
'status',
'acceptPayments',
'created',
'updated',
'link',
'paymentLink'
];
}
getHeaders() {
return [
{ sTitle: 'ID', bVisible: false },
{ sTitle: 'Payment Id' },
{ sTitle: 'Invoice ID' },
{ sTitle: 'Description' },
{ sTitle: 'Buyer Name' },
{ sTitle: 'Buyer Address' },
{ sTitle: 'Buyer Postal Code' },
{ sTitle: 'Buyer Country' },
{ sTitle: 'Buyer Vat Id' },
{ sTitle: 'Buyer Email' },
{ sTitle: 'Seller Name' },
{ sTitle: 'Seller Country' },
{ sTitle: 'Seller Vat Id' },
{ sTitle: 'Amount' },
{ sTitle: 'Vat' },
{ sTitle: 'Vat Rate' },
{ sTitle: 'Issued Date' },
{ sTitle: 'Paid Date' },
{ sTitle: 'Status' },
{ sTitle: 'Accept Payments' },
{ sTitle: 'Created' },
{ sTitle: 'Updated' },
{ sTitle: 'Link' },
{ sTitle: 'Payment Link' },
];
}
getFormFields() {
return [
[ 'id', {"label":"ID","type":"hidden"}],
[ 'paymentId', {"label":"Payment Id","type":"text","validation":"int"}],
[ 'invoiceId', {"label":"Invoice Id","type":"text","validation":"int"}],
[ 'description', {"label":"Description","type":"textarea","validation":"none"}],
[ 'buyerName', {"label":"Buyer Name","type":"text"}],
[ 'buyerAddress', {"label":"Buyer Address","type":"textarea"}],
[ 'buyerPostalCode', {"label":"Buyer Postal Code","type":"text"}],
[ 'buyerCountry', {"label":"Buyer Country","type":"select2", "source": this.getCountryList()}],
[ 'buyerVatId', {"label":"Buyer Vat Id","type":"text","validation":"none"}],
[ 'buyerEmail', {"label":"Buyer Email","type":"text"}],
[ 'sellerName', {"label":"Seller Name","type":"text"}],
[ 'sellerAddress', {"label":"Seller Address","type":"text"}],
[ 'sellerCountry', {"label":"Seller Country","type":"select2", "source": this.getCountryList()}],
[ 'sellerVatId', {"label":"Seller Vat Id","type":"text"}],
[ 'amount', {"label":"Amount with VAT","type":"text", "validation":"float"}],
[ 'vat', {"label":"Vat","type":"text", "validation":"float"}],
[ 'vatRate', {"label":"Vat Rate","type":"text", "validation":"float"}],
[ 'issuedDate', {"label":"Issued Date","type":"datetime", "validation":""}],
[ 'paidDate', {"label":"Paid Date","type":"datetime", "validation":""}],
[ 'status', {"label":"Status","type":"select","source":[["Pending","Pending"],["Paid","Paid"],["Processing","Processing"],["Draft","Draft"],["Sent","Sent"],["Canceled","Canceled"]]}],
[ 'acceptPayments', {"label":"Accept Payments","type":"select","source":[["0","No"],["1","Yes"]]}],
[ 'created', {"label":"Created","type":"datetime", "validation":""}],
[ 'updated', {"label":"Updated","type":"datetime", "validation":""}],
[ 'link', {"label":"Link","type":"placeholder"}],
[ 'paymentLink', {"label":"Payment Link","type":"placeholder"}],
];
}
getTableColumns() {
return [
{
title: 'Payment Id',
dataIndex: 'paymentId',
sorter: true,
},
{
title: 'Invoice Id',
dataIndex: 'invoiceId',
sorter: true,
},
];
}
}
module.exports ={InvoiceAdapter};
+47031 -4
View File
File diff suppressed because it is too large. Load diff
+531 -1
View File
@@ -1 +1,531 @@
var _0x3da4=['#_notifications_#','value','#_time_#','.label-danger','serverGMToffset','100%','\x20hours\x20ago','July','width','setTimeUtils','#notifications','timeUtils','image','Cannot\x20call\x20a\x20class\x20as\x20a\x20function','configurable','.notificationTime','renderNotifications','templates','removeAllByPrefix','storage','RequestCache','default','August','slimscroll','setTemplates','substring','<br/>','width=','indexOf','getMinutes','getTimezoneOffset','SUCCESS','getMonth','replace','http://twitter.com/share?text=','enumerable','width=550,height=260,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=200,top=200','parse','less\x20than\x20a\x20minute\x20ago','\x20new\x20notification','popup','notifications','defineProperty',',top=','3px','key','You\x20have\x20no\x20new\x20notifications','html','status','__esModule','Tuesday','https://www.linkedin.com/cws/share?url=','split','renderNotification','#_image_#','find','March','SocialShare','\x20minutes\x20ago','getHours',',height=','exports','./Notifications','getKey','.navbar\x20.menu','function','#_count_#','November','about\x20an\x20hour\x20ago','February',',left=','getNotifications','./TimeUtils','getLineBreakString','baseUrl','May','toString','getItem','replaceWith','clearNotifications','css','round','getTime','#_url_#','writable','MODULE_NOT_FOUND','prototype','Share\x20on\x20Google','Share\x20on\x20Linked\x20in','clearPendingNotifications','getMySQLFormatDate','code','concat','#_message_#','September','setData','notification','service.php','abs','action','Wednesday','getData','each','remove','invalidateTable','#_header_#','getJSON','message','keys','open','setupNotifications','\x20new\x20notifications','./SocialShare','setBaseUrl','height','You\x20have\x20','length','\x20at\x20','January','call','https://plus.google.com/share?url=','June','time','https://www.facebook.com/sharer/sharer.php?u=','&url=','Thursday','./RequestCache','about\x20a\x20minute\x20ago','December','Sunday','setServerGMToffset','Saturday','getFullYear','data','title','320px'];(function(_0x198ecd,_0x3da454){var _0x54958e=function(_0x484a68){while(--_0x484a68){_0x198ecd['push'](_0x198ecd['shift']());}};_0x54958e(++_0x3da454);}(_0x3da4,0x86));var _0x5495=function(_0x198ecd,_0x3da454){_0x198ecd=_0x198ecd-0x0;var _0x54958e=_0x3da4[_0x198ecd];return _0x54958e;};!function e(_0x484a68,_0x3c0cbb,_0x4be79d){var _0x53a125=_0x5495;function _0x1c5197(_0x411bc1,_0x5f551e){var _0x1842d6=_0x5495;if(!_0x3c0cbb[_0x411bc1]){if(!_0x484a68[_0x411bc1]){var _0x4d20c0='function'==typeof require&&require;if(!_0x5f551e&&_0x4d20c0)return _0x4d20c0(_0x411bc1,!0x0);if(_0x4f741c)return _0x4f741c(_0x411bc1,!0x0);var _0x2d52c9=new Error('Cannot\x20find\x20module\x20\x27'+_0x411bc1+'\x27');throw _0x2d52c9[_0x1842d6('0x5d')]=_0x1842d6('0x57'),_0x2d52c9;}var _0x557b9a=_0x3c0cbb[_0x411bc1]={'exports':{}};_0x484a68[_0x411bc1][0x0][_0x1842d6('0x79')](_0x557b9a[_0x1842d6('0x3f')],function(_0x20b96e){return _0x1c5197(_0x484a68[_0x411bc1][0x1][_0x20b96e]||_0x20b96e);},_0x557b9a,_0x557b9a[_0x1842d6('0x3f')],e,_0x484a68,_0x3c0cbb,_0x4be79d);}return _0x3c0cbb[_0x411bc1][_0x1842d6('0x3f')];}for(var _0x4f741c=_0x53a125('0x43')==typeof require&&require,_0x3d305d=0x0;_0x3d305d<_0x4be79d['length'];_0x3d305d++)_0x1c5197(_0x4be79d[_0x3d305d]);return _0x1c5197;}({0x1:[function(_0x1e7ed6,_0x1ede44,_0x347c04){var _0x2282bd=_0x5495;'use strict';function _0x24486b(_0x31cc8e,_0x34549e){var _0x3c6c9a=_0x5495;for(var _0x54c5b4=0x0;_0x54c5b4<_0x34549e[_0x3c6c9a('0x76')];_0x54c5b4++){var _0x35be4e=_0x34549e[_0x54c5b4];_0x35be4e[_0x3c6c9a('0x25')]=_0x35be4e[_0x3c6c9a('0x25')]||!0x1,_0x35be4e[_0x3c6c9a('0x10')]=!0x0,_0x3c6c9a('0x3')in _0x35be4e&&(_0x35be4e[_0x3c6c9a('0x56')]=!0x0),Object[_0x3c6c9a('0x2c')](_0x31cc8e,_0x35be4e[_0x3c6c9a('0x2f')],_0x35be4e);}}Object['defineProperty'](_0x347c04,_0x2282bd('0x33'),{'value':!0x0}),_0x347c04[_0x2282bd('0x17')]=void 0x0;var _0x5dbf35=function(){var _0x34c76f=_0x2282bd;function _0xd6b48a(){var _0x4bb2c8=_0x5495;!function(_0x44e54c,_0x7b9112){var _0xbe35ee=_0x5495;if(!(_0x44e54c instanceof _0x7b9112))throw new TypeError(_0xbe35ee('0xf'));}(this,_0xd6b48a),this['baseUrl']='',this[_0x4bb2c8('0x13')]={};}var _0x5c2002,_0x2dc18f,_0x5910b;return _0x5c2002=_0xd6b48a,(_0x2dc18f=[{'key':_0x34c76f('0x73'),'value':function(_0x5c8f0f){this['baseUrl']=_0x5c8f0f;}},{'key':_0x34c76f('0x1a'),'value':function(_0x1acf64){var _0x1b839d=_0x34c76f;this[_0x1b839d('0x13')]=_0x1acf64;}},{'key':_0x34c76f('0xb'),'value':function(_0x177850){var _0x5e1dc8=_0x34c76f;this[_0x5e1dc8('0xd')]=_0x177850;}},{'key':_0x34c76f('0x49'),'value':function(_0x3b4e27,_0x5520a2){var _0x6b77a9=_0x34c76f,_0x16838a=this;$['getJSON'](this[_0x6b77a9('0x4c')],{'a':_0x6b77a9('0x49')},function(_0x3c5c08){var _0x32508d=_0x6b77a9;_0x32508d('0x21')===_0x3c5c08[_0x32508d('0x32')]&&_0x16838a['renderNotifications'](_0x3c5c08[_0x32508d('0x87')][0x1],_0x3c5c08[_0x32508d('0x87')][0x0]);});}},{'key':_0x34c76f('0x5b'),'Line truncated (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/*
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
*/
var NotificationManager = /*#__PURE__*/function () {
function NotificationManager() {
_classCallCheck(this, NotificationManager);
this.baseUrl = '';
this.templates = {};
}
_createClass(NotificationManager, [{
key: "setBaseUrl",
value: function setBaseUrl(url) {
this.baseUrl = url;
}
}, {
key: "setTemplates",
value: function setTemplates(data) {
this.templates = data;
}
}, {
key: "setTimeUtils",
value: function setTimeUtils(timeUtils) {
this.timeUtils = timeUtils;
}
}, {
key: "getNotifications",
value: function getNotifications(name, data) {
var that = this;
$.getJSON(this.baseUrl, {
a: 'getNotifications'
}, function (_data) {
if (_data.status === 'SUCCESS') {
that.renderNotifications(_data.data[1], _data.data[0]);
}
});
}
}, {
key: "clearPendingNotifications",
value: function clearPendingNotifications(name, data) {
var that = this;
$.getJSON(this.baseUrl, {
a: 'clearNotifications'
}, function (_data) {});
}
}, {
key: "renderNotifications",
value: function renderNotifications(notifications, unreadCount) {
if (notifications.length === 0) {
return;
}
var t = this.templates.notifications;
if (unreadCount > 0) {
t = t.replace('#_count_#', unreadCount);
if (unreadCount > 1) {
t = t.replace('#_header_#', "You have ".concat(unreadCount, " new notifications"));
} else {
t = t.replace('#_header_#', "You have ".concat(unreadCount, " new notification"));
}
} else {
t = t.replace('#_count_#', '');
t = t.replace('#_header_#', 'You have no new notifications');
}
var notificationStr = '';
for (var index in notifications) {
notificationStr += this.renderNotification(notifications[index]);
}
t = t.replace('#_notifications_#', notificationStr);
var $obj = $(t);
if (unreadCount === 0) {
$obj.find('.label-danger').remove();
}
$obj.attr('id', 'notifications');
var k = $('#notifications');
k.replaceWith($obj);
$('.navbar .menu').slimscroll({
height: '320px',
alwaysVisible: false,
size: '3px'
}).css('width', '100%');
this.timeUtils.convertToRelativeTime($('.notificationTime'));
}
}, {
key: "renderNotification",
value: function renderNotification(notification) {
var t = this.templates.notification;
t = t.replace('#_image_#', notification.image);
try {
var json = JSON.parse(notification.action);
t = t.replace('#_url_#', this.baseUrl.replace('service.php', '?') + json.url);
} catch (e) {
t = t.replace('#_url_#', '');
}
t = t.replace('#_time_#', notification.time);
t = t.replace('#_fromName_#', notification.type);
t = t.replace('#_message_#', this.getLineBreakString(notification.message, 27));
return t;
}
}, {
key: "getLineBreakString",
value: function getLineBreakString(str, len) {
var t = '';
try {
var arr = str.split(' ');
var count = 0;
for (var i = 0; i < arr.length; i++) {
count += arr[i].length + 1;
if (count > len) {
t += "".concat(arr[i], "<br/>");
count = 0;
} else {
t += "".concat(arr[i], " ");
}
}
} catch (e) {// Do nothing
}
return t;
}
}]);
return NotificationManager;
}();
var _default = NotificationManager;
exports["default"] = _default;
},{}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/*
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
*/
/**
* RequestCache
*/
var MemoryStorage = /*#__PURE__*/function () {
function MemoryStorage() {
_classCallCheck(this, MemoryStorage);
this.data = {};
}
_createClass(MemoryStorage, [{
key: "getItem",
value: function getItem(key) {
return this.data[key];
}
}, {
key: "setItem",
value: function setItem(key, data) {
this.data[key] = data;
}
}, {
key: "removeAllByPrefix",
value: function removeAllByPrefix(prefix) {
var keys = Object.keys(this.data);
for (var i = 0; i < keys.length; i++) {
if (keys[i].indexOf(prefix) > 0) {
delete this.data[keys[i]];
}
}
}
}]);
return MemoryStorage;
}();
var RequestCache = /*#__PURE__*/function () {
function RequestCache(storage) {
_classCallCheck(this, RequestCache);
if (!storage) {
this.storage = new MemoryStorage();
} else {
this.storage = storage;
}
}
_createClass(RequestCache, [{
key: "getKey",
value: function getKey(url, params) {
var key = "".concat(url, "|");
for (var index in params) {
key += "".concat(index, "=").concat(params[index], "|");
}
return key;
}
/*
invalidateTable(table) {
let key;
for (let i = 0; i < this.storage.length; i++) {
key = this.storage.key(i);
if (key.indexOf(`t=${table}`) > 0) {
this.storage.removeItem(key);
}
}
}
*/
}, {
key: "invalidateTable",
value: function invalidateTable(table) {
this.storage.removeAllByPrefix("t=".concat(table));
}
}, {
key: "getData",
value: function getData(key) {
var data = this.storage.getItem(key);
if (!data) {
return null;
}
return data;
}
}, {
key: "setData",
value: function setData(key, data) {
if (data.status !== undefined && data.status != null && data.status !== 'SUCCESS') {
return null;
}
this.storage.setItem(key, data);
return data;
}
}]);
return RequestCache;
}();
var _default = RequestCache;
exports["default"] = _default;
},{}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
/* eslint-disable no-restricted-globals */
/*
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
*/
var SocialShare = {
facebook: function facebook(url) {
var w = 700;
var h = 500;
var left = screen.width / 2 - w / 2;
var top = screen.height / 2 - h / 2;
url = "https://www.facebook.com/sharer/sharer.php?u=".concat(encodeURIComponent(url));
window.open(url, 'Share on Facebook', "width=".concat(w, ",height=").concat(h, ",left=").concat(left, ",top=").concat(top));
return false;
},
google: function google(url) {
var w = 500;
var h = 500;
var left = screen.width / 2 - w / 2;
var top = screen.height / 2 - h / 2;
url = "https://plus.google.com/share?url=".concat(encodeURIComponent(url));
window.open(url, 'Share on Google', "width=".concat(w, ",height=").concat(h, ",left=").concat(left, ",top=").concat(top));
return false;
},
linkedin: function linkedin(url) {
var w = 500;
var h = 500;
var left = screen.width / 2 - w / 2;
var top = screen.height / 2 - h / 2;
url = "https://www.linkedin.com/cws/share?url=".concat(encodeURIComponent(url));
window.open(url, 'Share on Linked in', "width=".concat(w, ",height=").concat(h, ",left=").concat(left, ",top=").concat(top));
return false;
},
twitter: function twitter(url, msg) {
window.open("http://twitter.com/share?text=".concat(escape(msg), "&url=").concat(escape(url)), 'popup', 'width=550,height=260,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=200,top=200');
return false;
}
};
var _default = SocialShare;
exports["default"] = _default;
},{}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/* eslint-disable camelcase,brace-style */
/*
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
*/
var TimeUtils = /*#__PURE__*/function () {
function TimeUtils() {
_classCallCheck(this, TimeUtils);
}
_createClass(TimeUtils, [{
key: "setServerGMToffset",
value: function setServerGMToffset(serverGMToffset) {
this.serverGMToffset = serverGMToffset;
}
}, {
key: "getMySQLFormatDate",
value: function getMySQLFormatDate(date) {
var format = function format(val) {
if (val < 10) {
return "0".concat(val);
}
return val;
};
return "".concat(date.getUTCFullYear(), "-").concat(format(date.getUTCMonth() + 1), "-").concat(format(date.getUTCDate()));
}
}, {
key: "convertToRelativeTime",
value: function convertToRelativeTime(selector) {
var that = this;
var getAmPmTime = function getAmPmTime(curHour, curMin) {
var amPm = 'am';
var amPmHour = curHour;
if (amPmHour >= 12) {
amPm = 'pm';
if (amPmHour > 12) {
amPmHour -= 12;
}
}
var prefixCurMin = '';
if (curMin < 10) {
prefixCurMin = '0';
}
var prefixCurHour = '';
if (curHour === 0) {
prefixCurHour = '0';
}
return " at ".concat(prefixCurHour).concat(amPmHour, ":").concat(prefixCurMin).concat(curMin).concat(amPm);
};
var getBrowserTimeZone = function getBrowserTimeZone() {
var current_date = new Date();
var gmt_offset = current_date.getTimezoneOffset() / 60;
return -gmt_offset;
};
var curDate = new Date();
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var timezoneDiff = this.serverGMToffset - getBrowserTimeZone();
var timezoneTimeDiff = timezoneDiff * 60 * 60 * 1000;
selector.each(function () {
try {
var thisValue = $(this).html(); // Split value into date and time
var thisValueArray = thisValue.split(' ');
var thisValueDate = thisValueArray[0];
var thisValueTime = thisValueArray[1]; // Split date into components
var thisValueDateArray = thisValueDate.split('-');
var curYear = thisValueDateArray[0];
var curMonth = thisValueDateArray[1] - 1;
var curDay = thisValueDateArray[2]; // Split time into components
var thisValueTimeArray = thisValueTime.split(':');
var curHour = thisValueTimeArray[0];
var curMin = thisValueTimeArray[1];
var curSec = thisValueTimeArray[2]; // Create this date
var thisDate = new Date(curYear, curMonth, curDay, curHour, curMin, curSec);
var thisTime = thisDate.getTime();
var tzDate = new Date(thisTime - timezoneTimeDiff); // var tzDay = tzDate.getDay();//getDay will return the day of the week not the month
// var tzDay = tzDate.getUTCDate(); //getUTCDate will return the day of the month
var tzDay = tzDate.toString('d'); //
var tzYear = tzDate.getFullYear();
var tzHour = tzDate.getHours();
var tzMin = tzDate.getMinutes(); // Create the full date
// var fullDate = days[tzDate.getDay()] + ", " + months[tzDate.getMonth()] + " " + tzDay + ", " + tzYear + getAmPmTime(tzHour, tzMin);
var fullDate = "".concat(days[tzDate.getDay()], ", ").concat(months[tzDate.getMonth()], " ").concat(tzDay, ", ").concat(tzYear).concat(getAmPmTime(tzHour, tzMin)); // Get the time different
var timeDiff = (curDate.getTime() - tzDate.getTime()) / 1000;
var minDiff = Math.abs(timeDiff / 60);
var hourDiff = Math.abs(timeDiff / (60 * 60));
var dayDiff = Math.abs(timeDiff / (60 * 60 * 24));
var yearDiff = Math.abs(timeDiff / (60 * 60 * 24 * 365)); // If more than a day old, display the month, day and time (and year, if applicable)
var fbDate = '';
if (dayDiff > 1) {
// fbDate = curDay + " " + months[tzDate.getMonth()].substring(0,3);
fbDate = "".concat(tzDay, " ").concat(months[tzDate.getMonth()].substring(0, 3)); // Add the year, if applicable
if (yearDiff > 1) {
fbDate = "".concat(fbDate, " ").concat(curYear);
} // Add the time
fbDate += getAmPmTime(tzHour, tzMin);
} // Less than a day old, and more than an hour old
else if (hourDiff >= 1) {
var roundedHour = Math.round(hourDiff);
if (roundedHour === 1) fbDate = 'about an hour ago';else fbDate = "".concat(roundedHour, " hours ago");
} // Less than an hour, and more than a minute
else if (minDiff >= 1) {
var roundedMin = Math.round(minDiff);
if (roundedMin === 1) fbDate = 'about a minute ago';else fbDate = "".concat(roundedMin, " minutes ago");
} // Less than a minute
else if (minDiff < 1) {
fbDate = 'less than a minute ago';
} // Update this element
$(this).html(fbDate);
$(this).attr('title', fullDate);
} catch (e) {// Do nothing
}
});
}
}]);
return TimeUtils;
}();
var _default = TimeUtils;
exports["default"] = _default;
},{}],5:[function(require,module,exports){
"use strict";
var _Notifications = _interopRequireDefault(require("./Notifications"));
var _TimeUtils = _interopRequireDefault(require("./TimeUtils"));
var _RequestCache = _interopRequireDefault(require("./RequestCache"));
var _SocialShare = _interopRequireDefault(require("./SocialShare"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/* global timeUtils */
/*
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
*/
window.RequestCache = _RequestCache["default"];
window.SocialShare = _SocialShare["default"];
window.setupTimeUtils = function (diffHoursBetweenServerTimezoneWithGMT) {
var timeUtils = new _TimeUtils["default"]();
timeUtils.setServerGMToffset(diffHoursBetweenServerTimezoneWithGMT);
return timeUtils;
};
window.setupNotifications = function (baseUrl) {
var notificationManager = new _Notifications["default"]();
notificationManager.setBaseUrl(baseUrl);
notificationManager.setTimeUtils(timeUtils);
return notificationManager;
};
},{"./Notifications":1,"./RequestCache":2,"./SocialShare":3,"./TimeUtils":4}]},{},[5])
//# sourceMappingURL=common.js.map
+10479 -4
View File
File diff suppressed because it is too large. Load diff
+37477 -5
View File
File diff suppressed because it is too large. Load diff
+34095 -34095
View File
File diff suppressed because it is too large. Load diff
+91750 -5
View File
File diff suppressed because it is too large. Load diff
+39547 -2
View File
File diff suppressed because it is too large. Load diff
+92733 -5
View File
File diff suppressed because it is too large. Load diff
+15464 -2
View File
File diff suppressed because it is too large. Load diff
+28918 -10
View File
File diff suppressed because it is too large. Load diff