Esempio n. 1
0
 function create_pdf($load_id, $bol_number, $pages_number, $doc_type, $json = null)
 {
     $this->load->model('shipment_model');
     if (!$load_id) {
         $load_id = $this->input->post('load_id');
     }
     if (!$bol_number) {
         $bol_number = $this->input->post('bol_number');
     }
     if (!$pages_number) {
         $pages_number = $this->input->post('pages_number');
     }
     if (!$doc_type) {
         $doc_type = $this->input->post('doc_type');
     }
     $shipments = $this->shipment_model->get(['bol_number' => $bol_number]);
     $shipment = $shipments[0];
     if ($doc_type == 'sp') {
         $pages_number = $shipment['pickup_doc_pages'];
     }
     if ($doc_type == 'cs') {
         $pages_number = $shipment['drop_doc_pages'];
     }
     include '../testserver/MPDF53/mpdf.php';
     $mpdf = new mPDF();
     for ($i = 1; $i <= $pages_number; $i++) {
         $mpdf->WriteHTML('');
         if (file_exists(CONT_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '-' . $i . '.jpg')) {
             $mpdf->Image(CONT_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '-' . $i . '.jpg', 0, 0, 210, 297, 'jpg', '', true, false);
             if ($i < $pages_number) {
                 $mpdf->AddPage();
             }
         }
     }
     $url = CONT_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '.pdf';
     $url_view = VIEW_FILE_PATH . $load_id . '_bol_' . $bol_number . '_' . $doc_type . '.pdf';
     $mpdf->Output($url, 'F');
     if ($json) {
         $this->output->set_output(json_encode(['status' => 1, 'url' => $url_view]));
     }
 }
Esempio n. 2
0
<h4>Little Women - Chapter One - Playing Pilgrims</h4>

