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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
<?php
/* hook menu */
function job_portal_menu()
{
$items = array();
$items["jobs"] = array(
"title" => "FOSSEE Job Portal",
"page callback" => "job_portal_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/apply"] = array(
"title" => "FOSSEE Job Portal - Application Form",
"page callback" => "job_portal_application_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/view-applications"] = array(
"title" => "FOSSEE Job Portal - View Applications",
"page callback" => "job_portal_view_application_page",
"access arguments" => array(
"manage job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/view-applications-if32ggxV747"] = array(
"title" => "FOSSEE Job Portal - View Applications",
"page callback" => "job_portal_view_application_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/downloads_applications"] = array(
"title" => "Application Download",
"description" => "Applications Download",
"page callback" => "job_portal_downloads_applications_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/downloads_all_applications"] = array(
"title" => "Application Download",
"description" => "Applications Download",
"page callback" => "job_portal_downloads_all_applications_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/downloads_all_applications_spreadsheet"] = array(
"title" => "Application Download",
"description" => "Applications Data Download",
"page callback" => "job_portal_downloads_all_applications_spreadsheet_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/downloads_all_applications_doc"] = array(
"title" => "Application Download",
"description" => "Applications Data Download",
"page callback" => "job_portal_downloads_all_applications_document_page",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
$items["jobs/ajax"] = array(
"title" => "Ajax callbacks",
"page callback" => "job_portal_ajax",
"access arguments" => array(
"access job_portal"
),
"type" => MENU_CALLBACK
);
return $items;
}
/* hook permission */
function job_portal_permission()
{
return array(
"access job_portal" => array(
"title" => t("Access Job Portal"),
"description" => t("Allows users to view job postings.")
),
"manage job_portal" => array(
"title" => t("Manage Job Portal"),
"description" => t("Allows users to manage job postings.")
),
"manage download_application" => array(
"title" => t("Manage Download Portal"),
"description" => t("Allows users to download job applications.")
)
);
}
/* job portal application form */
function job_portal_application_form($form, &$form_state, $position_id = 0)
{
$form = array();
$form["wrapper"] = array(
"#type" => "fieldset",
"#title" => t("Application form"),
"#collapsible" => TRUE
);
$form["wrapper"]["position"] = array(
"#type" => "select",
"#title" => t("Job Position"),
"#description" => t("Select the position for which you are applying."),
"#options" => get_jobs_available("options"),
"#empty_option" => t("--- Select a position ---"),
"#default_value" => $position_id,
'#attributes' => array(
'disabled' => 'disabled'
),
"#required" => TRUE
);
$form["wrapper"]["name"] = array(
"#type" => "textfield",
"#title" => t("Name"),
"#description" => t("Please enter your full name."),
"#required" => TRUE,
"#attributes" => array(
'style' => 'text-transform:uppercase'
)
);
$form["wrapper"]["contact"] = array(
"#type" => "textfield",
"#title" => t("Contact Number"),
"#description" => t("Please enter your contact number."),
"#required" => TRUE
);
$form["wrapper"]["email"] = array(
"#type" => "textfield",
"#title" => t("Email"),
"#description" => t("Please enter your e-mail id."),
"#required" => TRUE
);
$form["wrapper"]["resume"] = array(
"#type" => "file",
"#title" => t("Resume" . required_star()),
"#description" => t("Please upload your resume [pdf].")
);
$form["wrapper"]["submit"] = array(
"#type" => "submit",
"#value" => "Submit Application"
);
return $form;
}
/* job portal application form validate */
function job_portal_application_form_validate($form, &$form_state)
{
$file = file_save_upload('resume', array(
// Validate extensions.
'file_validate_extensions' => array(
'pdf'
)
));
// If the file passed validation:
if ($file)
{
// Move the file into the Drupal file system.
if ($file = file_move($file, 'public://'))
{
// Save the file for use in the submit handler.
$form_state['storage']['resume'] = $file;
} //$file = file_move($file, 'public://')
else
{
form_set_error('resume', t("Failed to write the uploaded file to the site's file folder."));
}
} //$file
else
{
form_set_error('resume', t('No file was uploaded.'));
}
/* validating email field */
if (!valid_email_address($form_state["values"]["email"]))
{
form_set_error('email', t('Please enter an valid email address.'));
} //!valid_email_address($form_state["values"]["email"])
}
/* job portal application form validate */
function job_portal_application_form_submit($form, &$form_state)
{
$v = $form_state["values"];
$resume = $form_state["storage"]["resume"];
$display = 1;
$dt = new DateTime();
$current_date = $dt->format("Y-m-d H:i:s");
$query = "
INSERT INTO job_portal_applications
(name, contact, email, resume, position_id, date, display)
VALUES
(:name, :contact, :email, :resume, :position_id, :current_date, :display)
";
$args = array(
":name" => $v["name"],
":contact" => $v["contact"],
":email" => $v["email"],
":resume" => $resume->filename,
":position_id" => $v["position"],
":current_date" => $current_date,
":display" => $display
);
/* storing the row id in $result */
$result = db_query($query, $args, array(
'return' => Database::RETURN_INSERT_ID
));
/* moving the file to uploads/resumes */
$base_path = $_SERVER['DOCUMENT_ROOT'] . base_path();
$uploads_dir = $base_path . "uploads/resumes";
if (!file_exists($uploads_dir . "/{$result}/"))
{
mkdir($uploads_dir . "/{$result}/", 0755, TRUE);
} //!file_exists($uploads_dir . "/{$result}/")
file_unmanaged_move($resume->uri, $uploads_dir . "/{$result}/{$resume->filename}");
$emails = db_select("job_portal_positions")->fields("job_portal_positions", array(
"notify"
))->condition("id", $v["position"])->execute()->fetchObject();
$emails = $emails->notify;
$position = get_jobs_available("options");
$position = $position[$v["position"]];
/* preparing to send mail to the recruiters */
$from = "jobs@fossee.in";
$to = "jobs@fossee.in";
$cc = $emails;
$bcc = "prashantsinalkar@gmail.com";
$subject = "Job Application - {$position}";
$message = "
<p><strong>{$v['name']}</strong> has applied for
the post of <strong>{$position}</strong>.</p>
<table border='1' width='740px'>
<tr><td>Name</td><td>{$v['name']}</td></tr>
<tr><td>Contact</td><td>{$v['contact']}</td></tr>
<tr><td>Email</td><td>{$v['email']}</td></tr>
</table>
<p><em>Please check the resume attached to this mail.</em></p>
";
$file = $uploads_dir . "/{$result}/" . $resume->filename;
$mail_status = send_mail_attachment($from, $to, $cc, $bcc, $subject, $message, $file);
if (!$mail_status)
{
drupal_set_message("An error occurred while sending mail.", "error");
} //!$mail_status
else
{
drupal_set_message("We have received your application. Thank you!", "status");
}
/* cleaning up temporary storage */
file_delete($resume);
unset($form["storage"]["resume"]);
/* sending notification to the applicant */
$subject = "Application received for {$position}";
$message = "
Dear {$v['name']},
We have received your application for the post of {$position}.
We will get back to you shortly.
Regards,
FOSSEE Team
";
send_mail("jobs@fossee.in", $v["email"], $subject, $message);
}
/* job portal page */
function job_portal_page()
{
$output = "";
$quick_links = "";
$i = 1;
$result = get_jobs_available();
foreach ($result as $row)
{
$collapser_header = "#{$i} - {$row->project} - Job Details";
$collapser_content = "
<strong>Position</strong>: {$row->position}<br>
<strong>Specialization</strong>: {$row->specialization}<br>
<strong>Salary</strong>: {$row->salary}<br>
<strong>Qualification</strong>: {$row->qualification}
<strong>Skills</strong>: {$row->skills}
<strong>Job Responsibilities</strong>: {$row->responsibilities}
<strong>Location</strong>: {$row->location}<br><br>
";
$collapser_content .= "<center>";
$collapser_content .= l("<i class='icon icon-white icon-briefcase'></i> Apply Now", "jobs/apply/{$row->id}", array(
"attributes" => array(
"class" => "btn btn-success btn-large"
),
"html" => TRUE
));
$collapser_content .= "</center>";
$output .= collapser($collapser_header, $collapser_content, "", $i);
$quick_links .= "<a class='badge quick' data-toggle='tooltip' data-placement='right' title='{$row->project}' href='#fieldset-id-{$i}'>{$i}</a><br>";
$i++;
} //$result as $row
$output .= "
<hr style='height: 10px;border: 0;box-shadow: 0 10px 10px -10px #8c8b8b inset;position: initial;'></hr>
<p style='color:#000'>
<h3 class='page-title'>Semester Internships</h3>
FOSSEE group at IIT Bombay aims to improve the quality of education with the use of open source software tools such as Scilab, Python, eSim, and Sandhi amongst others.
<br><br>
We have semester internships available with the following groups-
<p style='color:#000'>
<ol>
<li> Scilab Signal Processing & DSP toolbox </li>
<li> Scilab Computer Vision toolbox </li>
<li> Scilab Image Processing toolbox </li>
<li> Scilab Communication Systems toolbox </li>
<li> IoT with RaspberryPi and Arduino </li>
</ol>
</p>
We invite coders/testers from any background to participate and contribute to this project as part of FOSSEE semester internship. To know more about the internship requirements, please read- <a href='https://goo.gl/OuHa2H' target='_blank'>https://goo.gl/OuHa2H</a>. If you have any doubts, please email <a href='mailto:toolbox@scilab.in'>toolbox[at]scilab[dot]in</a>.
</p>
<br>
<hr style='border-top: 3px double #8c8b8b;position: initial;'></hr>
<p style='color:#000'>
<h3 class='page-title'>Projects</h3>
<br>
<strong>Project 1:</strong>
<br><br>
<span style='color:#000; text-align: justify;'>
Nghdl is a FOSSEE product designed for providing mixed mode simulation. It does so by interfacing Ngspice and ghdl (both open source products themselves). The novelty of Nghdl is that the user can write a digital model in ghdl and put it as a dummy model in ngspice netlist, rather than going through the pain of writing a digital model in ngspice themselves. Whenever ngspice encounters such a model in netlist, it initiates a client-server connection with ghdl as server and ngspice as client, and ghdl will do all the computation for the digital model.
<br><br>
<strong>Problem Statement:</strong>
There is a problem while trying to use multiple digital models in a single netlist. This is being done by setting up multiple client-server connections, running at different ports. The port numbers are determined by corresponding instance id's of each models which are specified in the netlist.
<br><br>
One of the reasons for this problem could be related to multiplexing, as the select function is returning 0 while trying to run multiple models.
<br><br>
<strong>Assignment:</strong> Find the root cause of the issue, produce necessary code or make changes to existing code and test the functionality.
<br><br>
<strong>Github Link:</strong> <a href='https://github.com/FOSSEE/nghdl/' target='_blank'>https://github.com/FOSSEE/nghdl/</a>
<br><br>
<strong>Skill Required:</strong>
<br>
C,Socket programing, good to have ghdl knowledge
<br><br>
<strong>Perks:</strong> Attractive Honorarium and FOSSEE Certificate shall be provided on successful completion of the task(s).
<br><br>
If you are interested, write to: <a href='mailto:jobs@fossee.in'>jobs[at]fossee[dot]in</a>
</span>
</p>
<br>
<hr style='border-top: 3px double #8c8b8b;position: initial;'></hr>
<p style='color:#000'>
<h3 class='page-title'>Jobs</h3>
If your interest is to work on any other FOSS such as Python, OpenFOAM, Osdag, Sandhi, OpenModelica, eSim, Scilab, SBHS, DWSIM, FOSSEE-Netbook, etc, you may email your resumes to <a href='mailto:jobs@fossee.in'>jobs[at]fossee[dot]in</a></p>The email subject should contain:</p><ul><li>Your name</li><li>Position that you are applying for</li><li>FOSS that you wish to work on</li></ul>
";
$output = array(
"quick_links" => array(
"#prefix" => "<div id='quick-links'>",
"#markup" => $quick_links,
"#suffix" => "</div>"
),
"job_description" => array(
"#prefix" => "<div id='job-description'>",
"#markup" => $output,
"#suffix" => "</div>"
)
);
return $output;
}
function job_portal_application_page($position_id = 0)
{
$application_form = "";
$form_job = drupal_get_form("job_portal_application_form", $position_id);
$job_form = drupal_get_form("job_portal_application_form");
if ($position_id)
{
$application_form = drupal_render($form_job);
} //$position_id
else
{
$application_form = drupal_render($job);
}
$output = array(
"application_form" => array(
"#prefix" => "<div id='job-application'>",
"#markup" => $application_form,
"#suffix" => "</div>"
)
);
return $output;
}
function job_portal_view_application_page($position_id = 0)
{
$markup = "";
if (array_key_exists("saved", $_GET))
{
drupal_set_message("Selections saved successfully.", "success");
} //array_key_exists("saved", $_GET)
if ($position_id)
{
$result = db_select("job_portal_applications")->fields("job_portal_applications")->condition("position_id", $position_id)->condition("display", 1)->execute()->fetchAll();
$headers = array(
"#",
"Name",
"Email",
"Date",
"Download",
"Select"
);
$rows = array();
$i = 1;
foreach ($result as $row)
{
$item = array(
$i,
$row->name,
$row->email,
$row->date,
l(str_replace('.', '_', str_replace(' ', '_', strtolower("{$row->id}_{$row->name}"))) . '.pdf', "uploads/resumes/{$row->id}/{$row->resume}", array(
"attributes" => array(
"target" => "_blank"
)
))
);
if ($row->selected)
{
$check = "<input class='shortlist' type='checkbox' data-aid='{$row->id}' checked>";
} //$row->selected
else
{
$check = "<input class='shortlist' type='checkbox' data-aid='{$row->id}'>";
}
array_push($item, $check);
array_push($rows, $item);
$i++;
} //$result as $row
$job = db_select("job_portal_positions")->fields("job_portal_positions")->condition("id", $position_id)->condition("display", 1)->execute()->fetchObject();
$markup .= l("<< Back to the list of open positions", "jobs/view-applications-if32ggxV747");
$markup .= "<div style='float:right'>";
$markup .= l("Download all applications", "jobs/downloads_all_applications/{$position_id}");
$markup .= "<br>";
$markup .= l("Download selected applications", "jobs/downloads_selected_applications/{$position_id}", array(
"attributes" => array(
"id" => "d_app"
)
));
$markup .= "<br>";
$markup .= l("Download applications data in document", "jobs/downloads_all_applications_doc/{$position_id}", array(
"attributes" => array(
"id" => "d_aaps"
)
));
$markup .= "<br>";
$markup .= l("Download applications data in spreadsheet", "jobs/downloads_all_applications_spreadsheet/{$position_id}", array(
"attributes" => array(
"id" => "d_aaps"
)
));
$markup .= "</div>";
$markup .= "<h5><u>{$job->position} ({$job->specialization}) - List of applications</u></h5>";
$markup .= bootstrap_table($headers, $rows);
$markup .= l("Save Selections", "jobs/view-applications-if32ggxV747/", array(
"query" => array(
"saved" => "true"
),
"attributes" => array(
"class" => "btn btn-primary"
)
));
} //$position_id
else
{
/* List all the job positions.
* Change the condition later based on end date.
*/
$result = db_select("job_portal_positions")->fields("job_portal_positions")->condition("status", 0, '<>')->condition("display", 1)->execute()->fetchAll();
$headers = array(
"#",
"Position",
"Time",
"Action"
);
$rows = array();
$i = 1;
foreach ($result as $row)
{
$item = array(
$i,
"{$row->position} [ <strong>{$row->project}</strong> ]",
$row->time,
l("View applications", "jobs/view-applications-if32ggxV747/{$row->id}")
);
array_push($rows, $item);
$i++;
} //$result as $row
$markup .= "<h5><u>List of job openings</u></h5>";
$markup .= bootstrap_table($headers, $rows);
}
$output = array(
"positions_list" => array(
"#prefix" => "<div id='positions-list'>",
"#markup" => $markup,
"#suffix" => "</div>"
)
);
return $output;
}
/* job portal application download page */
function job_portal_downloads_applications_page($position_id)
{
if ($position_id)
{
$result = db_select("job_portal_applications")->fields("job_portal_applications")->condition("position_id", $position_id)->condition("selected", 1)->condition("display", 1)->execute()->fetchAll();
$i = 1;
$rows = array();
$dt = new DateTime();
$current_date = $dt->format("Y-m-d");
foreach ($result as $row)
{
$job = db_select("job_portal_positions")->fields("job_portal_positions")->condition("id", $position_id)->execute()->fetchObject();
$base_path = $_SERVER['DOCUMENT_ROOT'] . base_path();
$downloads_dir = "uploads/resumes/{$row->id}/{$row->resume}";
$files = $downloads_dir;
$zipname = str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . '.zip'));
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
$zip->addFile($files, str_replace('.', '_', str_replace(' ', '_', strtolower("{$row->id} {$row->name}"))) . ".pdf");
$zip->close();
$i++;
} //$result as $row
$base_path = $_SERVER['DOCUMENT_ROOT'] . base_path();
$zipname = str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . '.zip'));
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename= "' . str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . '.zip')));
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
unlink($zipname);
} //$position_id
}
/* job portal application download all page */
function job_portal_downloads_all_applications_page($position_id)
{
if ($position_id)
{
$result = db_select("job_portal_applications")->fields("job_portal_applications")->condition("position_id", $position_id)->condition("display", 1)->execute()->fetchAll();
$i = 1;
$rows = array();
$dt = new DateTime();
$current_date = $dt->format("Y-m-d");
foreach ($result as $row)
{
$job = db_select("job_portal_positions")->fields("job_portal_positions")->condition("id", $position_id)->execute()->fetchObject();
$base_path = $_SERVER['DOCUMENT_ROOT'] . base_path();
$downloads_dir = "uploads/resumes/{$row->id}/{$row->resume}";
$files = $downloads_dir;
$zipname = str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . '.zip'));
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
$zip->addFile($files, str_replace('.', '_', str_replace(' ', '_', strtolower("{$row->id} {$row->name}"))) . ".pdf");
$zip->close();
$i++;
} //$result as $row
$base_path = $_SERVER['DOCUMENT_ROOT'] . base_path();
$zipname = str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . '.zip'));
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename= "' . str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . '.zip')));
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
unlink($zipname);
} //$position_id
}
// Download application data in spreadsheet //
function job_portal_downloads_all_applications_spreadsheet_page($position_id)
{
$dt = new DateTime();
$current_date = $dt->format("Y-m-d");
$job = db_select("job_portal_positions")->fields("job_portal_positions")->condition("id", $position_id)->execute()->fetchObject();
header("Content-Type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=" . str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . ".xls")));
echo $job->project . "\t" . $job->position . "\t" . ' ' . "\t" . ' ' . "\t" . ' ' . "\n";
echo 'Sr No' . "\t" . 'Name' . "\t" . 'Phone' . "\t" . 'Email' . "\t" . 'Application Date' . "\n";
if ($position_id)
{
$result = db_select("job_portal_applications")->fields("job_portal_applications")->condition("position_id", $position_id)->condition("display", 1)->execute()->fetchAll();
$i = 1;
foreach ($result as $row)
{
echo $i . "\t" . ucfirst(strtolower($row->name)) . "\t" . $row->contact . "\t" . $row->email . "\t" . $row->date . "\n";
$i++;
} //$result as $row
} //$position_id
}
// Download application data in document //
function job_portal_downloads_all_applications_document_page($position_id)
{
$dt = new DateTime();
$current_date = $dt->format("Y-m-d");
$job = db_select("job_portal_positions")->fields("job_portal_positions")->condition("id", $position_id)->execute()->fetchObject();
header("Content-Type: application/vnd.ms-word");
header("Content-disposition: attachment; filename=" . str_replace(' ', '_', strtolower($job->project . '_' . $job->position . '_' . $current_date . ".doc")));
// echo $job->project . "\t" . $job->position . "\t" . ' ' . "\t" . ' ' . "\t" . ' ' . "\n";
echo '<table width=650 align="center"><tr><th colspan="5" align="left">Advt date: ' . $job->time . '</span></th></tr><tr><th colspan="5" align ="left">Position: ' . $job->position . '</br>Specialization: ' . $job->position . '<br>Salary: ' . $job->salary . '<br>Qualification: ' . $job->qualification . '<br>Skills: ' . $job->skills . '<br>Job Responsibilities: ' . $job->skills . '<br>Location: ' . $job->location . '</span></th></tr><tr><td>Sr No</td><td>Name</td><td>Phone</td><td>Email</td><td>Application Date</td></tr>';
// echo '<tr><td>Sr No</td><td>Name</td><td>Phone</td><td>Email</td><td>Application Date</td></tr>';
//echo 'Sr No' . "\t" . 'Name' . "\t" . 'Phone' . "\t" . 'Email'. "\t" . 'Application Date' . "\n";
if ($position_id)
{
$result = db_select("job_portal_applications")->fields("job_portal_applications")->condition("position_id", $position_id)->condition("display", 1)->execute()->fetchAll();
$i = 1;
foreach ($result as $row)
{
//$app_date = date("d/m/Y", strtotime($row->date));
echo '<tr><td>' . $i . '</td><td>' . ucfirst(strtolower($row->name)) . '</td><td>' . $row->contact . '</td><td>' . $row->email . '</td><td>' . $row->date . '</td></tr>';
$i++;
} //$result as $row
echo '</table>';
} //$position_id
}
/* job portal ajax fuction */
function job_portal_ajax($item = "", $key = "")
{
$data = "";
if ($item == "shortlist")
{
$query = "
UPDATE job_portal_applications
SET selected = !selected
WHERE id = :aid
";
$args = array(
":aid" => $key
);
db_query($query, $args);
$data = "updated";
} //$item == "shortlist"
echo $data;
exit();
}
/* job portal init fuction */
function job_portal_init()
{
drupal_add_js("misc/form.js");
drupal_add_js("misc/collapse.js");
drupal_add_js(drupal_get_path("module", "job_portal") . '/js/main.js', array(
'group' => JS_THEME,
'weight' => 20,
'every_page' => TRUE,
'cache' => TRUE,
'scope' => 'header'
));
/* drupal_add_js(
drupal_get_path('module', 'job_portal') . '/js/smooth_scroll.js',
array(
'group' => JS_THEME,
'weight' => 20,
'every_page' => TRUE,
'cache' => TRUE,
'scope' => 'header',
)
);*/
}
/* helper functions */
function collapser($title = "", $content = "", $description = "", $key = "")
{
return "
<fieldset id='fieldset-id-{$key}' class='collapsible'>
<legend>
<a class='fieldset-title' href='#'>
<span class='fieldset-legend'>{$title}</span>
</a>
<span class='summary'></span>
</legend>
<div class='fieldset-wrapper'>
<div class='fieldset-description'>{$description}</div>
{$content}
</div>
</fieldset>
";
}
/* job portal required * in red function */
function required_star()
{
return "<span class='form-required' title='This field is required.'> *</span>";
}
/* job portal send mail attachment function */
function send_mail_attachment($from, $to, $cc, $bcc, $subject, $message, $file)
{
// $file should include path and filename
$filename = basename($file);
$file_size = filesize($file);
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time()));
$from = str_replace(array(
"\r",
"\n"
), '', $from); // to prevent email injection
$header = "From: " . $from . "\r\n" . "Cc: " . $cc . "\r\n" . "Bcc: " . $bcc . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"" . $uid . "\"\r\n\r\n" . "This is a multi-part message in MIME format.\r\n" . "--" . $uid . "\r\n" . "Content-type: text/html; charset=UTF-8; format=flowed\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" . $message . "\r\n\r\n" . "--" . $uid . "\r\n" . "Content-Type: application/octet-stream; name=\"" . $filename . "\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: attachment; filename=\"" . $filename . "\"\r\n\r\n" . $content . "\r\n\r\n" . "--" . $uid . "--";
return mail($to, $subject, "", $header);
}
/* job portal send get job availabe function */
function get_jobs_available($key = "")
{
$result = db_select("job_portal_positions")->fields("job_portal_positions")->condition("status", 1)->orderBy("display_order", "ASC")->execute()->fetchAll();
if ($key == "options")
{
$options = array();
foreach ($result as $row)
{
$options[$row->id] = "{$row->position} ({$row->specialization})";
} //$result as $row
return $options;
} //$key == "options"
else
{
return $result;
}
}
/* job portal bootstrap table function */
function bootstrap_table($headers, $rows)
{
$thead = "";
$tbody = "";
foreach ($headers as $header)
{
$thead .= "<th>{$header}</th>";
} //$headers as $header
foreach ($rows as $row)
{
$tbody .= "<tr>";
foreach ($row as $data)
{
$tbody .= "<td>{$data}</td>";
} //$row as $data
$tbody .= "</tr>";
} //$rows as $row
$table = "
<table class='table table-bordered table-hover' style='margin-left:-140px'>
<thead>{$thead}</thead>
<tbody>{$tbody}</tbody>
</table>
";
return $table;
}
/**
* Simple wrapper function for drupal_mail() to avoid extraneous code.
*/
function send_mail($from, $to, $subject, $message)
{
$my_module = 'job_portal';
$my_mail_token = microtime();
$message = array(
'id' => $my_module . '_' . $my_mail_token,
'to' => $to,
'subject' => $subject,
'body' => array(
$message
),
'headers' => array(
'From' => $from,
'Sender' => $from,
'Return-Path' => $from,
'Bcc' => 'prashantsinalkar@gmail.com'
)
);
$system = drupal_mail_system($my_module, $my_mail_token);
$message = $system->format($message);
if ($system->mail($message))
{
return TRUE;
} //$system->mail($message)
else
{
return FALSE;
}
}
|