-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-addon.php
executable file
·81 lines (63 loc) · 3.42 KB
/
setup-addon.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
<?
if (!defined("SETUP_PHP")) {
exit;
}
newacc("1050", "000", "Hire Sales", "I", "f", "sales");
newacc("6180", "000", "Assets for Hire - Net Value", "B", "f", "fixed_asset");
newacc("6180", "010", "Assets for Hire - Cost", "B", "f", "fixed_asset");
newacc("6180", "020", "Assets for Hire - Accum Depreciation", "B", "f", "fixed_asset");
newacc("2180", "000", "Repairs and Maintenance - Equipment", "E", "f", "");
newacc("2810", "000", "Royalties", "E", "f", "");
$add_to_ledger = array(
"Hire Sales",
"Assets for Hire - Net Value",
"Assets for Hire - Cost",
"Assets for Hire - Accum Depreciation",
"Repairs and Maintenance - Equipment",
"Royalties"
);
foreach ($add_to_ledger as $value) {
for ($i = 1; $i <= 14; $i++) {
$sql = "SELECT accid, topacc, accnum FROM core.accounts
WHERE accname='$value'";
$acc_rslt = db_exec($sql) or errDie("Unable to retrieve account.");
list($accid, $topacc, $accnum) = pg_fetch_array($acc_rslt);
$date = date("Y-m-d");
$sql = "INSERT INTO \"$i\".ledger (acc, contra, edate, eref, descript,
credit, debit, div, caccname, ctopacc, caccnum, cbalance,
dbalance, refnum, sdate)
VALUES ('$accid', '$accid', '$date', '0', 'Balance', 0, 0,
'".USER_DIV."', '$value', '$topacc', '$accnum', 0.00, 0.00,
0, '$date')";
db_exec($sql) or errDie("Unable to create ledger entry.");
}
}
$sql = "INSERT INTO cubit.seq (type, last_value, div) VALUES ('hire', '0', '".USER_DIV."')";
db_exec($sql) or errDie("Unable to add hire sequence.");
// Retrieve the accounts
$sql = "SELECT accid FROM core.accounts WHERE topacc='6180' AND accnum='000'";
$net_rslt = db_exec($sql) or errDie("Unable to retrieve cost account.");
$net_acc = pg_fetch_result($net_rslt, 0);
$sql = "SELECT accid FROM core.accounts WHERE topacc='6180' AND accnum='010'";
$cos_rslt = db_exec($sql) or errDie("Unable to retrieve cost account.");
$cos_acc = pg_fetch_result($cos_rslt, 0);
$sql = "SELECT accid FROM core.accounts WHERE topacc='6180' AND accnum='020'";
$adep_rslt = db_exec($sql) or errDie("Unable to retrieve cost account.");
$adep_acc = pg_fetch_result($adep_rslt, 0);
$sql = "INSERT INTO exten.categories(category, div) VALUES ('Contract', '".USER_DIV."')";
$catRslt = db_exec ($sql) or errDie ("Unable to add category to system.", SELF);
$sql = "INSERT INTO exten.categories(category, div) VALUES ('Casual', '".USER_DIV."')";
$catRslt = db_exec ($sql) or errDie ("Unable to add category to system.", SELF);
$sql = "INSERT INTO cubit.assetgrp (grpname, costacc, accdacc, depacc, div)
VALUES ('Temporary - Equipment', '$cos_acc', '$adep_acc', '25', '".USER_DIV."')";
$grpRslt = db_exec($sql) or errDie("Unable to add asset group to system.");
$sql = "INSERT INTO cubit.assetgrp (grpname, costacc, accdacc, depacc, div)
VALUES ('Temporary - Plant', '$cos_acc', '$adep_acc', '25', '".USER_DIV."')";
$grpRslt = db_exec($sql) or errDie("Unable to add asset group to system.");
$sql = "INSERT INTO cubit.assetgrp (grpname, costacc, accdacc, depacc, div)
VALUES ('Equipment', '$cos_acc', '$adep_acc', '25', '".USER_DIV."')";
$grpRslt = db_exec($sql) or errDie("Unable to add asset group to system.");
$sql = "INSERT INTO cubit.assetgrp (grpname, costacc, accdacc, depacc, div)
VALUES ('Plant', '$cos_acc', '$adep_acc', '25', '".USER_DIV."')";
$grpRslt = db_exec($sql) or errDie("Unable to add asset group to system.");
?>