<p> Christmas won\'t be Christmas without any presents,  grumbled Jo, lying on the rug.</p><p> It\'s so dreadful to be poor!  sighed Meg, looking down at her old dress.</p><p> I don\'t think it\'s fair for some girls to have plenty of pretty things, and other girls nothing at all,  added little Amy, with an injured sniff.</p><p> We\'ve got Father and Mother, and each other,  said Beth contentedly from her corner.</p><p>The four young faces on which the firelight shone brightened at the cheerful words, but darkened again as Jo said sadly,  We haven\'t got Father, and shall not have him for a long time.  She didn\'t say  perhaps never,  but each silently added it, thinking of Father far away, where the fighting was.</p><p>Nobody spoke for a minute; then Meg said in an altered tone,  You know the reason Mother proposed not having any presents this Christmas was because it is going to be a hard winter for everyone; and she thinks we ought not to spend money for pleasure, when our men are suffering so in the army. We can\'t do much, but we can make our little sacrifices, and ought to do it gladly. But I am afraid I don\'t  And Meg shook her head, as she thought regretfully of all the pretty things she wanted.</p><p> But I don\'t think the little we should spend would do any good. We\'ve each got a dollar, and the army wouldn\'t be much helped by our giving that. I agree not to expect anything from Mother or you, but I do want to buy UNDINE AND SINTRAM for myself. I\'ve wanted it so long,  said Jo, who was a bookworm.</p><p> I planned to spend mine in new music,  said Beth, with a little sigh, which no one heard but the hearth brush and kettle holder.</p><p> I shall get a nice box of Faber\'s drawing pencils. I really need them,  said Amy decidedly.</p><p> Mother didn\'t say anything about our money, and she won\'t wish us to give up everything. Let\'s each buy what we want, and have a little fun. I\'m sure we work hard enough to earn it,  cried Jo, examining the heels of her shoes in a gentlemanly manner.</p><p> I know I do&mdash;teaching those tiresome children nearly all day, when I\'m longing to enjoy myself at home,  began Meg, in the complaining tone again.</p><p> You don\'t have half such a hard time as I do,  said Jo.  How would you like to be shut up for hours with a nervous, fussy old lady, who keeps you trotting, is never satisfied, and worries you till you you\'re ready to fly out the window or cry? </p><p> It\'s naughty to fret, but I do think washing dishes and keeping things tidy is the worst work in the world.  It makes me cross, and my hands get so stiff, I can\'t practice well at all.  And Beth looked at her rough hands with a sigh that any one could hear that time.</p><p> I don\'t believe any of you suffer as I do,  cried Amy,  for you don\'t have to go to school with impertinent girls, who plague you if you don\'t know your lessons, and laugh at your dresses, and label your father if he isn\'t rich, and insult you when your nose isn\'t nice. </p><p> If you mean libel, I\'d say so, and not talk about labels, as if Papa was a pickle bottle,  advised Jo, laughing.</p><p> I know what I mean, and you needn\'t be satirical about it. It\'s proper to use good words, and improve your vocabulary,  returned Amy, with dignity.</p><p> Don\'t peck at one another, children. Don\'t you wish we had the money Papa lost when we were little, Jo? Dear me! How happy and good we\'d be, if we had no worries!  said Meg, who could remember better times.</p><p> You said the other day you thought we were a deal happier than the King children, for they were fighting and fretting all the time, in spite of their money. </p><p> So I did, Beth. Well, I think we are. For though we do have to work, we make fun of ourselves, and are a pretty jolly set, as Jo would say. </p><p> Jo does use such slang words!   observed Amy, with a reproving look at the long figure stretched on the rug.</p><p>Jo immediately sat up, put her hands in her pockets, and began to whistle.</p><p> Don\'t, Jo. It\'s so boyish! </p><p> That\'s why I do it. </p><p> I detest rude, unladylike girls! </p><p> I hate affected, niminy-piminy chits! </p><p> Birds in their little nests agree,  sang Beth, the peacemaker, with such a funny face that both sharp voices softened to a laugh, and the  pecking  ended for that time.</p><p> Really, girls, you are both to be blamed,  said Meg, beginning to lecture in her elder-sisterly fashion. You are old enough to leave off boyish tricks, and to behave better, Josephine. It didn\'t matter so much when you were a little girl, but now you are so tall, and turn up your hair, you should remember that you are a young lady. </p><p> I\'m not!  And if turning up my hair makes me one, I\'ll wear it in two tails till I\'m twenty,  cried Jo, pulling off her net, and shaking down a chestnut mane.   I hate to think I\'ve got to grow up, and be Miss March, and wear long gowns, and look as prim as a China Aster! It\'s bad enough to be a girl, anyway, when I like boy\'s games and work and manners! I can\'t get over my disappointment in not being a boy. And it\'s worse than ever now, for I\'m dying to go and fight with Papa. And I can only stay home and knit, like a poky old woman! </p><p>And Jo shook the blue army sock till the needles rattled like castanets, and her ball bounded across the room.</p><p> Poor Jo! It\'s too bad, but it can\'t be helped. So you must try to be contented with making your name boyish, and playing brother to us girls,  said Beth, stroking the rough head with a hand that all the dish washing and dusting in the world could not make ungentle in its touch.</p><p> As for you, Amy,  continued Meg,  you are altogether to particular and prim. Your airs are funny now, but you\'ll grow up an affected little goose, if you don\'t take care. I I like your nice manners and refined ways of speaking, when you don\'t try to be elegant. But your absurd words are as bad as Jo\'s slang. </p><p> If Jo is a tomboy and Amy a goose, what am I, please?  asked Beth, ready to share the lecture.</p><p> You\'re a dear, and nothing else,  answered Meg warmly, and no one contradicted her, for the \'Mouse\' was the pet of the family.</p>

