-
Notifications
You must be signed in to change notification settings - Fork 12
/
boot.php
112 lines (95 loc) · 2.67 KB
/
boot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Imperium Bootstrap
*
* SPDX-License-Identifier: GPL-3.0-only
@deprecated ReturnGood => ReturnPath ? ret=1
@deprecated ReturnFail => ReturnPath ? ret=0
@deprecated $this->link
@deprecated $this->redirect
@deprecated $this->_s->
*/
namespace Edoceo\Imperium;
use Edoceo\Radix;
use Edoceo\Radix\DB\SQL;
error_reporting( (E_ALL | E_STRICT) ^ E_NOTICE );
$path = array();
$path[] = dirname(__FILE__) . '/lib';
$path[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $path));
define('APP_ROOT', dirname(__FILE__));
define('APP_NAME', 'Edoceo Imperium');
require_once('App.php');
require_once('App_Mail.php');
require_once('ACL.php');
require_once('ImperiumBase.php');
require_once('ImperiumView.php');
require_once('Auth/Hash.php');
require_once('Base/File.php');
require_once('Base/Note.php');
require_once('Base/Unit.php');
require_once('Account.php');
require_once('Account/Period.php');
require_once('Account/JournalEntry.php');
require_once('Account/LedgerEntry.php');
require_once('Contact.php');
require_once('Contact/Address.php');
require_once('Contact/Channel.php');
require_once('Contact/Event.php');
require_once('Invoice.php');
require_once('InvoiceItem.php');
require_once('WorkOrder.php');
require_once('WorkOrderItem.php');
require_once(APP_ROOT . '/vendor/autoload.php');
require_once('PDF/Base.php');
require_once('PDF/Invoice.php');
// Load Application Config
App::load_config();
// Database
SQL::init("pgsql:host={$_ENV['database']['hostname']};dbname={$_ENV['database']['database']}",$_ENV['database']['username'],$_ENV['database']['password']);
function _dbc()
{
static $dbc;
}
/**
Internal Hax0r Functions
*/
function html($x)
{
return htmlspecialchars($x, ENT_QUOTES, 'UTF-8', false);
}
function star($star)
{
if (empty($star)) return null;
$src = $_ENV['star'][$star];
$alt = basename($img,'.png');
$ret = '<img alt="' . $alt . '" class="star" data="' . $star . '" id="star" src="' . $src . '">';
return $ret;
}
/**
Takes Input Text and Return Tax as Floating Point 9.5% => 0.095
*/
function tax_rate_fix($x)
{
// Estimated Tax Rate Adjuster
if (preg_match('/([\d\.]+).*%$/',$x,$m)) {
// The input number was like: 9.5% or 9.5 % - numbers that end with "%" symbol
$x = floatval($m[1]) / 100;
}
$x = floatval($x);
if ($x > 1) {
// Not expressed as percentage (it's 9.5 but should be 0.095), /100 to get actual
$x = floatval($x / 100);
}
return $x;
}
function tax_rate_format($x)
{
$x = floatval($x);
if ($x < 1) {
$x = sprintf('%0.3f', $x * 100);
// $x = preg_replace('/0+$/', null, $x);
// $x.= '%';
}
return $x;
}