From a2e3024afc43fea31222a35cfc4d757be41fc2f0 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Thu, 19 Mar 2020 16:09:32 +0530 Subject: Add mentor certificate --- om_pssp.module | 11 +- pdf/images/bg_cert_mentor.png | Bin 0 -> 17983 bytes pdf/list_mentor_certificates.inc | 55 +++++++ pdf/mentor_cert_pdf.inc | 323 +++++++++++++++++++++++++++++++++++++++ pdf/verify_certificates.inc | 8 +- 5 files changed, 389 insertions(+), 8 deletions(-) create mode 100755 pdf/images/bg_cert_mentor.png create mode 100755 pdf/list_mentor_certificates.inc create mode 100755 pdf/mentor_cert_pdf.inc diff --git a/om_pssp.module b/om_pssp.module index fc4da49..a6713dd 100755 --- a/om_pssp.module +++ b/om_pssp.module @@ -1,5 +1,8 @@ 'pdf/cert_new.inc' ); - /*$items['powersystems/pssp/certificates-custom'] = array( + $items['powersystems/pssp/certificates-custom'] = array( 'title' => 'List of Power System Simulation Custom Certificates', 'description' => 'List of Power System Simulation Custom Certificates', 'page callback' => '_list_pssp_custom_certificates', @@ -301,7 +304,7 @@ function om_pssp_menu() 'generate pdf' ), 'file' => 'pdf/mentor_cert_pdf.inc' - );*/ + ); $items["powersystems/pssp/certificates/verify"] = array( "title" => "Certificate Verification", "page callback" => "verify_certificates", @@ -371,10 +374,10 @@ function om_pssp_permission() "title" => t("list Power System Simulation certificates"), "description" => t("Allows users to list Power System Simulation certificates.") ), - /*"list Power System Simulation custom certificates" => array( + "list Power System Simulation custom certificates" => array( "title" => t("list Power System Simulation custom certificates"), "description" => t("Allows users to list Power System Simulation custom certificates.") - ),*/ + ), "generate pdf" => array( "title" => t("Generate pdf"), "description" => t("Allows users to Generate pdf.") diff --git a/pdf/images/bg_cert_mentor.png b/pdf/images/bg_cert_mentor.png new file mode 100755 index 0000000..478dc8e Binary files /dev/null and b/pdf/images/bg_cert_mentor.png differ diff --git a/pdf/list_mentor_certificates.inc b/pdf/list_mentor_certificates.inc new file mode 100755 index 0000000..bf8f024 --- /dev/null +++ b/pdf/list_mentor_certificates.inc @@ -0,0 +1,55 @@ +fetchObject(); + if ($exist_id){ + if ($exist_id->id) { + if ($exist_id->id < 3) { + drupal_set_message('You need to propose a flowsheet Flowsheet Proposal or if you have already proposed then your flowsheet is under reviewing process', 'status'); + return ''; + } //$exist_id->id < 3 + else { + $search_rows = array(); + global $output; + $output = ''; + $query3 = db_query("SELECT id,project_guide_name,project_guide_university,project_title FROM +om_pssp_proposal WHERE project_guide_name != '' AND project_guide_university != '' AND approval_status=3"); + $i = 1; + while ($search_data3 = $query3->fetchObject()) { + $search_rows[] = array( + $i, + $search_data3->project_title, + $search_data3->project_guide_name, + l('Download Certificate', 'powersystems/pssp/certificates-custom/pdf/' . $search_data3->id) + ); + $i++; + //$search_data3->id + } //$search_data3 = $query3->fetchObject() + if ($search_rows) { + $search_header = array( + 'No', + 'Project Title', + 'Project Guide Name', + 'Download Certificates' + ); + $output = theme('table', array( + 'header' => $search_header, + 'rows' => $search_rows + )); + return $output; + } //$search_rows + else { + echo ("Error"); + return ''; + } + } + } + } //$exist_id->id + else { + drupal_set_message('You need to propose a flowsheet Flowsheet Proposal or if you have already proposed then your flowsheet is under reviewing process', 'status'); + $page_content = " No certificate available "; + return $page_content; + } +} diff --git a/pdf/mentor_cert_pdf.inc b/pdf/mentor_cert_pdf.inc new file mode 100755 index 0000000..7f63658 --- /dev/null +++ b/pdf/mentor_cert_pdf.inc @@ -0,0 +1,323 @@ +uid; + $proposal_id = arg(4); + $query3 = db_query("SELECT * FROM om_pssp_proposal WHERE approval_status=3 AND id=:proposal_id", array( + ':proposal_id'=>$proposal_id + )); + $data3 = $query3->fetchObject(); + $gender = array( + 'salutation' => 'Mr. /Ms.', + 'gender' => 'He/She' + ); + if ($data3->gender) { + if ($data3->gender == 'M') { + $gender = array( + 'salutation' => 'Mr.', + 'gender' => 'He' + ); + } //$data3->gender == 'M' + else { + $gender = array( + 'salutation' => 'Ms.', + 'gender' => 'She' + ); + } + } //$data3->gender + $pdf = new FPDF('L', 'mm', 'Letter'); + if (!$pdf) { + echo "Error!"; + } //!$pdf + $pdf->AddPage(); + $image_bg = $mpath . "/pdf/images/bg_cert_mentor.png"; + $pdf->Image($image_bg, 0, 0, $pdf->w, $pdf->h); + $pdf->SetMargins(18, 1, 18); + $path = drupal_get_path('module', 'om_pssp'); + $pdf->Ln(43); + $pdf->SetFont('Times', 'I', 12); + $pdf->SetTextColor(13, 5, 130); + $pdf->Cell(240, 20, 'This certificate recognizes the valuable mentorship of', '0', '1', 'C'); + $pdf->Ln(-6); + $pdf->SetFont('Times', 'BI', 16); + $pdf->SetTextColor(13, 5, 130); + $pdf->Cell(240, 8, $data3->project_guide_name, '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 12); + if (strtolower($data3->branch) != "others") { + $pdf->SetTextColor(13, 5, 130); + $pdf->SetFont('Times', 'I', 12); + $pdf->Cell(240, 8, 'from', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times','BI',16); + $pdf->Cell(240, 8, $data3->project_guide_university, '0','1','C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 12); + $pdf->Cell(240, 8, 'who has mentored', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'BI', 16); + $pdf->Cell(240, 8, $data3->contributor_name, '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 12); + $pdf->Cell(240, 8, 'for successfully completing internship under the Power System Simulation Project. The intern(s) has created a Simulation titled', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'BI', 16); + $pdf->SetTextColor(13, 5, 130); + $pdf->Cell(240, 8, $data3->project_title, '0', '1', 'C'); + $pdf->SetTextColor(13, 5, 130); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 12); + $pdf->Cell(240, 8, ' using OpenModelica .The work done is available at', '0', '1', 'C'); + $pdf->Cell(240, 4, '', '0', '1', 'C'); + $pdf->SetX(105); + $pdf->SetFont('', 'U'); + $pdf->SetTextColor(13, 5, 130); + $pdf->SetFont('Times', 'I', 12); + $pdf->write(0, 'https://om.fossee.in/powersystems/pssp', 'https://om.fossee.in/powersystems/pssp'); + $pdf->Ln(0); + } + else { + $pdf->SetTextColor(13, 5, 130); + $pdf->Cell(240, 8, 'from ' . $data3->project_guide_university . ' has successfully', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->Cell(240, 8, 'completed Internship under DWSIM Flowsheeting Project', '0', '1', 'C'); + $pdf->Ln(0); + } + $proposal_get_id = 0; + $UniqueString = ""; + $tempDir = $path . "/pdf/temp_prcode/"; + $query = db_select('om_pssp_qr_code'); + $query->fields('om_pssp_qr_code'); + $query->condition('proposal_id', $proposal_id); + $result = $query->execute(); + $data = $result->fetchObject(); + $proposal_get_id = $data->proposal_id; + $qrstring = $data->qr_code; + $codeContents = 'https://om.fossee.in/powersystems/pssp/certificates/verify/' . $qrstring; + $fileName = 'generated_qrcode.png'; + $pngAbsoluteFilePath = $tempDir . $fileName; + $urlRelativeFilePath = $path . "/pdf/temp_prcode/" . $fileName; + QRcode::png($codeContents, $pngAbsoluteFilePath); + $pdf->SetFont('Times', 'B', 12); + $pdf->SetY(-75); + $pdf->Ln(20); + $pdf->SetX(100); + $pdf->Cell(0, 0, $qrstring, '0', '0', 'L'); + $pdf->SetX(29); + $pdf->SetY(-65); + $pdf->Ln(13); + $pdf->Image($pngAbsoluteFilePath, $pdf->GetX() + 75, $pdf->GetY(), 30, 0); + $filename = str_replace(' ', '-', $data3->contributor_name) . '-DWSIM-Flowsheet-Certificate.pdf'; + $file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename; + $pdf->Output($file, 'F'); + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename=" . $filename); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header("Content-Length: " . filesize($file)); + flush(); + $fp = fopen($file, "r"); + while (!feof($fp)) { + echo fread($fp, 65536); + flush(); + } //!feof($fp) + fclose($fp); + unlink($file); + //drupal_goto('flowsheeting-project/certificate'); + return; +} +function generateRandomString($length = 5) +{ + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } //$i = 0; $i < $length; $i++ + return $randomString; +} +function generate_copyright_form_pdf() +{ + $mpath = drupal_get_path('module', 'om_pssp'); + require($mpath . '/pdf/fpdf/fpdf.php'); + global $user; + $x = $user->uid; + $proposal_id = arg(3); + $query2 = db_query("SELECT id FROM om_pssp_proposal WHERE approval_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $data2 = $query2->fetchObject(); + $query3 = db_query("SELECT * FROM om_pssp_proposal WHERE approval_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $data3 = $query3->fetchObject(); + $gender = array( + 'salutation' => 'Mr. /Ms.', + 'gender' => 'He/She' + ); + if ($data3->gender) { + if ($data3->gender == 'M') { + $gender = array( + 'salutation' => 'Mr.', + 'gender' => 'He' + ); + } //$data3->gender == 'M' + else { + $gender = array( + 'salutation' => 'Ms.', + 'gender' => 'She' + ); + } + } //$data3->gender + $pdf = new FPDF('P', 'mm', 'Letter'); + if (!$pdf) { + echo "Error!"; + } //!$pdf + $pdf->AddPage(); + $path = drupal_get_path('module', 'om_pssp'); + $pdf->SetFont('Times', 'B', 25); + $pdf->Ln(30); + $pdf->Cell(200, 8, 'Copyright Transfer Form', 0, 1, 'C'); + $pdf->Ln(20); + $pdf->SetFont('Times', '', 12); + $pdf->MultiCell(200, 8, 'I hereby transfer the copyrights of the DWSIM Flowsheeting Project for ' . $data2->project_title . ' to FOSSEE Project, IIT Bombay.', 0); + $pdf->Ln(10); + $pdf->MultiCell(200, 8, 'I understand that the FOSSEE project will release the Flowsheet under the Creative Commons (CC) license.'); + $pdf->SetX(75); + $pdf->SetFont('', 'U'); + $pdf->SetTextColor(0, 0, 255); + $pdf->SetFont('', ''); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', ''); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetY(-10); + $pdf->SetX(209); + $cur_date = date('jS F, Y'); + $pdf->SetY(140); + $pdf->SetFont('', ''); + $pdf->Ln(0); + $pdf->Cell(200, 0, ' Date: ' . $cur_date . '', 0, 1, 'L'); + $pdf->Cell(200, 20, ' Place: _________________', 0, 1, 'L'); + $pdf->SetY(140); + $pdf->SetX(120); + $pdf->Cell(180, 0, 'Signature: _________________', 0, 1, 'L'); + $pdf->SetY(144); + $pdf->SetX(120); + $pdf->multicell(140, 14, 'Name: ' . $gender['salutation'] . ' ' . $data3->full_name . '', 0, ''); + $filename = str_replace(' ', '-', $data3->full_name) . '-DWSIM-Flowsheet-copyright-form.pdf'; + $file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename; + $pdf->Output($file, 'F'); + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename=" . $filename); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header("Content-Length: " . filesize($file)); + flush(); + $fp = fopen($file, "r"); + while (!feof($fp)) { + echo fread($fp, 65536); + flush(); + } //!feof($fp) + fclose($fp); + unlink($file); + drupal_goto('Summer_Internship_Forms/forms'); + return; +} +function generate_undertaking_form_pdf() +{ + $mpath = drupal_get_path('module', 'textbook_companion'); + require($mpath . '/pdf/fpdf/fpdf.php'); + global $user; + $x = $user->uid; + $proposal_id = arg(3); + $query2 = db_query("SELECT id FROM om_pssp_proposal WHERE approval_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $data2 = $query2->fetchObject(); + $query3 = db_query("SELECT * FROM om_pssp_proposal WHERE approval_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $data3 = $query3->fetchObject(); + $gender = array( + 'salutation' => 'Mr. /Ms.', + 'gender' => 'He/She' + ); + if ($data3->gender) { + if ($data3->gender == 'M') { + $gender = array( + 'salutation' => 'Mr.', + 'gender' => 'He' + ); + } //$data3->gender == 'M' + else { + $gender = array( + 'salutation' => 'Ms.', + 'gender' => 'She' + ); + } + } //$data3->gender + $pdf = new FPDF('P', 'mm', 'Letter'); + if (!$pdf) { + echo "Error!"; + } //!$pdf + $pdf->AddPage(); + $path = drupal_get_path('module', 'om_pssp'); + $pdf->SetFont('Times', 'B', 25); + $pdf->Ln(30); + $pdf->Cell(200, 8, 'Undertaking Form', 0, 1, 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'B', 10); + $pdf->Cell(200, 8, '(To be signed by college teacher)', 0, 1, 'C'); + $pdf->Ln(20); + $pdf->SetFont('Times', '', 12); + $pdf->MultiCell(200, 8, 'I hereby certify that all the codes written by ' . $gender['salutation'] . ' ' . $data3->full_name . ' under the DWSIM Textbook Companion Project for the book ' . $data2->book . ' ( Author: ' . $data2->author . ', Edition: ' . $data2->edition . ', Publisher: ' . $data2->publisher . ', Year: ' . $data2->year . ') are correctly reproducing the results given in the aforementioned book.', 0); + $pdf->Ln(10); + $pdf->MultiCell(200, 8, 'I understand that the DWSIM Textbook Companion created is a part of FOSSEE project, IIT Bombay, and is sponsored by the National Mission on Education through Information and Communication Technology (NMEICT), under MHRD, Govt. of India. The project requires that the textbook companion is made available for public access as an open source document. Hence I undertake that this DWSIM Textbook Companion can be made public along with the information that I have certified all the codes as giving the correct answer.'); + $pdf->SetX(75); + $pdf->SetFont('', 'U'); + $pdf->SetTextColor(0, 0, 255); + $pdf->SetFont('', ''); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', ''); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetY(-10); + $pdf->SetX(209); + $cur_date = date('jS F, Y'); + $pdf->SetY(180); + $pdf->SetFont('', ''); + $pdf->Ln(0); + $pdf->Cell(200, 0, ' Date: ' . $cur_date . '', 0, 1, 'L'); + $pdf->Cell(200, 20, ' Place: _________________', 0, 1, 'L'); + $pdf->SetY(180); + $pdf->SetX(120); + $pdf->Cell(140, 0, 'Signature: _________________', 0, 1, 'L'); + $pdf->SetX(120); + $pdf->multicell(140, 14, 'Name: ' . '____________________', 0, ''); + $pdf->SetX(120); + $pdf->multicell(140, 14, 'Designation: ' . '______________', 0, ''); + $filename = str_replace(' ', '-', $data3->full_name) . '-DWSIM-Textbook-Companion-undertaking-form.pdf'; + $file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename; + $pdf->Output($file, 'F'); + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename=" . $filename); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header("Content-Length: " . filesize($file)); + flush(); + $fp = fopen($file, "r"); + while (!feof($fp)) { + echo fread($fp, 65536); + flush(); + } //!feof($fp) + fclose($fp); + unlink($file); + drupal_goto('Summer_Internship_Forms/forms'); + return; +} \ No newline at end of file diff --git a/pdf/verify_certificates.inc b/pdf/verify_certificates.inc index 562e290..4e5473c 100755 --- a/pdf/verify_certificates.inc +++ b/pdf/verify_certificates.inc @@ -86,8 +86,8 @@ function verify_qrcode_fromdb($qr_code) $page_content .= "

Participation Details

"; $page_content .= ""; $page_content .= ""; - $page_content .= ""; - $page_content .= ""; + $page_content .= ""; + $page_content .= ""; $page_content .= ""; $page_content .= ""; $page_content .= ""; @@ -98,8 +98,8 @@ function verify_qrcode_fromdb($qr_code) $page_content .= "

Participation Details

Name" . $data3->contributor_name . "
ProjectOpenModelica pssping Project
OpenModelica pssping completedOpenModelica Power System Simulation Project
OpenModelica Power System Simulation completed" . $data3->project_title . "
Project Guide" . $data3->project_guide_name . "
"; $page_content .= ""; $page_content .= ""; - $page_content .= ""; - $page_content .= ""; + $page_content .= ""; + $page_content .= ""; $page_content .= ""; $page_content .= "
Name" . $data3->contributor_name . "
ProjectOpenModelica pssping Project
OpenModelica pssping completedOpenModelica Power System Simulation Project
OpenModelica Power System Simulation completed" . $data3->project_title . "
"; } -- cgit