</body></html>';
//==============================================================
//==============================================================
//==============================================================
include "../mpdf.php";
$mpdf = new mPDF('', 'A4', '', '', 32, 25, 27, 25, 16, 13);
$mpdf->mirrorMargins = 1;
$mpdf->SetDisplayMode('fullpage', 'two');
$mpdf->useOnlyCoreFonts = true;
$mpdf->defaultfooterfontsize = 13;
$mpdf->AddPage();
$mpdf->Image('clematis.jpg', 0, 0, 210, 297, 'jpg', '', true, false);
// e.g. the last "false" allows a full page picture
$mpdf->y = 70;
$mpdf->Shaded_box('mPDF Example File', 'Arial', '', 28, '70%', 'DF', 3, '#FFFFFF', '#000044', 10);
$mpdf->AddPage();
$mpdf->SetFooter('{PAGENO}');
$mpdf->WriteHTML($html);
$mpdf->AddPage('', 'NEXT-EVEN');
$mpdf->SetFooter();
$mpdf->SetAlpha(0.5);
$mpdf->Image('clematis.jpg', 0, 0, 210, 297, 'jpg', '', true, false);
// e.g. the last "false" allows a full page picture
$mpdf->SetAlpha(1);
$mpdf->writeBarcode('978-0-9542246-0-8', 1, 130, 230, 1, 0, 3, 3, 4, 4);
// Save the pages to a file
$mpdf->Output('test.pdf', 'F');
Esempio n. 3
0
 $sel_sql .= ' AND tpl_id = :tpl_id AND y BETWEEN :page_top AND :page_bottom';
 $results = R::getAll($sel_sql, array(':tpl_id' => $tpl_id, ':page_top' => $page_top, ':page_bottom' => $page_bottom));
 foreach ($results as $form) {
     $valName = 'input_' . $form['form_id'];
     $sql = getSQLBaseForValList();
     $sql .= " AND val_name = :val_name";
     $sql .= " LIMIT 1";
     $row = R::getRow($sql, array(':file_id' => $file_id, ':val_name' => $valName));
     if ($row) {
         if ($schema_type == $SCHEMA_TYPE_SRC) {
             //pixel→mm変換
             $vertical_mm = round(($form['y'] - $page_top) / $convertUnit * $mm_per_inch);
             $horizontal_mm = round($form['x'] / $convertUnit * $mm_per_inch);
             if ($form['type'] == 'checkbox') {
                 if ($row['value'] == 'on') {
                     $mpdf->Image(\Sop\Resource::getImageFilePath('checkbox_on.png'), $horizontal_mm - 2, $vertical_mm - 2.4, 3, 3, 'png');
                 } else {
                     $mpdf->Image(\Sop\Resource::getImageFilePath('checkbox_off.png'), $horizontal_mm - 2, $vertical_mm - 2.4, 3, 3, 'png');
                 }
             } else {
                 $width_mm = round($form['width'] / $convertUnit * $mm_per_inch);
                 $height_mm = \Sop\Constant::PDF_MULTICELL_RIGHT;
                 //一行の高さ
                 $mpdf->SetXY($horizontal_mm, $vertical_mm);
                 $mpdf->MultiCell($width_mm, $height_mm, $row['value'], 0);
             }
         }
     }
 }
 if ($schema_type == $SCHEMA_TYPE_SRC) {
     $mark_position_x = 1150;
Esempio n. 4
-1
 function savepdfcertificate()
 {
     $datac = JRequest::get('post', JREQUEST_ALLOWRAW);
     include JPATH_SITE . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurutask.php';
     $background_color = "";
     $op = JRequest::getVar("op", "");
     if ($op == 9) {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $config = JFactory::getConfig();
         $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
         $db->setQuery($imagename);
         $db->query();
         $imagename = $db->loadAssocList();
         if ($imagename[0]["design_background"] != "") {
             $image_theme = explode("/", $imagename[0]["design_background"]);
             if (trim($image_theme[4]) == 'thumbs') {
                 $image_theme = $image_theme[5];
             } else {
                 $image_theme = $image_theme[4];
             }
         } else {
             $background_color = "background-color:" . "#" . $imagename[0]["design_background_color"];
         }
         $site_url = JURI::root();
         $coursename = JRequest::getVar('cn', '', 'get');
         $authorname = JRequest::getVar('an', '', 'get');
         $certificateid = JRequest::getVar('id', '', 'get');
         $completiondate = JRequest::getVar('cd', '', 'get');
         $course_id = JRequest::getVar('ci', '', 'get');
         $sitename = $config->get('sitename');
         $user_id = $user->id;
         $scores_avg_quizzes = @guruModelguruTask::getAvgScoresQ($user_id, $course_id);
         $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($avg_quizzes_cert);
         $db->query();
         $avg_quizzes_cert = $db->loadResult();
         $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $result = $db->loadResult();
         $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $resulthasq = $db->loadResult();
         $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
         $db->setQuery($sql);
         $result_maxs = $db->loadResult();
         // final quiz --------------------------------------------------
         $sql = "SELECT id, score_quiz FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
         $db->setQuery($sql);
         $result_q = $db->loadObject();
         $first = explode("|", @$result_q->score_quiz);
         @($res = intval($first[0] / $first[1] * 100));
         if ($resulthasq == 0 && $scores_avg_quizzes == "") {
             $avg_certc = "N/A";
         } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
             $avg_certc = "N/A";
         } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
             if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
                 $avg_certc = $scores_avg_quizzes . '%';
             } else {
                 $avg_certc = $scores_avg_quizzes . '%';
             }
         }
         // final quiz --------------------------------------------------
         // regular ----------------------------------------------
         $s = 0;
         $sql = "select mr.`media_id` from #__guru_mediarel mr, #__guru_days d where mr.`type`='dtask' and mr.`type_id`=d.`id` and d.`pid`=" . intval($course_id);
         $db->setQuery($sql);
         $db->query();
         $lessons = $db->loadColumn();
         if (!isset($lessons) || count($lessons) == 0) {
             $lessons = array("0");
         }
         $sql = "select mr.`media_id` from #__guru_mediarel mr where mr.`layout`='12' and mr.`type`='scr_m' and mr.`type_id` in (" . implode(", ", $lessons) . ")";
         $db->setQuery($sql);
         $db->query();
         $all_quizzes = $db->loadColumn();
         if (isset($all_quizzes) && count($all_quizzes) > 0) {
             foreach ($all_quizzes as $key_quiz => $quiz_id) {
                 $sql = "SELECT score_quiz FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($quiz_id) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
                 $db->setQuery($sql);
                 $db->query();
                 $result_q = $db->loadColumn();
                 $res = @$result_q["0"];
                 $s += $res;
             }
             $avg_certc1 = "N/A";
             if ($s > 0) {
                 $avg_certc1 = $s / count($all_quizzes) . "%";
             }
         }
         // regular ----------------------------------------------
         /*$sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken_v3 WHERE user_id=".intval($user_id)." and quiz_id=".intval($result)." and pid=".intval($course_id )." ORDER BY id DESC LIMIT 0,1";
         			$db->setQuery($sql);
         			$result_q = $db->loadObject();
         	
         			$first= explode("|", @$result_q->score_quiz);
         	
         			@$res = intval(($first[0]/$first[1])*100);
         	
         			if($resulthasq == 0 && $scores_avg_quizzes == ""){
         				$avg_certc1 = "N/A";
         			}
         			elseif($resulthasq != 0 && $scores_avg_quizzes == ""){
         				$avg_certc1 = "N/A";
         			}
         			elseif($resulthasq != 0 && isset($scores_avg_quizzes)){
         				if($scores_avg_quizzes >= intval($avg_quizzes_cert)){
         					$avg_certc1 =  $scores_avg_quizzes.'%'; 
         				}
         				else{
         					$avg_certc1 = $scores_avg_quizzes.'%';
         				}
         			}*/
         /*if($result !=0 && $res !="" ){
         			if( $res >= $result_maxs){
         				$avg_certc = $res.'%';
         			}
         			elseif($res < $result_maxs){
         				$avg_certc = $res.'%';
         			}
         		}
         		elseif(($result !=0 && $result !="")){
         			$avg_certc = "N/A";
         		}
         		elseif($result ==0 || $result ==""){
         			$avg_certc = "N/A";
         		}*/
         $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
         $db->setQuery($firstnamelastname);
         $db->query();
         $firstnamelastname = $db->loadAssocList();
         $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($coursemsg);
         $db->query();
         $coursemsg = $db->loadResult();
         $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid;
         $certificate_url = str_replace(" ", "%20", $certificate_url);
         $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
         while (ob_get_level()) {
             ob_end_clean();
         }
         header("Content-Encoding: None", true);
         if (strlen($imagename[0]["design_text_color"]) == 3) {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 1) . substr($imagename[0]["design_text_color"], 0, 1));
             $g = hexdec(substr($imagename[0]["design_text_color"], 1, 1) . substr($imagename[0]["design_text_color"], 1, 1));
             $b = hexdec(substr($imagename[0]["design_text_color"], 2, 1) . substr($imagename[0]["design_text_color"], 2, 1));
         } else {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 2));
             $g = hexdec(substr($imagename[0]["design_text_color"], 2, 2));
             $b = hexdec(substr($imagename[0]["design_text_color"], 4, 2));
         }
         $background_color = explode(":", $background_color);
         @($background_color[1] = str_replace("#", "", $background_color[1]));
         if (strlen($background_color[1]) == 3) {
             $rg = hexdec(substr($background_color[1], 0, 1) . substr($background_color[1], 0, 1));
             $gg = hexdec(substr($background_color[1], 1, 1) . substr($background_color, 1, 1));
             $bg = hexdec(substr($background_color[1], 2, 1) . substr($background_color[1], 2, 1));
         } else {
             $rg = hexdec(substr($background_color[1], 0, 2));
             $gg = hexdec(substr($background_color[1], 2, 2));
             $bg = hexdec(substr($background_color[1], 4, 2));
         }
         if ($imagename[0]["library_pdf"] == 0) {
             require_once JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
             $pdf = new PDF('L', 'mm', 'A5');
             $pdf->SetFont($imagename[0]["font_certificate"], '', 12);
             $pdf->SetTextColor($r, $g, $b);
             //set up a page
             $pdf->AddPage();
             if ($image_theme != "") {
                 $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $image_theme, -4, -1, 210, 150);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             $pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         } else {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
             $pdf = new mPDF('utf-8', 'A4-L');
             $pdf = new mPDF('utf-8', 'A4-L', 0, strtolower($imagename[0]["font_certificate"]));
             $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($imagename[0]["font_certificate"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
             //set up a page
             $pdf->AddPage('L');
             if ($image_theme != "") {
                 $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $image_theme, 0, 0, 298, 210, 'jpg', '', true, false);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             //$pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->SetDisplayMode('fullpage');
             $pdf->WriteHTML($imagename[0]["templates1"]);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
             exit;
         }
     } else {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $config = JFactory::getConfig();
         $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
         $db->setQuery($imagename);
         $db->query();
         $imagename = $db->loadAssocList();
         if ($imagename[0]["design_background"] != "") {
             $image_theme = explode("/", $imagename[0]["design_background"]);
             if (trim($image_theme[4]) == 'thumbs') {
                 $image_theme = $image_theme[5];
             } else {
                 $image_theme = $image_theme[4];
             }
         } else {
             $background_color = "background-color:" . "#" . $imagename[0]["design_background_color"];
         }
         $site_url = JURI::root();
         $coursename = $datac['cn'];
         $authorname = $datac['an'];
         $certificateid = $datac['id'];
         $completiondate = $datac['cd'];
         $course_id = $datac['ci'];
         $sitename = $config->get('config.sitename');
         $user_id = $user->id;
         $scores_avg_quizzes = guruModelguruTask::getAvgScoresQ($user_id, $course_id);
         $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($avg_quizzes_cert);
         $db->query();
         $avg_quizzes_cert = $db->loadResult();
         $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $result = $db->loadResult();
         $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $resulthasq = $db->loadResult();
         $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
         $db->setQuery($sql);
         $result_maxs = $db->loadResult();
         $sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
         $db->setQuery($sql);
         $result_q = $db->loadObject();
         $first = explode("|", @$result_q->score_quiz);
         @($res = intval($first[0] / $first[1] * 100));
         if ($resulthasq == 0 && $scores_avg_quizzes == "") {
             $avg_certc1 = "N/A";
         } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
             $avg_certc1 = "N/A";
         } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
             if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
                 $avg_certc1 = $scores_avg_quizzes . '%';
             } else {
                 $avg_certc1 = $scores_avg_quizzes . '%';
             }
         }
         if ($result != 0 && $res != "") {
             if ($res >= $result_maxs) {
                 $avg_certc = $res . '%';
             } elseif ($res < $result_maxs) {
                 $avg_certc = $res . '%';
             }
         } elseif ($result != 0 && $result != "") {
             $avg_certc = "N/A";
         } elseif ($result == 0 || $result == "") {
             $avg_certc = "N/A";
         }
         $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
         $db->setQuery($firstnamelastname);
         $db->query();
         $firstnamelastname = $db->loadAssocList();
         $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($coursemsg);
         $db->query();
         $coursemsg = $db->loadResult();
         $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid;
         $certificate_url = str_replace(" ", "%20", $certificate_url);
         $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
         while (ob_get_level()) {
             ob_end_clean();
         }
         header("Content-Encoding: None", true);
         if (strlen($imagename[0]["design_text_color"]) == 3) {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 1) . substr($imagename[0]["design_text_color"], 0, 1));
             $g = hexdec(substr($imagename[0]["design_text_color"], 1, 1) . substr($imagename[0]["design_text_color"], 1, 1));
             $b = hexdec(substr($imagename[0]["design_text_color"], 2, 1) . substr($imagename[0]["design_text_color"], 2, 1));
         } else {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 2));
             $g = hexdec(substr($imagename[0]["design_text_color"], 2, 2));
             $b = hexdec(substr($imagename[0]["design_text_color"], 4, 2));
         }
         $background_color = explode(":", $background_color);
         $background_color[1] = str_replace("#", "", $background_color[1]);
         if (strlen($background_color[1]) == 3) {
             $rg = hexdec(substr($background_color[1], 0, 1) . substr($background_color[1], 0, 1));
             $gg = hexdec(substr($background_color[1], 1, 1) . substr($background_color, 1, 1));
             $bg = hexdec(substr($background_color[1], 2, 1) . substr($background_color[1], 2, 1));
         } else {
             $rg = hexdec(substr($background_color[1], 0, 2));
             $gg = hexdec(substr($background_color[1], 2, 2));
             $bg = hexdec(substr($background_color[1], 4, 2));
         }
         if ($imagename[0]["library_pdf"] == 0) {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
             $pdf = new PDF('L', 'mm', 'A5');
             $pdf->SetFont($imagename[0]["font_certificate"], '', 12);
             $pdf->SetTextColor($r, $g, $b);
             //set up a page
             $pdf->AddPage();
             if ($image_theme != "") {
                 $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $image_theme, -4, -1, 210, 150);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             $pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         } else {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
             $pdf = new mPDF('utf-8', 'A4-L');
             $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($imagename[0]["font_certificate"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
             //set up a page
             $pdf->AddPage('L');
             if ($image_theme != "") {
                 $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $image_theme, 0, 0, 298, 210, 'jpg', '', true, false);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             //$pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->SetDisplayMode('fullpage');
             $pdf->WriteHTML($imagename[0]["templates1"]);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
             exit;
         }
     }
 }
