-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfinancialImports.php
262 lines (219 loc) · 8.37 KB
/
financialImports.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
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
<?php
require_once 'financialImports.civix.php';
/**
* Implementation of hook_civicrm_config
*/
function financialImports_civicrm_config(&$config) {
$template =& CRM_Core_Smarty::singleton( );
$batchingRoot = dirname( __FILE__ );
$batchingDir = $batchingRoot . DIRECTORY_SEPARATOR . 'templates';
if ( is_array( $template->template_dir ) ) {
array_unshift( $template->template_dir, $batchingDir );
} else {
$template->template_dir = array( $batchingDir, $template->template_dir );
}
// also fix php include path
$include_path = $batchingRoot . PATH_SEPARATOR . get_include_path( );
set_include_path( $include_path );
}
/**
* Implementation of hook_civicrm_xmlMenu
*
* @param $files array(string)
*/
function financialImports_civicrm_xmlMenu(&$files) {
_financialImports_civix_civicrm_xmlMenu($files);
}
function financialImports_civicrm_navigationMenu(&$params) {
$maxKey = ( max( array_keys($params) ) );
$params['civicrm_finance'] = array(
'attributes' => array (
'label' => 'Financial processing',
'name' => 'Financial processing',
'url' => null,
//'permission' => 'access FinancialProcessing',
'operator' => null,
'separator' => null,
'parentID' => null,
'navID' => 'civicrm_finance',
'active' => 1,
),
'child' => array(
array(
'attributes' => array (
'label' => 'Financial import',
'name' => 'Financial import',
'url' => 'civicrm/finance/import?reset=1',
//'permission' => 'access FinancialProcessing',
'operator' => null,
'separator' => null,
'parentID' => null,
'navID' => 'civicrm_finance_import',
'active' => 1,
),
'child' => array(
)
),
)
);
}
/**
* Implementation of hook_civicrm_install
*/
function financialImports_civicrm_install() {
// On install, create a table for keeping track of online direct debits
require_once "CRM/Core/DAO.php";
CRM_Core_DAO::executeQuery("
CREATE TABLE IF NOT EXISTS `veda_civicrm_financial_import` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(16) NOT NULL,
`source` varchar(64) NOT NULL,
`status` int(10) unsigned NOT NULL DEFAULT '0',
`created_by_id` int(11) NOT NULL COMMENT 'The user contact id that created the record',
`process_start` datetime NOT NULL,
`process_end` datetime DEFAULT NULL,
`handle` varchar(128) DEFAULT NULL,
`fields` text,
`count` int(11) DEFAULT NULL,
`data` text,
`amount` decimal(20,2) DEFAULT NULL,
`first_paid_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
CRM_Core_DAO::executeQuery("
CREATE TABLE IF NOT EXISTS `civicrm_financial_bank_account` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Default MySQL primary key',
`account_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`account_number` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`nominal_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`default` tinyint(4) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
/*
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `payment_instrument_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Payment Method';
");
*/
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `expected_posting_date` datetime DEFAULT NULL COMMENT 'Expected Posting Date';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `campaign_id` int(10) unsigned DEFAULT NULL COMMENT 'Campaign Id';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `banking_date` date DEFAULT NULL COMMENT 'Banking Date';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `banking_account` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Banking Account';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `contribution_type_id` int(10) unsigned DEFAULT NULL COMMENT 'Contribution Type Id';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `exclude_from_posting` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Exclude from posting';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `post_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Contact ID who do post';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `entity_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL;
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_batch`
ADD COLUMN `import_id` int(10) DEFAULT NULL;
");
/*
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `payment_instrument_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Payment Method';
");
*/
/*
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `expected_posting_date` datetime DEFAULT NULL COMMENT 'Expected Posting Date';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `campaign_id` int(10) unsigned DEFAULT NULL COMMENT 'Campaign Id';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `banking_date` date DEFAULT NULL COMMENT 'Banking Date';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `banking_account` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Banking Account';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `contribution_type_id` int(10) unsigned DEFAULT NULL COMMENT 'Contribution Type Id';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `exclude_from_posting` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Exclude from posting';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `post_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Contact ID who do post';
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `entity_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL;
");
CRM_Core_DAO::executeQuery("
ALTER TABLE `log_civicrm_batch`
ADD COLUMN `import_id` int(10) DEFAULT NULL;
");
*/
}
/**
* Implementation of hook_civicrm_uninstall
*/
function financialImports_civicrm_uninstall() {
return _financialImports_civix_civicrm_uninstall();
}
/**
* Implementation of hook_civicrm_enable
*/
function financialImports_civicrm_enable() {
return _financialImports_civix_civicrm_enable();
}
/**
* Implementation of hook_civicrm_disable
*/
function financialImports_civicrm_disable() {
return _financialImports_civix_civicrm_disable();
}
/**
* Implementation of hook_civicrm_upgrade
*
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
*
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*/
function financialImports_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
return _financialImports_civix_civicrm_upgrade($op, $queue);
}
/**
* Implementation of hook_civicrm_managed
*
* Generate a list of entities to create/deactivate/delete when this module
* is installed, disabled, uninstalled.
*/
function financialImports_civicrm_managed(&$entities) {
return _financialImports_civix_civicrm_managed($entities);
}