summaryrefslogtreecommitdiff
path: root/pdf/verify_certificates.inc
blob: 9f3fb32a3f89f5f35ad6d06cbbe17a2c6adab692 (plain)
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
<?php
function verify_certificates($qr_code = 0)
{
	$qr_code = arg(4);
	$page_content = "";
	if ($qr_code)
	{
		$page_content = verify_qrcode_fromdb($qr_code);
	} //$qr_code
	else
	{
		$verify_certificates_form = drupal_get_form("verify_certificates_form");
		$page_content = drupal_render($verify_certificates_form);
	}
	return $page_content;
}
function verify_certificates_form($form, &$form_state)
{
	$form = array();
	$form['Title'] = array(
		'#type' => 'markup',
		'#markup' => ''
	);
	$form["QR_code"] = array(
		"#type" => "textfield",
		"#title" => "Enter QR Code",
		"#default_value" => '',
		"#required" => TRUE
	);
	$form["submit"] = array(
		"#type" => "submit",
		"#value" => "Verify",
		'#ajax' => array(
			'callback' => 'verify_certificates_form_submit',
			'progress' => array(
				'message' => ''
			)
		)
	);
	$form['displaytable'] = array(
		'#type' => 'markup',
		'#prefix' => '<div><div id="displaytable" style="font-weight:bold;padding-top:10px">',
		'#suffix' => '</div></div>',
		'#markup' => ''
	);
	return $form;
}
function verify_certificates_form_submit($form, &$form_state)
{
	$page_content = "";
	$v = $form_state["values"];
	$qr_code = $v["QR_code"];
	$page_content = verify_qrcode_fromdb($qr_code);
	$form['displaytable']['#markup'] = $page_content;
	$commands[] = ajax_command_html("#displaytable", drupal_render($form['displaytable']));
	return array(
		'#type' => 'ajax',
		'#commands' => $commands
	);
}
function verify_qrcode_fromdb($qr_code)
{
	$query = db_select('om_flowsheet_qr_code');
	$query->fields('om_flowsheet_qr_code', array(
		'proposal_id'
	));
	$query->condition('qr_code', $qr_code);
	$result = $query->execute();
	$proposal_id = $result->fetchObject()->proposal_id;
	if ($proposal_id)
	{
		$query2 = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE approval_status=3", array(
		':uid' => $proposal_id
		));
		$data2 = $query2->fetchObject();
		$query3 = db_query("SELECT * FROM om_flowsheet_proposal WHERE approval_status=3 AND id=:uid", array(
		':uid' => $proposal_id
	));
	$data3 = $query3->fetchObject();
		/*$query3 = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE approval_status=3 AND uid= :uid", array(
		':uid' => $user->uid
		));
		$data3 = $query3->fetchObject();**/
		if($data3->project_guide_name) {
		$page_content = "";
		$page_content .= "<h4>Participation Details</h4><table><tr><td>Name</td>";
		$page_content .= "<td>" . $data3->contributor_name . "</td></tr>";
		$page_content .= "<tr><td>Project</td>";
		$page_content .= "<td>OpenModelica Flowsheeting Project</td></tr>";
		$page_content .= "<tr><td>OpenModelica Flowsheeting completed</td>";
		$page_content .= "<td>" . $data3->project_title . "</td></tr>";
		$page_content .= "<tr><td>Project Guide</td>";
		$page_content .= "<td>" . $data3->project_guide_name . "</td></tr>";
		$page_content .= "</table>";
		}
		else {
		$page_content = "";
		$page_content .= "<h4>Participation Details</h4><table><tr><td>Name</td>";
		$page_content .= "<td>" . $data3->contributor_name . "</td></tr>";
		$page_content .= "<tr><td>Project</td>";
		$page_content .= "<td>OpenModelica Flowsheeting Project</td></tr>";
		$page_content .= "<tr><td>OpenModelica Flowsheeting completed</td>";
		$page_content .= "<td>" . $data3->project_title . "</td></tr>";
		$page_content .= "</table>";
		}

	} //$proposal_id
	else
	{
		$page_content = "<b>Sorry ! The serial number you entered seems to be invalid. Please try again ! <b>";
	}
	return $page_content;
}