diff --git a/main/lp/lp_final_item.php b/main/lp/lp_final_item.php index 9ad716645b..e4dc371763 100644 --- a/main/lp/lp_final_item.php +++ b/main/lp/lp_final_item.php @@ -17,6 +17,7 @@ api_protect_course_script(true); // Get environment variables $courseCode = api_get_course_id(); +$courseId = api_get_course_int_id(); $userId = api_get_user_id(); $sessionId = api_get_session_id(); $id = isset($_GET['id']) ? intval($_GET['id']) : 0; @@ -28,6 +29,29 @@ if (!$id && !$lpId) { exit; } +// Certificate and Skills Premium with Service check +$plugin = BuyCoursesPlugin::create(); +$checker = ($plugin->get('paypal_enable') || $plugin->get('transfer_enable') || $plugin->get('culqi_enable')) && $plugin->get('include_services'); + +if ($checker) { + $serviceSale = $plugin->getServiceSale( + null, + $userId, + BuyCoursesPlugin::SERVICE_STATUS_COMPLETED, + $sessionId ? BuyCoursesPlugin::SERVICE_TYPE_SESSION : BuyCoursesPlugin::SERVICE_TYPE_COURSE, + $sessionId ? $sessionId : $courseId + ); + + if (empty($serviceSale)) { + // Instance a new template : No page tittle, No header, No footer + $tpl = new Template(null, false, false); + $content = sprintf(Display::return_message($plugin->get_lang('IfYouWantToGetTheCertificateAndOrSkillsAsociatedToThisCourseYouNeedToBuyTheCertificateServiceYouCanGoToServiceCatalogClickingHere'), 'normal', false), api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php'); + $tpl->assign('content', $content); + $tpl->display_blank_template(); + exit; + } +} + // Initialize variables required for the template $downloadCertificateLink = ''; $viewCertificateLink = ''; diff --git a/plugin/buycourses/lang/spanish.php b/plugin/buycourses/lang/spanish.php index af9b79cce5..c369bc82c2 100644 --- a/plugin/buycourses/lang/spanish.php +++ b/plugin/buycourses/lang/spanish.php @@ -163,3 +163,7 @@ $strings['BoughtBy'] = "Comprado por"; $strings['PurchaserUser'] = "Usuario comprador"; $strings['SalePrice'] = "Precio de venta"; $strings['Pending'] = "Pendiente"; +$strings['YouNeedToBeRegisteredInAtLeastOneCourse'] = "Necesitas estar registrado en al menos un curso"; +$strings['YouNeedToBeRegisteredInAtLeastOneSession'] = "Necesitas estar registrado en al menos una sesión"; +$strings['IfYouWantToGetTheCertificateAndOrSkillsAsociatedToThisCourseYouNeedToBuyTheCertificateServiceYouCanGoToServiceCatalogClickingHere'] = "Si quieres obtener el certificado y/o las competencias asociadas a este curso, necesitas comprar el servicio de Certificado , puedes ir al catálogo de servicios para comprarlo haciendo click AQUÍ"; + diff --git a/plugin/buycourses/src/buy_course_plugin.class.php b/plugin/buycourses/src/buy_course_plugin.class.php index 5c6847cb6c..cc7005dc25 100644 --- a/plugin/buycourses/src/buy_course_plugin.class.php +++ b/plugin/buycourses/src/buy_course_plugin.class.php @@ -1912,6 +1912,10 @@ class BuyCoursesPlugin extends Plugin $conditions = ['WHERE' => ['ss.node_type = ? AND ss.node_id = ?' => [$nodeType, $nodeId]], 'ORDER' => 'id ASC']; } + if ($nodeType && $nodeId && $buyerId && is_numeric($status)) { + $conditions = ['WHERE' => ['ss.node_type = ? AND ss.node_id = ? AND ss.buyer_id = ? AND ss.status = ?' => [$nodeType, $nodeId, $buyerId, $status]], 'ORDER' => 'id ASC']; + } + if ($hot) { $hot = "count(ss.service_id) as hot, "; $conditions = ['ORDER' => 'hot DESC', 'LIMIT' => '6']; diff --git a/plugin/buycourses/src/service_process.php b/plugin/buycourses/src/service_process.php index a54e04c915..43f14f1d14 100644 --- a/plugin/buycourses/src/service_process.php +++ b/plugin/buycourses/src/service_process.php @@ -110,19 +110,25 @@ if ($typeUser) { } elseif ($typeCourse) { $user = $em->getRepository('ChamiloUserBundle:User')->find($currentUserId); $courses = $user->getCourses(); - if (!empty($courses)) { - foreach ($courses as $course) { - $selectOptions[$course->getCourse()->getId()] = $course->getCourse()->getTitle(); - } + $checker = false; + foreach ($courses as $course) { + $checker = true; + $selectOptions[$course->getCourse()->getId()] = $course->getCourse()->getTitle(); + } + if (!$checker) { + $form->addHtml(Display::return_message($plugin->get_lang('YouNeedToBeRegisteredInAtLeastOneCourse'), 'error')); } $form->addSelect('info_select', get_lang('Course'), $selectOptions); } elseif ($typeSession) { $user = $em->getRepository('ChamiloUserBundle:User')->find($currentUserId); $sessions = $user->getSessionCourseSubscriptions(); - if (!empty($sessions)) { - foreach ($sessions as $session) { - $selectOptions[$session->getSession()->getId()] = $session->getSession()->getName(); - } + $checker = false; + foreach ($sessions as $session) { + $checker = true; + $selectOptions[$session->getSession()->getId()] = $session->getSession()->getName(); + } + if (!$checker) { + $form->addHtml(Display::return_message($plugin->get_lang('YouNeedToBeRegisteredInAtLeastOneSession'), 'error')); } $form->addSelect('info_select', get_lang('Session'), $selectOptions); }