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
|
<?php
// You can find all functions regarding manage proposal
/*
textbook companion proposal table column "proposal_status" field values means
0 = 'Pending';
1 = 'Approved';
2 = 'Dis-approved';
3 = 'Completed';
4 = 'External';
5 = 'Unknown';
*/
require_once('workshop_registration_email.inc');
function _proposal_pending()
{
/* get pending proposals to be approved */
$pending_rows = array();
$pending_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal}
WHERE proposal_status = 0 ORDER BY id DESC");
$i=1;
while ($pending_data = $pending_q->fetchObject())
{
$pending_rows[$pending_data->id] = array(
$i,
date('d-m-Y', $pending_data->creation_date),
l($pending_data->fname.' ' . $pending_data->lname, 'user/' .
$pending_data->uid),
$pending_data->workshop_type,
$pending_data->from_w_date.' to '. $pending_data->end_w_date,
l('Approve', 'osdag-workshop-booking/manage-proposal/approve/' .
$pending_data->id) //. ' | ' .
/*l('Edit', 'osdag-workshop-booking/manage-proposal/edit/' .
$pending_data->id)*/
);
$i++;
} //$pending_data = $pending_q->fetchObject()
/* check if there are any pending proposals */
if (!$pending_rows)
{
drupal_set_message(t('There are no pending proposals.'), 'status');
return '';
} //!$pending_rows
$pending_header = array(
'Sr. No.',
'Date',
'Coordinater Name',
'Workshop Type',
'Proposed Workshop date',
'Action'
);
$output = theme('table', array(
'header' => $pending_header,
'rows' => $pending_rows
));
return $output;
}
/* view all proposals */
function _proposal_all()
{
/* get pending proposals to be approved */
$proposal_rows = array();
$proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal}
ORDER BY id DESC");
$i=1;
while ($proposal_data = $proposal_q->fetchObject())
{
$proposal_status = '';
$action = '';
switch ($proposal_data->proposal_status)
{
case 0:
$proposal_status = 'Pending';
$action = l('Approve', 'osdag-workshop-booking/manage-proposal/approve/' .
$proposal_data->id);
break;
case 1:
$proposal_status = 'Approved';
break;
case 2:
$proposal_status = 'Dis-approved';
break;
case 3:
$proposal_status = 'Completed';
break;
case 4:
$proposal_status = 'External';
break;
default:
$proposal_status = 'Unknown';
break;
} //$proposal_data->proposal_status
$proposal_rows[$proposal_data->id] = array(
$i,
date('d-m-Y', $proposal_data->creation_date),
l($proposal_data->fname.' ' . $proposal_data->lname, 'user/' .
$proposal_data->uid),
$proposal_data->workshop_type,
$proposal_data->from_w_date.' to '. $proposal_data->end_w_date,
$proposal_status,
$action,
);
$i++;
} //$pending_data = $pending_q->fetchObject()
/* check if there are any pending proposals */
if (!$proposal_rows)
{
drupal_set_message(t('There are no pending proposals.'), 'status');
return '';
} //!$pending_rows
$proposal_header = array(
'Sr. No.',
'Date',
'Coordinater Name',
'Workshop Type',
'Proposed Workshop date',
'Status',
'Action'
);
$output = theme('table', array(
'header' => $proposal_header,
'rows' => $proposal_rows
));
return $output;
}
/* Proposal approval form */
function osdag_workshop_booking_proposal_approval_form($form, &$form_state)
{
global $user;
/* get current proposal */
$proposal_id = arg(3);
$result = db_query("SELECT * FROM {osdag_workshop_booking_proposal}
WHERE proposal_status = 0 and id = :id",
array(':id' =>$proposal_id));
if ($result)
{
if ($row = $result->fetchObject())
{
/* everything ok */
} //$row = $result->fetchObject()
else
{
drupal_set_message(t('Invalid proposal selected. Please try again.
'), 'error');
drupal_goto('manage-proposal');
return;
}
} //$result
else
{
drupal_set_message(t('Invalid proposal selected. Please try again.'),
'error');
drupal_goto('manage-proposal');
return;
}
$form['#attributes'] = array(
'enctype' => "multipart/form-data"
);
$form['personal_info'] = array(
'#type' => 'fieldset',
'#title' => t('Personal Information'),
'#tree' => TRUE,
);
$full_name = $row->title .' '. $row->fname. ' '. $row->lname;
$form['personal_info']['full_name'] = array(
'#type' => 'item',
'#title' => t('Full Name'),
'#markup' => $full_name,
);
$form['personal_info']['designation'] = array(
'#type' => 'item',
'#title' => t('Designation'),
'#markup' => $row->designation,
);
$form['personal_info']['email_id'] = array(
'#type' => 'item',
'#title' => t('Email'),
'#markup' => $row->email_id,
);
$form['personal_info']['contact_no'] = array(
'#type' => 'item',
'#title' => t('Contact No.'),
'#markup' => $row->contact_no,
);
$form['organization_info'] = array(
'#type' => 'fieldset',
'#title' => t('Organization Information'),
'#tree' => TRUE,
);
$form['organization_info']['institute_company'] = array(
'#type' => 'item',
'#title' => t('Name of the Institute/Company'),
'#markup' => $row->institute_company,
);
$form['organization_info']['alt_email_id'] = array(
'#type' => 'item',
'#title' => t('Official (Institute/Company) Email address'),
'#markup' => $row->address_of_institute_company,
);
$form['organization_info']['institute_company_address'] = array(
'#type' => 'item',
'#title' => t('Address of the Institute/Company'),
'#markup' => $row->org_email,
);
$form['organization_info']['city_district'] = array(
'#type' => 'item',
'#title' => t('City/District'),
'#markup' => $row->city_district,
);
$form['organization_info']['all_state'] = array(
'#type' => 'item',
'#title' => t('State'),
'#markup' => $row->indian_state,
);
$form['organization_info']['pincode'] = array(
'#type' => 'item',
'#title' => t('Pincode'),
'#markup' => $row->pincode,
);
$form['workshop_info'] = array(
'#type' => 'fieldset',
'#title' => t('Workshop Information'),
'#tree' => TRUE,
);
$form['workshop_info']['workshop_type'] = array(
'#type' => 'item',
'#title' => t('Workshop type'),
'#markup' => $row->workshop_type,
);
$form['workshop_info']['expected_number_of_participants'] = array(
'#type' => 'item',
'#title' => t('Expected number of participants'),
'#markup' => $row->exp_number_of_participent,
);
$form['workshop_info']['participant_type'] = array(
'#type' => 'item',
'#title' => t('Participant type'),
'#markup' => $row->participant_type,
);
$form['workshop_info']['checklist_group'] = array(
'#type' => 'fieldset',
'#title' => t('Workshop Checklist'),
'#tree' => TRUE,
);
$form['workshop_info']['checklist_group']['is_computer_lab_available'] =
array(
'#type' => 'item',
'#title' => t('Is a computer lab available at the organizing
institute/company?'),
'#markup' => $row->available_computer,
);
if($row->available_computer == 'Yes'){
$form['workshop_info']['checklist_group']['if_yes_1'] = array(
'#type' => 'item',
'#title' => t('What is the Operating system (Windows, Linux etc.)
[mention OS with configuration. Ex. Windows 10 or Ubuntu 18.04 etc]'),
'#markup' => $row->if_yes_1,
);
$form['workshop_info']['checklist_group']['if_yes_2'] = array(
'#type' => 'item',
'#title' => t('Is there a projection facility at the computer lab?'),
'#markup' => $row->if_yes_2,
);
$form['workshop_info']['checklist_group']['if_yes_3'] = array(
'#type' => 'item',
'#title' => t('Are all the computers connected to the Internet?'),
'#markup' => $row->if_yes_3,
);
}else{
$form['workshop_info']['checklist_group']['if_no_1'] = array(
'#type' => 'item',
'#title' => t('Every participant has to have an individual computer with
Osdag pre-installed in it.'),
'#markup' => $row->if_no_1,
);
$form['workshop_info']['checklist_group']['if_no_2'] = array(
'#type' => 'item',
'#title' => t('All the participants should be accommodated in a single
room with audio-visual projection facilities.'),
'#markup' => $row->if_no_2,
);
}
$form['workshop_info']['volunteers'] = array(
'#type' => 'item',
'#title' => t('Volunteers'),
'#markup' => $row->volunteers,
);
$form['workshop_info']['checklist_group']['suggested_date'] = array(
'#type' => 'fieldset',
'#title' => t('Suggested Date(s)'),
'#tree' => TRUE,
);
$form['workshop_info']['checklist_group']['suggested_date']['start_date'] =
array(
'#type' => 'item',
'#markup' => $row->from_w_date .' to '. $row->end_w_date,
);
$form['workshop_info']['proposed_travel_arrangement'] = array(
'#type' => 'item',
'#title' => t('What is the proposed travel arrangement for the Osdag
resource people'),
'#markup' => $row->travel_arrangement,
);
$form['workshop_info']['how_did_you_here'] = array(
'#type' => 'item',
'#title' => t('How did you hear about Osdag training workshop?'),
'#markup' => $row->how_did_you_here,
);
$form['approve_disapprove'] = array(
'#type' => 'radios',
'#title' => t('Approve/ Disapprove request'),
'#options' => array('approve' => 'Approve', 'disapprove' =>
'Disapprove'),
);
$form['message'] = array(
'#type' => 'textarea',
'#title' => t('Reason for disapproval'),
'#states' => array(
'visible' => array(
':input[name="approve_disapprove"]' => array(
'value' => 'disapprove'
)
),
'required' => array(
':input[name="approve_disapprove"]' => array(
'value' => 'disapprove'
)
)
)
);
$form['proposal_id'] = array(
'#type' => 'hidden',
'#value' => $proposal_id
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
$form['cancel'] = array(
'#type' => 'item',
'#markup' => "<input type='button' class='button-user' value='Back' onclick='window.history.go(-1); return false;'/>",
);
return $form;
}
function osdag_workshop_booking_proposal_approval_form_submit($form, &$form_state)
{
global $user;
/* get current proposal */
$proposal_id = $form_state['values']['proposal_id'];
$result = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE
proposal_status = 0 and id = :proposal_id", array(
':proposal_id' => $proposal_id
));
if ($result)
{
$row = $result->fetchObject();
} //$result
else
{
drupal_set_message(t('Invalid proposal selected. Please try again.'),
'error');
drupal_goto('osdag-workshop-booking/manage-proposal');
return;
}
/* disapprove */
if ($form_state['values']['approve_disapprove'] == 'disapprove')
{
db_query("UPDATE {osdag_workshop_booking_proposal} SET approver_uid =
:approver_uid, approval_date = :approval_date, proposal_status = 2,
disapprove_message = :message WHERE id = :id", array(
':approver_uid' => $user->uid,
':approval_date' => time(),
':message' => $form_state['values']['message'],
':id' => $proposal_id
));
/* sending email */
$osdag_user = user_load($row->uid);
$email_to = $osdag_user->mail;
$from = variable_get('osdag_workshop_booking_from_email', '');
$bcc = variable_get('osdag_workshop_booking_bcc_emails', '');
$cc = variable_get('osdag_workshop_booking_cc_emails', '');
$params['proposal_disapproved']['proposal_id'] = $proposal_id;
$params['proposal_disapproved']['user_id'] = $row->uid;
$params['proposal_disapproved']['headers'] = array(
'From' => $from,
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
'Cc' => $cc,
'Bcc' => $bcc
);
if (!drupal_mail('osdag_workshop_booking', 'proposal_disapproved', $email_to,
language_default(), $params, $from, TRUE))
if (!drupal_mail('osdag_workshop_booking', 'proposal_disapproved',
$email_to, language_default(), $params, $from, TRUE)){
}else{
drupal_set_message('Error sending email message.', 'error');
}
drupal_set_message('Proposal dis-approved. User has been notified of
the dis-approval.', 'status');
drupal_goto('osdag-workshop-booking/manage-proposal');
}elseif($form_state['values']['approve_disapprove'] == 'approve'){
db_query("UPDATE {osdag_workshop_booking_proposal} SET approver_uid =
:approver_uid, approval_date = :approval_date,
proposal_status = 1, disapprove_message = :message WHERE id = :id",
array(
':approver_uid' => $user->uid,
':approval_date' => time(),
':message' => 'none',
':id' => $proposal_id
));
/* sending email */
$osdag_user = user_load($row->uid);
$email_to = $osdag_user->mail;
$from = variable_get('osdag_workshop_booking_from_email', '');
$bcc = variable_get('osdag_workshop_booking_bcc_emails', '');
$cc = variable_get('osdag_workshop_booking_cc_emails', '');
$params['proposal_approved']['proposal_id'] = $proposal_id;
$params['proposal_approved']['user_id'] = $row->uid;
$params['proposal_approved']['headers'] = array(
'From' => $from,
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
'Cc' => $cc,
'Bcc' => $bcc
);
if (!drupal_mail('osdag_workshop_booking', 'proposal_approved',
$email_to, language_default(), $params, $from, TRUE)){
drupal_set_message('Error sending email message.', 'error');
}
drupal_set_message('Proposal approved. User has been notified of the
approval', 'status');
drupal_goto('osdag-workshop-booking/manage-proposal');
}else{
drupal_set_message('Something went wrong. Please contact to
administrator', 'error');
drupal_goto('osdag-workshop-booking/manage-proposal');
return;
}
}
|