session_panel.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /* For license terms, see /license.txt */
  3. /**
  4. * User Panel.
  5. *
  6. * @package chamilo.plugin.buycourses
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../../../main/inc/global.inc.php';
  10. $plugin = BuyCoursesPlugin::create();
  11. $includeSessions = $plugin->get('include_sessions') === 'true';
  12. $includeServices = $plugin->get('include_services') === 'true';
  13. $userInfo = api_get_user_info();
  14. $productTypes = $plugin->getProductTypes();
  15. $saleStatuses = $plugin->getSaleStatuses();
  16. $paymentTypes = $plugin->getPaymentTypes();
  17. $sales = $plugin->getSaleListByUserId($userInfo['id']);
  18. $saleList = [];
  19. foreach ($sales as $sale) {
  20. if ($sale['product_type'] == 2) {
  21. $saleList[] = [
  22. 'id' => $sale['id'],
  23. 'reference' => $sale['reference'],
  24. 'date' => api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H),
  25. 'currency' => $sale['iso_code'],
  26. 'price' => $sale['price'],
  27. 'product_name' => $sale['product_name'],
  28. 'product_type' => $productTypes[$sale['product_type']],
  29. 'payment_type' => $paymentTypes[$sale['payment_type']],
  30. ];
  31. }
  32. }
  33. $toolbar = Display::toolbarButton(
  34. $plugin->get_lang('CourseListOnSale'),
  35. 'course_catalog.php',
  36. 'search-plus',
  37. 'primary',
  38. ['title' => $plugin->get_lang('CourseListOnSale')]
  39. );
  40. $templateName = get_lang('Dashboard');
  41. $tpl = new Template($templateName);
  42. $tpl->assign('showing_courses', true);
  43. $tpl->assign('sessions_are_included', $includeSessions);
  44. $tpl->assign('services_are_included', $includeServices);
  45. $tpl->assign('sale_list', $saleList);
  46. $content = $tpl->fetch('buycourses/view/session_panel.tpl');
  47. $tpl->assign(
  48. 'actions',
  49. Display::toolbarAction('toolbar', [$toolbar])
  50. );
  51. $tpl->assign('header', $templateName);
  52. $tpl->assign('content', $content);
  53. $tpl->display_one_col_template();