terms_to_pdf.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /* For license terms, see /license.txt */
  3. /**
  4. * A script to render all mails templates
  5. * @package chamilo.plugin.advanced_subscription
  6. */
  7. require_once __DIR__.'/../config.php';
  8. // Protect test
  9. api_protect_admin_script();
  10. $data['action'] = 'confirm';
  11. $data['currentUserId'] = 1;
  12. $data['queueId'] = 0;
  13. $data['is_connected'] = true;
  14. $data['profile_completed'] = 90.0;
  15. $data['sessionId'] = intval($_REQUEST['s']);
  16. $data['studentUserId'] = intval($_REQUEST['u']);
  17. $data['student'] = api_get_user_info($data['studentUserId']);
  18. $data['session'] = api_get_session_info($data['sessionId']);
  19. if (!empty($data['sessionId']) && !empty($data['studentUserId'])) {
  20. $plugin = AdvancedSubscriptionPlugin::create();
  21. if (api_get_plugin_setting('courselegal', 'tool_enable')) {
  22. $courseLegal = CourseLegalPlugin::create();
  23. $courses = SessionManager::get_course_list_by_session_id($data['sessionId']);
  24. $course = current($courses);
  25. $data['courseId'] = $course['id'];
  26. $data['course'] = api_get_course_info_by_id($data['courseId']);
  27. $termsAndConditions = $courseLegal->getData($data['courseId'], $data['sessionId']);
  28. $termsAndConditions = $termsAndConditions['content'];
  29. $termsAndConditions = $plugin->renderTemplateString($termsAndConditions, $data);
  30. $tpl = new Template($plugin->get_lang('Terms'));
  31. $tpl->assign('session', $data['session']);
  32. $tpl->assign('student', $data['student']);
  33. $tpl->assign('sessionId', $data['sessionId']);
  34. $tpl->assign('termsContent', $termsAndConditions);
  35. $termsAndConditions = $tpl->fetch('/advanced_subscription/views/terms_and_conditions_to_pdf.tpl');
  36. $pdf = new PDF();
  37. $filename = 'terms'.sha1(rand(0, 99999));
  38. $pdf->content_to_pdf($termsAndConditions, null, $filename, null, 'F');
  39. $fileDir = api_get_path(WEB_ARCHIVE_PATH).$filename.'.pdf';
  40. echo '<pre>', print_r($fileDir, 1), '</pre>';
  41. }
  42. }