diff options
-rwxr-xr-x | abstract_bulk_approval.inc | 62 | ||||
-rwxr-xr-x | dwsim_flowsheet.module | 2 | ||||
-rwxr-xr-x | general_deletion.inc | 39 | ||||
-rwxr-xr-x | manage_proposal.inc | 64 | ||||
-rwxr-xr-x | pdf/cert_new.inc | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | pdf/images/bg_cert.png | bin | 17983 -> 2857289 bytes | |||
-rw-r--r--[-rwxr-xr-x] | pdf/images/bottom_line.png | bin | 17983 -> 24582 bytes | |||
-rwxr-xr-x | pdf/list_all_form_pdf.inc | 67 | ||||
-rwxr-xr-x | pdf/list_mentor_certificates.inc | 54 | ||||
-rwxr-xr-x | pdf/mentor_cert_pdf.inc | 357 | ||||
-rw-r--r--[-rwxr-xr-x] | pdf/temp_prcode/generated_qrcode.png | bin | 458 -> 448 bytes | |||
-rwxr-xr-x | pdf/temp_prcode/qrcode_name.png | bin | 380 -> 0 bytes | |||
-rwxr-xr-x | proposal.inc | 33 |
13 files changed, 551 insertions, 128 deletions
diff --git a/abstract_bulk_approval.inc b/abstract_bulk_approval.inc index dc6d62f..5a56682 100755 --- a/abstract_bulk_approval.inc +++ b/abstract_bulk_approval.inc @@ -253,36 +253,54 @@ FOSSEE,IIT Bombay', array( if (dwsim_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project'])) ////// { drupal_set_message(t('Dis-Approved and Deleted Entire Flowsheeting project.'), 'status'); - } //dwsim_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project']) - else - { - drupal_set_message(t('Error Dis-Approving and Deleting Entire flowsheeting project.'), 'error'); - } - // email - $email_subject = t('[!site_name][Flowsheeting Project] Your uploaded flowsheeting project have been marked as dis-approved', array( + $email_subject = t('[!site_name][Flowsheeting Project] Your uploaded flowsheeting project have been marked as dis-approved', array( '!site_name' => variable_get('site_name', '') - )); - $email_body = array( + )); + $email_body = array( 0 => t(' -Dear !user_name, + Dear !user_name, -We regret to inform you that your DWSIM flowsheet and abstract with the following details have been disapproved: + We regret to inform you that your DWSIM flowsheet and abstract with the following details have been disapproved: -Full Name: ' . $user_info->name_title . ' ' . $user_info->contributor_name . ' -Project Title: ' . $user_info->project_title . ' -Name of compound for which process development is carried out : ' . $user_info->process_development_compound_name . ' -Reason for dis-approval: ' . $form_state['values']['message'] . ' + Full Name: ' . $user_info->name_title . ' ' . $user_info->contributor_name . ' + Project Title: ' . $user_info->project_title . ' + Name of compound for which process development is carried out : ' . $user_info->process_development_compound_name . ' + Reason for dis-approval: ' . $form_state['values']['message'] . ' -Best Wishes, + Best Wishes, -!site_name Team, -FOSSEE,IIT Bombay', array( - '!site_name' => variable_get('site_name', ''), - '!user_name' => $user_data->name - )) + !site_name Team, + FOSSEE,IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + )) + ); + $email_to = $user_data->mail; + $from = variable_get('dwsim_flowsheet_from_email', ''); + $bcc = variable_get('dwsim_flowsheet_emails', ''); + $cc = variable_get('dwsim_flowsheet_cc_emails', ''); + $params['standard']['subject'] = $email_subject; + $params['standard']['body'] = $email_body; + $params['standard']['headers'] = array( + 'From' => $from, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer' => 'Drupal', + 'Cc' => $cc, + 'Bcc' => $bcc ); - } //$form_state['values']['flowsheet_actions'] == 3 + if (!drupal_mail('dwsim_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE)) + { + drupal_set_message('Error sending email message.', 'error'); + } + } //dwsim_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project']) + else + { + drupal_set_message(t('Error Dis-Approving and Deleting Entire flowsheeting project.'), 'error'); + } + }//$form_state['values']['flowsheet_actions'] == 3 elseif ($form_state['values']['flowsheet_actions'] == 4) { if (strlen(trim($form_state['values']['message'])) <= 30) diff --git a/dwsim_flowsheet.module b/dwsim_flowsheet.module index 43f8f8d..b8fd56b 100755 --- a/dwsim_flowsheet.module +++ b/dwsim_flowsheet.module @@ -864,11 +864,13 @@ function _df_list_of_software_version() } function _df_dir_name($project, $proposar_name) { + $project_title = ucname($project); $proposar_name = ucname($proposar_name); $dir_name = $project_title . ' By ' . $proposar_name; $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name)); return $directory_name; + //return $directory_name; } function dwsim_flowsheet_document_path() { diff --git a/general_deletion.inc b/general_deletion.inc index bbd4c46..fc916c9 100755 --- a/general_deletion.inc +++ b/general_deletion.inc @@ -22,18 +22,15 @@ WHERE dfsa.id = :abstract_id", array( $query->fields('dwsim_flowsheet_submitted_abstracts_file'); $query->condition('submitted_abstract_id', $abstract_id); $abstract_f_q = $query->execute(); - $delete_project_folder = FALSE; + while ($abstract_f_data = $abstract_f_q->fetchObject()) { - $delete_project_folder = TRUE; - if (!_dwsim_flowsheet_delete_abstract_file($abstract_f_data->id)) - $status = FALSE; - } //$abstract_f_data = $abstract_f_q->fetchObject() - if (!$delete_project_folder) - { - return TRUE; - } //!$delete_project_folder - if ($status) + unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath); + + } + //$abstract_f_data = $abstract_f_q->fetchObject() + //!$delete_project_folder + /*if ($status) { $dir_path_udc = $root_path . $abstract_f_data->directory_name . '/user_defined_compound'; if (is_dir($dir_path_udc)) @@ -46,7 +43,7 @@ WHERE dfsa.id = :abstract_id", array( '!folder' => $abstract_f_data->directory_name )), 'error'); /* sending email to admins */ - $email_to = variable_get('dwsim_flowsheet_emails', ''); + /* $email_to = variable_get('dwsim_flowsheet_emails', ''); $from = variable_get('dwsim_flowsheet_from_email', ''); $bcc = ""; $cc = variable_get('dwsim_flowsheet_cc_emails', ''); @@ -70,8 +67,8 @@ WHERE dfsa.id = :abstract_id", array( return TRUE; } } //is_dir($dir_path_udc) - } //$status - return FALSE; + } */ //$status + return True; } function dwsim_flowsheet_abstract_delete_project($proposal_id) { @@ -99,7 +96,6 @@ function dwsim_flowsheet_abstract_delete_project($proposal_id) $status = FALSE; } //!dwsim_flowsheet_delete_abstract_file($abstract_data->id) } //$abstract_data = $abstract_q->fetchObject() - db_delete('dwsim_flowsheet_submitted_abstracts')->condition('proposal_id', $proposal_data->id)->execute(); $dir_path_udc = $root_path . $proposal_data->directory_name . '/user_defined_compound'; if (is_dir($dir_path_udc)) { @@ -107,13 +103,16 @@ function dwsim_flowsheet_abstract_delete_project($proposal_id) $res = rmdir($dir_path_udc); } //is_dir($dir_path_udc) $dir_main_path = $root_path . $proposal_data->directory_name; + //var_dump($dir_main_path);die; if (is_dir($dir_main_path)) { $res_main = rmdir($dir_main_path); } //is_dir($dir_main_path) db_delete('dwsim_flowsheet_proposal')->condition('id', $proposal_data->id)->execute(); + db_delete('dwsim_flowsheet_submitted_abstracts')->condition('proposal_id', $proposal_data->id)->execute(); + db_delete('dwsim_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute(); return $status; -} +}/* function _dwsim_flowsheet_delete_abstract_file($abstract_id) { global $user; @@ -135,7 +134,7 @@ WHERE dfsa.id = :abstract_id", array( return FALSE; } //!$abstract_data /* deleting abstract files */ - $query = db_select('dwsim_flowsheet_submitted_abstracts_file'); + /*$query = db_select('dwsim_flowsheet_submitted_abstracts_file'); $query->fields('dwsim_flowsheet_submitted_abstracts_file'); $query->condition('submitted_abstract_id', $abstract_id); $abstract_f_q = $query->execute(); @@ -150,14 +149,14 @@ WHERE dfsa.id = :abstract_id", array( continue; } //!file_exists($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath) /* removing solution file */ - if (!unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath)) + /* if (!unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath)) { $status = FALSE; drupal_set_message(t('Error deleting !file', array( '!file' => $abstract_data->directory_name . '/' . $abstract_f_data->filepath )), 'error'); /* sending email to admins */ - $from = variable_get('dwsim_flowsheet_from_email', ''); + /* $from = variable_get('dwsim_flowsheet_from_email', ''); $bcc = variable_get('dwsim_flowsheet_emails', ''); $cc = variable_get('dwsim_flowsheet_cc_emails', ''); $params['standard']['subject'] = "[ERROR] Error deleting example file"; @@ -179,8 +178,8 @@ WHERE dfsa.id = :abstract_id", array( else { /* deleting example files database entries */ - db_delete('dwsim_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute(); - } + //db_delete('dwsim_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute(); +/* } } //$abstract_f_data = $abstract_f_q->fetchObject() if (!$status) { diff --git a/manage_proposal.inc b/manage_proposal.inc index 7f0f7cf..daa846c 100755 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -803,6 +803,12 @@ function dwsim_flowsheet_proposal_edit_form($form, &$form_state) '#title' => t('Email'), '#markup' => $user_data->mail ); + $form['contributor_contact_no'] = array( + '#type' => 'textfield', + '#title' => t('Contact No.'), + '#size' => 10, + '#default_value' => $proposal_data->contact_no + ); $form['month_year_of_degree'] = array( '#type' => 'date_popup', '#title' => t('Month and year of award of degree'), @@ -811,20 +817,34 @@ function dwsim_flowsheet_proposal_edit_form($form, &$form_state) '#default_value' => $proposal_data->month_year_of_degree, '#date_format' => 'M-Y', '#date_increment' => 0, - '#date_year_range' => '1960:+0', - '#datepicker_options' => array( - 'maxDate' => 0 - ), - '#required' => TRUE + '#date_year_range' => '1960:+22', ); $form['university'] = array( '#type' => 'textfield', '#title' => t('University/Institute'), '#size' => 80, '#maxlength' => 200, - '#required' => TRUE, '#default_value' => $proposal_data->university ); + $form['project_guide_name'] = array( + '#type' => 'textfield', + '#title' => t('Project guide'), + '#size' => 250, + '#default_value' => $proposal_data->project_guide_name + ); + $form['project_guide_email_id'] = array( + '#type' => 'textfield', + '#title' => t('Project guide email'), + '#size' => 30, + '#default_value' => $proposal_data->project_guide_email_id + ); + $form['project_guide_university'] = array( + '#type' => 'textfield', + '#title' => t('Project Guide University/ Institute'), + '#size' => 80, + '#maxlength' => 200, + '#default_value' => $proposal_data->project_guide_university + ); $form['country'] = array( '#type' => 'select', '#title' => t('Country'), @@ -935,9 +955,21 @@ function dwsim_flowsheet_proposal_edit_form($form, &$form_state) '#title' => t('Reference of the Flowsheet Project'), '#size' => 300, '#maxlength' => 350, - '#required' => TRUE, '#default_value' => $proposal_data->reference ); + $form['process_development_compound_name'] = array( + '#type' => 'textfield', + '#title' => t('Name of compound for which process development is carried out'), + '#size' => 50, + '#default_value' => $proposal_data->process_development_compound_name + ); + $form['process_development_compound_cas_no'] = array( + '#type' => 'textfield', + '#title' => t('CAS number for compound which process development is carried out'), + '#size' => 50, + '#default_value' => $proposal_data->process_development_compound_cas_number + + ); $form['delete_proposal'] = array( '#type' => 'checkbox', '#title' => t('Delete Proposal') @@ -1012,12 +1044,12 @@ function dwsim_flowsheet_proposal_edit_form_submit($form, &$form_state) if ($form_state['values']['delete_proposal'] == 1) { /* sending email */ - $email_to = $user->mail; + $email_to = $user_data->mail; $from = variable_get('dwsim_flowsheet_from_email', ''); $bcc = variable_get('dwsim_flowsheet_emails', ''); $cc = variable_get('dwsim_flowsheet_cc_emails', ''); $params['dwsim_flowsheet_proposal_deleted']['proposal_id'] = $proposal_id; - $params['dwsim_flowsheet_proposal_deleted']['user_id'] = $user->uid; + $params['dwsim_flowsheet_proposal_deleted']['user_id'] = $proposal_data->uid; //$params['dwsim_flowsheet_proposal_deleted']['file_name'] = $_FILES['files']['name'][$file_form_name]; $params['dwsim_flowsheet_proposal_deleted']['headers'] = array( 'From' => $from, @@ -1069,7 +1101,13 @@ function dwsim_flowsheet_proposal_edit_form_submit($form, &$form_state) state=:state, project_title=:project_title, reference=:reference, - directory_name=:directory_name + directory_name=:directory_name, + project_guide_university=:project_guide_university, + project_guide_email_id=:project_guide_email_id, + project_guide_name=:project_guide_name, + month_year_of_degree=:month_year_of_degree, + process_development_compound_name=:process_development_compound_name, + process_development_compound_cas_number=:process_development_compound_cas_number WHERE id=:proposal_id"; $args = array( ':name_title' => $v['name_title'], @@ -1082,6 +1120,12 @@ function dwsim_flowsheet_proposal_edit_form_submit($form, &$form_state) ':project_title' => $project_title, ':reference' => $v['reference'], ':directory_name' => $directory_name, + ':project_guide_university' => $v['project_guide_university'], + ':project_guide_email_id' => $v['project_guide_email_id'], + ':project_guide_name' => $v['project_guide_name'], + ':month_year_of_degree' => $v['month_year_of_degree'], + ':process_development_compound_name' => $v['process_development_compound_name'], + ':process_development_compound_cas_number' => $v['process_development_compound_cas_no'], ':proposal_id' => $proposal_id ); $result = db_query($query, $args); diff --git a/pdf/cert_new.inc b/pdf/cert_new.inc index ca5b46e..5c0dc1b 100755 --- a/pdf/cert_new.inc +++ b/pdf/cert_new.inc @@ -2,6 +2,7 @@ function generate_pdf() { $mpath = drupal_get_path('module', 'dwsim_flowsheet'); + //var_dump($mpath);die; require($mpath . '/pdf/fpdf/fpdf.php'); require($mpath . '/pdf/phpqrcode/qrlib.php'); global $user; diff --git a/pdf/images/bg_cert.png b/pdf/images/bg_cert.png Binary files differindex 478dc8e..22567f0 100755..100644 --- a/pdf/images/bg_cert.png +++ b/pdf/images/bg_cert.png diff --git a/pdf/images/bottom_line.png b/pdf/images/bottom_line.png Binary files differindex 478dc8e..5faea6b 100755..100644 --- a/pdf/images/bottom_line.png +++ b/pdf/images/bottom_line.png diff --git a/pdf/list_all_form_pdf.inc b/pdf/list_all_form_pdf.inc deleted file mode 100755 index e05924f..0000000 --- a/pdf/list_all_form_pdf.inc +++ /dev/null @@ -1,67 +0,0 @@ -<?php -//Used to generate forms dynamiclay -function _list_all_copyright_forms() -{ - 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 <a href="http://dwsim.fossee.in/textbook-companion/proposal">Book Proposal</a></strong> or if you have already proposed then your book is under reviewing process', 'status'); - return ''; - } //$exist_id->id < 3 - else - { - $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_rows[] = array( - $search_data3->isbn, - $search_data3->book, - $search_data3->author, - l('Download Copyright Form', 'Summer_Internship_Forms/copyright-form/generate_pdf/' . $search_data3->id), - l('Download Undertaking Form', 'Summer_Internship_Forms/undertaking-form/generate_pdf/' . $search_data3->id) - ); - } //$search_data3->id - } //$search_data3 = $query3->fetchObject() - if ($search_rows) - { - $search_header = array( - 'ISBN', - 'Book Name', - 'Author', - 'Download Copyright Form', - 'Download Undertaking Form' - ); - $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('<strong>You need to propose a book <a href="http://dwsim.fossee.in/textbook-companion/proposal">Book Proposal</a></strong> or if you have already proposed then your book is under reviewing process', 'status'); - return ''; - } -} - - diff --git a/pdf/list_mentor_certificates.inc b/pdf/list_mentor_certificates.inc new file mode 100755 index 0000000..f06efad --- /dev/null +++ b/pdf/list_mentor_certificates.inc @@ -0,0 +1,54 @@ +<?php +function _list_flowsheet_custom_certificates() +{ + global $user; + $query_id = db_query("SELECT id FROM dwsim_flowsheet_proposal WHERE approval_status=3"); + $exist_id = $query_id->fetchObject(); + if ($exist_id){ + if ($exist_id->id) { + if ($exist_id->id < 3) { + drupal_set_message('<strong>You need to propose a flowsheet <a href="http://dwsim.fossee.in/flowsheeting-project/proposal">Flowsheet Proposal</a></strong> 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_title FROM dwsim_flowsheet_proposal WHERE project_guide_name != '' 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', 'flowsheeting-project/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('<strong>You need to propose a flowsheet <a href="http://dwsim.fossee.in/flowsheeting-project/proposal">Flowsheet Proposal</a></strong> or if you have already proposed then your flowsheet is under reviewing process', 'status'); + $page_content = "<span style='color:red;'> No certificate available </span>"; + return $page_content; + } +} diff --git a/pdf/mentor_cert_pdf.inc b/pdf/mentor_cert_pdf.inc new file mode 100755 index 0000000..9e097eb --- /dev/null +++ b/pdf/mentor_cert_pdf.inc @@ -0,0 +1,357 @@ +<?php +function generate_pdf() +{ + $mpath = drupal_get_path('module', 'dwsim_flowsheet'); + require($mpath . '/pdf/fpdf/fpdf.php'); + require($mpath . '/pdf/phpqrcode/qrlib.php'); + global $user; + $x = $user->uid; + $proposal_id = arg(3); + $query3 = db_query("SELECT * FROM dwsim_flowsheet_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.png"; + $pdf->Image($image_bg, 0, 0, $pdf->w, $pdf->h); + $pdf->SetMargins(18, 1, 18); + $path = drupal_get_path('module', 'dwsim_flowsheet'); + $pdf->Ln(15); + $pdf->Ln(20); + $pdf->SetFont('Arial', 'BI', 25); + $pdf->Ln(26); + $pdf->SetFont('Arial', 'BI', 12); + $pdf->SetTextColor(0, 0, 0); + $pdf->Cell(240, 20, 'This certificate recognizes the valuable mentorship of', '0', '1', 'C'); + $pdf->Ln(-6); + $pdf->SetFont('Arial', 'BI', 25); + $pdf->SetTextColor(139, 69, 19); + $pdf->Cell(240, 8, $data3->project_guide_name, '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Arial', 'I', 12); + if (strtolower($data3->branch) != "others") { + $pdf->SetTextColor(0, 0, 0); + $pdf->MultiCell(240, 8, 'from ' . $data3->project_guide_university, '0','C'); + $pdf->Ln(0); + $pdf->Cell(240, 8, 'who has mentored', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->Cell(240, 8, $data3->contributor_name, '0', '1', 'C'); + $pdf->Ln(0); + $pdf->Cell(240, 8, 'for successfully completing internship under the DWSIM Flowsheeting project. The intern(s) has created a flowsheet titled', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetTextColor(139, 69, 19); + $pdf->Cell(240, 8, $data3->project_title, '0', '1', 'C'); + $pdf->SetTextColor(0, 0, 0); + $pdf->Ln(0); + $pdf->Cell(240, 8, ' using DWSIM .The work done is available at', '0', '1', 'C'); + $pdf->Cell(240, 4, '', '0', '1', 'C'); + $pdf->SetX(120); + $pdf->SetFont('', 'U'); + $pdf->SetTextColor(139, 69, 19); + $pdf->write(0, 'https://dwsim.fossee.in/', 'https://dwsim.fossee.in/'); + $pdf->Ln(0); + } + else { + $pdf->SetTextColor(0, 0, 0); + $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('dwsim_flowsheet_qr_code'); + $query->fields('dwsim_flowsheet_qr_code'); + $query->condition('proposal_id', $proposal_id); + $result = $query->execute(); + $data = $result->fetchObject(); + $DBString = $data->custom_qr_code; + $qrstring = $data->qr_code; + $proposal_get_id = $data->proposal_id; + if ($DBString == "" || $DBString == "null") { + $UniqueString = generateRandomString(); + $query = "UPDATE dwsim_flowsheet_qr_code SET custom_qr_code = :custom_qr_code WHERE proposal_id = :proposal_id"; + $args = array( + ":proposal_id" => $proposal_id, + ":custom_qr_code" => $UniqueString + ); + $result = db_query($query, $args, array( + 'return' => Database::RETURN_INSERT_ID + )); + } //$DBString == "" || $DBString == "null" + else { + $UniqueString = $DBString; + } + $codeContents = 'http://dwsim.fossee-dell/flowsheeting-project/certificates/verify/' . $qrstring; + $fileName = 'generated_qrcode.png'; + $pngAbsoluteFilePath = $tempDir . $fileName; + $urlRelativeFilePath = $path . "/pdf/temp_prcode/" . $fileName; + QRcode::png($codeContents, $pngAbsoluteFilePath); + $pdf->SetTextColor(0, 0, 0); + $pdf->Ln(30); + $pdf->SetX(198); + $pdf->SetFont('', ''); + $pdf->SetTextColor(0, 0, 0); + $pdf->SetY(-85); + $pdf->SetX(200); + $pdf->Ln(16); + $pdf->Cell(240, 8, 'Prof. Kannan M. Moudgalya', 0, 1, 'R'); + $pdf->SetX(199); + $pdf->SetFont('Arial', '', 10); + $pdf->Cell(0, 7, 'Co - Principal Investigator - FOSSEE', 0, 1, 'L'); + $pdf->SetX(190); + $pdf->Cell(0, 7, ' Dept. of Chemical Engineering, IIT Bombay.', 0, 1, 'L'); + $pdf->SetX(29); + $pdf->SetFont('Arial', 'B', 10); + $pdf->SetY(-58); + $pdf->Ln(14); + $pdf->SetX(10); + $pdf->Cell(0, 0, $UniqueString, 0, 0, 'C'); + $pdf->SetX(29); + $pdf->SetY(-50); + $image4 = $path . "/pdf/images/verify_content.png"; + $pdf->SetY(-50); + $pdf->SetX(80); + $image3 = $path . "/pdf/images/iitb.png"; + $image2 = $path . "/pdf/images/fossee.png"; + $pdf->Ln(8); + $pdf->Image($image2, $pdf->GetX() +15, $pdf->GetY() + 7, 40, 0); + $pdf->Ln(6); + $pdf->Image($pngAbsoluteFilePath, $pdf->GetX() + 102, $pdf->GetY() - 5, 30, 0); + $pdf->Image($image3, $pdf->GetX() + 200, $pdf->GetY() -3, 15, 0); + $pdf->Image($image4, $pdf->GetX() +50, $pdf->GetY() + 28, 150, 0); + $pdf->SetFont('Arial', 'I', 8); + $pdf->SetTextColor(0, 0, 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', 'dwsim_flowsheet'); + require($mpath . '/pdf/fpdf/fpdf.php'); + global $user; + $x = $user->uid; + $proposal_id = arg(3); + $query2 = db_query("SELECT id FROM dwsim_flowsheet_proposal WHERE approval_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $data2 = $query2->fetchObject(); + $query3 = db_query("SELECT * FROM dwsim_flowsheet_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', 'dwsim_flowsheet'); + $pdf->SetFont('Arial', 'B', 25); + $pdf->Ln(30); + $pdf->Cell(200, 8, 'Copyright Transfer Form', 0, 1, 'C'); + $pdf->Ln(20); + $pdf->SetFont('Arial', '', 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 dwsim_flowsheet_proposal WHERE approval_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $data2 = $query2->fetchObject(); + $query3 = db_query("SELECT * FROM dwsim_flowsheet_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', 'dwsim_flowsheet'); + $pdf->SetFont('Arial', 'B', 25); + $pdf->Ln(30); + $pdf->Cell(200, 8, 'Undertaking Form', 0, 1, 'C'); + $pdf->Ln(0); + $pdf->SetFont('Arial', 'B', 10); + $pdf->Cell(200, 8, '(To be signed by college teacher)', 0, 1, 'C'); + $pdf->Ln(20); + $pdf->SetFont('Arial', '', 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; +} diff --git a/pdf/temp_prcode/generated_qrcode.png b/pdf/temp_prcode/generated_qrcode.png Binary files differindex c9f4da7..3b7a13a 100755..100644 --- a/pdf/temp_prcode/generated_qrcode.png +++ b/pdf/temp_prcode/generated_qrcode.png diff --git a/pdf/temp_prcode/qrcode_name.png b/pdf/temp_prcode/qrcode_name.png Binary files differdeleted file mode 100755 index 0e88581..0000000 --- a/pdf/temp_prcode/qrcode_name.png +++ /dev/null diff --git a/proposal.inc b/proposal.inc index 9d9dec8..22bcc53 100755 --- a/proposal.inc +++ b/proposal.inc @@ -103,10 +103,8 @@ function dwsim_flowsheet_proposal_form($form, &$form_state, $no_js_use = FALSE) '#default_value' => '', '#date_format' => 'M-Y', '#date_increment' => 0, - '#date_year_range' => '1960:+0', - '#datepicker_options' => array( - 'maxDate' => 0 - ), + '#date_year_range' => '1960: +22', + '#required' => TRUE ); $form['contributor_email_id'] = array( @@ -116,6 +114,16 @@ function dwsim_flowsheet_proposal_form($form, &$form_state, $no_js_use = FALSE) '#value' => $user->mail, '#disabled' => TRUE ); + $form['university'] = array( + '#type' => 'textfield', + '#title' => t('University/ Institute'), + '#size' => 80, + '#maxlength' => 200, + '#required' => TRUE, + '#attributes' => array( + 'placeholder' => 'Insert full name of your institute/ university.... ' + ) + ); $form['project_guide_name'] = array( '#type' => 'textfield', '#title' => t('Project guide'), @@ -130,14 +138,13 @@ function dwsim_flowsheet_proposal_form($form, &$form_state, $no_js_use = FALSE) '#title' => t('Project guide email'), '#size' => 30 ); - $form['university'] = array( + $form['project_guide_university'] = array( '#type' => 'textfield', - '#title' => t('University/ Institute'), + '#title' => t('Project Guide University/ Institute'), '#size' => 80, '#maxlength' => 200, - '#required' => TRUE, '#attributes' => array( - 'placeholder' => 'Insert full name of your institute/ university.... ' + 'placeholder' => 'Insert full name of the institute/ university of your project guide.... ' ) ); $form['country'] = array( @@ -514,7 +521,11 @@ function dwsim_flowsheet_proposal_form_validate($form, &$form_state) else if (strlen($form_state['values']['project_title']) < 10) { form_set_error('project_title', t('Minimum charater limit is 10 charaters, please check the length of the project title')); - } //strlen($form_state['values']['project_title']) < 10 + + } + else if(preg_match('/[\/^£$%&*()}{@#~?><>,|=_+¬]/', $form_state['values']['project_title'])) + form_set_error('project_title', t('Special characters aree not allowed for project title')); + //strlen($form_state['values']['project_title']) < 10 } //$form_state['values']['project_title'] != '' else { @@ -637,6 +648,7 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) version, project_guide_name, project_guide_email_id, + project_guide_university, project_title, process_development_compound_name, process_development_compound_cas_number, @@ -666,6 +678,7 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) :version, :project_guide_name, :project_guide_email_id, + :project_guide_university, :project_title, :process_development_compound_name, :process_development_compound_cas_number, @@ -695,6 +708,7 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) ":version" => $v['version'], ":project_guide_name" => _df_sentence_case($v['project_guide_name']), ":project_guide_email_id" => trim($v['project_guide_email_id']), + ":project_guide_university" => trim($v['project_guide_university']), ":project_title" => _df_sentence_case($v['project_title']), ":process_development_compound_name" => _df_sentence_case($v['process_development_compound_name']), ":process_development_compound_cas_number" => $v['process_development_compound_cas_no'], @@ -747,6 +761,7 @@ function dwsim_flowsheet_proposal_form_submit($form, &$form_state) $dest_path2 = 'user_defined_compound/'; $dest_path = $dest_path1 . 'user_defined_compound/'; $db_path = 'user_defined_compound/'; + //var_dump($root_path . $dest_path1);die; if (!is_dir($root_path . $dest_path1)) mkdir($root_path . $dest_path1); if (!is_dir($root_path . $dest_path)) |