@ -0,0 +1,86 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php'; |
||||
|
||||
if (PHP_SAPI != 'cli') { |
||||
exit('Run this script through the command line or comment this line in the code'); |
||||
} |
||||
|
||||
$urlList = UrlManager::get_url_data(); |
||||
|
||||
$defaultSenderId = 1; |
||||
|
||||
// Loop all portals |
||||
foreach ($urlList as $url) { |
||||
// Set access_url in order to get the correct url links and admins |
||||
$_configuration['access_url'] = $url['id']; |
||||
|
||||
$sql = ''; |
||||
$user_table = Database::get_main_table(TABLE_MAIN_USER); |
||||
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); |
||||
|
||||
$sql .= "SELECT u.id, v.updated_at FROM $user_table u"; |
||||
|
||||
// adding the filter to see the user's only of the current access_url |
||||
if (api_get_multiple_access_url()) { |
||||
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
||||
$sql .= " INNER JOIN $access_url_rel_user_table url_rel_user |
||||
ON (u.id = url_rel_user.user_id)"; |
||||
} |
||||
|
||||
$extraFields = UserManager::createDataPrivacyExtraFields(); |
||||
$extraFieldId = $extraFields['delete_legal']; |
||||
$extraFieldIdDeleteAccount = $extraFields['delete_account_extra_field']; |
||||
|
||||
$extraFieldValue = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
||||
$sql .= " INNER JOIN $extraFieldValue v |
||||
ON ( |
||||
u.id = v.item_id AND |
||||
(field_id = $extraFieldId OR field_id = $extraFieldIdDeleteAccount) AND |
||||
v.value = 1 |
||||
) "; |
||||
|
||||
$sql .= " WHERE 1 = 1 "; |
||||
|
||||
if (api_get_multiple_access_url()) { |
||||
$sql .= " AND url_rel_user.access_url_id = ".api_get_current_access_url_id(); |
||||
} |
||||
|
||||
$numberOfDays = 7; |
||||
$date = new DateTime(); |
||||
$date->sub(new \DateInterval('P'.$numberOfDays.'D')); |
||||
$dateToString = $date->format('Y-m-d h:i:s'); |
||||
$sql .= " AND v.updated_at < '$dateToString'"; |
||||
|
||||
$url = api_get_path(WEB_CODE_PATH).'admin/user_list_consent.php'; |
||||
$link = Display::url($url, $url); |
||||
$subject = get_lang('UserRequestWaitingForAction'); |
||||
|
||||
$email = api_get_configuration_value('data_protection_officer_email'); |
||||
|
||||
$message = 'Checking requests from '.strip_tags(Display::dateToStringAgoAndLongDate($dateToString))."\n"; |
||||
|
||||
$result = Database::query($sql); |
||||
while ($user = Database::fetch_array($result, 'ASSOC')) { |
||||
$userId = $user['id']; |
||||
$userInfo = api_get_user_info($userId); |
||||
if ($userInfo) { |
||||
$content = sprintf( |
||||
get_lang('TheUserXIsWaitingForAnActionGoHereX'), |
||||
$userInfo['complete_name'], |
||||
$link |
||||
); |
||||
|
||||
if (!empty($email)) { |
||||
api_mail_html('', $email, $subject, $content); |
||||
} else { |
||||
MessageManager::sendMessageToAllAdminUsers($defaultSenderId, $subject, $content); |
||||
} |
||||
|
||||
$date = strip_tags(Display::dateToStringAgoAndLongDate($user['updated_at'])); |
||||
$message .= "User ".$userInfo['complete_name_with_username']." is waiting for an action since $date \n"; |
||||
} |
||||
} |
||||
echo $message; |
||||
} |
@ -0,0 +1,11 @@ |
||||
$(document).ready(function() { |
||||
//get the path to mediaelement plugins
|
||||
var scripts = document.getElementsByTagName('script'); |
||||
var scriptPath = scripts[scripts.length-1].src; |
||||
var basePath = scriptPath.substring(0, scriptPath.indexOf('/main/')+1) + 'web/assets/mediaelement/build/'; |
||||
$('video:not(.skip), audio:not(.skip)').mediaelementplayer({ |
||||
pluginPath: basePath, |
||||
shimScriptAccess: 'always' |
||||
// more configuration
|
||||
}); |
||||
}); |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,48 @@ |
||||
{{ search_form }} |
||||
<table class="table table-hover table-striped"> |
||||
<thead> |
||||
<tr> |
||||
<th>{{ 'CreatedAt'|get_lang }}</th> |
||||
<th>{{ 'Status'|get_lang }}</th> |
||||
<th>{{ 'Records'|get_plugin_lang('BBBPlugin') }}</th> |
||||
<th>{{ 'Course'|get_lang }}</th> |
||||
<th>{{ 'Session'|get_lang }}</th> |
||||
<th>{{ 'Participants'|get_lang }}</th> |
||||
<th>{{ 'Actions'|get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for meeting in meetings %} |
||||
<tr id="meeting-{{ meeting.id }}"> |
||||
{% if meeting.visibility == 0 %} |
||||
<td class="muted">{{ meeting.created_at }}</td> |
||||
{% else %} |
||||
<td>{{ meeting.created_at }}</td> |
||||
{% endif %} |
||||
<td> |
||||
{% if meeting.status == 1 %} |
||||
<span class="label label-success">{{ 'MeetingOpened'|get_plugin_lang('BBBPlugin') }}</span> |
||||
{% else %} |
||||
<span class="label label-info">{{ 'MeetingClosed'|get_plugin_lang('BBBPlugin') }}</span> |
||||
{% endif %} |
||||
</td> |
||||
<td> |
||||
{% if meeting.record == 1 %} |
||||
{# Record list #} |
||||
{{ meeting.show_links }} |
||||
{% else %} |
||||
{{ 'NoRecording'|get_plugin_lang('BBBPlugin') }} |
||||
{% endif %} |
||||
</td> |
||||
<td>{{ meeting.course ?: '-' }}</td> |
||||
<td>{{ meeting.session ?: '-' }}</td> |
||||
<td> |
||||
{{ meeting.participants ? meeting.participants|join('<br>') : '-' }} |
||||
</td> |
||||
<td> |
||||
{{ meeting.action_links }} |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
@ -0,0 +1,176 @@ |
||||
<style type="text/css"> |
||||
.conference .url{ |
||||
padding: 5px; |
||||
margin-bottom: 5px; |
||||
} |
||||
.conference .share{ |
||||
padding: 10px; |
||||
margin-top: 5px; |
||||
margin-bottom: 5px; |
||||
font-weight: bold; |
||||
} |
||||
</style> |
||||
<div class ="row"> |
||||
{% if bbb_status == true %} |
||||
<div class ="col-md-12" style="text-align:center"> |
||||
{{ form }} |
||||
{% if show_join_button == true %} |
||||
{% if show_client_options %} |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<div class="panel panel-default conference"> |
||||
<div class="panel-body"> |
||||
<div class="url"> |
||||
<a class="btn btn-default" href="{{ enter_conference_links.0.url }}"> |
||||
<img src="{{ enter_conference_links.0.icon }}" /><br> |
||||
{{ enter_conference_links.0.text }} |
||||
</a> |
||||
</div> |
||||
<div class="share"> |
||||
{{ 'UrlMeetingToShare'| get_plugin_lang('BBBPlugin') }} |
||||
</div> |
||||
<div class="form-inline"> |
||||
<div class="form-group"> |
||||
<input id="share_button_flash" type="text" |
||||
style="width:300px" |
||||
class="form-control" readonly value="{{ conference_url }}&inteface=0"> |
||||
<button onclick="copyTextToClipBoard('share_button_flash');" class="btn btn-default"> |
||||
<span class="fa fa-copy"></span> {{ 'CopyTextToClipboard' | get_lang }} |
||||
</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
<div class="col-md-6"> |
||||
<div class="panel panel-default conference"> |
||||
<div class="panel-body"> |
||||
<div class="url"> |
||||
<a class="btn btn-default" href="{{ enter_conference_links.1.url }}"> |
||||
<img src="{{ enter_conference_links.1.icon }}" /><br> |
||||
{{ enter_conference_links.1.text }} |
||||
</a> |
||||
</div> |
||||
<div class="share"> |
||||
{{ 'UrlMeetingToShare'| get_plugin_lang('BBBPlugin') }} |
||||
</div> |
||||
<div class="form-inline"> |
||||
<div class="form-group"> |
||||
<input id="share_button_html" type="text" |
||||
style="width:300px" |
||||
class="form-control" readonly value="{{ conference_url }}&inteface=1"> |
||||
|
||||
<button onclick="copyTextToClipBoard('share_button_html');" class="btn btn-default"> |
||||
<span class="fa fa-copy"></span> {{ 'CopyTextToClipboard' | get_lang }} |
||||
</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% else %} |
||||
{{ enter_conference_links.0 }} |
||||
<br /> |
||||
<strong>{{ 'UrlMeetingToShare'| get_plugin_lang('BBBPlugin') }}</strong> |
||||
<div class="well"> |
||||
<div class="form-inline"> |
||||
<div class="form-group"> |
||||
<input id="share_button" |
||||
type="text" |
||||
style="width:600px" |
||||
class="form-control" readonly value="{{ conference_url }}"> |
||||
<button onclick="copyTextToClipBoard('share_button');" class="btn btn-default"> |
||||
<span class="fa fa-copy"></span> {{ 'CopyTextToClipboard' | get_lang }} |
||||
</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endif %} |
||||
<p> |
||||
<span id="users_online" class="label label-warning"> |
||||
{{ 'XUsersOnLine'| get_plugin_lang('BBBPlugin') | format(users_online) }} |
||||
</span> |
||||
</p> |
||||
{{ warning_inteface_msg }} |
||||
{% if max_users_limit > 0 %} |
||||
{% if conference_manager == true %} |
||||
<p>{{ 'MaxXUsersWarning' | get_plugin_lang('BBBPlugin') | format(max_users_limit) }}</p> |
||||
{% elseif users_online >= max_users_limit/2 %} |
||||
<p>{{ 'MaxXUsersWarning' | get_plugin_lang('BBBPlugin') | format(max_users_limit) }}</p> |
||||
{% endif %} |
||||
{% endif %} |
||||
</div> |
||||
{% elseif max_users_limit > 0 %} |
||||
{% if conference_manager == true %} |
||||
<p>{{ 'MaxXUsersReachedManager' | get_plugin_lang('BBBPlugin') | format(max_users_limit) }}</p> |
||||
{% elseif users_online > 0 %} |
||||
<p>{{ 'MaxXUsersReached' | get_plugin_lang('BBBPlugin') | format(max_users_limit) }}</p> |
||||
{% endif %} |
||||
{% endif %} |
||||
</div> |
||||
|
||||
<div class ="col-md-12"> |
||||
<div class="page-header"> |
||||
<h2>{{ 'RecordList'| get_plugin_lang('BBBPlugin') }}</h2> |
||||
</div> |
||||
|
||||
<table class="table"> |
||||
<tr> |
||||
<!-- th>#</th --> |
||||
<th>{{ 'CreatedAt'| get_plugin_lang('BBBPlugin') }}</th> |
||||
<th>{{ 'Status'| get_lang }}</th> |
||||
<th>{{ 'Records'| get_plugin_lang('BBBPlugin') }}</th> |
||||
|
||||
{% if allow_to_edit %} |
||||
<th>{{ 'Actions'| get_lang }}</th> |
||||
{% endif %} |
||||
|
||||
</tr> |
||||
{% for meeting in meetings %} |
||||
<tr> |
||||
<!-- td>{{ meeting.id }}</td --> |
||||
{% if meeting.visibility == 0 %} |
||||
<td class="muted">{{ meeting.created_at }}</td> |
||||
{% else %} |
||||
<td>{{ meeting.created_at }}</td> |
||||
{% endif %} |
||||
<td> |
||||
{% if meeting.status == 1 %} |
||||
<span class="label label-success">{{ 'MeetingOpened'|get_plugin_lang('BBBPlugin') }}</span> |
||||
{% else %} |
||||
<span class="label label-info">{{ 'MeetingClosed'|get_plugin_lang('BBBPlugin') }}</span> |
||||
{% endif %} |
||||
</td> |
||||
<td> |
||||
{% if meeting.record == 1 %} |
||||
{# Record list #} |
||||
{{ meeting.show_links }} |
||||
{% else %} |
||||
{{ 'NoRecording'|get_plugin_lang('BBBPlugin') }} |
||||
{% endif %} |
||||
</td> |
||||
|
||||
{% if allow_to_edit %} |
||||
<td> |
||||
{% if meeting.status == 1 %} |
||||
<a class="btn btn-default" href="{{ meeting.end_url }} "> |
||||
{{ 'CloseMeeting'|get_plugin_lang('BBBPlugin') }} |
||||
</a> |
||||
{% else %} |
||||
{{ meeting.action_links }} |
||||
{% endif %} |
||||
</td> |
||||
{% endif %} |
||||
|
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
</div> |
||||
{% else %} |
||||
<div class ="col-md-12" style="text-align:center"> |
||||
{{ 'ServerIsNotRunning' | get_plugin_lang('BBBPlugin') | return_message('warning') }} |
||||
</div> |
||||
{% endif %} |
||||
</div> |
@ -0,0 +1,26 @@ |
||||
CustomCertificate plugin |
||||
=============== |
||||
Este plugin da la posibilidad al administrador de disponer de una herramienta de certificados alternativa |
||||
a la que tiene por defecto la plataforma Chamilo. |
||||
|
||||
**Instrucciones de puesta en funcionamiento** |
||||
|
||||
- Habilitar el plugin en la administración de Chamilo. |
||||
- Indicar 'menu_administrator' en la configuración de la región del plugin. |
||||
|
||||
**accesos a la herramienta** |
||||
|
||||
- Desde la pantalla de Administración para configurar el certificado por defecto. |
||||
- Desde las herramientas del curso, para la configuración del diploma especifico. |
||||
|
||||
**Importante a tener en cuenta** |
||||
|
||||
Por defecto los certificados utilizados serán los de la plataforma chamilo. Para habilitar el certificado alternativo |
||||
en un curso se debe entrar en la configuración del curso y habilitar en la pestaña de "certificados personalizado" la |
||||
casilla de verificación de "Habilitar en el curso el certificado alternativo". |
||||
Si se desea usar el certificado por defecto se deberá mostrar la segunda casilla de verificación. |
||||
|
||||
|
||||
Credits |
||||
------- |
||||
Contributed by [Nosolored](https://www.nosolored.com/). |
@ -0,0 +1,10 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Config the plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
* |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com> |
||||
*/ |
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
@ -0,0 +1,68 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
use Doctrine\DBAL\Types\Type; |
||||
|
||||
/** |
||||
* Plugin database installation script. Can only be executed if included |
||||
* inside another script loading global.inc.php. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
/** |
||||
* Check if script can be called. |
||||
*/ |
||||
if (!function_exists('api_get_path')) { |
||||
die('This script must be loaded through the Chamilo plugin installer sequence'); |
||||
} |
||||
|
||||
$entityManager = Database::getManager(); |
||||
$pluginSchema = new \Doctrine\DBAL\Schema\Schema(); |
||||
$connection = $entityManager->getConnection(); |
||||
$platform = $connection->getDatabasePlatform(); |
||||
|
||||
if ($pluginSchema->hasTable(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE)) { |
||||
return; |
||||
} |
||||
|
||||
//Create tables |
||||
$certificateTable = $pluginSchema->createTable(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
||||
$certificateTable->addColumn('id', Type::INTEGER, ['autoincrement' => true, 'unsigned' => true]); |
||||
$certificateTable->addColumn('access_url_id', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('c_id', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('session_id', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('content_course', Type::TEXT); |
||||
$certificateTable->addColumn('contents_type', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('contents', Type::TEXT); |
||||
$certificateTable->addColumn('date_change', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('date_start', Type::DATETIME); |
||||
$certificateTable->addColumn('date_end', Type::DATETIME); |
||||
$certificateTable->addColumn('type_date_expediction', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('place', Type::STRING); |
||||
$certificateTable->addColumn('day', Type::STRING, ['notnull' => false]); |
||||
$certificateTable->addColumn('month', Type::STRING, ['notnull' => false]); |
||||
$certificateTable->addColumn('year', Type::STRING, ['notnull' => false]); |
||||
$certificateTable->addColumn('logo_left', Type::STRING); |
||||
$certificateTable->addColumn('logo_center', Type::STRING); |
||||
$certificateTable->addColumn('logo_right', Type::STRING); |
||||
$certificateTable->addColumn('seal', Type::STRING); |
||||
$certificateTable->addColumn('signature1', Type::STRING); |
||||
$certificateTable->addColumn('signature2', Type::STRING); |
||||
$certificateTable->addColumn('signature3', Type::STRING); |
||||
$certificateTable->addColumn('signature4', Type::STRING); |
||||
$certificateTable->addColumn('signature_text1', Type::STRING); |
||||
$certificateTable->addColumn('signature_text2', Type::STRING); |
||||
$certificateTable->addColumn('signature_text3', Type::STRING); |
||||
$certificateTable->addColumn('signature_text4', Type::STRING); |
||||
$certificateTable->addColumn('background', Type::STRING); |
||||
$certificateTable->addColumn('margin_left', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('margin_right', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addColumn('certificate_default', Type::INTEGER, ['unsigned' => true]); |
||||
$certificateTable->addIndex(['c_id', 'session_id']); |
||||
$certificateTable->setPrimaryKey(['id']); |
||||
|
||||
$queries = $pluginSchema->toSql($platform); |
||||
|
||||
foreach ($queries as $query) { |
||||
Database::query($query); |
||||
} |
@ -0,0 +1,3 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
require_once 'config.php'; |
@ -0,0 +1,15 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* This script is included by main/admin/settings.lib.php and generally |
||||
* includes things to execute in the main database (settings_current table). |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
|
||||
CustomCertificatePlugin::create()->install(); |
@ -0,0 +1,72 @@ |
||||
<?php |
||||
$strings['plugin_title'] = "Custom certificate"; |
||||
$strings['plugin_comment'] = "This plugin allows you to create custom certificates for each course."; |
||||
$strings['enable_plugin_customcertificate'] = "Enable plugin"; |
||||
$strings['customcertificate_course_enable'] = "Custom certificate enable in course"; |
||||
$strings['use_certificate_default'] = "Use default custom certificate"; |
||||
$strings['ToolDisabled'] = "The tool is disabled from the administration"; |
||||
$strings['OnlyAdminPlatform'] = "Tool only for administrators"; |
||||
$strings['OnlyAdminPlatformOrTeacher'] = "Tool only for administrators and teachers"; |
||||
$strings['TrainingEntity'] = "Training entity"; |
||||
$strings['DescriptionFront'] = "Description front"; |
||||
$strings['DescriptionRear'] = "Description rear"; |
||||
$strings['Certify'] = "Certify"; |
||||
$strings['CertificateType'] = "Certificate type"; |
||||
$strings['CertifyThat'] = "CERTIFY THAT"; |
||||
$strings['StudentCourseInfo'] = 'Student and Course data'; |
||||
$strings['StudentData'] = "Student data"; |
||||
$strings['CourseData'] = "Course data"; |
||||
$strings['Modality'] = "Modality"; |
||||
$strings['Contents'] = "Contents"; |
||||
$strings['ContentsToShow'] = "Contents to show"; |
||||
$strings['ContentsCourseDescription'] = 'Use section "Course description"> "Contents"'; |
||||
$strings['ContentsIndexLearnpath'] = "Use learnpath index"; |
||||
$strings['ContentsCustom'] = "Use custom content"; |
||||
$strings['ContentsHide'] = "No show contents"; |
||||
$strings['Dates'] = "Dates"; |
||||
$strings['CourseDeliveryDates'] = "Course delivery dates"; |
||||
$strings['Custom'] = "Custom"; |
||||
$strings['UseDateSessionAccess'] = "Use access dates to the session"; |
||||
$strings['ExpectionPlace'] = "Expection place"; |
||||
$strings['DateExpediction'] = "Expediction date"; |
||||
$strings['UseDateEndAccessSession'] = "Use end date of session access"; |
||||
$strings['UseDateDownloadCertificate'] = "Use certificate download date"; |
||||
$strings['UseCustomDate'] = "Use custom date"; |
||||
$strings['LogosSeal'] = "Logos / Seals"; |
||||
$strings['LogoLeft'] = "Logo left"; |
||||
$strings['LogoCenter'] = "Logo center"; |
||||
$strings['LogoRight'] = "Logo right"; |
||||
$strings['Seal'] = "Seal"; |
||||
$strings['Signature1'] = "Signature 1"; |
||||
$strings['Signature2'] = "Signature 2"; |
||||
$strings['Signature3'] = "Signature 3"; |
||||
$strings['Signature4'] = "Signature 4"; |
||||
$strings['SignatureText1'] = "Signature text 1"; |
||||
$strings['SignatureText2'] = "Signature text 2"; |
||||
$strings['SignatureText3'] = "Signature text 3"; |
||||
$strings['SignatureText4'] = "Signature text 4"; |
||||
$strings['OtherOptions'] = "Others options"; |
||||
$strings['MarginRight'] = "Margin right"; |
||||
$strings['MarginLeft'] = "Margin left"; |
||||
$strings['SetDefaultTemplate'] = "Set template by default"; |
||||
$strings['MessageDefaultTemplate'] = "Save this default customization for courses and sessions without |
||||
defined certificates"; |
||||
$strings['None'] = "None"; |
||||
$strings['ErrorTemplateCertificate'] = "There is no template defined for the certificate. |
||||
There is no template by default."; |
||||
$strings['DateStartEnd'] = "With Start date and End date: "; |
||||
$strings['ExpedictionIn'] = "Expediction in"; |
||||
$strings['Signatures'] = "Signatures"; |
||||
$strings['BackgroundCertificate'] = "Background image of the certificate"; |
||||
$strings['Background'] = "Background"; |
||||
$strings['CertificateSetting'] = "Certificate setting"; |
||||
$strings['ToolDisabledCourse'] = "Tool disabled in course setting"; |
||||
$strings['ToolUseDefaultSettingCourse'] = "Tool configured to use the default certificate. <br> |
||||
You can edit it from the Administration screen -> Plugins -> Custom Certificate. <br> |
||||
Or if you want you can disable the option to use certificate by default in the plugin configuration in the course"; |
||||
$strings['CertificateSettingDefault'] = "Default certificate settings"; |
||||
$strings['InfoFromDefaultCertificate'] = "The content of the certificate is based on the default certificate. |
||||
The modifications you make will not affect the default certificate."; |
||||
$strings['to'] = " to "; |
||||
$strings['formatDownloadDate'] = " to %sth %s, %s"; |
||||
$strings['PrintCertificate'] = "Print certificate"; |
@ -0,0 +1,74 @@ |
||||
<?php |
||||
$strings['plugin_title'] = "Certificado personalizado"; |
||||
$strings['plugin_comment'] = "Este plugin permite crear certificados personalizados por curso."; |
||||
$strings['enable_plugin_customcertificate'] = "Activar plugin"; |
||||
$strings['customcertificate_course_enable'] = "Habilitar en el curso el certificado alternativo"; |
||||
$strings['use_certificate_default'] = "Usar el certificado personalizado por defecto"; |
||||
$strings['ToolDisabled'] = "La herramienta está deshabilitada desde la administración"; |
||||
$strings['OnlyAdminPlatform'] = "Herramienta exclusiva para administradores"; |
||||
$strings['OnlyAdminPlatformOrTeacher'] = "Herramienta para administradores y profesores"; |
||||
$strings['TrainingEntity'] = "Entidad formadora"; |
||||
$strings['DescriptionFront'] = "Descripción principal"; |
||||
$strings['DescriptionRear'] = "Descripción trasera"; |
||||
$strings['Certify'] = "Certifica"; |
||||
$strings['CertificateType'] = "Tipo certificado"; |
||||
$strings['CertifyThat'] = "CERTIFICA QUE"; |
||||
$strings['StudentCourseInfo'] = 'Datos del alumno y curso'; |
||||
$strings['StudentData'] = "Datos estudiante"; |
||||
$strings['CourseData'] = "Datos curso"; |
||||
$strings['Modality'] = "Modalidad"; |
||||
$strings['Contents'] = "Contenidos"; |
||||
$strings['ContentsToShow'] = "Contenidos a mostrar"; |
||||
$strings['ContentsCourseDescription'] = 'Usar apartado "Descripcion del curso" > "Contenidos"'; |
||||
$strings['ContentsIndexLearnpath'] = "Usar indice de lecciones"; |
||||
$strings['ContentsCustom'] = "Usar contenido personalizado"; |
||||
$strings['ContentsHide'] = "No mostrar contenidos"; |
||||
$strings['Dates'] = "Fechas"; |
||||
$strings['CourseDeliveryDates'] = "Fechas de impartición del curso"; |
||||
$strings['Custom'] = "Personalizado"; |
||||
$strings['UseDateSessionAccess'] = "Usar fechas de acceso a la sesión"; |
||||
$strings['ExpectionPlace'] = "Lugar expedición"; |
||||
$strings['DateExpediction'] = "Fecha expedición"; |
||||
$strings['UseDateEndAccessSession'] = "Usar fecha fin de acceso de la sesión"; |
||||
$strings['UseDateDownloadCertificate'] = "Usar fecha de descarga del certificado"; |
||||
$strings['UseCustomDate'] = "Usar fechas personalizadas"; |
||||
$strings['LogosSeal'] = "Logos / Sellos"; |
||||
$strings['LogoLeft'] = "Logo izquierda"; |
||||
$strings['LogoCenter'] = "Logo central"; |
||||
$strings['LogoRight'] = "Logo derecha"; |
||||
$strings['Seal'] = "Sello"; |
||||
$strings['Signature1'] = "Firma 1"; |
||||
$strings['Signature2'] = "Firma 2"; |
||||
$strings['Signature3'] = "Firma 3"; |
||||
$strings['Signature4'] = "Firma 4"; |
||||
$strings['SignatureText1'] = "Texto firma 1"; |
||||
$strings['SignatureText2'] = "Texto firma 2"; |
||||
$strings['SignatureText3'] = "Texto firma 3"; |
||||
$strings['SignatureText4'] = "Texto firma 4"; |
||||
$strings['OtherOptions'] = "Otras opciones"; |
||||
$strings['MarginRight'] = "Margen derecho"; |
||||
$strings['MarginLeft'] = "Margen izquierdo"; |
||||
$strings['SetDefaultTemplate'] = "Establecer plantilla por defecto"; |
||||
$strings['MessageDefaultTemplate'] = "Guardar esta personalización por defecto para cursos y |
||||
sesiones sin certificados definidos"; |
||||
$strings['None'] = "Ninguno"; |
||||
$strings['ErrorTemplateCertificate'] = "No hay una plantilla definida para el certificado. |
||||
No existe plantilla por defecto."; |
||||
$strings['DateStartEnd'] = "Con Fecha de inicio y Fecha fin: "; |
||||
$strings['ExpedictionIn'] = "Expedido en"; |
||||
$strings['Signatures'] = "Firmas"; |
||||
$strings['BackgroundCertificate'] = "Imagen de fondo del certificado"; |
||||
$strings['Background'] = "Fondo"; |
||||
$strings['CertificateSetting'] = "Configuración Certificado"; |
||||
$strings['ToolDisabledCourse'] = "Herramienta desabilitada en el curso"; |
||||
$strings['ToolUseDefaultSettingCourse'] = "Herramienta configurada para usar el certificado por defecto.<br> |
||||
Podrá editarlo desde la pantalla de Administración -> Plugins -> Certificado personalizado.<br> |
||||
O si lo desea puede desactivar la opción de usar certificado por defecto en la configuración del |
||||
plugin en el curso"; |
||||
$strings['CertificateSettingDefault'] = "Configuración del certificado por defecto"; |
||||
$strings['InfoFromDefaultCertificate'] = "El contenido del certificado está basado en el certificado por defecto. |
||||
Las modificaciones que realice no afectará al certificado por defecto."; |
||||
$strings['to'] = " a "; |
||||
$strings['formatDownloadDate'] = " a %s de %s de %s"; |
||||
$strings['MessageUpdate'] = "El proceso de actualización ha terminado"; |
||||
$strings['PrintCertificate'] = "Imprimir certificado"; |
@ -0,0 +1,16 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script is a configuration file for the date plugin. |
||||
* You can use it as a master for other platform plugins (course plugins are slightly different). |
||||
* These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins). |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
|
||||
/** |
||||
* Plugin details (must be present). |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
$plugin_info = CustomCertificatePlugin::create()->get_info(); |
@ -0,0 +1,11 @@ |
||||
body {background-repeat:no-repeat; margin:0; padding: 0;} |
||||
td { font-family:arial, sans-serif; font-size:18px; } |
||||
.logo {height: 150px; vertical-align: middle; } |
||||
.seals { font-size: 16px; text-align:center;} |
||||
.logo-seals { height: 100px; text-align:center; vertical-align: middle;} |
||||
@page caraA { height: 210mm; margin:0; padding:0; page-break-before:always;} |
||||
.caraA {box-decoration-break: slice; page: caraA} |
||||
@page caraB { background:#FFFFFF; } |
||||
.caraB {box-decoration-break: slice; page: caraB} |
||||
.contents-learnpath td {background: #FFFFFF; font-size: 12px; height: 160mm; vertical-align: top;} |
||||
ol {margin: 0; padding:0;} |
@ -0,0 +1,18 @@ |
||||
.form-control-cert { |
||||
background-color: #fff; |
||||
background-image: none; |
||||
border: 1px solid #ccc; |
||||
border-radius: 4px; |
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.075); |
||||
color: #555; |
||||
font-size: 14px; |
||||
line-height: 1.42857143; |
||||
padding: 6px 12px; |
||||
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; |
||||
} |
||||
.certificado-text-label { |
||||
font-weight: 700; |
||||
margin: 0 10px 0 10px; |
||||
} |
||||
input:disabled { background: #eee; } |
||||
label { font-size: 13px; } |
After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
@ -0,0 +1,38 @@ |
||||
function dateCertificateSwitchRadioButton2(){ |
||||
$("#date_start").prop("disabled", true).val(""); |
||||
$("#date_end").prop("disabled", true).val(""); |
||||
} |
||||
|
||||
function dateCertificateSwitchRadioButton1(){ |
||||
$("#date_start").prop("disabled", false); |
||||
$("#date_end").prop("disabled", false); |
||||
} |
||||
|
||||
function dateCertificateSwitchRadioButton0(){ |
||||
$("#date_start").prop("disabled", true).val(""); |
||||
$("#date_end").prop("disabled", true).val(""); |
||||
} |
||||
|
||||
function typeDateExpedictionSwitchRadioButton(){ |
||||
$("[name=\"type_date_expediction\"]").each(function( index ) { |
||||
if ( $(this).is(":checked") && $(this).val() === "2") { |
||||
$("#day, #month, #year").prop("disabled", false); |
||||
} else { |
||||
$("#day, #month, #year").prop("disabled", true); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
function contentsTypeSwitchRadioButton(){ |
||||
$("[name=\"contents_type\"]").each(function( index ) { |
||||
if ( $(this).is(":checked") && $(this).val() === "2") { |
||||
$("#contents").prop("disabled", false); |
||||
} else { |
||||
$("#contents").prop("disabled", true); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
$(document).ready(function() { |
||||
$( ".datepicker" ).datepicker(); |
||||
}); |
@ -0,0 +1,281 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Plugin class for the CustomCertificate plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
* |
||||
* @author Jose Angel Ruiz <desarrollo@nosolored.com> |
||||
*/ |
||||
class CustomCertificatePlugin extends Plugin |
||||
{ |
||||
const TABLE_CUSTOMCERTIFICATE = 'plugin_customcertificate'; |
||||
public $isCoursePlugin = true; |
||||
|
||||
// When creating a new course this settings are added to the course |
||||
public $course_settings = [ |
||||
[ |
||||
'name' => 'customcertificate_course_enable', |
||||
'type' => 'checkbox', |
||||
], |
||||
[ |
||||
'name' => 'use_certificate_default', |
||||
'type' => 'checkbox', |
||||
], |
||||
]; |
||||
|
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
protected function __construct() |
||||
{ |
||||
parent::__construct( |
||||
'1.0', |
||||
'Jose Angel Ruiz - NoSoloRed (original author), Julio Montoya', |
||||
[ |
||||
'enable_plugin_customcertificate' => 'boolean', |
||||
] |
||||
); |
||||
|
||||
$this->isAdminPlugin = true; |
||||
} |
||||
|
||||
/** |
||||
* Instance the plugin. |
||||
* |
||||
* @staticvar null $result |
||||
* |
||||
* @return CustomCertificatePlugin |
||||
*/ |
||||
public static function create() |
||||
{ |
||||
static $result = null; |
||||
|
||||
return $result ? $result : $result = new self(); |
||||
} |
||||
|
||||
/** |
||||
* This method creates the tables required to this plugin. |
||||
*/ |
||||
public function install() |
||||
{ |
||||
//Installing course settings |
||||
$this->install_course_fields_in_all_courses(); |
||||
|
||||
$tablesToBeCompared = [self::TABLE_CUSTOMCERTIFICATE]; |
||||
$em = Database::getManager(); |
||||
$cn = $em->getConnection(); |
||||
$sm = $cn->getSchemaManager(); |
||||
$tables = $sm->tablesExist($tablesToBeCompared); |
||||
|
||||
if ($tables) { |
||||
return false; |
||||
} |
||||
|
||||
require_once api_get_path(SYS_PLUGIN_PATH).'customcertificate/database.php'; |
||||
} |
||||
|
||||
/** |
||||
* This method drops the plugin tables. |
||||
*/ |
||||
public function uninstall() |
||||
{ |
||||
// Deleting course settings. |
||||
$this->uninstall_course_fields_in_all_courses(); |
||||
|
||||
$tablesToBeDeleted = [self::TABLE_CUSTOMCERTIFICATE]; |
||||
foreach ($tablesToBeDeleted as $tableToBeDeleted) { |
||||
$table = Database::get_main_table($tableToBeDeleted); |
||||
$sql = "DROP TABLE IF EXISTS $table"; |
||||
Database::query($sql); |
||||
} |
||||
$this->manageTab(false); |
||||
} |
||||
|
||||
/** |
||||
* This method update the previous plugin tables. |
||||
*/ |
||||
public function update() |
||||
{ |
||||
$oldCertificateTable = 'gradebook_certificate_alternative'; |
||||
$base = api_get_path(WEB_UPLOAD_PATH); |
||||
if (Database::num_rows(Database::query("SHOW TABLES LIKE '$oldCertificateTable'")) == 1) { |
||||
$sql = "SELECT * FROM $oldCertificateTable"; |
||||
$res = Database::query($sql); |
||||
while ($row = Database::fetch_assoc($res)) { |
||||
$pathOrigin = $base.'certificates/'.$row['id'].'/'; |
||||
$params = [ |
||||
'access_url_id' => api_get_current_access_url_id(), |
||||
'c_id' => $row['c_id'], |
||||
'session_id' => $row['session_id'], |
||||
'content_course' => $row['content_course'], |
||||
'contents_type' => intval($row['contents_type']), |
||||
'contents' => $row['contents'], |
||||
'date_change' => intval($row['date_change']), |
||||
'date_start' => $row['date_start'], |
||||
'date_end' => $row['date_end'], |
||||
'place' => $row['place'], |
||||
'type_date_expediction' => intval($row['type_date_expediction']), |
||||
'day' => $row['day'], |
||||
'month' => $row['month'], |
||||
'year' => $row['year'], |
||||
'logo_left' => $row['logo_left'], |
||||
'logo_center' => $row['logo_center'], |
||||
'logo_right' => $row['logo_right'], |
||||
'seal' => $row['seal'], |
||||
'signature1' => $row['signature1'], |
||||
'signature2' => $row['signature2'], |
||||
'signature3' => $row['signature3'], |
||||
'signature4' => $row['signature4'], |
||||
'signature_text1' => $row['signature_text1'], |
||||
'signature_text2' => $row['signature_text2'], |
||||
'signature_text3' => $row['signature_text3'], |
||||
'signature_text4' => $row['signature_text4'], |
||||
'background' => $row['background'], |
||||
'margin_left' => intval($row['margin']), |
||||
'margin_right' => 0, |
||||
'certificate_default' => 0, |
||||
]; |
||||
|
||||
$certificateId = Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params); |
||||
|
||||
// Image manager |
||||
$pathDestiny = $base.'certificates/'.$certificateId.'/'; |
||||
|
||||
if (!file_exists($pathDestiny)) { |
||||
mkdir($pathDestiny, api_get_permissions_for_new_directories(), true); |
||||
} |
||||
|
||||
$imgList = [ |
||||
'logo_left', |
||||
'logo_center', |
||||
'logo_right', |
||||
'seal', |
||||
'signature1', |
||||
'signature2', |
||||
'signature3', |
||||
'signature4', |
||||
'background', |
||||
]; |
||||
foreach ($imgList as $value) { |
||||
if (!empty($row[$value])) { |
||||
copy( |
||||
$pathOrigin.$row[$value], |
||||
$pathDestiny.$row[$value] |
||||
); |
||||
} |
||||
} |
||||
|
||||
if ($row['certificate_default'] == 1) { |
||||
$params['c_id'] = 0; |
||||
$params['session_id'] = 0; |
||||
$params['certificate_default'] = 1; |
||||
$certificateId = Database::insert(self::TABLE_CUSTOMCERTIFICATE, $params); |
||||
$pathOrigin = $base.'certificates/default/'; |
||||
$pathDestiny = $base.'certificates/'.$certificateId.'/'; |
||||
foreach ($imgList as $value) { |
||||
if (!empty($row[$value])) { |
||||
copy( |
||||
$pathOrigin.$row[$value], |
||||
$pathDestiny.$row[$value] |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$sql = "DROP TABLE IF EXISTS $oldCertificateTable"; |
||||
Database::query($sql); |
||||
|
||||
echo get_lang('MessageUpdate'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* By default new icon is invisible. |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public function isIconVisibleByDefault() |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* Get certificate data. |
||||
* |
||||
* @param int $id The certificate |
||||
* |
||||
* @return array |
||||
*/ |
||||
public static function getCertificateData($id) |
||||
{ |
||||
$id = (int) $id; |
||||
if (empty($id)) { |
||||
return []; |
||||
} |
||||
|
||||
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
||||
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
||||
$sql = "SELECT cer.user_id AS user_id, cat.session_id AS session_id, cat.course_code AS course_code |
||||
FROM $certificateTable cer |
||||
INNER JOIN $categoryTable cat |
||||
ON (cer.cat_id = cat.id) |
||||
WHERE cer.id = $id"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$row = Database::fetch_assoc($rs); |
||||
$courseCode = $row['course_code']; |
||||
$sessionId = $row['session_id']; |
||||
$userId = $row['user_id']; |
||||
if (api_get_course_setting('customcertificate_course_enable', $courseCode) == 1) { |
||||
return [ |
||||
'course_code' => $courseCode, |
||||
'session_id' => $sessionId, |
||||
'user_id' => $userId, |
||||
]; |
||||
} |
||||
} |
||||
|
||||
return []; |
||||
} |
||||
|
||||
/** |
||||
* Check if it redirects. |
||||
* |
||||
* @param certificate $certificate |
||||
* @param int $certId |
||||
*/ |
||||
public static function redirectCheck($certificate, $certId) |
||||
{ |
||||
$certId = (int) $certId; |
||||
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true') { |
||||
$infoCertificate = CustomCertificatePlugin::getCertificateData($certId); |
||||
if (!empty($infoCertificate)) { |
||||
if ($certificate->user_id == api_get_user_id() && !empty($certificate->certificate_data)) { |
||||
$certificateId = $certificate->certificate_data['id']; |
||||
$extraFieldValue = new ExtraFieldValue('user_certificate'); |
||||
$value = $extraFieldValue->get_values_by_handler_and_field_variable( |
||||
$certificateId, |
||||
'downloaded_at' |
||||
); |
||||
if (empty($value)) { |
||||
$params = [ |
||||
'item_id' => $certificate->certificate_data['id'], |
||||
'extra_downloaded_at' => api_get_utc_datetime(), |
||||
]; |
||||
$extraFieldValue->saveFieldValues($params); |
||||
} |
||||
} |
||||
|
||||
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/print_certificate.php'. |
||||
'?student_id='.$infoCertificate['user_id']. |
||||
'&course_code='.$infoCertificate['course_code']. |
||||
'&session_id='.$infoCertificate['session_id']; |
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,951 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
if (intval($_GET['default']) == 1) { |
||||
$cidReset = true; |
||||
} |
||||
|
||||
$course_plugin = 'customcertificate'; |
||||
require_once __DIR__.'/../config.php'; |
||||
|
||||
$_setting['student_view_enabled'] = 'false'; |
||||
|
||||
$userId = api_get_user_id(); |
||||
$plugin = CustomCertificatePlugin::create(); |
||||
$nameTools = $plugin->get_lang('CertificateSetting'); |
||||
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; |
||||
$accessUrlId = api_get_current_access_url_id(); |
||||
$course_info = api_get_course_info(); |
||||
|
||||
if (intval($_GET['default']) == 1) { |
||||
$courseId = 0; |
||||
$courseCode = ''; |
||||
$sessionId = 0; |
||||
$enableCourse = false; |
||||
$useDefault = true; |
||||
$defaultCertificate = 1; |
||||
$nameTools = $plugin->get_lang('CertificateSettingDefault'); |
||||
$urlParams = '?default=1'; |
||||
} else { |
||||
$courseId = api_get_course_int_id(); |
||||
$courseCode = api_get_course_id(); |
||||
$sessionId = api_get_session_id(); |
||||
$enableCourse = api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 ? true : false; |
||||
$useDefault = api_get_course_setting('use_certificate_default', $courseCode) == 1 ? true : false; |
||||
$defaultCertificate = 0; |
||||
$urlParams = '?'.api_get_cidreq(); |
||||
} |
||||
|
||||
if (!$enable) { |
||||
api_not_allowed(true, $plugin->get_lang('ToolDisabled')); |
||||
} |
||||
|
||||
if (!$enableCourse && !$useDefault) { |
||||
api_not_allowed(true, $plugin->get_lang('ToolDisabledCourse')); |
||||
} |
||||
|
||||
if ($enableCourse && $useDefault) { |
||||
api_not_allowed(true, $plugin->get_lang('ToolUseDefaultSettingCourse')); |
||||
} |
||||
|
||||
$allow = api_is_platform_admin() || api_is_teacher(); |
||||
if (!$allow) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
||||
$htmlHeadXtra[] = api_get_js_simple( |
||||
api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/js/certificate.js' |
||||
); |
||||
$htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css'); |
||||
$htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js'); |
||||
$htmlHeadXtra[] = api_get_css( |
||||
api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/form.css' |
||||
); |
||||
|
||||
// Get info certificate |
||||
$infoCertificate = Database::select( |
||||
'*', |
||||
$table, |
||||
['where' => [ |
||||
'access_url_id = ? AND c_id = ? AND session_id = ?' => [$accessUrlId, $courseId, $sessionId], ], |
||||
], |
||||
'first' |
||||
); |
||||
if (!is_array($infoCertificate)) { |
||||
$infoCertificate = [ |
||||
'type_date_expediction' => '', |
||||
'year' => '', |
||||
'month' => '', |
||||
'day' => '', |
||||
'date_change' => '', |
||||
]; |
||||
} |
||||
|
||||
$form = new FormValidator( |
||||
'formEdit', |
||||
'post', |
||||
api_get_self().$urlParams, |
||||
null, |
||||
['class' => 'form-vertical'] |
||||
); |
||||
|
||||
if ($form->validate()) { |
||||
$formValues = $form->getSubmitValues(); |
||||
if (empty($formValues['contents'])) { |
||||
$contents = ''; |
||||
} else { |
||||
$contents = $formValues['contents']; |
||||
} |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$date_start = str_replace('/', '-', $formValues['date_start']); |
||||
$date_end = str_replace('/', '-', $formValues['date_end']); |
||||
$params = [ |
||||
'access_url_id' => api_get_current_access_url_id(), |
||||
'c_id' => $formValues['c_id'], |
||||
'session_id' => $formValues['session_id'], |
||||
'content_course' => $formValues['content_course'], |
||||
'contents_type' => intval($formValues['contents_type']), |
||||
'contents' => $contents, |
||||
'date_change' => intval($formValues['date_change']), |
||||
'date_start' => date("Y-m-d", strtotime($date_start)), |
||||
'date_end' => date("Y-m-d", strtotime($date_end)), |
||||
'place' => $formValues['place'], |
||||
'type_date_expediction' => intval($formValues['type_date_expediction']), |
||||
'day' => $formValues['day'], |
||||
'month' => $formValues['month'], |
||||
'year' => $formValues['year'], |
||||
'signature_text1' => $formValues['signature_text1'], |
||||
'signature_text2' => $formValues['signature_text2'], |
||||
'signature_text3' => $formValues['signature_text3'], |
||||
'signature_text4' => $formValues['signature_text4'], |
||||
'margin_left' => intval($formValues['margin_left']), |
||||
'margin_right' => intval($formValues['margin_right']), |
||||
'certificate_default' => 0, |
||||
]; |
||||
|
||||
if (intval($formValues['default_certificate'] == 1)) { |
||||
$params['certificate_default'] = 1; |
||||
} |
||||
|
||||
// Insert or Update |
||||
if ($infoCertificate['id'] > 0) { |
||||
$certificateId = $infoCertificate['id']; |
||||
Database::update($table, $params, ['id = ?' => $certificateId]); |
||||
} else { |
||||
$certificateId = Database::insert($table, $params); |
||||
} |
||||
|
||||
// Image manager |
||||
$fieldList = [ |
||||
'logo_left', |
||||
'logo_center', |
||||
'logo_right', |
||||
'seal', |
||||
'signature1', |
||||
'signature2', |
||||
'signature3', |
||||
'signature4', |
||||
'background', |
||||
]; |
||||
|
||||
foreach ($fieldList as $field) { |
||||
$checkLogo[$field] = false; |
||||
if (!empty($formValues['remove_'.$field]) || $_FILES[$field]['size']) { |
||||
checkInstanceImage( |
||||
$certificateId, |
||||
$infoCertificate[$field], |
||||
$field |
||||
); |
||||
} |
||||
|
||||
if ($_FILES[$field]['size']) { |
||||
$newPicture = api_upload_file( |
||||
'certificates', |
||||
$_FILES[$field], |
||||
$certificateId, |
||||
$formValues[$field.'_crop_result'] |
||||
); |
||||
if ($newPicture) { |
||||
$sql = "UPDATE $table |
||||
SET $field = '".$newPicture['path_to_save']."' |
||||
WHERE id = $certificateId"; |
||||
Database::query($sql); |
||||
$checkLogo[$field] = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Certificate Default |
||||
if (intval($formValues['use_default'] == 1)) { |
||||
$infoCertificateDefault = Database::select( |
||||
'*', |
||||
$table, |
||||
['where' => ['certificate_default = ? ' => 1]], |
||||
'first' |
||||
); |
||||
|
||||
if (!empty($infoCertificateDefault)) { |
||||
foreach ($fieldList as $field) { |
||||
if (!empty($infoCertificateDefault[$field]) && !$checkLogo[$field]) { |
||||
$sql = "UPDATE $table |
||||
SET $field = '".$infoCertificateDefault[$field]."' |
||||
WHERE id = $certificateId"; |
||||
Database::query($sql); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
Display::addFlash(Display::return_message(get_lang('Saved'))); |
||||
|
||||
Security::clear_token(); |
||||
header('Location: '.api_get_self().$urlParams); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
if (empty($infoCertificate)) { |
||||
$infoCertificate = Database::select( |
||||
'*', |
||||
$table, |
||||
['where' => ['access_url_id = ? AND certificate_default = ? ' => [$accessUrlId, 1]]], |
||||
'first' |
||||
); |
||||
|
||||
if (!is_array($infoCertificate)) { |
||||
$infoCertificate = []; |
||||
} |
||||
if (!empty($infoCertificate)) { |
||||
$useDefault = true; |
||||
} |
||||
} |
||||
|
||||
// Display the header |
||||
Display::display_header($nameTools); |
||||
$actionsLeft = Display::url( |
||||
Display::return_icon('certificate.png', get_lang('Certificate'), '', ICON_SIZE_MEDIUM), |
||||
'print_certificate.php'.$urlParams |
||||
); |
||||
|
||||
echo Display::toolbarAction( |
||||
'toolbar-document', |
||||
[$actionsLeft] |
||||
); |
||||
|
||||
if ($useDefault && $courseId > 0) { |
||||
echo Display::return_message(get_lang('InfoFromDefaultCertificate'), 'info'); |
||||
} |
||||
|
||||
// Student and course section |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang('StudentCourseInfo')).'</legend>'); |
||||
$form->addHtml('<div class="col-sm-8">'); |
||||
$dir = '/'; |
||||
$courseInfo = api_get_course_info(); |
||||
$isAllowedToEdit = api_is_allowed_to_edit(null, true); |
||||
$editorConfig = [ |
||||
'ToolbarSet' => ($isAllowedToEdit ? 'Documents' : 'DocumentsStudent'), |
||||
'Width' => '100%', |
||||
'Height' => '300', |
||||
'cols-size' => [0, 12, 0], |
||||
'FullPage' => true, |
||||
'InDocument' => true, |
||||
'CreateDocumentDir' => api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/', |
||||
'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/', |
||||
'BaseHref' => api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document'.$dir, |
||||
]; |
||||
$form->addHtmlEditor( |
||||
'content_course', |
||||
'', |
||||
false, |
||||
true, |
||||
$editorConfig, |
||||
true |
||||
); |
||||
$form->addHtml('</div>'); |
||||
$form->addHtml('<div class="col-sm-4">'); |
||||
$strInfo = '((user_firstname))<br />'; |
||||
$strInfo .= '((user_lastname))<br />'; |
||||
$strInfo .= '((gradebook_institution))<br />'; |
||||
$strInfo .= '((gradebook_sitename))<br />'; |
||||
$strInfo .= '((teacher_firstname))<br />'; |
||||
$strInfo .= '((teacher_lastname))<br />'; |
||||
$strInfo .= '((official_code))<br />'; |
||||
$strInfo .= '((date_certificate))<br />'; |
||||
$strInfo .= '((date_certificate_no_time))<br />'; |
||||
$strInfo .= '((course_code))<br />'; |
||||
$strInfo .= '((course_title))<br />'; |
||||
$strInfo .= '((gradebook_grade))<br />'; |
||||
$strInfo .= '((external_style))<br />'; |
||||
$strInfo .= '((start_date))<br />'; |
||||
$strInfo .= '((end_date))<br />'; |
||||
$strInfo .= '((date_expediction))'; |
||||
|
||||
$createCertificate = get_lang('CreateCertificateWithTags'); |
||||
$form->addElement( |
||||
'html', |
||||
Display::return_message($createCertificate.': <br />'.$strInfo, 'normal', false) |
||||
); |
||||
$form->addHtml('</div>'); |
||||
$form->addHtml('</fieldset>'); |
||||
$form->addHtml('<div class="clearfix"></div>'); |
||||
|
||||
// Contents section |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang('Contents')).'</legend>'); |
||||
$extra = ''; |
||||
if (empty($infoCertificate['contents_type'])) { |
||||
$infoCertificate['contents_type'] = 0; |
||||
$extra = 'disabled'; |
||||
} |
||||
|
||||
$group = []; |
||||
$element = &$form->createElement( |
||||
'radio', |
||||
'contents_type', |
||||
'', |
||||
get_lang('ContentsCourseDescription'), |
||||
0, |
||||
['id' => 'contents_type_0', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();'] |
||||
); |
||||
|
||||
$group[] = $element; |
||||
|
||||
$element = &$form->createElement( |
||||
'radio', |
||||
'contents_type', |
||||
'', |
||||
get_lang('ContentsIndexLearnpath'), |
||||
1, |
||||
['id' => 'contents_type_1', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();'] |
||||
); |
||||
$group[] = $element; |
||||
|
||||
$element = &$form->createElement( |
||||
'radio', |
||||
'contents_type', |
||||
'', |
||||
get_lang('ContentsHide'), |
||||
3, |
||||
['id' => 'contents_type_3', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();'] |
||||
); |
||||
$group[] = $element; |
||||
|
||||
$element = &$form->createElement( |
||||
'radio', |
||||
'contents_type', |
||||
'', |
||||
get_lang('ContentsCustom'), |
||||
2, |
||||
['id' => 'contents_type_2', 'onclick' => 'javascript: contentsTypeSwitchRadioButton();'] |
||||
); |
||||
$group[] = $element; |
||||
|
||||
$form->addGroup( |
||||
$group, |
||||
'contents_type', |
||||
get_lang('ContentsToShow'), |
||||
null, |
||||
false |
||||
); |
||||
|
||||
$form->addHtml('<div id="contents-section">'); |
||||
$editorConfig = [ |
||||
'ToolbarSet' => ($isAllowedToEdit ? 'Documents' : 'DocumentsStudent'), |
||||
'Width' => '100%', |
||||
'Height' => '200', |
||||
'cols-size' => [2, 10, 0], |
||||
'FullPage' => true, |
||||
'InDocument' => true, |
||||
'CreateDocumentDir' => api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/', |
||||
'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/', |
||||
'BaseHref' => api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document'.$dir, |
||||
'id' => 'contents', |
||||
$extra, |
||||
]; |
||||
$form->addHtmlEditor( |
||||
'contents', |
||||
get_lang('Contents'), |
||||
false, |
||||
true, |
||||
$editorConfig, |
||||
true |
||||
); |
||||
$form->addHtml('</div>'); |
||||
|
||||
// Dates section |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang("Dates")).'</legend>'); |
||||
|
||||
$group = []; |
||||
$option1 = &$form->createElement( |
||||
'radio', |
||||
'date_change', |
||||
'', |
||||
get_lang('UseDateSessionAccess'), |
||||
0, |
||||
['id' => 'date_change_0', 'onclick' => 'javascript: dateCertificateSwitchRadioButton0();'] |
||||
); |
||||
$group[] = $option1; |
||||
|
||||
$option2 = &$form->createElement( |
||||
'radio', |
||||
'date_change', |
||||
'', |
||||
get_lang('None'), |
||||
2, |
||||
['id' => 'date_change_2', 'onclick' => 'javascript: dateCertificateSwitchRadioButton2();'] |
||||
); |
||||
$group[] = $option2; |
||||
|
||||
$option3 = &$form->createElement( |
||||
'radio', |
||||
'date_change', |
||||
'', |
||||
get_lang('Custom'), |
||||
1, |
||||
['id' => 'date_change_1', 'onclick' => 'javascript: dateCertificateSwitchRadioButton1();'] |
||||
); |
||||
$group[] = $option3; |
||||
|
||||
$form->addGroup( |
||||
$group, |
||||
'date_change', |
||||
get_lang('CourseDeliveryDates'), |
||||
null, |
||||
false |
||||
); |
||||
$form->addHtml('<div class="form-group" style="padding-top: 10px;"> |
||||
<label for="date_certificate" class="col-sm-2 control-label"> </label> |
||||
<div class="col-sm-10"> |
||||
<div class="radio" style="margin-top: -25px;"> |
||||
<span style="margin: 0 10px; font-style: italic;">'.get_lang('From').'</span> |
||||
<input |
||||
size="20" |
||||
autofocus="autofocus" |
||||
class="form-control-cert text-center datepicker" |
||||
name="date_start" |
||||
id="date_start" |
||||
type="text" |
||||
value="'.(($infoCertificate['date_change'] == '1') |
||||
? date("d/m/Y", strtotime($infoCertificate['date_start'])) |
||||
: '').'" |
||||
'.(($infoCertificate['date_change'] == '') ? 'disabled' : '').' |
||||
> |
||||
<span style="margin: 0 10px; font-style: italic;">'.get_lang('Until').'</span> |
||||
<input |
||||
size="20" |
||||
class="form-control-cert text-center datepicker" |
||||
name="date_end" |
||||
id="date_end" |
||||
type="text" |
||||
value="'.(($infoCertificate['date_change'] == '1') |
||||
? date("d/m/Y", strtotime($infoCertificate['date_end'])) |
||||
: '').'" |
||||
'.(($infoCertificate['date_change'] == "0") ? 'disabled' : '').' |
||||
> |
||||
</div> |
||||
</div> |
||||
</div>'); |
||||
|
||||
$form->addText( |
||||
'place', |
||||
get_lang('ExpectionPlace'), |
||||
false, |
||||
['id' => 'place', 'cols-size' => [2, 5, 5], 'autofocus'] |
||||
); |
||||
|
||||
$group = []; |
||||
$option1 = &$form->createElement( |
||||
'radio', |
||||
'type_date_expediction', |
||||
'', |
||||
get_lang('UseDateEndAccessSession'), |
||||
0, |
||||
[ |
||||
'id' => 'type_date_expediction_0', |
||||
'onclick' => 'javascript: dateCertificateSwitchRadioButton0();', |
||||
(($sessionId == 0) ? 'disabled' : ''), |
||||
] |
||||
); |
||||
$group[] = $option1; |
||||
|
||||
$option2 = &$form->createElement( |
||||
'radio', |
||||
'type_date_expediction', |
||||
'', |
||||
get_lang('UseDateDownloadCertificate'), |
||||
1, |
||||
[ |
||||
'id' => 'type_date_expediction_1', |
||||
'onclick' => 'javascript: typeDateExpedictionSwitchRadioButton();', |
||||
] |
||||
); |
||||
$group[] = $option2; |
||||
|
||||
$option4 = &$form->createElement( |
||||
'radio', |
||||
'type_date_expediction', |
||||
'', |
||||
get_lang('None'), |
||||
3, |
||||
[ |
||||
'id' => 'type_date_expediction_3', |
||||
'onclick' => 'javascript: typeDateExpedictionSwitchRadioButton();', |
||||
] |
||||
); |
||||
$group[] = $option4; |
||||
|
||||
$option3 = &$form->createElement( |
||||
'radio', |
||||
'type_date_expediction', |
||||
'', |
||||
get_lang('UseCustomDate'), |
||||
2, |
||||
[ |
||||
'id' => 'type_date_expediction_2', |
||||
'onclick' => 'javascript: typeDateExpedictionSwitchRadioButton();', |
||||
] |
||||
); |
||||
$group[] = $option3; |
||||
|
||||
$form->addGroup( |
||||
$group, |
||||
'type_date_expediction', |
||||
get_lang('DateExpediction'), |
||||
null, |
||||
false |
||||
); |
||||
|
||||
$form->addHtml( |
||||
'<div class="form-group" style="padding-top: 10px;"> |
||||
<label for="date_certificate" class="col-sm-2 control-label"> </label> |
||||
<div class="col-sm-10"> |
||||
<div class="radio" style="margin-top: -25px;"> |
||||
<span class="certificado-text-label">a</span> |
||||
<input |
||||
size="4" |
||||
autofocus="autofocus" |
||||
class="form-control-cert text-center" |
||||
name="day" |
||||
id="day" |
||||
type="text" |
||||
value="'.$infoCertificate['day'].'" |
||||
'.(($infoCertificate['type_date_expediction'] != '2') ? 'disabled' : '').' |
||||
> |
||||
<span class="certificado-text-label">de</span> |
||||
<input |
||||
size="10" |
||||
autofocus="autofocus" |
||||
class="form-control-cert text-center" |
||||
name="month" |
||||
id="month" |
||||
type="text" |
||||
value="'.$infoCertificate['month'].'" |
||||
'.(($infoCertificate['type_date_expediction'] != '2') ? 'disabled' : '').' |
||||
> |
||||
<span class="certificado-text-label">de</span> |
||||
<input |
||||
size="4" |
||||
autofocus="autofocus" |
||||
class="form-control-cert text-center" |
||||
name="year" |
||||
id="year" |
||||
type="text" |
||||
value="'.$infoCertificate['year'].'" |
||||
'.(($infoCertificate['type_date_expediction'] != '2') ? 'disabled' : '').' |
||||
> |
||||
</div> |
||||
</div> |
||||
</div>' |
||||
); |
||||
$form->addHtml('</fieldset>'); |
||||
|
||||
// Signature section |
||||
$base = api_get_path(WEB_UPLOAD_PATH); |
||||
$path = $base.'certificates/'; |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang('LogosSeal')).'</legend>'); |
||||
// Logo 1 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addFile( |
||||
'logo_left', |
||||
get_lang('LogoLeft'), |
||||
[ |
||||
'id' => 'logo_left', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['logo_left'])) { |
||||
$form->addElement('checkbox', 'remove_logo_left', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['logo_left'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'logo_left', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div>'); |
||||
// Logo 2 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addFile( |
||||
'logo_center', |
||||
get_lang('LogoCenter'), |
||||
[ |
||||
'id' => 'logo_center', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['logo_center'])) { |
||||
$form->addElement('checkbox', 'remove_logo_center', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['logo_center'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'logo_center', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div><div class="clearfix"></div>'); |
||||
// Logo 3 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addFile( |
||||
'logo_right', |
||||
get_lang('LogoRight'), |
||||
[ |
||||
'id' => 'logo_right', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['logo_right'])) { |
||||
$form->addElement('checkbox', 'remove_logo_right', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['logo_right'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$tblProperty = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'logo_right', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div>'); |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addFile( |
||||
'seal', |
||||
get_lang('Seal'), |
||||
[ |
||||
'id' => 'seal', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['seal'])) { |
||||
$form->addElement('checkbox', 'remove_seal', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['seal'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'seal', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div><div class="clearfix"></div>'); |
||||
$form->addHtml('</fieldset>'); |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang('Signatures')).'</legend>'); |
||||
// signature 1 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addText( |
||||
'signature_text1', |
||||
get_lang('SignatureText1'), |
||||
false, |
||||
['cols-size' => [2, 10, 0], 'autofocus'] |
||||
); |
||||
$form->addFile( |
||||
'signature1', |
||||
get_lang('Signature1'), |
||||
[ |
||||
'id' => 'signature1', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['signature1'])) { |
||||
$form->addElement('checkbox', 'remove_signature1', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['signature1'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'signature1', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div>'); |
||||
// signature 2 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addText( |
||||
'signature_text2', |
||||
get_lang('SignatureText2'), |
||||
false, |
||||
['cols-size' => [2, 10, 0], 'autofocus'] |
||||
); |
||||
$form->addFile( |
||||
'signature2', |
||||
get_lang('Signature2'), |
||||
[ |
||||
'id' => 'signature2', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['signature2'])) { |
||||
$form->addElement('checkbox', 'remove_signature2', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['signature2'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'signature2', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div><div class="clearfix"></div>'); |
||||
// signature 3 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addText( |
||||
'signature_text3', |
||||
get_lang('SignatureText3'), |
||||
false, |
||||
['cols-size' => [2, 10, 0], 'autofocus'] |
||||
); |
||||
$form->addFile( |
||||
'signature3', |
||||
get_lang('Signature3'), |
||||
[ |
||||
'id' => 'signature3', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['signature3'])) { |
||||
$form->addElement('checkbox', 'remove_signature3', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['signature3'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'signature3', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div>'); |
||||
// signature 4 |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addText( |
||||
'signature_text4', |
||||
get_lang('SignatureText4'), |
||||
false, |
||||
['cols-size' => [2, 10, 0], 'autofocus'] |
||||
); |
||||
$form->addFile( |
||||
'signature4', |
||||
get_lang('Signature4'), |
||||
[ |
||||
'id' => 'signature4', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_scalable' => 'true', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['signature4'])) { |
||||
$form->addElement('checkbox', 'remove_signature4', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['signature4'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'signature4', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</div><div class="clearfix"></div>'); |
||||
$form->addHtml('</fieldset><br>'); |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang('BackgroundCertificate')).'</legend>'); |
||||
// background |
||||
$form->addFile( |
||||
'background', |
||||
get_lang('Background'), |
||||
[ |
||||
'id' => 'background', |
||||
'class' => 'picture-form', |
||||
'crop_image' => true, |
||||
'crop_ratio' => '297 / 210', |
||||
] |
||||
); |
||||
$form->addProgress(); |
||||
if (!empty($infoCertificate['background'])) { |
||||
$form->addElement('checkbox', 'remove_background', null, get_lang('DelImage')); |
||||
$form->addElement( |
||||
'html', |
||||
'<label class="col-sm-2"> </label> |
||||
<img src="'.$path.$infoCertificate['background'].'" width="100" /> |
||||
<br><br>' |
||||
); |
||||
} |
||||
$allowedPictureTypes = api_get_supported_image_extensions(false); |
||||
$form->addRule( |
||||
'background', |
||||
get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowedPictureTypes).')', |
||||
'filetype', |
||||
$allowedPictureTypes |
||||
); |
||||
$form->addHtml('</fieldset>'); |
||||
$form->addHtml('</div>'); |
||||
$form->addHtml('<div class="col-sm-6">'); |
||||
$form->addHtml('<fieldset><legend>'.strtoupper(get_lang('OtherOptions')).'</legend>'); |
||||
$marginOptions = []; |
||||
$i = 0; |
||||
while ($i < 298) { |
||||
$marginOptions[$i] = $i.' mm'; |
||||
$i++; |
||||
} |
||||
$form->addElement( |
||||
'select', |
||||
'margin_left', |
||||
get_lang('MarginLeft'), |
||||
$marginOptions, |
||||
['cols-size' => [4, 8, 0]] |
||||
); |
||||
$form->addElement( |
||||
'select', |
||||
'margin_right', |
||||
get_lang('MarginRight'), |
||||
$marginOptions, |
||||
['cols-size' => [4, 8, 0]] |
||||
); |
||||
$form->addHtml('</fieldset>'); |
||||
$form->addHtml('</div>'); |
||||
$form->addHtml('<div class="clearfix"></div>'); |
||||
|
||||
$form->addButton( |
||||
'submit', |
||||
get_lang('SaveCertificate'), |
||||
'check', |
||||
'primary', |
||||
null, |
||||
null, |
||||
['cols-size' => [5, 2, 5]], |
||||
false |
||||
); |
||||
|
||||
$form->addElement('hidden', 'formSent'); |
||||
$infoCertificate['formSent'] = 1; |
||||
$form->setDefaults($infoCertificate); |
||||
$token = Security::get_token(); |
||||
$form->addElement('hidden', 'sec_token'); |
||||
$form->addElement('hidden', 'use_default'); |
||||
$form->addElement('hidden', 'default_certificate'); |
||||
$form->addElement('hidden', 'c_id'); |
||||
$form->addElement('hidden', 'session_id'); |
||||
$form->setConstants( |
||||
[ |
||||
'sec_token' => $token, |
||||
'use_default' => $useDefault, |
||||
'default_certificate' => $defaultCertificate, |
||||
'c_id' => $courseId, |
||||
'session_id' => $sessionId, |
||||
] |
||||
); |
||||
echo '<div class="page-create">'; |
||||
echo '<div class="row" style="overflow:hidden">'; |
||||
echo '<div id="doc_form" class="col-md-12">'; |
||||
echo $form->returnForm(); |
||||
echo '</div>'; |
||||
echo '</div>'; |
||||
echo '</div>'; |
||||
Display::display_footer(); |
||||
|
||||
/** |
||||
* Delete the file if there is only one instance. |
||||
* |
||||
* @param int $certificateId |
||||
* @param string $imagePath |
||||
* @param string $field |
||||
* @param string $type |
||||
*/ |
||||
function checkInstanceImage($certificateId, $imagePath, $field, $type = 'certificates') |
||||
{ |
||||
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
||||
$imagePath = Database::escape_string($imagePath); |
||||
$field = Database::escape_string($field); |
||||
|
||||
$sql = "SELECT * FROM $table WHERE $field = '$imagePath'"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) == 1) { |
||||
api_remove_uploaded_file($type, $imagePath); |
||||
} |
||||
|
||||
$sql = "UPDATE $table SET $field = '' WHERE id = $certificateId"; |
||||
Database::query($sql); |
||||
} |
@ -0,0 +1,497 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use Chamilo\CourseBundle\Entity\CLpCategory; |
||||
|
||||
if (intval($_GET['default']) == 1) { |
||||
$cidReset = true; |
||||
} |
||||
|
||||
$course_plugin = 'customcertificate'; |
||||
require_once __DIR__.'/../config.php'; |
||||
|
||||
api_block_anonymous_users(); |
||||
$plugin = CustomCertificatePlugin::create(); |
||||
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; |
||||
$tblProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); |
||||
|
||||
if (!$enable) { |
||||
api_not_allowed(true, $plugin->get_lang('ToolDisabled')); |
||||
} |
||||
|
||||
if (intval($_GET['default']) == 1) { |
||||
$courseId = 0; |
||||
$courseCode = ''; |
||||
$sessionId = 0; |
||||
$enableCourse = false; |
||||
$useDefault = true; |
||||
} else { |
||||
$courseId = api_get_course_int_id(); |
||||
$courseCode = api_get_course_id(); |
||||
$sessionId = api_get_session_id(); |
||||
$enableCourse = api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 ? true : false; |
||||
$useDefault = api_get_course_setting('use_certificate_default', $courseCode) == 1 ? true : false; |
||||
} |
||||
$accessUrlId = api_get_current_access_url_id(); |
||||
|
||||
$userList = []; |
||||
if (empty($_GET['export_all'])) { |
||||
if (!isset($_GET['student_id'])) { |
||||
$studentId = api_get_user_id(); |
||||
} else { |
||||
$studentId = intval($_GET['student_id']); |
||||
} |
||||
$userList[] = api_get_user_info($studentId); |
||||
} else { |
||||
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
||||
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
||||
$sql = "SELECT cer.user_id AS user_id |
||||
FROM $certificateTable cer |
||||
INNER JOIN $categoryTable cat |
||||
ON (cer.cat_id = cat.id) |
||||
WHERE cat.course_code = '$courseCode' AND cat.session_id = $sessionId"; |
||||
$rs = Database::query($sql); |
||||
while ($row = Database::fetch_assoc($rs)) { |
||||
$userList[] = api_get_user_info($row['user_id']); |
||||
} |
||||
} |
||||
|
||||
$sessionInfo = []; |
||||
if ($sessionId > 0) { |
||||
$sessionInfo = SessionManager::fetch($sessionId); |
||||
} |
||||
|
||||
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
||||
$useDefault = false; |
||||
$path = api_get_path(SYS_UPLOAD_PATH).'certificates/'; |
||||
|
||||
// Get info certificate |
||||
$infoCertificate = Database::select( |
||||
'*', |
||||
$table, |
||||
['where' => ['access_url_id = ? AND c_id = ? AND session_id = ?' => [$accessUrlId, $courseId, $sessionId]]], |
||||
'first' |
||||
); |
||||
|
||||
if (!is_array($infoCertificate)) { |
||||
$infoCertificate = []; |
||||
} |
||||
|
||||
if (empty($infoCertificate)) { |
||||
$infoCertificate = Database::select( |
||||
'*', |
||||
Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE), |
||||
['where' => ['access_url_id = ? AND certificate_default = ? ' => [$accessUrlId, 1]]], |
||||
'first' |
||||
); |
||||
|
||||
if (!is_array($infoCertificate)) { |
||||
$infoCertificate = []; |
||||
} |
||||
|
||||
if (empty($infoCertificate)) { |
||||
Display::display_header($plugin->get_lang('PrintCertificate')); |
||||
echo Display::return_message($plugin->get_lang('ErrorTemplateCertificate'), 'error'); |
||||
Display::display_footer(); |
||||
exit; |
||||
} else { |
||||
$useDefault = true; |
||||
} |
||||
} |
||||
|
||||
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']); |
||||
$widthCell = intval($workSpace / 6); |
||||
$htmlText = '<html>'; |
||||
$htmlText .= ' |
||||
<link rel="stylesheet" |
||||
type="text/css" |
||||
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">'; |
||||
$htmlText .= ' |
||||
<link rel="stylesheet" |
||||
type="text/css" |
||||
href="'.api_get_path(WEB_CSS_PATH).'document.css">'; |
||||
$htmlText .= '<body>'; |
||||
foreach ($userList as $userInfo) { |
||||
$studentId = $userInfo['user_id']; |
||||
|
||||
if (empty($infoCertificate['background'])) { |
||||
$htmlText .= '<div class="caraA" style="page-break-before:always; margin:0px; padding:0px;">'; |
||||
} else { |
||||
$urlBackground = $path.$infoCertificate['background']; |
||||
$htmlText .= ' <div |
||||
class = "caraA" |
||||
style = "background-image:url('.$urlBackground.') no-repeat; background-image-resize:6; margin:0px; padding:0px;">'; |
||||
} |
||||
|
||||
if (!empty($infoCertificate['logo_left'])) { |
||||
$logoLeft = ' |
||||
<img |
||||
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;" |
||||
src="'.$path.$infoCertificate['logo_left'].'" />'; |
||||
} else { |
||||
$logoLeft = ''; |
||||
} |
||||
|
||||
$logoCenter = ''; |
||||
if (!empty($infoCertificate['logo_center'])) { |
||||
$logoCenter = ' |
||||
<img |
||||
style="max-height: 150px; max-width: '.intval($workSpace - (2 * $widthCell)).'mm;" |
||||
src="'.$path.$infoCertificate['logo_center'].'" />'; |
||||
} |
||||
|
||||
$logoRight = ''; |
||||
if (!empty($infoCertificate['logo_right'])) { |
||||
$logoRight = ' |
||||
<img |
||||
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;" |
||||
src="'.$path.$infoCertificate['logo_right'].'" />'; |
||||
} |
||||
|
||||
$htmlText .= '<table |
||||
width="'.$workSpace.'mm" |
||||
style=" |
||||
margin-left:'.$infoCertificate['margin_left'].'mm; |
||||
margin-right:'.$infoCertificate['margin_right'].'mm; |
||||
" |
||||
border="0">'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td style="width:'.intval($workSpace / 3).'mm" class="logo">'.$logoLeft.'</td>'; |
||||
$htmlText .= '<td style="width:'.intval($workSpace / 3).'mm; text-align:center;" class="logo">'.$logoCenter.'</td>'; |
||||
$htmlText .= '<td style="width:'.intval($workSpace / 3).'mm; text-align:right;" class="logo">'.$logoRight.'</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
|
||||
$all_user_info = DocumentManager::get_all_info_to_certificate( |
||||
$studentId, |
||||
$courseCode, |
||||
true |
||||
); |
||||
|
||||
$myContentHtml = $infoCertificate['content_course']; |
||||
$myContentHtml = str_replace(chr(13).chr(10).chr(13).chr(10), chr(13).chr(10), $myContentHtml); |
||||
$info_to_be_replaced_in_content_html = $all_user_info[0]; |
||||
$info_to_replace_in_content_html = $all_user_info[1]; |
||||
$myContentHtml = str_replace( |
||||
$info_to_be_replaced_in_content_html, |
||||
$info_to_replace_in_content_html, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$startDate = ''; |
||||
$endDate = ''; |
||||
switch ($infoCertificate['date_change']) { |
||||
case 0: |
||||
if (!empty($sessionInfo['access_start_date'])) { |
||||
$startDate = date("d/m/Y", strtotime(api_get_local_time($sessionInfo['access_start_date']))); |
||||
} |
||||
if (!empty($sessionInfo['access_end_date'])) { |
||||
$endDate = date("d/m/Y", strtotime(api_get_local_time($sessionInfo['access_end_date']))); |
||||
} |
||||
break; |
||||
case 1: |
||||
$startDate = date("d/m/Y", strtotime($infoCertificate['date_start'])); |
||||
$endDate = date("d/m/Y", strtotime($infoCertificate['date_end'])); |
||||
break; |
||||
} |
||||
|
||||
$myContentHtml = str_replace( |
||||
'((start_date))', |
||||
$startDate, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$myContentHtml = str_replace( |
||||
'((end_date))', |
||||
$endDate, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$dateExpediction = ''; |
||||
if ($infoCertificate['type_date_expediction'] != 3) { |
||||
$dateExpediction .= $plugin->get_lang('ExpedictionIn').' '.$infoCertificate['place']; |
||||
if ($infoCertificate['type_date_expediction'] == 1) { |
||||
$dateExpediction .= $plugin->get_lang('to').api_format_date(time(), DATE_FORMAT_LONG); |
||||
} elseif ($infoCertificate['type_date_expediction'] == 2) { |
||||
$dateFormat = $plugin->get_lang('formatDownloadDate'); |
||||
if (!empty($infoCertificate['day']) && |
||||
!empty($infoCertificate['month']) && |
||||
!empty($infoCertificate['year']) |
||||
) { |
||||
$dateExpediction .= sprintf( |
||||
$dateFormat, |
||||
$infoCertificate['day'], |
||||
$infoCertificate['month'], |
||||
$infoCertificate['year'] |
||||
); |
||||
} else { |
||||
$dateExpediction .= sprintf( |
||||
$dateFormat, |
||||
'......', |
||||
'....................', |
||||
'............' |
||||
); |
||||
} |
||||
} else { |
||||
$dateInfo = api_get_local_time($sessionInfo['access_end_date']); |
||||
$dateExpediction .= $plugin->get_lang('to').api_format_date($dateInfo, DATE_FORMAT_LONG); |
||||
} |
||||
} |
||||
|
||||
$myContentHtml = str_replace( |
||||
'((date_expediction))', |
||||
$dateExpediction, |
||||
$myContentHtml |
||||
); |
||||
|
||||
$myContentHtml = strip_tags( |
||||
$myContentHtml, |
||||
'<p><b><strong><table><tr><td><th><tbody><span><i><li><ol><ul> |
||||
<dd><dt><dl><br><hr><img><a><div><h1><h2><h3><h4><h5><h6>' |
||||
); |
||||
|
||||
$htmlText .= '<div style=" |
||||
height: 480px; |
||||
width:'.$workSpace.'mm; |
||||
margin-left:'.$infoCertificate['margin_left'].'mm; |
||||
margin-right:'.$infoCertificate['margin_right'].'mm; |
||||
">'; |
||||
$htmlText .= $myContentHtml; |
||||
$htmlText .= '</div>'; |
||||
|
||||
$htmlText .= '<table |
||||
width="'.$workSpace.'mm" |
||||
style=" |
||||
margin-left:'.$infoCertificate['margin_left'].'mm; |
||||
margin-right:'.$infoCertificate['margin_right'].'mm; |
||||
" |
||||
border="0">'; |
||||
|
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : ''). |
||||
'</td> |
||||
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : ''). |
||||
'</td> |
||||
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : ''). |
||||
'</td> |
||||
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature_text4'])) ? $infoCertificate['signature_text4'] : ''). |
||||
'</td> |
||||
<td colspan="4" class="seals" style="width:'.(2 * $widthCell).'mm"> |
||||
'.((!empty($infoCertificate['seal'])) ? $plugin->get_lang('Seal') : ''). |
||||
'</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature1'])) |
||||
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature1'].'" />' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature2'])) |
||||
? '<img style="max-height: 100px; '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature2'].'" />' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature3'])) |
||||
? '<img style="max-height: 100px; '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature3'].'" />' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'. |
||||
((!empty($infoCertificate['signature4'])) |
||||
? '<img style="max-height: 100px; '.$widthCell.'mm;" |
||||
src="'.$path.$infoCertificate['signature4'].'" />' |
||||
: ''). |
||||
'</td> |
||||
<td colspan="4" class="logo-seals" style="width:'.(2 * $widthCell).'mm">'. |
||||
((!empty($infoCertificate['seal'])) |
||||
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;" |
||||
src="'.$path.$infoCertificate['seal'].'" />' |
||||
: ''). |
||||
'</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
$htmlText .= '</div>'; |
||||
|
||||
// Rear certificate |
||||
if ($infoCertificate['contents_type'] != 3) { |
||||
$htmlText .= '<div class="caraB" style="page-break-before:always; margin:0px; padding:0px;">'; |
||||
if ($infoCertificate['contents_type'] == 0) { |
||||
$courseDescription = new CourseDescription(); |
||||
$contentDescription = $courseDescription->get_data_by_description_type(3, $courseId, 0); |
||||
$domd = new DOMDocument(); |
||||
libxml_use_internal_errors(true); |
||||
if (isset($contentDescription['description_content'])) { |
||||
$domd->loadHTML($contentDescription['description_content']); |
||||
} |
||||
libxml_use_internal_errors(false); |
||||
$domx = new DOMXPath($domd); |
||||
$items = $domx->query("//li[@style]"); |
||||
foreach ($items as $item) { |
||||
$item->removeAttribute("style"); |
||||
} |
||||
|
||||
$items = $domx->query("//span[@style]"); |
||||
foreach ($items as $item) { |
||||
$item->removeAttribute("style"); |
||||
} |
||||
|
||||
$output = $domd->saveHTML(); |
||||
$htmlText .= getIndexFiltered($output); |
||||
} |
||||
|
||||
if ($infoCertificate['contents_type'] == 1) { |
||||
$items = []; |
||||
$categoriesTempList = learnpath::getCategories($courseId); |
||||
$categoryTest = new CLpCategory(); |
||||
$categoryTest->setId(0); |
||||
$categoryTest->setName($plugin->get_lang('WithOutCategory')); |
||||
$categoryTest->setPosition(0); |
||||
$categories = [$categoryTest]; |
||||
|
||||
if (!empty($categoriesTempList)) { |
||||
$categories = array_merge($categories, $categoriesTempList); |
||||
} |
||||
|
||||
foreach ($categories as $item) { |
||||
$categoryId = $item->getId(); |
||||
|
||||
if (!learnpath::categoryIsVisibleForStudent($item, api_get_user_entity($studentId))) { |
||||
continue; |
||||
} |
||||
|
||||
$sql = "SELECT 1 |
||||
FROM $tblProperty |
||||
WHERE tool = 'learnpath_category' |
||||
AND ref = $categoryId |
||||
AND visibility = 0 |
||||
AND (session_id = $sessionId OR session_id IS NULL)"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) > 0) { |
||||
continue; |
||||
} |
||||
|
||||
$list = new LearnpathList( |
||||
$studentId, |
||||
$courseCode, |
||||
$sessionId, |
||||
null, |
||||
false, |
||||
$categoryId |
||||
); |
||||
|
||||
$flat_list = $list->get_flat_list(); |
||||
|
||||
if (empty($flat_list)) { |
||||
continue; |
||||
} |
||||
|
||||
if (count($categories) > 1 && count($flat_list) > 0) { |
||||
if ($item->getName() != $plugin->get_lang('WithOutCategory')) { |
||||
$items[] = '<h4 style="margin:0">'.$item->getName().'</h4>'; |
||||
} |
||||
} |
||||
|
||||
foreach ($flat_list as $learnpath) { |
||||
$lpId = $learnpath['lp_old_id']; |
||||
$sql = "SELECT 1 |
||||
FROM $tblProperty |
||||
WHERE tool = 'learnpath' |
||||
AND ref = $lpId AND visibility = 0 |
||||
AND (session_id = $sessionId OR session_id IS NULL)"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) > 0) { |
||||
continue; |
||||
} |
||||
$lpName = $learnpath['lp_name']; |
||||
$items[] = $lpName.'<br>'; |
||||
} |
||||
$items[] = '<br>'; |
||||
} |
||||
|
||||
if (count($items) > 0) { |
||||
$htmlText .= '<table width="100%" class="contents-learnpath">'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td>'; |
||||
$i = 0; |
||||
foreach ($items as $value) { |
||||
if ($i == 50) { |
||||
$htmlText .= '</td><td>'; |
||||
} |
||||
$htmlText .= $value; |
||||
$i++; |
||||
} |
||||
$htmlText .= '</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
} |
||||
$htmlText .= '</td></table>'; |
||||
} |
||||
|
||||
if ($infoCertificate['contents_type'] == 2) { |
||||
$htmlText .= '<table width="100%" class="contents-learnpath">'; |
||||
$htmlText .= '<tr>'; |
||||
$htmlText .= '<td>'; |
||||
$myContentHtml = strip_tags( |
||||
$infoCertificate['contents'], |
||||
'<p><b><strong><table><tr><td><th><span><i><li><ol><ul>'. |
||||
'<dd><dt><dl><br><hr><img><a><div><h1><h2><h3><h4><h5><h6>' |
||||
); |
||||
$htmlText .= $myContentHtml; |
||||
$htmlText .= '</td>'; |
||||
$htmlText .= '</tr>'; |
||||
$htmlText .= '</table>'; |
||||
} |
||||
$htmlText .= '</div>'; |
||||
} |
||||
} |
||||
$htmlText .= '</body></html>'; |
||||
|
||||
$fileName = 'certificate_'.date("Ymd_His"); |
||||
$params = [ |
||||
'filename' => $fileName, |
||||
'pdf_title' => "Certificate", |
||||
'pdf_description' => '', |
||||
'format' => 'A4-L', |
||||
'orientation' => 'L', |
||||
'left' => 15, |
||||
'top' => 15, |
||||
'bottom' => 0, |
||||
]; |
||||
|
||||
$pdf = new PDF($params['format'], $params['orientation'], $params); |
||||
$pdf->content_to_pdf($htmlText, '', $fileName, null, 'D', false, null, false, false, false); |
||||
exit; |
||||
|
||||
function getIndexFiltered($index) |
||||
{ |
||||
$txt = strip_tags($index, "<b><strong><i>"); |
||||
$txt = str_replace(chr(13).chr(10).chr(13).chr(10), chr(13).chr(10), $txt); |
||||
$lines = explode(chr(13).chr(10), $txt); |
||||
$text1 = ''; |
||||
for ($x = 0; $x < 47; $x++) { |
||||
$text1 .= $lines[$x].chr(13).chr(10); |
||||
} |
||||
|
||||
$text2 = ''; |
||||
for ($x = 47; $x < 94; $x++) { |
||||
$text2 .= $lines[$x].chr(13).chr(10); |
||||
} |
||||
|
||||
$showLeft = str_replace(chr(13).chr(10), "<br/>", $text1); |
||||
$showRight = str_replace(chr(13).chr(10), "<br/>", $text2); |
||||
$result = '<table width="100%">'; |
||||
$result .= '<tr>'; |
||||
$result .= '<td style="width:50%;vertical-align:top;padding-left:15px; font-size:12px;">'.$showLeft.'</td>'; |
||||
$result .= '<td style="vertical-align:top; font-size:12px;">'.$showRight.'</td>'; |
||||
$result .= '<tr>'; |
||||
$result .= '</table>'; |
||||
|
||||
return $result; |
||||
} |
@ -0,0 +1,34 @@ |
||||
<?php |
||||
/** |
||||
* This script initiates a customcertificate plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
$course_plugin = 'customcertificate'; |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
$plugin = CustomCertificatePlugin::create(); |
||||
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; |
||||
|
||||
if ($enable) { |
||||
if (api_is_platform_admin() || api_is_teacher()) { |
||||
$url = 'src/index.php?'; |
||||
$url .= (isset($_GET['cidReq']) ? api_get_cidreq() : 'default=1'); |
||||
header('Location: '.$url); |
||||
exit; |
||||
} else { |
||||
$session = api_get_session_entity(api_get_session_id()); |
||||
$_course = api_get_course_info(); |
||||
$webCoursePath = api_get_path(WEB_COURSE_PATH); |
||||
$url = $webCoursePath.$_course['path'].'/index.php'.($session ? '?id_session='.$session->getId() : ''); |
||||
|
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('OnlyAdminPlatform')) |
||||
); |
||||
|
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
} else { |
||||
api_not_allowed(true, $plugin->get_lang('ToolDisabled')); |
||||
} |
@ -0,0 +1,12 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script is included by main/admin/settings.lib.php when unselecting a plugin |
||||
* and is meant to remove things installed by the install.php script in both |
||||
* the global database and the courses tables. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
CustomCertificatePlugin::create()->uninstall(); |
@ -0,0 +1,14 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* This script is meant to update previous version the plugin. |
||||
* |
||||
* @package chamilo.plugin.customcertificate |
||||
*/ |
||||
require_once __DIR__.'/config.php'; |
||||
|
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
|
||||
CustomCertificatePlugin::create()->update(); |
@ -0,0 +1,2 @@ |
||||
## Learning calendar |
||||
|
@ -0,0 +1,43 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
|
||||
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; |
||||
$calendarId = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0; |
||||
|
||||
$plugin = LearningCalendarPlugin::create(); |
||||
$item = $plugin->getCalendar($calendarId); |
||||
$plugin->protectCalendar($item); |
||||
|
||||
switch ($action) { |
||||
case 'toggle_day': |
||||
$startDate = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : ''; |
||||
if (empty($startDate)) { |
||||
exit; |
||||
} |
||||
$endDate = isset($_REQUEST['end_date']) ? $_REQUEST['end_date'] : ''; |
||||
if ($startDate == $endDate) { |
||||
// One day |
||||
$plugin->toogleDayType($calendarId, $startDate); |
||||
} else { |
||||
// A list of days |
||||
$startDateTime = new DateTime($startDate); |
||||
$endDateTime = new DateTime($endDate); |
||||
$diff = $startDateTime->diff($endDateTime); |
||||
$countDays = $diff->format('%a'); |
||||
$dayList[] = $startDate; |
||||
for ($i = 0; $i < $countDays; $i++) { |
||||
$startDateTime->modify('+1 day'); |
||||
$dayList[] = $startDateTime->format('Y-m-d'); |
||||
} |
||||
foreach ($dayList as $day) { |
||||
$plugin->toogleDayType($calendarId, $day); |
||||
} |
||||
} |
||||
break; |
||||
case 'get_events': |
||||
$list = $plugin->getEvents($calendarId); |
||||
echo json_encode($list); |
||||
break; |
||||
} |
@ -0,0 +1,50 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
|
||||
$calendarId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
||||
$plugin = LearningCalendarPlugin::create(); |
||||
$item = $plugin->getCalendar($calendarId); |
||||
$plugin->protectCalendar($item); |
||||
|
||||
$isoCode = api_get_language_isocode(); |
||||
$htmlHeadXtra[] = api_get_asset('bootstrap-year-calendar/js/bootstrap-year-calendar.js'); |
||||
$calendarLanguage = 'en'; |
||||
if ($isoCode !== 'en') { |
||||
$file = 'bootstrap-year-calendar/js/languages/bootstrap-year-calendar.'.$isoCode.'.js'; |
||||
$path = api_get_path(SYS_PUBLIC_PATH).'assets/'.$file; |
||||
if (file_exists($path)) { |
||||
$htmlHeadXtra[] = api_get_asset($file); |
||||
$calendarLanguage = $isoCode; |
||||
} |
||||
} |
||||
|
||||
$htmlHeadXtra[] = api_get_css_asset('bootstrap-year-calendar/css/bootstrap-year-calendar.css'); |
||||
|
||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
||||
$formToString = ''; |
||||
|
||||
$template = new Template(); |
||||
$actionLeft = Display::url( |
||||
Display::return_icon( |
||||
'back.png', |
||||
get_lang('Add'), |
||||
null, |
||||
ICON_SIZE_MEDIUM |
||||
), |
||||
api_get_path(WEB_PLUGIN_PATH).'learning_calendar/start.php' |
||||
); |
||||
|
||||
$actions = Display::toolbarAction('toolbar-forum', [$actionLeft]); |
||||
|
||||
$eventList = $plugin->getEventTypeList(); |
||||
$template->assign('events', $eventList); |
||||
$template->assign('calendar_language', $calendarLanguage); |
||||
$template->assign('ajax_url', api_get_path(WEB_PLUGIN_PATH).'learning_calendar/ajax.php?id='.$calendarId); |
||||
$template->assign('header', $item['title']); |
||||
$content = $template->fetch('learning_calendar/view/calendar.tpl'); |
||||
$template->assign('actions', $actions); |
||||
$template->assign('content', $content); |
||||
|
||||
$template->display_one_col_template(); |
@ -0,0 +1,108 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
|
||||
$calendarId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
||||
$plugin = LearningCalendarPlugin::create(); |
||||
$plugin->protectCalendar($calendarId); |
||||
$item = $plugin->getCalendar($calendarId); |
||||
|
||||
if (empty($item)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
||||
$formToString = ''; |
||||
$template = new Template(); |
||||
$actionLeft = Display::url( |
||||
Display::return_icon( |
||||
'back.png', |
||||
get_lang('Add'), |
||||
null, |
||||
ICON_SIZE_MEDIUM |
||||
), |
||||
api_get_path(WEB_PLUGIN_PATH).'learning_calendar/start.php' |
||||
); |
||||
|
||||
$actions = Display::toolbarAction('toolbar-forum', [$actionLeft]); |
||||
|
||||
// jqgrid will use this URL to do the selects |
||||
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_calendar_users&id='.$calendarId; |
||||
|
||||
// The order is important you need to check the the $column variable in the model.ajax.php file |
||||
$columns = [ |
||||
get_lang('FirstName'), |
||||
get_lang('LastName'), |
||||
get_lang('Exam'), |
||||
]; |
||||
|
||||
// Column config |
||||
$column_model = [ |
||||
['name' => 'firstname', 'index' => 'firstname', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], |
||||
['name' => 'lastname', 'index' => 'lastname', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], |
||||
[ |
||||
'name' => 'exam', |
||||
'index' => 'exam', |
||||
'width' => '20', |
||||
'align' => 'center', |
||||
'sortable' => 'false', |
||||
], |
||||
]; |
||||
|
||||
// Autowidth |
||||
$extraParams['autowidth'] = 'true'; |
||||
// height auto |
||||
$extraParams['height'] = 'auto'; |
||||
$extraParams['sortname'] = 'name'; |
||||
$extraParams['sortorder'] = 'desc'; |
||||
$extraParams['multiselect'] = true; |
||||
|
||||
$deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL); |
||||
$urlStats = api_get_path(WEB_CODE_PATH); |
||||
$action_links = ''; |
||||
$deleteUrl = ''; |
||||
|
||||
// Add the JS needed to use the jqgrid |
||||
$htmlHeadXtra[] = api_get_jqgrid_js(); |
||||
|
||||
Display::display_header(); |
||||
|
||||
?> |
||||
<script> |
||||
$(function() { |
||||
<?php |
||||
// grid definition see the $usergroup>display() function |
||||
echo Display::grid_js( |
||||
'usergroups', |
||||
$url, |
||||
$columns, |
||||
$column_model, |
||||
$extraParams, |
||||
[], |
||||
$action_links, |
||||
true |
||||
); |
||||
?> |
||||
$("#usergroups").jqGrid( |
||||
"navGrid", |
||||
"#usergroups_pager", |
||||
{ edit: false, add: false, del: true, search: false}, |
||||
{ height:280, reloadAfterSubmit:false }, // edit options |
||||
{ height:280, reloadAfterSubmit:false }, // add options |
||||
{ reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
|
||||
{ width:500 } // search options |
||||
); |
||||
}); |
||||
</script> |
||||
<?php |
||||
|
||||
// action links |
||||
echo '<div class="actions">'; |
||||
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/usergroup_users.php?id='.$calendarId.'">'. |
||||
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', '32'). |
||||
'</a>'; |
||||
echo '</div>'; |
||||
echo Display::grid_html('usergroups'); |
||||
|
||||
Display::display_footer(); |
@ -0,0 +1,8 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
if (!api_is_platform_admin()) { |
||||
die('You must have admin permissions to install plugins'); |
||||
} |
||||
|
||||
LearningCalendarPlugin::create()->install(); |
@ -0,0 +1,22 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
$strings['plugin_title'] = 'Learning calendar'; |
||||
$strings['plugin_comment'] = ''; |
||||
$strings['enabled'] = 'Enabled'; |
||||
$strings['LearningCalendar'] = 'Learning calendar'; |
||||
$strings['NumberDaysAccumulatedInCalendar'] = 'Number of days accumulated in the calendar: '; |
||||
$strings['NumberDaysAccumulatedInLp'] = 'Number of days accumulated in the LP: '; |
||||
$strings['NumberDaysInRetard'] = 'Number of days in retard: '; |
||||
$strings['DifferenceOfDaysAndCalendar'] = 'Difference of days and calendar'; |
||||
|
||||
$strings['EventTypeTaken'] = 'Taken'; |
||||
$strings['EventTypeExam'] = 'Exam'; |
||||
$strings['EventTypeFree'] = 'Free'; |
||||
$strings['CourseHoursDuration'] = 'Course hours duration'; |
||||
$strings['LearningCalendarOneDayMarker'] = 'Learning calendar one day marker'; |
||||
$strings['ControlPointAdded'] = 'Control point added'; |
||||
$strings['NumberOfDays'] = 'Number of days'; |
||||
$strings['Date'] = 'Date'; |
||||
$strings['AddMultipleUsersToCalendar'] = 'Add multiple users to a calendar'; |
||||
$strings['UpdateCalendar'] = 'Update calendar'; |
@ -0,0 +1,14 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
$strings['plugin_title'] = 'Learning calendar'; |
||||
$strings['plugin_comment'] = ''; |
||||
$strings['enabled'] = 'Enabled'; |
||||
$strings['LearningCalendar'] = 'Learning calendar'; |
||||
$strings['NumberDaysAccumulatedInCalendar'] = 'Nombre de jours cumulés dans le calendrier: '; |
||||
$strings['NumberDaysAccumulatedInLp'] = 'Nombre de jours cumulés dans les parcours réalisés: '; |
||||
$strings['NumberDaysInRetard'] = "Nombre de jour de retard ou d'avance à la date d'aujourd'hui: "; |
||||
$strings['DifferenceOfDaysAndCalendar'] = 'Différence de nombre de jours avec le plan issu du learning_calendar'; |
||||
$strings['EventTypeTaken'] = 'Occupé'; |
||||
$strings['EventTypeExam'] = 'Examen'; |
||||
$strings['EventTypeFree'] = 'Libre'; |
@ -0,0 +1,7 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
$strings['plugin_title'] = 'Learning calendar'; |
||||
$strings['plugin_comment'] = ''; |
||||
$strings['enabled'] = 'Activado'; |
||||
$strings['LearningCalendar'] = 'Learning calendar'; |
@ -0,0 +1,4 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
$plugin_info = LearningCalendarPlugin::create()->get_info(); |
@ -0,0 +1,191 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
|
||||
$allow = api_is_platform_admin() || api_is_teacher(); |
||||
|
||||
if (!$allow) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$plugin = LearningCalendarPlugin::create(); |
||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
||||
$calendarId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
||||
$formToString = ''; |
||||
|
||||
switch ($action) { |
||||
case 'add': |
||||
$form = new FormValidator('calendar', 'post', api_get_self().'?action=add'); |
||||
$plugin->getForm($form); |
||||
$form->addButtonSave(get_lang('Save')); |
||||
$formToString = $form->returnForm(); |
||||
|
||||
if ($form->validate()) { |
||||
$values = $form->getSubmitValues(); |
||||
$params = [ |
||||
'title' => $values['title'], |
||||
'total_hours' => $values['total_hours'], |
||||
'minutes_per_day' => $values['minutes_per_day'], |
||||
'description' => $values['description'], |
||||
'author_id' => api_get_user_id(), |
||||
]; |
||||
Database::insert('learning_calendar', $params); |
||||
Display::addFlash(Display::return_message(get_lang('Saved'))); |
||||
header('Location: start.php'); |
||||
exit; |
||||
} |
||||
break; |
||||
case 'edit': |
||||
$form = new FormValidator('calendar', 'post', api_get_self().'?action=edit&id='.$calendarId); |
||||
$plugin->getForm($form); |
||||
$form->addButtonSave(get_lang('Update')); |
||||
$item = $plugin->getCalendar($calendarId); |
||||
$plugin->protectCalendar($item); |
||||
|
||||
if (empty($item)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$form->setDefaults($item); |
||||
$formToString = $form->returnForm(); |
||||
|
||||
if ($form->validate()) { |
||||
$values = $form->getSubmitValues(); |
||||
$params = [ |
||||
'title' => $values['title'], |
||||
'total_hours' => $values['total_hours'], |
||||
'minutes_per_day' => $values['minutes_per_day'], |
||||
'description' => $values['description'], |
||||
]; |
||||
Database::update('learning_calendar', $params, ['id = ?' => $calendarId]); |
||||
Display::addFlash(Display::return_message(get_lang('Updated'))); |
||||
header('Location: start.php'); |
||||
exit; |
||||
} |
||||
break; |
||||
case 'copy': |
||||
$result = $plugin->copyCalendar($calendarId); |
||||
if ($result) { |
||||
Display::addFlash(Display::return_message(get_lang('Saved'))); |
||||
} |
||||
header('Location: start.php'); |
||||
exit; |
||||
|
||||
break; |
||||
case 'delete': |
||||
$result = $plugin->deleteCalendar($calendarId); |
||||
if ($result) { |
||||
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
||||
} |
||||
header('Location: start.php'); |
||||
exit; |
||||
break; |
||||
case 'toggle_visibility': |
||||
$itemId = isset($_REQUEST['lp_item_id']) ? $_REQUEST['lp_item_id'] : 0; |
||||
$lpId = isset($_REQUEST['lp_id']) ? $_REQUEST['lp_id'] : 0; |
||||
$plugin->toggleVisibility($itemId); |
||||
Display::addFlash(Display::return_message(get_lang('Updated'))); |
||||
$url = api_get_path(WEB_CODE_PATH). |
||||
'lp/lp_controller.php?action=add_item&type=step&lp_id='.$lpId.'&'.api_get_cidreq(); |
||||
header("Location: $url"); |
||||
exit; |
||||
break; |
||||
} |
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js(); |
||||
|
||||
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_learning_path_calendars'; |
||||
$columns = [ |
||||
get_lang('Title'), |
||||
get_lang('TotalHours'), |
||||
get_lang('MinutesPerDay'), |
||||
get_lang('Actions'), |
||||
]; |
||||
|
||||
$columnModel = [ |
||||
[ |
||||
'name' => 'title', |
||||
'index' => 'title', |
||||
'width' => '300', |
||||
'align' => 'left', |
||||
'sortable' => 'false', |
||||
], |
||||
[ |
||||
'name' => 'total_hours', |
||||
'index' => 'total_hours', |
||||
'width' => '100', |
||||
'align' => 'left', |
||||
'sortable' => 'false', |
||||
], |
||||
[ |
||||
'name' => 'minutes_per_day', |
||||
'index' => 'minutes_per_day', |
||||
'width' => '100', |
||||
'align' => 'left', |
||||
'sortable' => 'false', |
||||
], |
||||
[ |
||||
'name' => 'actions', |
||||
'index' => 'actions', |
||||
'width' => '150', |
||||
'align' => 'left', |
||||
//'formatter' => 'action_formatter', |
||||
'sortable' => 'false', |
||||
], |
||||
]; |
||||
|
||||
$extraParams = []; |
||||
$extraParams['autowidth'] = 'true'; |
||||
// height auto |
||||
$extraParams['height'] = 'auto'; |
||||
|
||||
$template = new Template(); |
||||
|
||||
if (in_array($action, ['add', 'edit'])) { |
||||
$actionLeft = Display::url( |
||||
Display::return_icon( |
||||
'back.png', |
||||
get_lang('Back'), |
||||
null, |
||||
ICON_SIZE_MEDIUM |
||||
), |
||||
api_get_self().'?'.api_get_cidreq() |
||||
); |
||||
} else { |
||||
$actionLeft = Display::url( |
||||
Display::return_icon( |
||||
'add.png', |
||||
get_lang('Add'), |
||||
null, |
||||
ICON_SIZE_MEDIUM |
||||
), |
||||
api_get_self().'?'.api_get_cidreq().'&action=add' |
||||
); |
||||
|
||||
$content = '<script> |
||||
$(function() {'. |
||||
Display::grid_js( |
||||
'calendars', |
||||
$url, |
||||
$columns, |
||||
$columnModel, |
||||
$extraParams, |
||||
[], |
||||
'', |
||||
true |
||||
).' |
||||
}); |
||||
</script>'; |
||||
|
||||
$content .= Display::grid_html('calendars'); |
||||
$template->assign('grid', $content); |
||||
} |
||||
|
||||
$template->assign('form', $formToString); |
||||
$actions = Display::toolbarAction('toolbar-calendar', [$actionLeft]); |
||||
$content = $template->fetch('learning_calendar/view/start.tpl'); |
||||
$template->assign('content', $content); |
||||
$template->assign('actions', $actions); |
||||
|
||||
$template->display_one_col_template(); |
@ -0,0 +1,4 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
LearningCalendarPlugin::create()->uninstall(); |
@ -0,0 +1,102 @@ |
||||
<script> |
||||
function getEvents(e) { |
||||
var myData = []; |
||||
$.ajax({ |
||||
dataType: "json", |
||||
url: "{{ ajax_url }}&a=get_events", |
||||
success: function(response) { |
||||
for (var i = 0; i < response.length; i++) { |
||||
myData.push({ |
||||
id: response[i].id, |
||||
title: response[i].title, |
||||
startDate: new Date(response[i].start_date), |
||||
endDate: new Date(response[i].end_date), |
||||
color: response[i].color |
||||
}); |
||||
} |
||||
$(e.target).data('calendar').setDataSource(myData); |
||||
} |
||||
}); |
||||
} |
||||
$(document).ready(function() { |
||||
$('#calendar').calendar({ |
||||
style:'background', |
||||
language : '{{ calendar_language }}', |
||||
enableRangeSelection: true, |
||||
enableContextMenu: true, |
||||
/*contextMenuItems:[ |
||||
{ |
||||
text: 'Update', |
||||
//click: editEvent |
||||
}, |
||||
{ |
||||
text: 'Delete', |
||||
click: deleteEvent |
||||
} |
||||
],*/ |
||||
customDayRenderer: function(e) { |
||||
$(e).parent().css('background-color', 'green'); |
||||
}, |
||||
{#clickDay: function(e) {#} |
||||
{#var dateString = moment(e.date).format("YYYY-MM-DD");#} |
||||
{#$.ajax({#} |
||||
{#type: "GET",#} |
||||
{#url: "{{ ajax_url }}&a=toggle_day&start_date="+dateString+"&end_date=",#} |
||||
{#success: function(returnValue) {#} |
||||
{#getEvents(e);#} |
||||
{#}#} |
||||
{#});#} |
||||
{#},#} |
||||
selectRange: function(e) { |
||||
var startString = moment(e.startDate).format("YYYY-MM-DD"); |
||||
var endString = moment(e.endDate).format("YYYY-MM-DD"); |
||||
$.ajax({ |
||||
type: "GET", |
||||
url: "{{ ajax_url }}&a=toggle_day&start_date="+startString+"&end_date=" + endString, |
||||
success: function(returnValue) { |
||||
getEvents(e); |
||||
} |
||||
}); |
||||
}, |
||||
yearChanged: function(e) { |
||||
e.preventRendering = true; |
||||
$(e.target).append('<div style="text-align:center"><i class="fa fa-spinner fa-spin fa-2x"></i></div>'); |
||||
getEvents(e); |
||||
}, |
||||
}); |
||||
}); |
||||
</script> |
||||
|
||||
<style> |
||||
#calendar { |
||||
overflow: visible; |
||||
} |
||||
|
||||
.calendar table.month tr td .day-content { |
||||
height: 24px; |
||||
} |
||||
</style> |
||||
|
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-12"> |
||||
<div id="calendar"></div> |
||||
</div> |
||||
</div> |
||||
<br /> |
||||
<br /> |
||||
<div class="row"> |
||||
<div class="col-xs-12 col-md-12"> |
||||
<table> |
||||
{% for event in events %} |
||||
<tr> |
||||
<td> |
||||
{{ event.name }}: |
||||
</td> |
||||
<td> |
||||
<span style="display:block;height:20px;width:100px; background-color: {{ event.color }}"></span> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
</div> |
||||
</div> |
@ -0,0 +1,3 @@ |
||||
{{ form }} |
||||
|
||||
{{ grid }} |