summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2016-08-18 12:31:57 +0530
committerprashantsinalkar2016-08-18 12:31:57 +0530
commitf532da15debb0a9e3f2dc4953c2e9a10b4153bbd (patch)
tree86cafa784e11523c655ef5902f4d2b690197b381
parent237172fbbd89e594128ebad8ebfc6d732b89e660 (diff)
downloadscilab_textbook_companion-f532da15debb0a9e3f2dc4953c2e9a10b4153bbd.tar.gz
scilab_textbook_companion-f532da15debb0a9e3f2dc4953c2e9a10b4153bbd.tar.bz2
scilab_textbook_companion-f532da15debb0a9e3f2dc4953c2e9a10b4153bbd.zip
formated the code
-rwxr-xr-xpdf/generate_pdf.inc268
-rwxr-xr-xpdf/list_all_certificates.inc174
2 files changed, 228 insertions, 214 deletions
diff --git a/pdf/generate_pdf.inc b/pdf/generate_pdf.inc
index cec2bcf..4a60020 100755
--- a/pdf/generate_pdf.inc
+++ b/pdf/generate_pdf.inc
@@ -1,140 +1,138 @@
<?php
-
- function generate_pdf()
- { $mpath = drupal_get_path('module', 'textbook_companion');
- require($mpath.'/pdf/fpdf/fpdf.php');
- global $user;
- $x = $user->uid;
- $proposal_id = arg(2);
- $query2 = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status=1 AND proposal_id= :prop_id", array(':prop_id' => $proposal_id));
- $data2 = $query2->fetchObject();
- $query3 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id= :prop_id", array(':prop_id' =>$proposal_id));
- $data3 = $query3->fetchObject();
- //var_dump($data3->gender);
- $gender = array('salutation' => 'Mr. /Ms.', 'gender' => 'He/She');
- if($data3->gender){
- if($data3->gender == 'M'){
- $gender = array('salutation' => 'Mr.', 'gender' => 'He');
-
- }else{
- $gender = array('salutation' => 'Ms.', 'gender' => 'She');
- }
- }
- //die;
- /*if($data3->proposal_status == 3)
- {*/
- $pdf=new FPDF('L', 'mm', 'Letter');
- if (!$pdf)
- {
- echo "Error!";
- }
- $pdf->AddPage();
-
- $pdf->SetMargins(18,1,18);
-
- $pdf->Line(7.0,7.0,270.0,7.0);
- $pdf->Line(7.0,7.0,7.0,210.0);
- $pdf->Line(270.0,210.0,270.0,7.0);
- $pdf->Line(7.0,210.0,270.0,210.0);
-
- $pdf->Image("/Sites/scilab_in_2015/sites/default/files/scilab_logo.png", 10, 9, 0, 15);
- $path = drupal_get_path('module', 'textbook_companion');
- $pdf->Image($path."/pdf/images/fossee.png", 228, 9, 0, 15);
-
- $pdf->SetFont('Arial','B',25);
- $pdf->Ln(30);
- $pdf->Cell(240,8,'Certificate', 0,1,'C');
- $pdf->Ln(5);
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(240,8,'Textbook Companion', '0','1','C');
-
- $pdf->Ln(20);
- //$pdf->Cell(240,8,'IIT Bombay', '0','1','C');
-
- $pdf->SetFont('Arial','',12);
- if(strtolower($data3->branch)!="others")
+function generate_pdf()
+{
+ $mpath = drupal_get_path('module', 'textbook_companion');
+ require($mpath . '/pdf/fpdf/fpdf.php');
+ global $user;
+ $x = $user->uid;
+ $proposal_id = arg(2);
+ $query2 = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status=1 AND proposal_id= :prop_id", array(
+ ':prop_id' => $proposal_id
+ ));
+ $data2 = $query2->fetchObject();
+ $query3 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id= :prop_id", array(
+ ':prop_id' => $proposal_id
+ ));
+ $data3 = $query3->fetchObject();
+ //var_dump($data3->gender);
+ $gender = array(
+ 'salutation' => 'Mr. /Ms.',
+ 'gender' => 'He/She'
+ );
+ if ($data3->gender)
+ {
+ if ($data3->gender == 'M')
{
- $pdf->MultiCell(240,8,'This is to certify that '.$gender['salutation']." ".$data3->full_name.' from the Department of '.$data3->branch.', '.$data3->university.' has successfully completed Internship under Scilab Textbook Companion for a duration equivalent to six weeks. '.$gender['gender'].' has coded, in Scilab, all the solved examples of the allotted textbook: '.$data2->book.' by '.$data2->author.'.', 0);
- }
+ $gender = array(
+ 'salutation' => 'Mr.',
+ 'gender' => 'He'
+ );
+ } //$data3->gender == 'M'
else
{
- $pdf->MultiCell(240,8,'This is to certify that '.$gender['salutation']." ".$data3->full_name.' from '.$data3->university.' has successfully completed training under Scilab Textbook Companion for a duration equivalent to six weeks. '.$gender['gender'].' has coded, in Scilab, all the solved examples of the allotted textbook: '.$data2->book.' by '.$data2->author.'.', 0);
- } $pdf->Cell(10,10,'The work done is available at ', '0','0','L');
-
- $pdf->SetX(75);
- $pdf->SetFont('','U');
- $pdf->SetTextColor(0,0,255);
- $pdf->write(10,'http://scilab.in','http://scilab.in');
- $pdf->SetFont('','');
- $pdf->SetTextColor(0,0,0);
- $pdf->write(10,'.','.');
-
- $pdf->Ln(10);
-
- $pdf->SetFont('Arial','',12);
- $pdf->SetTextColor(0,0,0);
- $pdf->Cell(10,10,'This work was funded by the FOSSEE project, IIT Bombay (for more details visit', '0','0','L');
-
- $pdf->SetX(170);
- $pdf->SetFont('','U');
- $pdf->SetTextColor(0,0,255);
- $pdf->write(10,'http://fossee.in','http://fossee.in');
-
- $pdf->SetX(198);
- $pdf->SetFont('','');
- $pdf->SetTextColor(0,0,0);
- $pdf->write(10,').');
-
- $pdf->SetY(-50);
-
- $pdf->SetX(209);
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','B');
- $pdf->Image($path."/pdf/images/sign.png", 212, 151, 0, 15);
- //$pdf->SetX(206);
- $pdf->Cell(0,7,'Prof. Madhu Belur', 0,1,'L');
- $pdf->SetX(195);
- $pdf->Cell(0,7,'Principal Investigator - FOSSEE',0,1,'L');
- $pdf->SetX(195);
- $pdf->Cell(0,7,' Dept. of Electrical Engineering', 0,1,'L');
-
- $pdf->SetX(216);
- $pdf->Cell(0,7,'IIT Bombay', 0,1,'L');
-
- $cur_date=date('jS F, Y');
- $pdf->SetY(180);
- $pdf->SetFont('','');
- $pdf->Cell(200,0,' Date: '.$cur_date.'',0,1,'L');
- //$pdf->Cell(200,0,' Date: 28th August, 2013',0,1,'L');
- $pdf->Cell(200,15,'Email: textbook@scilab.in', 0,1,'L');
- $filename = str_replace(' ','-', $data3->full_name).'-Scilab-Textbook-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(); // this doesn't really matter.
- $fp = fopen($file, "r");
- while (!feof($fp))
- {
- echo fread($fp, 65536);
- flush(); // this is essential for large downloads
- }
- fclose($fp);
- unlink($file);
- drupal_goto('certificate');
- return;
- /*}
- else
- {
- drupal_set_message('Your Book Is Still Under Review.', 'status');
- }*/
-}
+ $gender = array(
+ 'salutation' => 'Ms.',
+ 'gender' => 'She'
+ );
+ }
+ } //$data3->gender
+ //die;
+ /*if($data3->proposal_status == 3)
+ {*/
+ $pdf = new FPDF('L', 'mm', 'Letter');
+ if (!$pdf)
+ {
+ echo "Error!";
+ } //!$pdf
+ $pdf->AddPage();
+ $pdf->SetMargins(18, 1, 18);
+ $pdf->Line(7.0, 7.0, 270.0, 7.0);
+ $pdf->Line(7.0, 7.0, 7.0, 210.0);
+ $pdf->Line(270.0, 210.0, 270.0, 7.0);
+ $pdf->Line(7.0, 210.0, 270.0, 210.0);
+ $pdf->Image("/Sites/scilab_in_2015/sites/default/files/scilab_logo.png", 10, 9, 0, 15);
+ $path = drupal_get_path('module', 'textbook_companion');
+ $pdf->Image($path . "/pdf/images/fossee.png", 228, 9, 0, 15);
+ $pdf->SetFont('Arial', 'B', 25);
+ $pdf->Ln(30);
+ $pdf->Cell(240, 8, 'Certificate', 0, 1, 'C');
+ $pdf->Ln(5);
+ $pdf->SetFont('Arial', 'B', 12);
+ $pdf->Cell(240, 8, 'Textbook Companion', '0', '1', 'C');
+ $pdf->Ln(20);
+ //$pdf->Cell(240,8,'IIT Bombay', '0','1','C');
+ $pdf->SetFont('Arial', '', 12);
+ if (strtolower($data3->branch) != "others")
+ {
+ $pdf->MultiCell(240, 8, 'This is to certify that ' . $gender['salutation'] . " " . $data3->full_name . ' from the Department of ' . $data3->branch . ', ' . $data3->university . ' has successfully completed Internship under Scilab Textbook Companion for a duration equivalent to six weeks. ' . $gender['gender'] . ' has coded, in Scilab, all the solved examples of the allotted textbook: ' . $data2->book . ' by ' . $data2->author . '.', 0);
+ } //strtolower($data3->branch) != "others"
+ else
+ {
+ $pdf->MultiCell(240, 8, 'This is to certify that ' . $gender['salutation'] . " " . $data3->full_name . ' from ' . $data3->university . ' has successfully completed training under Scilab Textbook Companion for a duration equivalent to six weeks. ' . $gender['gender'] . ' has coded, in Scilab, all the solved examples of the allotted textbook: ' . $data2->book . ' by ' . $data2->author . '.', 0);
+ }
+ $pdf->Cell(10, 10, 'The work done is available at ', '0', '0', 'L');
+ $pdf->SetX(75);
+ $pdf->SetFont('', 'U');
+ $pdf->SetTextColor(0, 0, 255);
+ $pdf->write(10, 'http://scilab.in', 'http://scilab.in');
+ $pdf->SetFont('', '');
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->write(10, '.', '.');
+ $pdf->Ln(10);
+ $pdf->SetFont('Arial', '', 12);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->Cell(10, 10, 'This work was funded by the FOSSEE project, IIT Bombay (for more details visit', '0', '0', 'L');
+ $pdf->SetX(170);
+ $pdf->SetFont('', 'U');
+ $pdf->SetTextColor(0, 0, 255);
+ $pdf->write(10, 'http://fossee.in', 'http://fossee.in');
+ $pdf->SetX(198);
+ $pdf->SetFont('', '');
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->write(10, ').');
+ $pdf->SetY(-50);
+ $pdf->SetX(209);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', 'B');
+ $pdf->Image($path . "/pdf/images/sign.png", 212, 151, 0, 15);
+ //$pdf->SetX(206);
+ $pdf->Cell(0, 7, 'Prof. Madhu Belur', 0, 1, 'L');
+ $pdf->SetX(195);
+ $pdf->Cell(0, 7, 'Principal Investigator - FOSSEE', 0, 1, 'L');
+ $pdf->SetX(195);
+ $pdf->Cell(0, 7, ' Dept. of Electrical Engineering', 0, 1, 'L');
+ $pdf->SetX(216);
+ $pdf->Cell(0, 7, 'IIT Bombay', 0, 1, 'L');
+ $cur_date = date('jS F, Y');
+ $pdf->SetY(180);
+ $pdf->SetFont('', '');
+ $pdf->Cell(200, 0, ' Date: ' . $cur_date . '', 0, 1, 'L');
+ //$pdf->Cell(200,0,' Date: 28th August, 2013',0,1,'L');
+ $pdf->Cell(200, 15, 'Email: textbook@scilab.in', 0, 1, 'L');
+ $filename = str_replace(' ', '-', $data3->full_name) . '-Scilab-Textbook-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(); // this doesn't really matter.
+ $fp = fopen($file, "r");
+ while (!feof($fp))
+ {
+ echo fread($fp, 65536);
+ flush(); // this is essential for large downloads
+ } //!feof($fp)
+ fclose($fp);
+ unlink($file);
+ drupal_goto('certificate');
+ return;
+ /*}
+ else
+ {
+ drupal_set_message('Your Book Is Still Under Review.', 'status');
+ }*/
+}
?>
-
diff --git a/pdf/list_all_certificates.inc b/pdf/list_all_certificates.inc
index e094d5f..57d1a49 100755
--- a/pdf/list_all_certificates.inc
+++ b/pdf/list_all_certificates.inc
@@ -1,97 +1,113 @@
<?php
/* function _list_all_certificates()
- {
- global $user;
- $uid1 = $user->uid;
+{
+global $user;
+$uid1 = $user->uid;
- $query2 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE proposal_status=3 AND uid=".$user->uid);
- $data2 = db_fetch_object($query2);
- if($data2->id)
- /*while($data2 = db_fetch_object($query2))
- {*/
- /* if($data2->id)
- {
- $search_rows = array();
- global $output;
- $output = '';
- $query3 = db_query("SELECT * FROM textbook_companion_preference WHERE approval_status=1 AND proposal_id=".$data2->id);
+$query2 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE proposal_status=3 AND uid=".$user->uid);
+$data2 = db_fetch_object($query2);
+if($data2->id)
+/*while($data2 = db_fetch_object($query2))
+{*/
+/* if($data2->id)
+{
+$search_rows = array();
+global $output;
+$output = '';
+$query3 = db_query("SELECT * FROM textbook_companion_preference WHERE approval_status=1 AND proposal_id=".$data2->id);
- while ($search_data3 = db_fetch_object($query3))
- {
- $search_rows[] = array($search_data3->isbn,$search_data3->book,$search_data3->author,l('Download Certificate', 'certificate/generate_pdf/'.$search_data3->id));
- }
- if ($search_rows)
- {
- $search_header = array('ISBN', 'Book Name', 'Author', 'Download Certificates');
- $output = theme_table($search_header, $search_rows);
- return $output;
- }
- else
- {
- echo("Error");
- return '';
- }
- }
- else
- {
- $query3 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid=".$user->uid);
- $data3 = db_fetch_object($query3);
- if($data3)
- {
- drupal_set_message('<strong>Your book is still under Review!</strong>', 'status');
- return '';
- }
- else
- {
- drupal_set_message('<strong>You need to propose a book <a href="/proposal">Book Proposal</a></strong>', 'status');
- return '';
- }
- }
+while ($search_data3 = db_fetch_object($query3))
+{
+$search_rows[] = array($search_data3->isbn,$search_data3->book,$search_data3->author,l('Download Certificate', 'certificate/generate_pdf/'.$search_data3->id));
+}
+if ($search_rows)
+{
+$search_header = array('ISBN', 'Book Name', 'Author', 'Download Certificates');
+$output = theme_table($search_header, $search_rows);
+return $output;
+}
+else
+{
+echo("Error");
+return '';
+}
+}
+else
+{
+$query3 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid=".$user->uid);
+$data3 = db_fetch_object($query3);
+if($data3)
+{
+drupal_set_message('<strong>Your book is still under Review!</strong>', 'status');
+return '';
+}
+else
+{
+drupal_set_message('<strong>You need to propose a book <a href="/proposal">Book Proposal</a></strong>', 'status');
+return '';
+}
+}
//}
-} */
-
+} */
function _list_all_certificates()
+{
+ global $user;
+ $query_id = db_query("SELECT id FROM textbook_companion_proposal WHERE proposal_status=3 AND uid= :uid", array(
+ ':uid' => $user->uid
+ ));
+ $exist_id = $query_id->fetchObject();
+ if ($exist_id->id)
{
- global $user;
- $query_id =db_query("SELECT id FROM textbook_companion_proposal WHERE proposal_status=3 AND uid= :uid", array(':uid' => $user->uid));
- $exist_id = $query_id->fetchObject();
- if($exist_id->id)
+ if ($exist_id->id < 3)
+ {
+ drupal_set_message('<strong>You need to propose a book <a href="/proposal">Book Proposal</a></strong>', 'status');
+ return '';
+ } //$exist_id->id < 3
+ else
{
- if($exist_id->id<3)
+ $search_rows = array();
+ global $output;
+ $output = '';
+ $query3 = db_query("SELECT prop.id,pref.isbn,pref.book,pref.author FROM textbook_companion_proposal as prop,textbook_companion_preference as pref WHERE prop.proposal_status=3 AND pref.approval_status=1 AND pref.proposal_id=prop.id AND prop.uid= :uid", array(
+ ':uid' => $user->uid
+ ));
+ while ($search_data3 = $query3->fetchObject())
{
- drupal_set_message('<strong>You need to propose a book <a href="/proposal">Book Proposal</a></strong>', 'status');
- return '';
- }
- else
+ if ($search_data3->id)
+ {
+ $search_rows[] = array(
+ $search_data3->isbn,
+ $search_data3->book,
+ $search_data3->author,
+ l('Download Certificate', 'certificate/generate_pdf/' . $search_data3->id)
+ );
+ } //$search_data3->id
+ } //$search_data3 = $query3->fetchObject()
+ if ($search_rows)
{
- $search_rows = array();
- global $output;
- $output = '';
- $query3 = db_query("SELECT prop.id,pref.isbn,pref.book,pref.author FROM textbook_companion_proposal as prop,textbook_companion_preference as pref WHERE prop.proposal_status=3 AND pref.approval_status=1 AND pref.proposal_id=prop.id AND prop.uid= :uid",array(':uid' => $user->uid));
- while ($search_data3 = $query3->fetchObject())
- {
- if($search_data3->id)
+ $search_header = array(
+ 'ISBN',
+ 'Book Name',
+ 'Author',
+ 'Download Certificates'
+ );
+ $output = theme('table', array(
+ 'header' => $search_header,
+ 'rows' => $search_rows
+ ));
+ return $output;
+ } //$search_rows
+ else
{
- $search_rows[] = array($search_data3->isbn,$search_data3->book,$search_data3->author,l('Download Certificate', 'certificate/generate_pdf/'.$search_data3->id));
+ echo ("Error");
+ return '';
}
}
- if($search_rows)
- {
- $search_header = array('ISBN', 'Book Name', 'Author', 'Download Certificates');
- $output = theme('table',array('header'=>$search_header, 'rows'=>$search_rows));
- return $output;
- }
- else
- {
- echo("Error");
- return '';
- }
- }
- }
+ } //$exist_id->id
else
{
drupal_set_message('<strong>You need to propose a book <a href="/proposal">Book Proposal</a></strong>', 'status');
- return '';
+ return '';
}
-}
+}
?>