-
Notifications
You must be signed in to change notification settings - Fork 0
/
budgetsys.install
627 lines (618 loc) · 18.4 KB
/
budgetsys.install
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
<?php
/**
* @file
* The install file for the budget system.
*/
/**
* Implements hook_enable
*/
function budgetsys_enable() {
budgetsys_add_taxonomy();
}
/**
* Adds vocabularies necessary for the Budget System to work.
*/
function budgetsys_add_taxonomy() {
$vid = variable_get('budgetsys_fiscal_years_vid', '');
if (!taxonomy_vocabulary_load($vid)) {
$vocabulary = array(
'name' => t('Allowed Fiscal Years'),
'machine_name' => 'allowed_fiscal_years',
'description' => 'Taxonomy used to determine the fiscal years available',
'multiple' => 0,
'required' => 1,
'hierarchy' => 0,
'module' => 'budgetsys',
'weight' => '-10',
);
$vocabulary_obj = (object)$vocabulary;
taxonomy_vocabulary_save($vocabulary_obj);
variable_set('budgetsys_fiscal_years_vid', $vocabulary_obj);
dpm($vocabulary_obj);
}
}
/**
* Implements hook_schema
*/
function budgetsys_schema() {
$schema['budgetsys_line'] = array(
'description' => 'The base table for line items.',
'fields' => array(
'lid' => array(
'description' => 'The primary identifier for a line item.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'description' => 'The current {budgetsys_line_revision}.vid version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The id of the creation user.',
'type' => 'int',
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of this line item.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the line item was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the line item was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'account_number' => array(
'description' => 'The account number this value belongs to.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
),
'oid' => array(
'description' => 'The oid of an associated organization.',
'type' => 'int',
'not null' => FALSE,
),
'type' => array(
'description' => 'The type of account line item.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'operational',
),
),
'unique keys' => array(
'lid_vid' => array('lid', 'vid'),
'lid' => array('lid'),
),
'primary key' => array('lid'),
);
$schema['budgetsys_line_revision'] = array(
'description' => 'Stores information about each saved version of a {budgetsys_line}.',
'fields' => array(
'lid' => array(
'description' => 'The {budgetsys_line} this version belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'vid' => array(
'description' => 'The primary indetifier for this version.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The id of the creation user.',
'type' => 'int',
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of this organization.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the organization was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the organization was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'account_number' => array(
'description' => 'The account number this value belongs to.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
),
'oid' => array(
'description' => 'The oid of an associated organization.',
'type' => 'int',
'not null' => FALSE,
),
'type' => array(
'description' => 'The type of account line item.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'operational',
),
),
'indexes' => array(
'lid' => array('lid'),
),
'primary key' => array('vid'),
'foreign keys' => array(
'budgetsys_line' => array(
'table' => 'budgetsys_line',
'columns' => array(
'lid' => 'lid',
),
),
),
);
$schema['budgetsys_line_type'] = array(
'description' => 'Stores information about all defined task types.',
'fields' => array(
'ltid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique line items type ID.',
),
'type' => array(
'description' => 'The machine-readable name of this type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'value_type' => array(
'description' => 'The type of value this line item contains.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
'translatable' => TRUE,
),
) + entity_exportable_schema_fields(),
'primary key' => array('ltid'),
'unique keys' => array(
'type' => array('type'),
),
);
$schema['budgetsys_org'] = array(
'description' => 'The base table for organizations.',
'fields' => array(
'oid' => array(
'description' => 'The primary identifier for an organization.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'description' => 'The current {budgetsys_org_revision}.vid version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'title' => array(
'description' => 'The title of this organization.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the organization was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the organization was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'active' => array(
'description' => 'Whether the organization is active.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'budget_category' => array(
'description' => 'The budgetary category this organization is a member of.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
'unique keys' => array(
'oid_vid' => array('oid', 'vid'),
'oid' => array('oid'),
),
'primary key' => array('oid'),
);
$schema['budgetsys_org_revision'] = array(
'description' => 'Stores information about each saved version of a {budgetsys_organization}.',
'fields' => array(
'oid' => array(
'description' => 'The {budgetsys_org} this version belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'vid' => array(
'description' => 'The primary indetifier for this version.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of this organization.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the organization was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the organization was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'active' => array(
'description' => 'Whether the organization is active.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'budget_category' => array(
'description' => 'The budgetary category this organization is a member of.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
'indexes' => array(
'oid' => array('oid'),
),
'primary key' => array('vid'),
'foreign keys' => array(
'budgetsys_org' => array(
'table' => 'budgetsys_org',
'columns' => array(
'oid' => 'oid',
),
),
),
);
$schema['budgetsys_total'] = array(
'description' => 'Stores the budget totals for each organization, for each year and budget type..',
'fields' => array(
'tid' => array(
'description' => 'The primary identifier for an organization total.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'year' => array(
'description' => 'The budgeting fiscal year this budget total belongs to.',
'type' => 'varchar',
'length' => 9,
'not null' => TRUE,
'default' => '2011-2012',
),
'type' => array(
'description' => 'The type of account line item this total is tied to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'expenditure',
),
'value' => array(
'description' => 'The value for this budget total.',
'type' => 'float',
'not null' => TRUE,
),
'oid' => array(
'description' => 'The organization associated with this budget total',
'type' => 'int',
'not null' => TRUE,
),
'taxid' => array(
'description' => 'The taxonomy associated with this budget total',
'type' => 'int',
'not null' => TRUE,
),
),
'unique keys' => array(
'oid_tid' => array('oid', 'tid'),
'tid' => array('tid'),
),
'primary key' => array('tid'),
);
$schema['budgetsys_value'] = array(
'description' => 'The base table for budget values.',
'fields' => array(
'bvid' => array(
'description' => 'The primary identifier for a budget value.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'description' => 'The current {budget_budget_value_revision}.vid version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'The id of the creation user.',
'type' => 'int',
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of this budget value.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the budget value was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the budget value was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'account_number' => array(
'description' => 'The account number this value belongs to.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => 'N0000',
),
'year' => array(
'description' => 'The budgeting fiscal year this budget value belongs to.',
'type' => 'varchar',
'length' => 9,
'not null' => TRUE,
'default' => '2011-2012',
),
'type' => array(
'description' => 'The type of account line item this value is tied to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'expenditure',
),
'value' => array(
'description' => 'The value for this budget value.',
'type' => 'float',
'not null' => TRUE,
),
'oid' => array(
'description' => 'The organization associated with this budget value',
'type' => 'int',
'not null' => TRUE,
),
),
'unique keys' => array(
'bvid_vid' => array('bvid', 'vid'),
'bvid' => array('bvid'),
),
'primary key' => array('bvid'),
);
$schema['budgetsys_value_revision'] = array(
'description' => 'Stores information about each saved version of a {budget_budget_value}.',
'fields' => array(
'bvid' => array(
'description' => 'The {budget_budget_value} this version belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'vid' => array(
'description' => 'The primary indetifier for this version.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The id of the creation user.',
'type' => 'int',
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of this budget value.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the budget value was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'account_number' => array(
'description' => 'The account number this value belongs to.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => 'N0000',
),
'year' => array(
'description' => 'The budgeting fiscal year this budget value belongs to.',
'type' => 'varchar',
'length' => 9,
'not null' => TRUE,
'default' => '2011-2012',
),
'type' => array(
'description' => 'The type of account line item this value is tied to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'expenditure',
),
'value' => array(
'description' => 'The value for this budget value.',
'type' => 'float',
'not null' => TRUE,
),
'oid' => array(
'description' => 'The organization associated with this budget value',
'type' => 'int',
'not null' => TRUE,
),
),
'indexes' => array(
'bvid' => array('bvid'),
),
'primary key' => array('vid'),
'foreign keys' => array(
'budgetsys_value' => array(
'table' => 'budgetsys_value',
'columns' => array(
'bvid' => 'bvid',
),
),
),
);
$schema['budgetsys_value_type'] = array(
'description' => 'Stores information about all defined value types.',
'fields' => array(
'vtid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique value type ID.',
),
'type' => array(
'description' => 'The machine-readable name of this type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
'translatable' => TRUE,
),
) + entity_exportable_schema_fields(),
'primary key' => array('vtid'),
'unique keys' => array(
'type' => array('type'),
),
);
return $schema;
}
/**
* Create new database table {budgetsys_total}.
*/
function budgetsys_update_7006() {
$schema['budgetsys_total'] = array(
'description' => 'Stores the budget totals for each organization, for each year and budget type..',
'fields' => array(
'tid' => array(
'description' => 'The primary identifier for an organization total.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'year' => array(
'description' => 'The budgeting fiscal year this budget total belongs to.',
'type' => 'varchar',
'length' => 9,
'not null' => TRUE,
'default' => '2011-2012',
),
'type' => array(
'description' => 'The type of account line item this total is tied to.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => 'expenditure',
),
'value' => array(
'description' => 'The value for this budget total.',
'type' => 'float',
'not null' => TRUE,
),
'oid' => array(
'description' => 'The organization associated with this budget total',
'type' => 'int',
'not null' => TRUE,
),
),
'unique keys' => array(
'oid_tid' => array('oid', 'tid'),
'tid' => array('tid'),
),
'primary key' => array('tid'),
);
db_create_table('budgetsys_total', $schema['budgetsys_total']);
return "Table created successfully!";
}