-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
153 lines (121 loc) · 3.99 KB
/
setup.php
File metadata and controls
153 lines (121 loc) · 3.99 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/*
Unitcost setup file
Written by Alejandro Imass <ait@p2ee.org>
Version 1.0 completed 2006/08/14
Used Resources modules written by ajdonnison as base
*/
$config = array(
'mod_name' => 'Unitcost',
'mod_version' => '1.0.0',
'mod_directory' => 'unitcost',
'mod_setup_class' => 'setup_unitcost',
'mod_type' => 'user',
'mod_ui_name' => 'Unitcost',
'mod_ui_icon' => 'helpdesk.png',
'mod_description' => '',
// no permission stuff yet; may not be needed
// because we run under tasks, so user permission
// is checked from there... will leave this here
// just in case for a new version or comments
// from core team or other people
//'permissions_item_table' => '',
//'permissions_item_field' => '',
//'permissions_item_label' => ''
);
if (@$a == 'setup') {
echo dPshowModuleConfig($config);
}
class setup_unitcost {
function install() {
$ok = true;
$q = new DBQuery;
/*
Table: unitcost_task_costs
This table is basically an extension of the tasks table. Both
budget and actual values go here. The actuals are accumultated
actuals. Note that the original tasks table already has a
percent_complete and that is why we don't have one
here. performance refers to how many units can be completed per
unit of time that is defined in the dates tab (hours=1 or
days=24).
*/
$sql = "(
task_id integer not null,
unit_of_measure varchar(5) not null default 'UOM',
equipment_unit_cost decimal(15,2) default 0,
material_unit_cost decimal(15,2) default 0,
labor_unit_cost decimal(15,2) default 0,
other_unit_cost decimal(15,2) default 0,
total_unit_cost decimal(15,2) default 0,
total_units decimal(10,2) default 0,
performance decimal(10,2) default 0,
task_total_cost decimal(15,2) default 0,
norm_ref varchar(40),
norm_dsc text,
task_actual_units decimal(10,2) default 0,
task_actual_cost decimal(15,2) default 0,
primary key (task_id)
)";
$q->createTable('unitcost_task_costs');
$q->createDefinition($sql);
$ok = $ok && $q->exec();
$q->clear();
/*
Table: unitcost_task_log_costs
This table is basically an extension of the tasks_log table. It
keeps the cost history of each log and also keeps the reported
task_percent_complete history which the original code does
not. This history is useful for figuring out the delta between
each report and for plotting the actuals S curve.
*/
$sql = "(
task_log_id integer not null,
task_percent_complete decimal(4,2),
task_actual_units decimal(10,2),
task_actual_cost decimal(15,2),
primary key (task_log_id)
)";
$q->createTable('unitcost_task_log_costs');
$q->createDefinition($sql);
$ok = $ok && $q->exec();
$q->clear();
/*
Database Alters
We need to alter all money fields to at least 999,999,999,999.99
so we leave some extra room and use (15,2) as the new standard
*/
// projects table: project target budget is now 15,2
$sql = "alter table projects modify column project_target_budget decimal(15,2)";
$ok = $ok && db_exec( $sql );
// projects table: project actual budget is now 15,2
$sql = "alter table projects modify column project_actual_budget decimal(15,2)";
$ok = $ok && db_exec( $sql );
// tasks table: task target budget is now 15,2
$sql = "alter table tasks modify column task_target_budget decimal(15,2)";
$ok = $ok && db_exec( $sql );
// tasks table: task percent complete is now decimal 4,2 !!!
$sql = "alter table tasks modify column task_percent_complete decimal(4,2)";
$ok = $ok && db_exec( $sql );
if (!$ok)
return false;
return null;
}
function remove() {
$q = new DBQuery;
$q->dropTable('unitcost_task_costs');
$q->exec();
$q->clear();
$q->dropTable('unitcost_task_log_costs');
$q->exec();
return null;
}
function upgrade($old_version) {
switch ($old_version) {
case "1.0.0":
break;
}
return true;
}
}
?>