Esempio n. 5
-2
 function savecertificatepdf()
 {
     $datac = JRequest::get('post', JREQUEST_ALLOWRAW);
     $db = JFactory::getDBO();
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $user_id = $user->id;
     $sql = "SELECT `name` from #__guru_program WHERE `id` =" . $datac['ci'];
     $db->setQuery($sql);
     $db->query();
     $result = $db->loadResult();
     $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
     $db->setQuery($imagename);
     $db->query();
     $imagename = $db->loadAssocList();
     $authorname = "SELECT name from #__users where id IN (SELECT author_id FROM #__guru_mycertificates WHERE user_id = " . intval($user_id) . " AND course_id =" . $datac['ci'] . " )";
     $db->setQuery($authorname);
     $db->query();
     $authorname = $db->loadResult();
     $date_completed = "SELECT datecertificate FROM #__guru_mycertificates WHERE user_id=" . intval($user_id) . " AND course_id=" . intval($datac['ci']);
     $db->setQuery($date_completed);
     $db->query();
     $date_completed = $db->loadResult();
     $format = "SELECT datetype FROM #__guru_config WHERE id=1";
     $db->setQuery($format);
     $db->query();
     $format = $db->loadResult();
     $date_completed = date($format, strtotime($date_completed));
     $completiondate = $date_completed;
     $sitename = $config->get('sitename');
     $coursename = $result;
     $site_url = JURI::root();
     $certificateid = $datac['id'];
     $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($coursemsg);
     $db->query();
     $coursemsg = $db->loadResult();
     $scores_avg_quizzes = guruModelguruTask::getAvgScoresQ($user_id, $course_id);
     $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($avg_quizzes_cert);
     $db->query();
     $avg_quizzes_cert = $db->loadResult();
     $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($sql);
     $result = $db->loadResult();
     $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($datac['ci']);
     $db->setQuery($sql);
     $resulthasq = $db->loadResult();
     $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
     $db->setQuery($sql);
     $result_maxs = $db->loadResult();
     $sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($datac['ci']) . " ORDER BY id DESC LIMIT 0,1";
     $db->setQuery($sql);
     $result_q = $db->loadObject();
     $first = explode("|", @$result_q->score_quiz);
     @($res = intval($first[0] / $first[1] * 100));
     if ($resulthasq == 0 && $scores_avg_quizzes == "") {
         $avg_certc1 = "N/A";
     } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
         $avg_certc1 = "N/A";
     } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
         if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
             $avg_certc1 = $scores_avg_quizzes . '%';
         } else {
             $avg_certc1 = $scores_avg_quizzes . '%';
         }
     }
     if ($result != 0 && $res != "") {
         if ($res >= $result_maxs) {
             $avg_certc = $res . '%';
         } elseif ($res < $result_maxs) {
             $avg_certc = $res . '%';
         }
     } elseif ($result != 0 && $result != "") {
         $avg_certc = "N/A";
     } elseif ($result == 0 || $result == "") {
         $avg_certc = "N/A";
     }
     $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
     $db->setQuery($firstnamelastname);
     $db->query();
     $firstnamelastname = $db->loadAssocList();
     $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid . "&ci=" . $datac['ci'];
     $certificate_url = str_replace(" ", "%20", $certificate_url);
     $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
     $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
     $datac["content"] = $imagename[0]["templates1"];
     while (ob_get_level()) {
         ob_end_clean();
     }
     header("Content-Encoding: None", true);
     if (strlen($datac["color"]) == 3) {
         $r = hexdec(substr($datac["color"], 0, 1) . substr($datac["color"], 0, 1));
         $g = hexdec(substr($datac["color"], 1, 1) . substr($datac["color"], 1, 1));
         $b = hexdec(substr($datac["color"], 2, 1) . substr($datac["color"], 2, 1));
     } else {
         $r = hexdec(substr($datac["color"], 0, 2));
         $g = hexdec(substr($datac["color"], 2, 2));
         $b = hexdec(substr($datac["color"], 4, 2));
     }
     $datac["bgcolor"] = explode(":", $datac["bgcolor"]);
     $datac["bgcolor"][1] = str_replace("#", "", $datac["bgcolor"][1]);
     if (strlen($datac["bgcolor"][1]) == 3) {
         $rg = hexdec(substr($datac["bgcolor"][1], 0, 1) . substr($datac["bgcolor"][1], 0, 1));
         $gg = hexdec(substr($datac["bgcolor"][1], 1, 1) . substr($datac["bgcolor"][1], 1, 1));
         $bg = hexdec(substr($datac["bgcolor"][1], 2, 1) . substr($datac["bgcolor"][1], 2, 1));
     } else {
         $rg = hexdec(substr($datac["bgcolor"][1], 0, 2));
         $gg = hexdec(substr($datac["bgcolor"][1], 2, 2));
         $bg = hexdec(substr($datac["bgcolor"][1], 4, 2));
     }
     if ($imagename[0]["library_pdf"] == 0) {
         require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
         $pdf = new PDF('L', 'mm', 'A5');
         $pdf->SetFont($datac["font"], '', 12);
         $pdf->SetTextColor($r, $g, $b);
         //set up a page
         $pdf->AddPage();
         if ($datac["image"] != "") {
             $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $datac["image"], -4, -1, 210, 150);
             //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
         } else {
             $pdf->SetFillColor($rg, $gg, $bg);
             //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
         }
         $pdf->Ln(20);
         $pdf->SetXY(100, 50);
         $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
         $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
     } else {
         require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
         $pdf = new mPDF('utf-8', 'A4-L');
         $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($datac["font"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
         //set up a page
         $pdf->AddPage('L');
         if ($datac["image"] != "") {
             $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $datac["image"], 0, 0, 298, 210, 'jpg', '', true, false);
             //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
         } else {
             $pdf->SetFillColor($rg, $gg, $bg);
             //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
         }
         //$pdf->Ln(20);
         $pdf->SetXY(100, 50);
         $pdf->SetDisplayMode('fullpage');
         $pdf->WriteHTML($imagename[0]["templates1"]);
         $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         exit;
     }
 }