parent
4c08b6b3b5
commit
193a286273
@ -1,220 +1,219 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a formative action edit form. |
||||
*/ |
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$actionOrigin = Database::escape_string(trim($_POST['action_origin'])); |
||||
$actionCode = Database::escape_string(trim($_POST['action_code'])); |
||||
$situation = Database::escape_string(trim($_POST['situation'])); |
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin'])); |
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area'])); |
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code'])); |
||||
$duration = Database::escape_string(trim($_POST['duration'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$fullItineraryIndicator = Database::escape_string(trim($_POST['full_itinerary_indicator'])); |
||||
$financingType = Database::escape_string(trim($_POST['financing_type'])); |
||||
$attendeesCount = intval($_POST['attendees_count']); |
||||
$actionName = Database::escape_string(trim($_POST['action_name'])); |
||||
$globalInfo = Database::escape_string(trim($_POST['global_info'])); |
||||
$schedule = Database::escape_string(trim($_POST['schedule'])); |
||||
$requirements = Database::escape_string(trim($_POST['requirements'])); |
||||
$contactAction = Database::escape_string(trim($_POST['contact_action'])); |
||||
$actionId = intval($_POST['action_id']); |
||||
$courseId = intval($_POST['course_id']); |
||||
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (!empty($actionId) && $actionId != '0') { |
||||
$sql = "UPDATE plugin_sepe_actions SET |
||||
action_origin='".$actionOrigin."', |
||||
action_code='".$actionCode."', |
||||
situation='".$situation."', |
||||
specialty_origin='".$specialtyOrigin."', |
||||
professional_area='".$professionalArea."', |
||||
specialty_code='".$specialtyCode."', |
||||
duration='".$duration."', |
||||
start_date='".$startDate."', |
||||
end_date='".$endDate."', |
||||
full_itinerary_indicator='".$fullItineraryIndicator."', |
||||
financing_type='".$financingType."', |
||||
attendees_count='".$attendeesCount."', |
||||
action_name='".$actionName."', |
||||
global_info='".$globalInfo."', |
||||
schedule='".$schedule."', |
||||
requirements='".$requirements."', |
||||
contact_action='".$contactAction."' |
||||
WHERE id='".$actionId."';"; |
||||
} else { |
||||
$sql = "INSERT INTO plugin_sepe_actions ( |
||||
action_origin, |
||||
action_code, |
||||
situation, |
||||
specialty_origin, |
||||
professional_area, |
||||
specialty_code, |
||||
duration, |
||||
start_date, |
||||
end_date, |
||||
full_itinerary_indicator, |
||||
financing_type, |
||||
attendees_count, |
||||
action_name, |
||||
global_info, |
||||
schedule, |
||||
requirements, |
||||
contact_action |
||||
) VALUES ( |
||||
'".$actionOrigin."', |
||||
'".$actionCode."', |
||||
'".$situation."', |
||||
'".$specialtyOrigin."', |
||||
'".$professionalArea."', |
||||
'".$specialtyCode."', |
||||
'".$duration."', |
||||
'".$startDate."', |
||||
'".$endDate."', |
||||
'".$fullItineraryIndicator."', |
||||
'".$financingType."', |
||||
'".$attendeesCount."', |
||||
'".$actionName."', |
||||
'".$globalInfo."', |
||||
'".$schedule."', |
||||
'".$requirements."', |
||||
'".$contactAction."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
echo Database::error(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($actionId == '0') { |
||||
//Sync formative action and course |
||||
$actionId = Database::insert_id(); |
||||
$sql = "SELECT 1 FROM course WHERE id='".$courseId."';"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) == 0) { |
||||
$sepe_message_error .= $plugin->get_lang('NoExistsCourse'); |
||||
error_log($sepe_message_error); |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeCourseActions (course_id, action_id) VALUES ('".$courseId."','".$actionId."');"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
$sepe_message_error .= $plugin->get_lang('NoSaveSeleccion'); |
||||
error_log($sepe_message_error); |
||||
} else { |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
$courseId = getCourse($actionId); |
||||
header("Location: formative-action.php?cid=".$courseId); |
||||
} else { |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
$actionId = intval($_POST['action_id']); |
||||
if ($actionId == '0') { |
||||
$courseId = intval($_POST['course_id']); |
||||
header("Location: formative-action-edit.php?new_action=1&cid=".$courseId); |
||||
} else { |
||||
header("Location: formative-action-edit.php?action_id=".$actionId); |
||||
} |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
if (isset($_GET['new_action']) && intval($_GET['new_action']) == 1) { |
||||
$info = array(); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$templateName = $plugin->get_lang('formativeActionNew'); |
||||
$tpl = new Template($templateName); |
||||
$yearStart = $yearEnd = date("Y"); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_action', '1'); |
||||
$tpl->assign('course_id', intval($_GET['cid'])); |
||||
} else { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$info = getActionInfo(intval($_GET['action_id'])); |
||||
$templateName = $plugin->get_lang('formativeActionEdit'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('info', $info); |
||||
if ($info['start_date'] != "0000-00-00" && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['start_date'], '0000') === false) { |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$yearStart = date("Y"); |
||||
} |
||||
if ($info['end_date'] != "0000-00-00" && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$yearEnd = date("Y"); |
||||
} |
||||
$tpl->assign('new_action', '0'); |
||||
} |
||||
|
||||
$yearList = array(); |
||||
if ($yearStart > $yearEnd) { |
||||
$tmp = $yearStart; |
||||
$yearStart = $yearEnd; |
||||
$yearEnd = $tmp; |
||||
} |
||||
$yearStart -= 5; |
||||
$yearEnd += 5; |
||||
$fin_rango_anio = (($yearStart + 15) < $yearEnd) ? ($yearEnd + 1) : ($yearStart + 15); |
||||
while ($yearStart <= $fin_rango_anio) { |
||||
$yearList[] = $yearStart; |
||||
$yearStart++; |
||||
} |
||||
$tpl->assign('list_year', $yearList); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/formative-action-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a formative action edit form. |
||||
*/ |
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$actionOrigin = Database::escape_string(trim($_POST['action_origin'])); |
||||
$actionCode = Database::escape_string(trim($_POST['action_code'])); |
||||
$situation = Database::escape_string(trim($_POST['situation'])); |
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin'])); |
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area'])); |
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code'])); |
||||
$duration = Database::escape_string(trim($_POST['duration'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$fullItineraryIndicator = Database::escape_string(trim($_POST['full_itinerary_indicator'])); |
||||
$financingType = Database::escape_string(trim($_POST['financing_type'])); |
||||
$attendeesCount = intval($_POST['attendees_count']); |
||||
$actionName = Database::escape_string(trim($_POST['action_name'])); |
||||
$globalInfo = Database::escape_string(trim($_POST['global_info'])); |
||||
$schedule = Database::escape_string(trim($_POST['schedule'])); |
||||
$requirements = Database::escape_string(trim($_POST['requirements'])); |
||||
$contactAction = Database::escape_string(trim($_POST['contact_action'])); |
||||
$actionId = intval($_POST['action_id']); |
||||
$courseId = intval($_POST['course_id']); |
||||
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (!empty($actionId) && $actionId != '0') { |
||||
$sql = "UPDATE plugin_sepe_actions SET |
||||
action_origin='".$actionOrigin."', |
||||
action_code='".$actionCode."', |
||||
situation='".$situation."', |
||||
specialty_origin='".$specialtyOrigin."', |
||||
professional_area='".$professionalArea."', |
||||
specialty_code='".$specialtyCode."', |
||||
duration='".$duration."', |
||||
start_date='".$startDate."', |
||||
end_date='".$endDate."', |
||||
full_itinerary_indicator='".$fullItineraryIndicator."', |
||||
financing_type='".$financingType."', |
||||
attendees_count='".$attendeesCount."', |
||||
action_name='".$actionName."', |
||||
global_info='".$globalInfo."', |
||||
schedule='".$schedule."', |
||||
requirements='".$requirements."', |
||||
contact_action='".$contactAction."' |
||||
WHERE id='".$actionId."';"; |
||||
} else { |
||||
$sql = "INSERT INTO plugin_sepe_actions ( |
||||
action_origin, |
||||
action_code, |
||||
situation, |
||||
specialty_origin, |
||||
professional_area, |
||||
specialty_code, |
||||
duration, |
||||
start_date, |
||||
end_date, |
||||
full_itinerary_indicator, |
||||
financing_type, |
||||
attendees_count, |
||||
action_name, |
||||
global_info, |
||||
schedule, |
||||
requirements, |
||||
contact_action |
||||
) VALUES ( |
||||
'".$actionOrigin."', |
||||
'".$actionCode."', |
||||
'".$situation."', |
||||
'".$specialtyOrigin."', |
||||
'".$professionalArea."', |
||||
'".$specialtyCode."', |
||||
'".$duration."', |
||||
'".$startDate."', |
||||
'".$endDate."', |
||||
'".$fullItineraryIndicator."', |
||||
'".$financingType."', |
||||
'".$attendeesCount."', |
||||
'".$actionName."', |
||||
'".$globalInfo."', |
||||
'".$schedule."', |
||||
'".$requirements."', |
||||
'".$contactAction."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($actionId == '0') { |
||||
//Sync formative action and course |
||||
$actionId = Database::insert_id(); |
||||
$sql = "SELECT 1 FROM course WHERE id='".$courseId."';"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) == 0) { |
||||
$sepe_message_error .= $plugin->get_lang('NoExistsCourse'); |
||||
error_log($sepe_message_error); |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeCourseActions (course_id, action_id) VALUES ('".$courseId."','".$actionId."');"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
$sepe_message_error .= $plugin->get_lang('NoSaveSeleccion'); |
||||
error_log($sepe_message_error); |
||||
} else { |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
$courseId = getCourse($actionId); |
||||
header("Location: formative-action.php?cid=".$courseId); |
||||
} else { |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
$actionId = intval($_POST['action_id']); |
||||
if ($actionId == '0') { |
||||
$courseId = intval($_POST['course_id']); |
||||
header("Location: formative-action-edit.php?new_action=1&cid=".$courseId); |
||||
} else { |
||||
header("Location: formative-action-edit.php?action_id=".$actionId); |
||||
} |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
if (isset($_GET['new_action']) && intval($_GET['new_action']) == 1) { |
||||
$info = array(); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$templateName = $plugin->get_lang('formativeActionNew'); |
||||
$tpl = new Template($templateName); |
||||
$yearStart = $yearEnd = date("Y"); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_action', '1'); |
||||
$tpl->assign('course_id', intval($_GET['cid'])); |
||||
} else { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$info = getActionInfo(intval($_GET['action_id'])); |
||||
$templateName = $plugin->get_lang('formativeActionEdit'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('info', $info); |
||||
if ($info['start_date'] != "0000-00-00" && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['start_date'], '0000') === false) { |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$yearStart = date("Y"); |
||||
} |
||||
if ($info['end_date'] != "0000-00-00" && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$yearEnd = date("Y"); |
||||
} |
||||
$tpl->assign('new_action', '0'); |
||||
} |
||||
|
||||
$yearList = array(); |
||||
if ($yearStart > $yearEnd) { |
||||
$tmp = $yearStart; |
||||
$yearStart = $yearEnd; |
||||
$yearEnd = $tmp; |
||||
} |
||||
$yearStart -= 5; |
||||
$yearEnd += 5; |
||||
$fin_rango_anio = (($yearStart + 15) < $yearEnd) ? ($yearEnd + 1) : ($yearStart + 15); |
||||
while ($yearStart <= $fin_rango_anio) { |
||||
$yearList[] = $yearStart; |
||||
$yearStart++; |
||||
} |
||||
$tpl->assign('list_year', $yearList); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/formative-action-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
@ -1,200 +1,200 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* Functions for the Sepe plugin |
||||
* @package chamilo.plugin.sepe |
||||
*/ |
||||
|
||||
require_once '../config.php'; |
||||
|
||||
$plugin = SepePlugin::create(); |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_center_data') { |
||||
$sql = "DELETE FROM $tableSepeCenter;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$sql = "DELETE FROM $tableSepeActions;"; |
||||
$res = Database::query($sql); |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoCenter').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_action') { |
||||
$id = intval($_REQUEST['id']); |
||||
$sql = "DELETE FROM $tableSepeActions WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoAction').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
$_SESSION['sepe_message_info'] = $content; |
||||
echo json_encode(array("status" => "true")); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_specialty') { |
||||
$id = intval(substr($_REQUEST['id'], 9)); |
||||
$sql = "DELETE FROM $tableSepeSpecialty WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialty').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_specialty_participant') { |
||||
$id = intval(substr($_REQUEST['id'], 9)); |
||||
$sql = "DELETE FROM $tableSepeParticipantsSpecialty WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialty').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_classroom') { |
||||
$id = intval(substr($_REQUEST['id'], 9)); |
||||
$sql = "DELETE FROM $tableSepeSpecialtyClassroom WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialtyClassroom').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'checkTutorEdit') { |
||||
$type = Database::escape_string(trim($_REQUEST['type'])); |
||||
$number = Database::escape_string(trim($_REQUEST['number'])); |
||||
$letter = Database::escape_string(trim($_REQUEST['letter'])); |
||||
$platform_user_id = intval($_REQUEST['platform_user_id']); |
||||
|
||||
$sql = "SELECT platform_user_id |
||||
FROM $tableSepeTutors |
||||
WHERE document_type='".$type."' AND document_number='".$number."' AND document_letter='".$letter."';"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemDataBase').Database::error(); |
||||
error_log(print_r($content, 1)); |
||||
exit; |
||||
} else { |
||||
$aux = Database::fetch_assoc($res); |
||||
if ($aux['platform_user_id'] == $platform_user_id || $aux['platform_user_id'] == 0) { |
||||
echo json_encode(array("status" => "true")); |
||||
} else { |
||||
$content = $plugin->get_lang('ModDataTeacher'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_tutor') { |
||||
$id = intval(substr($_REQUEST['id'], 5)); |
||||
$sql = "DELETE FROM $tableSepeSpecialtyTutors WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialtyTutor').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_participant') { |
||||
$id = intval(substr($_REQUEST['id'], 11)); |
||||
$sql = "SELECT platform_user_id, action_id FROM $tableSepeParticipants WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
$row = Database::fetch_assoc($res); |
||||
|
||||
$sql = "UPDATE plugin_sepe_log_participant SET fecha_baja='".date("Y-m-d H:i:s")."' WHERE platform_user_id='".$row['platform_user_id']."' AND action_id='".$row['action_id']."';"; |
||||
$res = Database::query($sql); |
||||
|
||||
$sql = "DELETE FROM $tableSepeParticipants WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoParticipant').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'unlink_action') { |
||||
$id = intval(substr($_REQUEST['id'], 16)); |
||||
$sql = "DELETE FROM $tableSepeCourseActions WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDesvincularInfoAction').Database::error(); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'assign_action') { |
||||
$course_id = intval(substr($_REQUEST['course_id'], 9)); |
||||
$action_id = intval($_REQUEST['action_id']); |
||||
|
||||
if ($action_id != 0 && $course_id != 0) { |
||||
$sql = "SELECT * FROM $tableSepeCourseActions WHERE action_id = $action_id;"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$content = $plugin->get_lang('FormativeActionInUse'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$sql = "SELECT 1 FROM course WHERE id = $course_id;"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) == 0) { |
||||
$content = $plugin->get_lang('NoExistsCourse'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeCourseActions (course_id, action_id) VALUES ($course_id, $action_id);"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
$content = $plugin->get_lang('NoSaveData'); |
||||
echo json_encode(array("status" => "false", "content" => utf8_encode($content))); |
||||
} else { |
||||
echo json_encode(array("status" => "true")); |
||||
} |
||||
} |
||||
} |
||||
} else { |
||||
$content = $plugin->get_lang('ErrorDataIncorrect'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'key_sepe_generator') { |
||||
$tApi = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
||||
$info_user = api_get_user_info_from_username('SEPE'); |
||||
|
||||
$array_list_key = array(); |
||||
$user_id = $info_user['user_id']; |
||||
$api_service = 'dokeos'; |
||||
$num = UserManager::update_api_key($user_id, $api_service); |
||||
$array_list_key = UserManager::get_api_keys($user_id, $api_service); |
||||
|
||||
if (trim($array_list_key[$num]) != '') { |
||||
$content = $array_list_key[$num]; |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('ProblemGenerateApiKey'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} |
||||
} |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* Functions for the Sepe plugin |
||||
* @package chamilo.plugin.sepe |
||||
*/ |
||||
|
||||
require_once '../config.php'; |
||||
|
||||
$plugin = SepePlugin::create(); |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_center_data') { |
||||
$sql = "DELETE FROM $tableSepeCenter;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$sql = "DELETE FROM $tableSepeActions;"; |
||||
$res = Database::query($sql); |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoCenter'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_action') { |
||||
$id = intval($_REQUEST['id']); |
||||
$sql = "DELETE FROM $tableSepeActions WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoAction'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
$_SESSION['sepe_message_info'] = $content; |
||||
echo json_encode(array("status" => "true")); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_specialty') { |
||||
$id = intval(substr($_REQUEST['id'], 9)); |
||||
$sql = "DELETE FROM $tableSepeSpecialty WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialty'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_specialty_participant') { |
||||
$id = intval(substr($_REQUEST['id'], 9)); |
||||
$sql = "DELETE FROM $tableSepeParticipantsSpecialty WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialty'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_classroom') { |
||||
$id = intval(substr($_REQUEST['id'], 9)); |
||||
$sql = "DELETE FROM $tableSepeSpecialtyClassroom WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialtyClassroom'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'checkTutorEdit') { |
||||
$type = Database::escape_string(trim($_REQUEST['type'])); |
||||
$number = Database::escape_string(trim($_REQUEST['number'])); |
||||
$letter = Database::escape_string(trim($_REQUEST['letter'])); |
||||
$platform_user_id = intval($_REQUEST['platform_user_id']); |
||||
|
||||
$sql = "SELECT platform_user_id |
||||
FROM $tableSepeTutors |
||||
WHERE document_type='".$type."' AND document_number='".$number."' AND document_letter='".$letter."';"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemDataBase'); |
||||
error_log(print_r($content, 1)); |
||||
exit; |
||||
} else { |
||||
$aux = Database::fetch_assoc($res); |
||||
if ($aux['platform_user_id'] == $platform_user_id || $aux['platform_user_id'] == 0) { |
||||
echo json_encode(array("status" => "true")); |
||||
} else { |
||||
$content = $plugin->get_lang('ModDataTeacher'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_tutor') { |
||||
$id = intval(substr($_REQUEST['id'], 5)); |
||||
$sql = "DELETE FROM $tableSepeSpecialtyTutors WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoSpecialtyTutor'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'delete_participant') { |
||||
$id = intval(substr($_REQUEST['id'], 11)); |
||||
$sql = "SELECT platform_user_id, action_id FROM $tableSepeParticipants WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
$row = Database::fetch_assoc($res); |
||||
|
||||
$sql = "UPDATE plugin_sepe_log_participant SET fecha_baja='".date("Y-m-d H:i:s")."' WHERE platform_user_id='".$row['platform_user_id']."' AND action_id='".$row['action_id']."';"; |
||||
$res = Database::query($sql); |
||||
|
||||
$sql = "DELETE FROM $tableSepeParticipants WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDeleteInfoParticipant'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'unlink_action') { |
||||
$id = intval(substr($_REQUEST['id'], 16)); |
||||
$sql = "DELETE FROM $tableSepeCourseActions WHERE id = $id;"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$content = $plugin->get_lang('ProblemToDesvincularInfoAction'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('DeleteOk'); |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'assign_action') { |
||||
$course_id = intval(substr($_REQUEST['course_id'], 9)); |
||||
$action_id = intval($_REQUEST['action_id']); |
||||
|
||||
if ($action_id != 0 && $course_id != 0) { |
||||
$sql = "SELECT * FROM $tableSepeCourseActions WHERE action_id = $action_id;"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$content = $plugin->get_lang('FormativeActionInUse'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$sql = "SELECT 1 FROM course WHERE id = $course_id;"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) == 0) { |
||||
$content = $plugin->get_lang('NoExistsCourse'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeCourseActions (course_id, action_id) VALUES ($course_id, $action_id);"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
$content = $plugin->get_lang('NoSaveData'); |
||||
echo json_encode(array("status" => "false", "content" => utf8_encode($content))); |
||||
} else { |
||||
echo json_encode(array("status" => "true")); |
||||
} |
||||
} |
||||
} |
||||
} else { |
||||
$content = $plugin->get_lang('ErrorDataIncorrect'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} |
||||
} |
||||
|
||||
if ($_REQUEST['tab'] == 'key_sepe_generator') { |
||||
$tApi = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
||||
$info_user = api_get_user_info_from_username('SEPE'); |
||||
|
||||
$array_list_key = array(); |
||||
$user_id = $info_user['user_id']; |
||||
$api_service = 'dokeos'; |
||||
$num = UserManager::update_api_key($user_id, $api_service); |
||||
$array_list_key = UserManager::get_api_keys($user_id, $api_service); |
||||
|
||||
if (trim($array_list_key[$num]) != '') { |
||||
$content = $array_list_key[$num]; |
||||
echo json_encode(array("status" => "true", "content" => $content)); |
||||
} else { |
||||
$content = $plugin->get_lang('ProblemGenerateApiKey'); |
||||
echo json_encode(array("status" => "false", "content" => $content)); |
||||
} |
||||
} |
||||
|
@ -1,240 +1,237 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a participant edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$companyTutorId = (!empty($_POST['company_tutor_id']) ? intval($_POST['company_tutor_id']) : NULL); |
||||
$trainingTutorId = (!empty($_POST['training_tutor_id']) ? intval($_POST['training_tutor_id']) : NULL); |
||||
$tutorCompanyDocumentType = Database::escape_string(trim($_POST['tutor_company_document_type'])); |
||||
$tutorCompanyDocumentNumber = Database::escape_string(trim($_POST['tutor_company_document_number'])); |
||||
$tutorCompanyDocumentLetter = Database::escape_string(trim($_POST['tutor_company_document_letter'])); |
||||
$tutorCompanyAlias = Database::escape_string(trim($_POST['tutor_company_alias'])); |
||||
$tutorTrainingDocumentType = Database::escape_string(trim($_POST['tutor_training_document_type'])); |
||||
$tutorTrainingDocumentNumber = Database::escape_string(trim($_POST['tutor_training_document_number'])); |
||||
$tutorTrainingDocumentLetter = Database::escape_string(trim($_POST['tutor_training_document_letter'])); |
||||
$tutorTrainingAlias = Database::escape_string(trim($_POST['tutor_training_alias'])); |
||||
$newParticipant = intval($_POST['new_participant']); |
||||
$platformUserId = intval($_POST['platform_user_id']); |
||||
$documentType = Database::escape_string(trim($_POST['document_type'])); |
||||
$documentNumber = Database::escape_string(trim($_POST['document_number'])); |
||||
$documentLetter = Database::escape_string(trim($_POST['document_letter'])); |
||||
$keyCompetence = Database::escape_string(trim($_POST['key_competence'])); |
||||
$contractId = Database::escape_string(trim($_POST['contract_id'])); |
||||
$companyFiscalNumber = Database::escape_string(trim($_POST['company_fiscal_number'])); |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
|
||||
if (isset($companyTutorId) && $companyTutorId == 0) { |
||||
$sql = "SELECT * FROM $tableTutorCompany |
||||
WHERE document_type = '".$tutorCompanyDocumentType."' |
||||
AND document_number = '".$tutorCompanyDocumentNumber."' |
||||
AND document_letter = '".$tutorCompanyDocumentLetter."';"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$row = Database::fetch_assoc($rs); |
||||
$companyTutorId = $row['id']; |
||||
$sql = "UPDATE $tableTutorCompany SET company = 1 WHERE id = $companyTutorId"; |
||||
Database::query($sql); |
||||
} else { |
||||
$sql = "INSERT INTO $tableTutorCompany (alias,document_type,document_number,document_letter,company) |
||||
VALUES ('".$tutorCompanyAlias."','".$tutorCompanyDocumentType."','".$tutorCompanyDocumentNumber."','".$tutorCompanyDocumentLetter."','1');"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
echo Database::error(); |
||||
} else { |
||||
$companyTutorId = Database::insert_id(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (isset($trainingTutorId) && $trainingTutorId == 0) { |
||||
$sql = "SELECT * FROM $tableTutorCompany |
||||
WHERE document_type = '".$tutorTrainingDocumentType."' AND document_number = '".$tutorTrainingDocumentNumber."' AND document_letter = '".$tutorTrainingDocumentLetter."';"; |
||||
$rs = Database::query($sql); |
||||
|
||||
if (Database::num_rows($rs) > 0) { |
||||
$row = Database::fetch_assoc($rs); |
||||
$trainingTutorId = $row['id']; |
||||
$sql = "UPDATE $tableTutorCompany SET training = 1 WHERE id = $trainingTutorId"; |
||||
Database::query($sql); |
||||
} else { |
||||
$sql = "INSERT INTO $tableTutorCompany (alias,document_type,document_number,document_letter,training) |
||||
VALUES ('".$tutorTrainingAlias."','".$tutorTrainingDocumentType."','".$tutorTrainingDocumentNumber."','".$tutorTrainingDocumentLetter."','1');"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
echo Database::error(); |
||||
} else { |
||||
$trainingTutorId = Database::insert_id(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (isset($newParticipant) && $newParticipant != 1) { |
||||
$sql = "UPDATE $tableSepeParticipants SET |
||||
platform_user_id = '".$platformUserId."', |
||||
document_type = '".$documentType."', |
||||
document_number = '".$documentNumber."', |
||||
document_letter = '".$documentLetter."', |
||||
key_competence = '".$keyCompetence."', |
||||
contract_id = '".$contractId."', |
||||
company_fiscal_number = '".$companyFiscalNumber."' |
||||
WHERE id = $participantId"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeParticipants( |
||||
action_id, |
||||
platform_user_id, |
||||
document_type, |
||||
document_number, |
||||
document_letter, |
||||
key_competence, |
||||
contract_id, |
||||
company_fiscal_number |
||||
) VALUES ( |
||||
'".$actionId."', |
||||
'".$platformUserId."', |
||||
'".$documentType."', |
||||
'".$documentNumber."', |
||||
'".$documentLetter."', |
||||
'".$keyCompetence."', |
||||
'".$contractId."', |
||||
'".$companyFiscalNumber."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
error_log(Database::error()); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newParticipant == 1) { |
||||
$participantId = Database::insert_id(); |
||||
} |
||||
// Update tutors |
||||
if (is_null($companyTutorId)) { |
||||
$sql = "UPDATE $tableSepeParticipants SET company_tutor_id = NULL WHERE id = $participantId"; |
||||
} else { |
||||
$sql = "UPDATE $tableSepeParticipants SET company_tutor_id = $companyTutorId WHERE id = $participantId"; |
||||
} |
||||
Database::query($sql); |
||||
if (is_null($trainingTutorId)) { |
||||
$sql = "UPDATE $tableSepeParticipants SET training_tutor_id = NULL WHERE id = $participantId"; |
||||
} else { |
||||
$sql = "UPDATE $tableSepeParticipants SET training_tutor_id = $trainingTutorId WHERE id = $participantId"; |
||||
} |
||||
Database::query($sql); |
||||
|
||||
$insertLog = checkInsertNewLog($platformUserId, $actionId); |
||||
if ($insertLog) { |
||||
$sql = "INSERT INTO $tableSepeLogParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
registration_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
);"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeLogChangeParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
change_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
session_write_close(); |
||||
header("Location: participant-action-edit.php?new_participant=0&participant_id=".$participantId."&action_id=".$actionId); |
||||
} else { |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$newParticipant = intval($_POST['new_participant']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: participant-action-edit.php?new_participant=".$newParticipant."&participant_id=".$participantId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$actionId = intval($_GET['action_id']); |
||||
$courseId = getCourse($actionId); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
if (isset($_GET['new_participant']) && intval($_GET['new_participant']) == 1) { |
||||
$templateName = $plugin->get_lang('NewParticipantAction'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_participant', '1'); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditParticipantAction'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$info = getInfoParticipantAction(intval($_GET['participant_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_participant', '0'); |
||||
$tpl->assign('participant_id', intval($_GET['participant_id'])); |
||||
|
||||
if ($info['platform_user_id'] != 0) { |
||||
$infoUserPlatform = api_get_user_info($info['platform_user_id']); |
||||
$tpl->assign('info_user_platform', $infoUserPlatform); |
||||
} |
||||
$listParticipantSpecialty = listParticipantSpecialty(intval($_GET['participant_id'])); |
||||
$tpl->assign('listParticipantSpecialty', $listParticipantSpecialty); |
||||
} |
||||
$courseCode = getCourseCode($actionId); |
||||
$listStudentInfo = array(); |
||||
$listStudent = CourseManager::get_student_list_from_course_code($courseCode); |
||||
|
||||
foreach ($listStudent as $value) { |
||||
$sql = "SELECT 1 FROM $tableSepeParticipants WHERE platform_user_id = '".$value['user_id']."';"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) == 0) { |
||||
$listStudentInfo[] = api_get_user_info($value['user_id']); |
||||
} |
||||
} |
||||
$tpl->assign('listStudent', $listStudentInfo); |
||||
$listTutorCompany = array(); |
||||
$listTutorCompany = listTutorType("company = '1'"); |
||||
$tpl->assign('list_tutor_company', $listTutorCompany); |
||||
$listTutorTraining = array(); |
||||
$listTutorTraining = listTutorType("training = '1'"); |
||||
$tpl->assign('list_tutor_training', $listTutorTraining); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
$listing_tpl = 'sepe/view/participant-action-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a participant edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$companyTutorId = (!empty($_POST['company_tutor_id']) ? intval($_POST['company_tutor_id']) : NULL); |
||||
$trainingTutorId = (!empty($_POST['training_tutor_id']) ? intval($_POST['training_tutor_id']) : NULL); |
||||
$tutorCompanyDocumentType = Database::escape_string(trim($_POST['tutor_company_document_type'])); |
||||
$tutorCompanyDocumentNumber = Database::escape_string(trim($_POST['tutor_company_document_number'])); |
||||
$tutorCompanyDocumentLetter = Database::escape_string(trim($_POST['tutor_company_document_letter'])); |
||||
$tutorCompanyAlias = Database::escape_string(trim($_POST['tutor_company_alias'])); |
||||
$tutorTrainingDocumentType = Database::escape_string(trim($_POST['tutor_training_document_type'])); |
||||
$tutorTrainingDocumentNumber = Database::escape_string(trim($_POST['tutor_training_document_number'])); |
||||
$tutorTrainingDocumentLetter = Database::escape_string(trim($_POST['tutor_training_document_letter'])); |
||||
$tutorTrainingAlias = Database::escape_string(trim($_POST['tutor_training_alias'])); |
||||
$newParticipant = intval($_POST['new_participant']); |
||||
$platformUserId = intval($_POST['platform_user_id']); |
||||
$documentType = Database::escape_string(trim($_POST['document_type'])); |
||||
$documentNumber = Database::escape_string(trim($_POST['document_number'])); |
||||
$documentLetter = Database::escape_string(trim($_POST['document_letter'])); |
||||
$keyCompetence = Database::escape_string(trim($_POST['key_competence'])); |
||||
$contractId = Database::escape_string(trim($_POST['contract_id'])); |
||||
$companyFiscalNumber = Database::escape_string(trim($_POST['company_fiscal_number'])); |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
|
||||
if (isset($companyTutorId) && $companyTutorId == 0) { |
||||
$sql = "SELECT * FROM $tableTutorCompany |
||||
WHERE document_type = '".$tutorCompanyDocumentType."' |
||||
AND document_number = '".$tutorCompanyDocumentNumber."' |
||||
AND document_letter = '".$tutorCompanyDocumentLetter."';"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$row = Database::fetch_assoc($rs); |
||||
$companyTutorId = $row['id']; |
||||
$sql = "UPDATE $tableTutorCompany SET company = 1 WHERE id = $companyTutorId"; |
||||
Database::query($sql); |
||||
} else { |
||||
$sql = "INSERT INTO $tableTutorCompany (alias,document_type,document_number,document_letter,company) |
||||
VALUES ('".$tutorCompanyAlias."','".$tutorCompanyDocumentType."','".$tutorCompanyDocumentNumber."','".$tutorCompanyDocumentLetter."','1');"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
} else { |
||||
$companyTutorId = Database::insert_id(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (isset($trainingTutorId) && $trainingTutorId == 0) { |
||||
$sql = "SELECT * FROM $tableTutorCompany |
||||
WHERE document_type = '".$tutorTrainingDocumentType."' AND document_number = '".$tutorTrainingDocumentNumber."' AND document_letter = '".$tutorTrainingDocumentLetter."';"; |
||||
$rs = Database::query($sql); |
||||
|
||||
if (Database::num_rows($rs) > 0) { |
||||
$row = Database::fetch_assoc($rs); |
||||
$trainingTutorId = $row['id']; |
||||
$sql = "UPDATE $tableTutorCompany SET training = 1 WHERE id = $trainingTutorId"; |
||||
Database::query($sql); |
||||
} else { |
||||
$sql = "INSERT INTO $tableTutorCompany (alias,document_type,document_number,document_letter,training) |
||||
VALUES ('".$tutorTrainingAlias."','".$tutorTrainingDocumentType."','".$tutorTrainingDocumentNumber."','".$tutorTrainingDocumentLetter."','1');"; |
||||
$rs = Database::query($sql); |
||||
if (!$rs) { |
||||
} else { |
||||
$trainingTutorId = Database::insert_id(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (isset($newParticipant) && $newParticipant != 1) { |
||||
$sql = "UPDATE $tableSepeParticipants SET |
||||
platform_user_id = '".$platformUserId."', |
||||
document_type = '".$documentType."', |
||||
document_number = '".$documentNumber."', |
||||
document_letter = '".$documentLetter."', |
||||
key_competence = '".$keyCompetence."', |
||||
contract_id = '".$contractId."', |
||||
company_fiscal_number = '".$companyFiscalNumber."' |
||||
WHERE id = $participantId"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeParticipants( |
||||
action_id, |
||||
platform_user_id, |
||||
document_type, |
||||
document_number, |
||||
document_letter, |
||||
key_competence, |
||||
contract_id, |
||||
company_fiscal_number |
||||
) VALUES ( |
||||
'".$actionId."', |
||||
'".$platformUserId."', |
||||
'".$documentType."', |
||||
'".$documentNumber."', |
||||
'".$documentLetter."', |
||||
'".$keyCompetence."', |
||||
'".$contractId."', |
||||
'".$companyFiscalNumber."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newParticipant == 1) { |
||||
$participantId = Database::insert_id(); |
||||
} |
||||
// Update tutors |
||||
if (is_null($companyTutorId)) { |
||||
$sql = "UPDATE $tableSepeParticipants SET company_tutor_id = NULL WHERE id = $participantId"; |
||||
} else { |
||||
$sql = "UPDATE $tableSepeParticipants SET company_tutor_id = $companyTutorId WHERE id = $participantId"; |
||||
} |
||||
Database::query($sql); |
||||
if (is_null($trainingTutorId)) { |
||||
$sql = "UPDATE $tableSepeParticipants SET training_tutor_id = NULL WHERE id = $participantId"; |
||||
} else { |
||||
$sql = "UPDATE $tableSepeParticipants SET training_tutor_id = $trainingTutorId WHERE id = $participantId"; |
||||
} |
||||
Database::query($sql); |
||||
|
||||
$insertLog = checkInsertNewLog($platformUserId, $actionId); |
||||
if ($insertLog) { |
||||
$sql = "INSERT INTO $tableSepeLogParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
registration_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
);"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeLogChangeParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
change_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
session_write_close(); |
||||
header("Location: participant-action-edit.php?new_participant=0&participant_id=".$participantId."&action_id=".$actionId); |
||||
} else { |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$newParticipant = intval($_POST['new_participant']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: participant-action-edit.php?new_participant=".$newParticipant."&participant_id=".$participantId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$actionId = intval($_GET['action_id']); |
||||
$courseId = getCourse($actionId); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
if (isset($_GET['new_participant']) && intval($_GET['new_participant']) == 1) { |
||||
$templateName = $plugin->get_lang('NewParticipantAction'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_participant', '1'); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditParticipantAction'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$info = getInfoParticipantAction(intval($_GET['participant_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_participant', '0'); |
||||
$tpl->assign('participant_id', intval($_GET['participant_id'])); |
||||
|
||||
if ($info['platform_user_id'] != 0) { |
||||
$infoUserPlatform = api_get_user_info($info['platform_user_id']); |
||||
$tpl->assign('info_user_platform', $infoUserPlatform); |
||||
} |
||||
$listParticipantSpecialty = listParticipantSpecialty(intval($_GET['participant_id'])); |
||||
$tpl->assign('listParticipantSpecialty', $listParticipantSpecialty); |
||||
} |
||||
$courseCode = getCourseCode($actionId); |
||||
$listStudentInfo = array(); |
||||
$listStudent = CourseManager::get_student_list_from_course_code($courseCode); |
||||
|
||||
foreach ($listStudent as $value) { |
||||
$sql = "SELECT 1 FROM $tableSepeParticipants WHERE platform_user_id = '".$value['user_id']."';"; |
||||
$res = Database::query($sql); |
||||
if (Database::num_rows($res) == 0) { |
||||
$listStudentInfo[] = api_get_user_info($value['user_id']); |
||||
} |
||||
} |
||||
$tpl->assign('listStudent', $listStudentInfo); |
||||
$listTutorCompany = array(); |
||||
$listTutorCompany = listTutorType("company = '1'"); |
||||
$tpl->assign('list_tutor_company', $listTutorCompany); |
||||
$listTutorTraining = array(); |
||||
$listTutorTraining = listTutorType("training = '1'"); |
||||
$tpl->assign('list_tutor_training', $listTutorTraining); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
$listing_tpl = 'sepe/view/participant-action-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
@ -1,276 +1,275 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a participant specialty edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin'])); |
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area'])); |
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code'])); |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$finalResult = Database::escape_string(trim($_POST['final_result'])); |
||||
$finalQualification = Database::escape_string(trim($_POST['final_qualification'])); |
||||
$finalScore = Database::escape_string(trim($_POST['final_score'])); |
||||
$yearRegistration = Database::escape_string(trim($_POST['year_registration'])); |
||||
$monthRegistration = Database::escape_string(trim($_POST['month_registration'])); |
||||
$dayRegistration = Database::escape_string(trim($_POST['day_registration'])); |
||||
$yearLeaving = Database::escape_string(trim($_POST['year_leaving'])); |
||||
$monthLeaving = Database::escape_string(trim($_POST['month_leaving'])); |
||||
$dayLeaving = Database::escape_string(trim($_POST['day_leaving'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
|
||||
$registrationDate = $yearRegistration."-".$monthRegistration."-".$dayRegistration; |
||||
$leavingDate = $yearLeaving."-".$monthLeaving."-".$dayLeaving; |
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (isset($newSpecialty) && $newSpecialty != 1) { |
||||
$sql = "UPDATE $tableSepeParticipantsSpecialty SET |
||||
specialty_origin = '".$specialtyOrigin."', |
||||
professional_area = '".$professionalArea."', |
||||
specialty_code = '".$specialtyCode."', |
||||
registration_date = '".$registrationDate."', |
||||
leaving_date = '".$leavingDate."', |
||||
center_origin = '".$centerOrigin."', |
||||
center_code = '".$centerCode."', |
||||
start_date = '".$startDate."', |
||||
end_date = '".$endDate."', |
||||
final_result = '".$finalResult."', |
||||
final_qualification = '".$finalQualification."', |
||||
final_score = '".$finalScore."' |
||||
WHERE id = $specialtyId"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeParticipantsSpecialty ( |
||||
participant_id, |
||||
specialty_origin, |
||||
professional_area, |
||||
specialty_code, |
||||
registration_date, |
||||
leaving_date, |
||||
center_origin, |
||||
center_code, |
||||
start_date, |
||||
end_date, |
||||
final_result, |
||||
final_qualification, |
||||
final_score |
||||
) VALUES ( |
||||
$participantId, |
||||
'".$specialtyOrigin."', |
||||
'".$professionalArea."', |
||||
'".$specialtyCode."', |
||||
'".$registrationDate."', |
||||
'".$leavingDate."', |
||||
'".$centerOrigin."', |
||||
'".$centerCode."', |
||||
'".$startDate."', |
||||
'".$endDate."', |
||||
'".$finalResult."', |
||||
'".$finalQualification."', |
||||
'".$finalScore."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
echo Database::error(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
if ($newSpecialty == "1") { |
||||
$specialtyId = Database::insert_id(); |
||||
} |
||||
|
||||
$platformUserId = getUserPlatformFromParticipant($participantId); |
||||
$insertLog = checkInsertNewLog($platformUserId, $actionId); |
||||
if ($insertLog) { |
||||
if ($finalResult == "1" || $finalResult == "2") { |
||||
$leavingDateLog = date("Y-m-d H:i:s"); |
||||
} else { |
||||
$leavingDateLog = '0000-00-00'; |
||||
} |
||||
$sql = "INSERT INTO $tableSepeLogParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
registration_date, |
||||
leaving_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
'".$leavingDateLog."' |
||||
);"; |
||||
|
||||
} else { |
||||
if ($finalResult == "1" || $finalResult == "2") { |
||||
$sql = "UPDATE $tableSepeLogParticipant |
||||
SET leaving_date = '".date("Y-m-d H:i:s")."' |
||||
WHERE platform_user_id = '".$platformUserId."' AND action_id = '".$actionId."';"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeLogChangeParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
change_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
);"; |
||||
} |
||||
} |
||||
$res = Database::query($sql); |
||||
} |
||||
session_write_close(); |
||||
header("Location: participant-specialty-edit.php?new_specialty=0&specialty_id=".$specialtyId."&participant_id=".$participantId."&action_id=".$actionId); |
||||
} else { |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: participant-specialty-edit.php?new_specialty=".$newSpecialty."&specialty_id=".$specialtyId."&participant_id=".$participantId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$actionId = intval($_GET['action_id']); |
||||
$courseId = getCourse($actionId); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "participant-action-edit.php?new_participant=0&participant_id=".intval($_GET['participant_id'])."&action_id=".$_GET['action_id'], "name" => $plugin->get_lang('FormativeActionParticipant')); |
||||
if (isset($_GET['new_specialty']) && intval($_GET['new_specialty']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyParticipant'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$tpl->assign('participant_id', intval($_GET['participant_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_specialty', '1'); |
||||
$startYear = $endYear = date("Y"); |
||||
$registrationYear = $leaveYear = date("Y"); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyParticipant'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('participant_id', intval($_GET['participant_id'])); |
||||
$info = getInfoSpecialtyParticipant(intval($_GET['specialty_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_specialty', '0'); |
||||
if ($info['registration_date'] != '0000-00-00' && $info['registration_date'] != NULL) { |
||||
$tpl->assign('day_registration', date("j", strtotime($info['registration_date']))); |
||||
$tpl->assign('month_registration', date("n", strtotime($info['registration_date']))); |
||||
$tpl->assign('year_registration', date("Y", strtotime($info['registration_date']))); |
||||
$registrationYear = date("Y", strtotime($info['registration_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$registrationYear = date("Y", strtotime($info['registration_date'])); |
||||
} else { |
||||
$registrationYear = date("Y"); |
||||
} |
||||
if ($info['leaving_date'] != '0000-00-00' && $info['leaving_date'] != NULL) { |
||||
$tpl->assign('day_leaving', date("j", strtotime($info['leaving_date']))); |
||||
$tpl->assign('month_leaving', date("n", strtotime($info['leaving_date']))); |
||||
$tpl->assign('year_leaving', date("Y", strtotime($info['leaving_date']))); |
||||
$leaveYear = date("Y", strtotime($info['leaving_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$leaveYear = date("Y", strtotime($info['leaving_date'])); |
||||
} else { |
||||
$leaveYear = date("Y"); |
||||
} |
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$startYear = date("Y"); |
||||
} |
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$endYear = date("Y"); |
||||
} |
||||
$listSpecialtyTutorials = getListSpecialtyTutorial(intval($_GET['specialty_id'])); |
||||
$tpl->assign('listSpecialtyTutorials', $listSpecialtyTutorials); |
||||
} |
||||
|
||||
|
||||
$listYear = array(); |
||||
if ($registrationYear > $leaveYear) { |
||||
$tmp = $registrationYear; |
||||
$registrationYear = $leaveYear; |
||||
$leaveYear = $tmp; |
||||
} |
||||
$registrationYear -= 5; |
||||
$leaveYear += 5; |
||||
$endRangeYear = (($registrationYear + 15) < $leaveYear) ? ($leaveYear + 1) : ($registrationYear + 15); |
||||
while ($registrationYear <= $endRangeYear) { |
||||
$listYear[] = $registrationYear; |
||||
$registrationYear++; |
||||
} |
||||
$tpl->assign('list_year', $listYear); |
||||
|
||||
$listYear = array(); |
||||
if ($startYear > $endYear) { |
||||
$tmp = $startYear; |
||||
$startYear = $endYear; |
||||
$endYear = $tmp; |
||||
} |
||||
$startYear -= 5; |
||||
$endYear += 5; |
||||
$endRangeYear = (($startYear + 15) < $endYear) ? ($endYear + 1) : ($startYear + 15); |
||||
while ($startYear <= $endRangeYear) { |
||||
$listYear[] = $startYear; |
||||
$startYear++; |
||||
} |
||||
$tpl->assign('list_year_2', $listYear); |
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
$listing_tpl = 'sepe/view/participant-specialty-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a participant specialty edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin'])); |
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area'])); |
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code'])); |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$finalResult = Database::escape_string(trim($_POST['final_result'])); |
||||
$finalQualification = Database::escape_string(trim($_POST['final_qualification'])); |
||||
$finalScore = Database::escape_string(trim($_POST['final_score'])); |
||||
$yearRegistration = Database::escape_string(trim($_POST['year_registration'])); |
||||
$monthRegistration = Database::escape_string(trim($_POST['month_registration'])); |
||||
$dayRegistration = Database::escape_string(trim($_POST['day_registration'])); |
||||
$yearLeaving = Database::escape_string(trim($_POST['year_leaving'])); |
||||
$monthLeaving = Database::escape_string(trim($_POST['month_leaving'])); |
||||
$dayLeaving = Database::escape_string(trim($_POST['day_leaving'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
|
||||
$registrationDate = $yearRegistration."-".$monthRegistration."-".$dayRegistration; |
||||
$leavingDate = $yearLeaving."-".$monthLeaving."-".$dayLeaving; |
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (isset($newSpecialty) && $newSpecialty != 1) { |
||||
$sql = "UPDATE $tableSepeParticipantsSpecialty SET |
||||
specialty_origin = '".$specialtyOrigin."', |
||||
professional_area = '".$professionalArea."', |
||||
specialty_code = '".$specialtyCode."', |
||||
registration_date = '".$registrationDate."', |
||||
leaving_date = '".$leavingDate."', |
||||
center_origin = '".$centerOrigin."', |
||||
center_code = '".$centerCode."', |
||||
start_date = '".$startDate."', |
||||
end_date = '".$endDate."', |
||||
final_result = '".$finalResult."', |
||||
final_qualification = '".$finalQualification."', |
||||
final_score = '".$finalScore."' |
||||
WHERE id = $specialtyId"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeParticipantsSpecialty ( |
||||
participant_id, |
||||
specialty_origin, |
||||
professional_area, |
||||
specialty_code, |
||||
registration_date, |
||||
leaving_date, |
||||
center_origin, |
||||
center_code, |
||||
start_date, |
||||
end_date, |
||||
final_result, |
||||
final_qualification, |
||||
final_score |
||||
) VALUES ( |
||||
$participantId, |
||||
'".$specialtyOrigin."', |
||||
'".$professionalArea."', |
||||
'".$specialtyCode."', |
||||
'".$registrationDate."', |
||||
'".$leavingDate."', |
||||
'".$centerOrigin."', |
||||
'".$centerCode."', |
||||
'".$startDate."', |
||||
'".$endDate."', |
||||
'".$finalResult."', |
||||
'".$finalQualification."', |
||||
'".$finalScore."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
if ($newSpecialty == "1") { |
||||
$specialtyId = Database::insert_id(); |
||||
} |
||||
|
||||
$platformUserId = getUserPlatformFromParticipant($participantId); |
||||
$insertLog = checkInsertNewLog($platformUserId, $actionId); |
||||
if ($insertLog) { |
||||
if ($finalResult == "1" || $finalResult == "2") { |
||||
$leavingDateLog = date("Y-m-d H:i:s"); |
||||
} else { |
||||
$leavingDateLog = '0000-00-00'; |
||||
} |
||||
$sql = "INSERT INTO $tableSepeLogParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
registration_date, |
||||
leaving_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
'".$leavingDateLog."' |
||||
);"; |
||||
|
||||
} else { |
||||
if ($finalResult == "1" || $finalResult == "2") { |
||||
$sql = "UPDATE $tableSepeLogParticipant |
||||
SET leaving_date = '".date("Y-m-d H:i:s")."' |
||||
WHERE platform_user_id = '".$platformUserId."' AND action_id = '".$actionId."';"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeLogChangeParticipant ( |
||||
platform_user_id, |
||||
action_id, |
||||
change_date |
||||
) VALUES ( |
||||
'".$platformUserId."', |
||||
'".$actionId."', |
||||
'".date("Y-m-d H:i:s")."' |
||||
);"; |
||||
} |
||||
} |
||||
$res = Database::query($sql); |
||||
} |
||||
session_write_close(); |
||||
header("Location: participant-specialty-edit.php?new_specialty=0&specialty_id=".$specialtyId."&participant_id=".$participantId."&action_id=".$actionId); |
||||
} else { |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
$participantId = intval($_POST['participant_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: participant-specialty-edit.php?new_specialty=".$newSpecialty."&specialty_id=".$specialtyId."&participant_id=".$participantId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$actionId = intval($_GET['action_id']); |
||||
$courseId = getCourse($actionId); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "participant-action-edit.php?new_participant=0&participant_id=".intval($_GET['participant_id'])."&action_id=".$_GET['action_id'], "name" => $plugin->get_lang('FormativeActionParticipant')); |
||||
if (isset($_GET['new_specialty']) && intval($_GET['new_specialty']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyParticipant'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$tpl->assign('participant_id', intval($_GET['participant_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_specialty', '1'); |
||||
$startYear = $endYear = date("Y"); |
||||
$registrationYear = $leaveYear = date("Y"); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyParticipant'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', $actionId); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('participant_id', intval($_GET['participant_id'])); |
||||
$info = getInfoSpecialtyParticipant(intval($_GET['specialty_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_specialty', '0'); |
||||
if ($info['registration_date'] != '0000-00-00' && $info['registration_date'] != NULL) { |
||||
$tpl->assign('day_registration', date("j", strtotime($info['registration_date']))); |
||||
$tpl->assign('month_registration', date("n", strtotime($info['registration_date']))); |
||||
$tpl->assign('year_registration', date("Y", strtotime($info['registration_date']))); |
||||
$registrationYear = date("Y", strtotime($info['registration_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$registrationYear = date("Y", strtotime($info['registration_date'])); |
||||
} else { |
||||
$registrationYear = date("Y"); |
||||
} |
||||
if ($info['leaving_date'] != '0000-00-00' && $info['leaving_date'] != NULL) { |
||||
$tpl->assign('day_leaving', date("j", strtotime($info['leaving_date']))); |
||||
$tpl->assign('month_leaving', date("n", strtotime($info['leaving_date']))); |
||||
$tpl->assign('year_leaving', date("Y", strtotime($info['leaving_date']))); |
||||
$leaveYear = date("Y", strtotime($info['leaving_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$leaveYear = date("Y", strtotime($info['leaving_date'])); |
||||
} else { |
||||
$leaveYear = date("Y"); |
||||
} |
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$startYear = date("Y"); |
||||
} |
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$endYear = date("Y"); |
||||
} |
||||
$listSpecialtyTutorials = getListSpecialtyTutorial(intval($_GET['specialty_id'])); |
||||
$tpl->assign('listSpecialtyTutorials', $listSpecialtyTutorials); |
||||
} |
||||
|
||||
|
||||
$listYear = array(); |
||||
if ($registrationYear > $leaveYear) { |
||||
$tmp = $registrationYear; |
||||
$registrationYear = $leaveYear; |
||||
$leaveYear = $tmp; |
||||
} |
||||
$registrationYear -= 5; |
||||
$leaveYear += 5; |
||||
$endRangeYear = (($registrationYear + 15) < $leaveYear) ? ($leaveYear + 1) : ($registrationYear + 15); |
||||
while ($registrationYear <= $endRangeYear) { |
||||
$listYear[] = $registrationYear; |
||||
$registrationYear++; |
||||
} |
||||
$tpl->assign('list_year', $listYear); |
||||
|
||||
$listYear = array(); |
||||
if ($startYear > $endYear) { |
||||
$tmp = $startYear; |
||||
$startYear = $endYear; |
||||
$endYear = $tmp; |
||||
} |
||||
$startYear -= 5; |
||||
$endYear += 5; |
||||
$endRangeYear = (($startYear + 15) < $endYear) ? ($endYear + 1) : ($startYear + 15); |
||||
while ($startYear <= $endRangeYear) { |
||||
$listYear[] = $startYear; |
||||
$startYear++; |
||||
} |
||||
$tpl->assign('list_year_2', $listYear); |
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
$listing_tpl = 'sepe/view/participant-specialty-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
@ -1,235 +1,234 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty action edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin'])); |
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area'])); |
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code'])); |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$modality_impartition = Database::escape_string(trim($_POST['modality_impartition'])); |
||||
$classroomHours = Database::escape_string(trim($_POST['classroom_hours'])); |
||||
$distanceHours = intval($_POST['distance_hours']); |
||||
$morningsParticipantsNumber = intval($_POST['mornings_participants_number']); |
||||
$morningsAccessNumber = intval($_POST['mornings_access_number']); |
||||
$morningTotalDuration = intval($_POST['morning_total_duration']); |
||||
$afternoonParticipantsNumber = intval($_POST['afternoon_participants_number']); |
||||
$afternoonAccessNumber = intval($_POST['afternoon_access_number']); |
||||
$afternoonTotalDuration = intval($_POST['afternoon_total_duration']); |
||||
$nightParticipantsNumber = intval($_POST['night_participants_number']); |
||||
$nightAccessNumber = intval($_POST['night_access_number']); |
||||
$nightTotalDuration = intval($_POST['night_total_duration']); |
||||
$attendeesCount = intval($_POST['attendees_count']); |
||||
$learningActivityCount = intval($_POST['learning_activity_count']); |
||||
$attemptCount = intval($_POST['attempt_count']); |
||||
$evaluationActivityCount = intval($_POST['evaluation_activity_count']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (isset($newSpecialty) && $newSpecialty != 1) { |
||||
$sql = "UPDATE plugin_sepe_specialty SET |
||||
specialty_origin='".$specialtyOrigin."', |
||||
professional_area='".$professionalArea."', |
||||
specialty_code='".$specialtyCode."', |
||||
center_origin='".$centerOrigin."', |
||||
center_code='".$centerCode."', |
||||
start_date='".$startDate."', |
||||
end_date='".$endDate."', |
||||
modality_impartition='".$modalityImpartition."', |
||||
classroom_hours = $classroomHours, |
||||
distance_hours = $distanceHours, |
||||
mornings_participants_number = $morningsParticipantsNumber, |
||||
mornings_access_number = $morningsAccessNumber, |
||||
morning_total_duration = $morningTotalDuration, |
||||
afternoon_participants_number = $afternoonParticipantsNumber, |
||||
afternoon_access_number = $afternoonAccessNumber, |
||||
afternoon_total_duration = $afternoonTotalDuration, |
||||
night_participants_number = $nightParticipantsNumber, |
||||
night_access_number = $nightAccessNumber, |
||||
night_total_duration = $nightTotalDuration, |
||||
attendees_count = $attendeesCount, |
||||
learning_activity_count = $learningActivityCount, |
||||
attempt_count = $attemptCount, |
||||
evaluation_activity_count = $evaluationActivityCount |
||||
WHERE id = $specialtyId;"; |
||||
} else { |
||||
$sql = "INSERT INTO plugin_sepe_specialty ( |
||||
action_id, |
||||
specialty_origin, |
||||
professional_area, |
||||
specialty_code, |
||||
center_origin, |
||||
center_code, |
||||
start_date, |
||||
end_date, |
||||
modality_impartition, |
||||
classroom_hours, |
||||
distance_hours, |
||||
mornings_participants_number, |
||||
mornings_access_number, |
||||
morning_total_duration, |
||||
afternoon_participants_number, |
||||
afternoon_access_number, |
||||
afternoon_total_duration, |
||||
night_participants_number, |
||||
night_access_number, |
||||
night_total_duration, |
||||
attendees_count, |
||||
learning_activity_count, |
||||
attempt_count, |
||||
evaluation_activity_count |
||||
) VALUES ( |
||||
$actionId, |
||||
'".$specialtyOrigin."', |
||||
'".$professionalArea."', |
||||
'".$specialtyCode."', |
||||
'".$centerOrigin."', |
||||
'".$centerCode."', |
||||
'".$startDate."', |
||||
'".$endDate."', |
||||
'".$modalityImpartition."', |
||||
$classroomHours, |
||||
$distanceHours, |
||||
$morningsParticipantsNumber, |
||||
$morningsAccessNumber, |
||||
$morningTotalDuration, |
||||
$afternoonParticipantsNumber, |
||||
$afternoonAccessNumber, |
||||
$afternoonTotalDuration, |
||||
$nightParticipantsNumber, |
||||
$nightAccessNumber, |
||||
$nightTotalDuration, |
||||
$attendeesCount, |
||||
$learningActivityCount, |
||||
$attemptCount, |
||||
$evaluationActivityCount |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
echo Database::error(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newSpecialty == 1) { |
||||
$specialtyId = Database::insert_id(); |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=".$newSpecialty."&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$id_course = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$id_course, "name" => $plugin->get_lang('FormativeAction')); |
||||
if (isset($_GET['new_specialty']) && intval($_GET['new_specialty']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyAccion'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_action', '1'); |
||||
$yearStart = $yearEnd = date("Y"); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyAccion'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$info = getSpecialtActionInfo(intval($_GET['specialty_id'])); |
||||
$tpl->assign('info', $info); |
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['start_date'], '0000') === false) { |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$yearStart = date("Y"); |
||||
} |
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$yearEnd = date("Y"); |
||||
} |
||||
$tpl->assign('new_action', '0'); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
|
||||
$listClassroom = classroomList(intval($_GET['specialty_id'])); |
||||
$tpl->assign('listClassroom', $listClassroom); |
||||
$listTutors = tutorsList(intval($_GET['specialty_id'])); |
||||
$tpl->assign('listTutors', $listTutors); |
||||
} |
||||
|
||||
$yearList = array(); |
||||
if ($yearStart > $yearEnd) { |
||||
$tmp = $yearStart; |
||||
$yearStart = $yearEnd; |
||||
$yearEnd = $tmp; |
||||
} |
||||
$yearStart -= 5; |
||||
$yearEnd += 5; |
||||
$fin_rango_anio = (($yearStart + 15) < $yearEnd) ? ($yearEnd + 1) : ($yearStart + 15); |
||||
while ($yearStart <= $fin_rango_anio) { |
||||
$yearList[] = $yearStart; |
||||
$yearStart++; |
||||
} |
||||
$tpl->assign('list_year', $yearList); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
$listing_tpl = 'sepe/view/specialty-action-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
|
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty action edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$specialtyOrigin = Database::escape_string(trim($_POST['specialty_origin'])); |
||||
$professionalArea = Database::escape_string(trim($_POST['professional_area'])); |
||||
$specialtyCode = Database::escape_string(trim($_POST['specialty_code'])); |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$modality_impartition = Database::escape_string(trim($_POST['modality_impartition'])); |
||||
$classroomHours = Database::escape_string(trim($_POST['classroom_hours'])); |
||||
$distanceHours = intval($_POST['distance_hours']); |
||||
$morningsParticipantsNumber = intval($_POST['mornings_participants_number']); |
||||
$morningsAccessNumber = intval($_POST['mornings_access_number']); |
||||
$morningTotalDuration = intval($_POST['morning_total_duration']); |
||||
$afternoonParticipantsNumber = intval($_POST['afternoon_participants_number']); |
||||
$afternoonAccessNumber = intval($_POST['afternoon_access_number']); |
||||
$afternoonTotalDuration = intval($_POST['afternoon_total_duration']); |
||||
$nightParticipantsNumber = intval($_POST['night_participants_number']); |
||||
$nightAccessNumber = intval($_POST['night_access_number']); |
||||
$nightTotalDuration = intval($_POST['night_total_duration']); |
||||
$attendeesCount = intval($_POST['attendees_count']); |
||||
$learningActivityCount = intval($_POST['learning_activity_count']); |
||||
$attemptCount = intval($_POST['attempt_count']); |
||||
$evaluationActivityCount = intval($_POST['evaluation_activity_count']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
|
||||
$startDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (isset($newSpecialty) && $newSpecialty != 1) { |
||||
$sql = "UPDATE plugin_sepe_specialty SET |
||||
specialty_origin='".$specialtyOrigin."', |
||||
professional_area='".$professionalArea."', |
||||
specialty_code='".$specialtyCode."', |
||||
center_origin='".$centerOrigin."', |
||||
center_code='".$centerCode."', |
||||
start_date='".$startDate."', |
||||
end_date='".$endDate."', |
||||
modality_impartition='".$modalityImpartition."', |
||||
classroom_hours = $classroomHours, |
||||
distance_hours = $distanceHours, |
||||
mornings_participants_number = $morningsParticipantsNumber, |
||||
mornings_access_number = $morningsAccessNumber, |
||||
morning_total_duration = $morningTotalDuration, |
||||
afternoon_participants_number = $afternoonParticipantsNumber, |
||||
afternoon_access_number = $afternoonAccessNumber, |
||||
afternoon_total_duration = $afternoonTotalDuration, |
||||
night_participants_number = $nightParticipantsNumber, |
||||
night_access_number = $nightAccessNumber, |
||||
night_total_duration = $nightTotalDuration, |
||||
attendees_count = $attendeesCount, |
||||
learning_activity_count = $learningActivityCount, |
||||
attempt_count = $attemptCount, |
||||
evaluation_activity_count = $evaluationActivityCount |
||||
WHERE id = $specialtyId;"; |
||||
} else { |
||||
$sql = "INSERT INTO plugin_sepe_specialty ( |
||||
action_id, |
||||
specialty_origin, |
||||
professional_area, |
||||
specialty_code, |
||||
center_origin, |
||||
center_code, |
||||
start_date, |
||||
end_date, |
||||
modality_impartition, |
||||
classroom_hours, |
||||
distance_hours, |
||||
mornings_participants_number, |
||||
mornings_access_number, |
||||
morning_total_duration, |
||||
afternoon_participants_number, |
||||
afternoon_access_number, |
||||
afternoon_total_duration, |
||||
night_participants_number, |
||||
night_access_number, |
||||
night_total_duration, |
||||
attendees_count, |
||||
learning_activity_count, |
||||
attempt_count, |
||||
evaluation_activity_count |
||||
) VALUES ( |
||||
$actionId, |
||||
'".$specialtyOrigin."', |
||||
'".$professionalArea."', |
||||
'".$specialtyCode."', |
||||
'".$centerOrigin."', |
||||
'".$centerCode."', |
||||
'".$startDate."', |
||||
'".$endDate."', |
||||
'".$modalityImpartition."', |
||||
$classroomHours, |
||||
$distanceHours, |
||||
$morningsParticipantsNumber, |
||||
$morningsAccessNumber, |
||||
$morningTotalDuration, |
||||
$afternoonParticipantsNumber, |
||||
$afternoonAccessNumber, |
||||
$afternoonTotalDuration, |
||||
$nightParticipantsNumber, |
||||
$nightAccessNumber, |
||||
$nightTotalDuration, |
||||
$attendeesCount, |
||||
$learningActivityCount, |
||||
$attemptCount, |
||||
$evaluationActivityCount |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newSpecialty == 1) { |
||||
$specialtyId = Database::insert_id(); |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newSpecialty = intval($_POST['new_specialty']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=".$newSpecialty."&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$id_course = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$id_course, "name" => $plugin->get_lang('FormativeAction')); |
||||
if (isset($_GET['new_specialty']) && intval($_GET['new_specialty']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyAccion'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_action', '1'); |
||||
$yearStart = $yearEnd = date("Y"); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyAccion'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$info = getSpecialtActionInfo(intval($_GET['specialty_id'])); |
||||
$tpl->assign('info', $info); |
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['start_date'], '0000') === false) { |
||||
$yearStart = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$yearStart = date("Y"); |
||||
} |
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$yearEnd = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$yearEnd = date("Y"); |
||||
} |
||||
$tpl->assign('new_action', '0'); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
|
||||
$listClassroom = classroomList(intval($_GET['specialty_id'])); |
||||
$tpl->assign('listClassroom', $listClassroom); |
||||
$listTutors = tutorsList(intval($_GET['specialty_id'])); |
||||
$tpl->assign('listTutors', $listTutors); |
||||
} |
||||
|
||||
$yearList = array(); |
||||
if ($yearStart > $yearEnd) { |
||||
$tmp = $yearStart; |
||||
$yearStart = $yearEnd; |
||||
$yearEnd = $tmp; |
||||
} |
||||
$yearStart -= 5; |
||||
$yearEnd += 5; |
||||
$fin_rango_anio = (($yearStart + 15) < $yearEnd) ? ($yearEnd + 1) : ($yearStart + 15); |
||||
while ($yearStart <= $fin_rango_anio) { |
||||
$yearList[] = $yearStart; |
||||
$yearStart++; |
||||
} |
||||
$tpl->assign('list_year', $yearList); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
$listing_tpl = 'sepe/view/specialty-action-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
|
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
@ -1,133 +1,131 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty classroom edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$sltCentersExists = intval($_POST['slt_centers_exists']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$existsCenterId = intval($_POST['exists_center_id']); |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$newClassroom = intval($_POST['new_classroom']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$classroomId = intval($_POST['classroom_id']); |
||||
|
||||
if ($sltCentersExists == 1) { |
||||
$sql = "INSERT INTO $tableSepeSpecialtyClassroom (specialty_id, center_id) |
||||
VALUES ($specialtyId, $existsCenterId);"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
echo Database::error(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newClassroom == 1) { |
||||
$classroomId = Database::insert_id(); |
||||
} |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} else { |
||||
//Checker exists centers |
||||
$sql = "SELECT * FROM $tableCenters |
||||
WHERE center_origin='".$centerOrigin."' AND center_code='".$centerCode."'"; |
||||
$rs_tmp = Database::query($sql); |
||||
if (Database::num_rows($rs_tmp) > 0) { |
||||
$aux = Database::fetch_assoc($rs_tmp); |
||||
$centerId = $aux['id']; |
||||
} else { |
||||
$params = array( |
||||
'center_origin' => $centerOrigin, |
||||
'center_code' => $centerCode, |
||||
); |
||||
$centerId = Database::insert($tableCenters, $params); |
||||
} |
||||
|
||||
if (isset($newClassroom) && $newClassroom != 1) { |
||||
$sql = "UPDATE $tableSepeSpecialtyClassroom SET center_id = $centerId WHERE id = $classroomId;"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeSpecialtyClassroom (specialty_id, center_id) VALUES ($specialtyId, $centerId);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
echo Database::error(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newClassroom == 1) { |
||||
$classroomId = Database::insert_id(); |
||||
} |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$newClassroom = intval($_POST['new_classroom']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$classroomId = intval($_POST['classroom_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
Security::clear_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
$token = Security::get_token(); |
||||
session_write_close(); |
||||
header("Location:specialty-classroom-edit.php?new_classroom=".$newClassroom."&specialty_id=".$specialtyId."&classroom_id=".$classroomId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".intval($_GET['action_id']), "name" => $plugin->get_lang('SpecialtyFormativeAction')); |
||||
if (isset($_GET['new_classroom']) && intval($_GET['new_classroom']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyClassroom'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_classroom', '1'); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyClassroom'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('classroom_id', intval($_GET['classroom_id'])); |
||||
$info = getInfoSpecialtyClassroom(intval($_GET['classroom_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_classroom', '0'); |
||||
|
||||
} |
||||
$centerList = getCentersList(); |
||||
$tpl->assign('listExistsCenters', $centerList); |
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/specialty-classroom-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty classroom edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$sltCentersExists = intval($_POST['slt_centers_exists']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$existsCenterId = intval($_POST['exists_center_id']); |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$newClassroom = intval($_POST['new_classroom']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$classroomId = intval($_POST['classroom_id']); |
||||
|
||||
if ($sltCentersExists == 1) { |
||||
$sql = "INSERT INTO $tableSepeSpecialtyClassroom (specialty_id, center_id) |
||||
VALUES ($specialtyId, $existsCenterId);"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newClassroom == 1) { |
||||
$classroomId = Database::insert_id(); |
||||
} |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} else { |
||||
//Checker exists centers |
||||
$sql = "SELECT * FROM $tableCenters |
||||
WHERE center_origin='".$centerOrigin."' AND center_code='".$centerCode."'"; |
||||
$rs_tmp = Database::query($sql); |
||||
if (Database::num_rows($rs_tmp) > 0) { |
||||
$aux = Database::fetch_assoc($rs_tmp); |
||||
$centerId = $aux['id']; |
||||
} else { |
||||
$params = array( |
||||
'center_origin' => $centerOrigin, |
||||
'center_code' => $centerCode, |
||||
); |
||||
$centerId = Database::insert($tableCenters, $params); |
||||
} |
||||
|
||||
if (isset($newClassroom) && $newClassroom != 1) { |
||||
$sql = "UPDATE $tableSepeSpecialtyClassroom SET center_id = $centerId WHERE id = $classroomId;"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeSpecialtyClassroom (specialty_id, center_id) VALUES ($specialtyId, $centerId);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newClassroom == 1) { |
||||
$classroomId = Database::insert_id(); |
||||
} |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$newClassroom = intval($_POST['new_classroom']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$classroomId = intval($_POST['classroom_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
Security::clear_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
$token = Security::get_token(); |
||||
session_write_close(); |
||||
header("Location:specialty-classroom-edit.php?new_classroom=".$newClassroom."&specialty_id=".$specialtyId."&classroom_id=".$classroomId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".intval($_GET['action_id']), "name" => $plugin->get_lang('SpecialtyFormativeAction')); |
||||
if (isset($_GET['new_classroom']) && intval($_GET['new_classroom']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyClassroom'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_classroom', '1'); |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyClassroom'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('classroom_id', intval($_GET['classroom_id'])); |
||||
$info = getInfoSpecialtyClassroom(intval($_GET['classroom_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_classroom', '0'); |
||||
|
||||
} |
||||
$centerList = getCentersList(); |
||||
$tpl->assign('listExistsCenters', $centerList); |
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/specialty-classroom-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
@ -1,223 +1,220 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty tutors edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$sltUserExists = intval($_POST['slt_user_exists']); |
||||
$existingTutor = intval($_POST['existingTutor']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$tutorAccreditation = Database::escape_string(trim($_POST['tutor_accreditation'])); |
||||
$professionalExperience = intval($_POST['professional_experience']); |
||||
$teachingCompetence = Database::escape_string(trim($_POST['teaching_competence'])); |
||||
$experienceTeleforming = intval($_POST['experience_teleforming']); |
||||
$trainingTeleforming = Database::escape_string(trim($_POST['training_teleforming'])); |
||||
$specialtyTutorId = intval($_POST['specialtyTutorId']); |
||||
$documentType = Database::escape_string(trim($_POST['document_type'])); |
||||
$documentNumber = Database::escape_string(trim($_POST['document_number'])); |
||||
$documentLetter = Database::escape_string(trim($_POST['document_letter'])); |
||||
$actionId = intval($_POST['action_id']); |
||||
$newTutor = intval($_POST['new_tutor']); |
||||
$platformUserId = intval($_POST['platform_user_id']); |
||||
|
||||
if ($sltUserExists == 1) { |
||||
$sql = "SELECT * FROM $tableSepeTutors WHERE id = $existingTutor;"; |
||||
$rs = Database::query($sql); |
||||
$tmp = Database::fetch_assoc($rs); |
||||
|
||||
$sql = "INSERT INTO $tableSepeSpecialtyTutors ( |
||||
specialty_id, |
||||
tutor_id, |
||||
tutor_accreditation, |
||||
professional_experience, |
||||
teaching_competence, |
||||
experience_teleforming , |
||||
training_teleforming |
||||
) VALUES ( |
||||
$specialtyId, |
||||
$existingTutor, |
||||
'".$tmp['tutor_accreditation']."', |
||||
'".$tmp['professional_experience']."', |
||||
'".$tmp['teaching_competence']."', |
||||
'".$tmp['experience_teleforming ']."', |
||||
'".$tmp['training_teleforming']."' |
||||
);"; |
||||
$res = Database::query($sql); |
||||
} else { |
||||
$sql = "SELECT id |
||||
FROM $tableSepeTutors |
||||
WHERE |
||||
document_type = '".$documentType."' |
||||
AND document_number = '".$documentNumber."' |
||||
AND document_letter = '".$documentLetter."';"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$aux = Database::fetch_assoc($rs); |
||||
$sql = "UPDATE $tableSepeTutors SET |
||||
platform_user_id = $platformUserId, |
||||
tutor_accreditation = '".$tutorAccreditation."', |
||||
professional_experience = $professionalExperience, |
||||
teaching_competence = '".$teachingCompetence."', |
||||
experience_teleforming = $experienceTeleforming, |
||||
training_teleforming = '".$trainingTeleforming."' |
||||
WHERE id = '".$aux['id']."';"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
error_log(Database::error()); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} |
||||
$newTutor = 0; //Reset variable, no create new tutor, exists tutor |
||||
$tutorId = $aux['id']; |
||||
$specialtyTutorId = getSpecialtyTutorId($specialtyId, $tutorId); |
||||
} else { |
||||
$sql = "UPDATE $tableSepeTutors |
||||
SET platform_user_id='' |
||||
WHERE platform_user_id='".$platformUserId."'"; |
||||
Database::query($sql); |
||||
$sql = "INSERT INTO $tableSepeTutors ( |
||||
platform_user_id, |
||||
document_type, |
||||
document_number, |
||||
document_letter, |
||||
tutor_accreditation, |
||||
professional_experience, |
||||
teaching_competence, |
||||
experience_teleforming, |
||||
training_teleforming |
||||
) VALUES ( |
||||
$platformUserId, |
||||
'".$documentType."', |
||||
'".$documentNumber."', |
||||
'".$documentLetter."', |
||||
'".$tutorAccreditation."', |
||||
$professionalExperience, |
||||
'".$teachingCompetence."', |
||||
$experienceTeleforming, |
||||
'".$trainingTeleforming."' |
||||
);"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
error_log(Database::error()); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
$tutorId = Database::insert_id(); |
||||
} |
||||
} |
||||
|
||||
if (isset($newTutor) && $newTutor != 1) { |
||||
$sql = "UPDATE $tableSepeSpecialtyTutors SET |
||||
tutor_id = $tutorId, |
||||
tutor_accreditation = '".$tutorAccreditation."', |
||||
professional_experience = $professionalExperience, |
||||
teaching_competence = '".$teachingCompetence."', |
||||
experience_teleforming = $experienceTeleforming, |
||||
training_teleforming='".$trainingTeleforming."' |
||||
WHERE id = $specialtyTutorId;"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeSpecialtyTutors ( |
||||
specialty_id, |
||||
tutor_id, |
||||
tutor_accreditation, |
||||
professional_experience, |
||||
teaching_competence, |
||||
experience_teleforming, |
||||
training_teleforming |
||||
) VALUES ( |
||||
$specialtyId, |
||||
$tutorId, |
||||
'".$tutorAccreditation."', |
||||
$professionalExperience, |
||||
'".$teachingCompetence."', |
||||
$experienceTeleforming, |
||||
'".$trainingTeleforming."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
error_log(Database::error()); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newTutor == 1) { |
||||
$tutorId = Database::insert_id(); |
||||
} |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$actionId = intval($_POST['action_id']); |
||||
$newTutor = intval($_POST['new_tutor']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$specialtyTutorId = intval($_POST['specialtyTutorId']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: specialty-tutor-edit.php?new_tutor=".$newTutor."&specialty_id=".$specialtyId."&tutor_id=".$specialtyTutorId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".$_GET['action_id'], "name" => $plugin->get_lang('SpecialtyFormativeAction')); |
||||
if (isset($_GET['new_tutor']) && intval($_GET['new_tutor']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyTutor'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutor', '1'); |
||||
$platformUserId = ''; |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyTutor'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('tutor_id', intval($_GET['tutor_id'])); |
||||
$info = getInfoSpecialtyTutor(intval($_GET['tutor_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutor', '0'); |
||||
$platformUserId = $info['platform_user_id']; |
||||
|
||||
} |
||||
$tutorsList = getTutorsSpecialty(intval($_GET['specialty_id'])); |
||||
$tpl->assign('ExistingTutorsList', $tutorsList); |
||||
|
||||
$listTeachers = CourseManager::getTeachersFromCourse($courseId); |
||||
$listTeachers = freeTeacherList($listTeachers, intval($_GET['specialty_id']), $platformUserId); |
||||
$tpl->assign('listTeachers', $listTeachers); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/specialty-tutor-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty tutors edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$sltUserExists = intval($_POST['slt_user_exists']); |
||||
$existingTutor = intval($_POST['existingTutor']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$tutorAccreditation = Database::escape_string(trim($_POST['tutor_accreditation'])); |
||||
$professionalExperience = intval($_POST['professional_experience']); |
||||
$teachingCompetence = Database::escape_string(trim($_POST['teaching_competence'])); |
||||
$experienceTeleforming = intval($_POST['experience_teleforming']); |
||||
$trainingTeleforming = Database::escape_string(trim($_POST['training_teleforming'])); |
||||
$specialtyTutorId = intval($_POST['specialtyTutorId']); |
||||
$documentType = Database::escape_string(trim($_POST['document_type'])); |
||||
$documentNumber = Database::escape_string(trim($_POST['document_number'])); |
||||
$documentLetter = Database::escape_string(trim($_POST['document_letter'])); |
||||
$actionId = intval($_POST['action_id']); |
||||
$newTutor = intval($_POST['new_tutor']); |
||||
$platformUserId = intval($_POST['platform_user_id']); |
||||
|
||||
if ($sltUserExists == 1) { |
||||
$sql = "SELECT * FROM $tableSepeTutors WHERE id = $existingTutor;"; |
||||
$rs = Database::query($sql); |
||||
$tmp = Database::fetch_assoc($rs); |
||||
|
||||
$sql = "INSERT INTO $tableSepeSpecialtyTutors ( |
||||
specialty_id, |
||||
tutor_id, |
||||
tutor_accreditation, |
||||
professional_experience, |
||||
teaching_competence, |
||||
experience_teleforming , |
||||
training_teleforming |
||||
) VALUES ( |
||||
$specialtyId, |
||||
$existingTutor, |
||||
'".$tmp['tutor_accreditation']."', |
||||
'".$tmp['professional_experience']."', |
||||
'".$tmp['teaching_competence']."', |
||||
'".$tmp['experience_teleforming ']."', |
||||
'".$tmp['training_teleforming']."' |
||||
);"; |
||||
$res = Database::query($sql); |
||||
} else { |
||||
$sql = "SELECT id |
||||
FROM $tableSepeTutors |
||||
WHERE |
||||
document_type = '".$documentType."' |
||||
AND document_number = '".$documentNumber."' |
||||
AND document_letter = '".$documentLetter."';"; |
||||
$rs = Database::query($sql); |
||||
if (Database::num_rows($rs) > 0) { |
||||
$aux = Database::fetch_assoc($rs); |
||||
$sql = "UPDATE $tableSepeTutors SET |
||||
platform_user_id = $platformUserId, |
||||
tutor_accreditation = '".$tutorAccreditation."', |
||||
professional_experience = $professionalExperience, |
||||
teaching_competence = '".$teachingCompetence."', |
||||
experience_teleforming = $experienceTeleforming, |
||||
training_teleforming = '".$trainingTeleforming."' |
||||
WHERE id = '".$aux['id']."';"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} |
||||
$newTutor = 0; //Reset variable, no create new tutor, exists tutor |
||||
$tutorId = $aux['id']; |
||||
$specialtyTutorId = getSpecialtyTutorId($specialtyId, $tutorId); |
||||
} else { |
||||
$sql = "UPDATE $tableSepeTutors |
||||
SET platform_user_id='' |
||||
WHERE platform_user_id='".$platformUserId."'"; |
||||
Database::query($sql); |
||||
$sql = "INSERT INTO $tableSepeTutors ( |
||||
platform_user_id, |
||||
document_type, |
||||
document_number, |
||||
document_letter, |
||||
tutor_accreditation, |
||||
professional_experience, |
||||
teaching_competence, |
||||
experience_teleforming, |
||||
training_teleforming |
||||
) VALUES ( |
||||
$platformUserId, |
||||
'".$documentType."', |
||||
'".$documentNumber."', |
||||
'".$documentLetter."', |
||||
'".$tutorAccreditation."', |
||||
$professionalExperience, |
||||
'".$teachingCompetence."', |
||||
$experienceTeleforming, |
||||
'".$trainingTeleforming."' |
||||
);"; |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
$tutorId = Database::insert_id(); |
||||
} |
||||
} |
||||
|
||||
if (isset($newTutor) && $newTutor != 1) { |
||||
$sql = "UPDATE $tableSepeSpecialtyTutors SET |
||||
tutor_id = $tutorId, |
||||
tutor_accreditation = '".$tutorAccreditation."', |
||||
professional_experience = $professionalExperience, |
||||
teaching_competence = '".$teachingCompetence."', |
||||
experience_teleforming = $experienceTeleforming, |
||||
training_teleforming='".$trainingTeleforming."' |
||||
WHERE id = $specialtyTutorId;"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeSpecialtyTutors ( |
||||
specialty_id, |
||||
tutor_id, |
||||
tutor_accreditation, |
||||
professional_experience, |
||||
teaching_competence, |
||||
experience_teleforming, |
||||
training_teleforming |
||||
) VALUES ( |
||||
$specialtyId, |
||||
$tutorId, |
||||
'".$tutorAccreditation."', |
||||
$professionalExperience, |
||||
'".$teachingCompetence."', |
||||
$experienceTeleforming, |
||||
'".$trainingTeleforming."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
if ($newTutor == 1) { |
||||
$tutorId = Database::insert_id(); |
||||
} |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
} |
||||
session_write_close(); |
||||
header("Location: specialty-action-edit.php?new_specialty=0&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$actionId = intval($_POST['action_id']); |
||||
$newTutor = intval($_POST['new_tutor']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$specialtyTutorId = intval($_POST['specialtyTutorId']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: specialty-tutor-edit.php?new_tutor=".$newTutor."&specialty_id=".$specialtyId."&tutor_id=".$specialtyTutorId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "specialty-action-edit.php?new_specialty=0&specialty_id=".intval($_GET['specialty_id'])."&action_id=".$_GET['action_id'], "name" => $plugin->get_lang('SpecialtyFormativeAction')); |
||||
if (isset($_GET['new_tutor']) && intval($_GET['new_tutor']) == 1) { |
||||
$templateName = $plugin->get_lang('NewSpecialtyTutor'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutor', '1'); |
||||
$platformUserId = ''; |
||||
} else { |
||||
$templateName = $plugin->get_lang('EditSpecialtyTutor'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('tutor_id', intval($_GET['tutor_id'])); |
||||
$info = getInfoSpecialtyTutor(intval($_GET['tutor_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutor', '0'); |
||||
$platformUserId = $info['platform_user_id']; |
||||
|
||||
} |
||||
$tutorsList = getTutorsSpecialty(intval($_GET['specialty_id'])); |
||||
$tpl->assign('ExistingTutorsList', $tutorsList); |
||||
|
||||
$listTeachers = CourseManager::getTeachersFromCourse($courseId); |
||||
$listTeachers = freeTeacherList($listTeachers, intval($_GET['specialty_id']), $platformUserId); |
||||
$tpl->assign('listTeachers', $listTeachers); |
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/specialty-tutor-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
@ -1,158 +1,157 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty tutorial edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$tutorialId = intval($_POST['tutorial_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newTutorial = intval($_POST['new_tutorial']); |
||||
$starDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (isset($newTutorial) && $newTutorial != 1) { |
||||
$sql = "UPDATE $tableSepeParticipantsSpecialtyTutorials SET |
||||
center_origin='".$centerOrigin."', |
||||
center_code='".$centerCode."', |
||||
start_date='".$starDate."', |
||||
end_date='".$endDate."' |
||||
WHERE id = $tutorialId;"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeParticipantsSpecialtyTutorials ( |
||||
participant_specialty_id, |
||||
center_origin, |
||||
center_code, |
||||
start_date, |
||||
end_date |
||||
) VALUES ( |
||||
$specialtyId, |
||||
'".$centerOrigin."', |
||||
'".$centerCode."', |
||||
'".$starDate."', |
||||
'".$endDate."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
error_log(Database::error()); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
|
||||
session_write_close(); |
||||
$participantId = getParticipantId($specialtyId); |
||||
header("Location: participant-specialty-edit.php?new_specialty=0&participant_id=".$participantId."&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$tutorialId = intval($_POST['tutorial_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newTutorial = intval($_POST['new_tutorial']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: specialty-tutorial-edit.php?new_tutorial=".$newTutorial."&specialty_id=".$specialtyId."&tutorial_id=".$tutorialId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$participantId = getParticipantId(intval($_GET['specialty_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "participant-specialty-edit.php?new_specialty=0&participant_id=".$participantId."&specialty_id=".intval($_GET['specialty_id'])."&action_id=".intval($_GET['action_id']), "name" => $plugin->get_lang('SpecialtyFormativeParcipant')); |
||||
if (isset($_GET['new_tutorial']) && intval($_GET['new_tutorial']) == 1) { |
||||
$templateName = $plugin->get_lang('new_tutorial'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutorial', '1'); |
||||
$startYear = $endYear = date("Y"); |
||||
} else { |
||||
$templateName = $plugin->get_lang('edit_tutorial'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('tutorial_id', intval($_GET['tutorial_id'])); |
||||
$info = getInfoSpecialtyTutorial(intval($_GET['tutorial_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutorial', '0'); |
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$startYear = date("Y"); |
||||
} |
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$endYear = date("Y"); |
||||
} |
||||
} |
||||
$listYears = array(); |
||||
if ($startYear > $endYear) { |
||||
$tmp = $startYear; |
||||
$startYear = $endYear; |
||||
$endYear = $tmp; |
||||
} |
||||
$startYear -= 5; |
||||
$endYear += 5; |
||||
$endRangeYear = (($startYear + 15) < $endYear) ? ($endYear + 1) : ($startYear + 15); |
||||
while ($startYear <= $endRangeYear) { |
||||
$listYears[] = $startYear; |
||||
$startYear++; |
||||
} |
||||
$tpl->assign('list_year', $listYears); |
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/specialty-tutorial-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This script displays a specialty tutorial edit form. |
||||
*/ |
||||
|
||||
use \ChamiloSession as Session; |
||||
require_once '../config.php'; |
||||
|
||||
$course_plugin = 'sepe'; |
||||
$plugin = SepePlugin::create(); |
||||
$_cid = 0; |
||||
|
||||
if (!empty($_POST)) { |
||||
$check = Security::check_token('post'); |
||||
if ($check) { |
||||
$centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||||
$centerCode = Database::escape_string(trim($_POST['center_code'])); |
||||
$dayStart = Database::escape_string(trim($_POST['day_start'])); |
||||
$monthStart = Database::escape_string(trim($_POST['month_start'])); |
||||
$yearStart = Database::escape_string(trim($_POST['year_start'])); |
||||
$dayEnd = Database::escape_string(trim($_POST['day_end'])); |
||||
$monthEnd = Database::escape_string(trim($_POST['month_end'])); |
||||
$yearEnd = Database::escape_string(trim($_POST['year_end'])); |
||||
$tutorialId = intval($_POST['tutorial_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newTutorial = intval($_POST['new_tutorial']); |
||||
$starDate = $yearStart."-".$monthStart."-".$dayStart; |
||||
$endDate = $yearEnd."-".$monthEnd."-".$dayEnd; |
||||
|
||||
if (isset($newTutorial) && $newTutorial != 1) { |
||||
$sql = "UPDATE $tableSepeParticipantsSpecialtyTutorials SET |
||||
center_origin='".$centerOrigin."', |
||||
center_code='".$centerCode."', |
||||
start_date='".$starDate."', |
||||
end_date='".$endDate."' |
||||
WHERE id = $tutorialId;"; |
||||
} else { |
||||
$sql = "INSERT INTO $tableSepeParticipantsSpecialtyTutorials ( |
||||
participant_specialty_id, |
||||
center_origin, |
||||
center_code, |
||||
start_date, |
||||
end_date |
||||
) VALUES ( |
||||
$specialtyId, |
||||
'".$centerOrigin."', |
||||
'".$centerCode."', |
||||
'".$starDate."', |
||||
'".$endDate."' |
||||
);"; |
||||
} |
||||
$res = Database::query($sql); |
||||
if (!$res) { |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||||
} else { |
||||
$_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||||
} |
||||
|
||||
session_write_close(); |
||||
$participantId = getParticipantId($specialtyId); |
||||
header("Location: participant-specialty-edit.php?new_specialty=0&participant_id=".$participantId."&specialty_id=".$specialtyId."&action_id=".$actionId); |
||||
} else { |
||||
$tutorialId = intval($_POST['tutorial_id']); |
||||
$actionId = intval($_POST['action_id']); |
||||
$specialtyId = intval($_POST['specialty_id']); |
||||
$newTutorial = intval($_POST['new_tutorial']); |
||||
Security::clear_token(); |
||||
$token = Security::get_token(); |
||||
$_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||||
session_write_close(); |
||||
header("Location: specialty-tutorial-edit.php?new_tutorial=".$newTutorial."&specialty_id=".$specialtyId."&tutorial_id=".$tutorialId."&action_id=".$actionId); |
||||
} |
||||
} else { |
||||
$token = Security::get_token(); |
||||
} |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$courseId = getCourse(intval($_GET['action_id'])); |
||||
$participantId = getParticipantId(intval($_GET['specialty_id'])); |
||||
$interbreadcrumb[] = array("url" => "/plugin/sepe/src/sepe-administration-menu.php", "name" => $plugin->get_lang('MenuSepe')); |
||||
$interbreadcrumb[] = array("url" => "formative-actions-list.php", "name" => $plugin->get_lang('FormativesActionsList')); |
||||
$interbreadcrumb[] = array("url" => "formative-action.php?cid=".$courseId, "name" => $plugin->get_lang('FormativeAction')); |
||||
$interbreadcrumb[] = array("url" => "participant-specialty-edit.php?new_specialty=0&participant_id=".$participantId."&specialty_id=".intval($_GET['specialty_id'])."&action_id=".intval($_GET['action_id']), "name" => $plugin->get_lang('SpecialtyFormativeParcipant')); |
||||
if (isset($_GET['new_tutorial']) && intval($_GET['new_tutorial']) == 1) { |
||||
$templateName = $plugin->get_lang('new_tutorial'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$info = array(); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutorial', '1'); |
||||
$startYear = $endYear = date("Y"); |
||||
} else { |
||||
$templateName = $plugin->get_lang('edit_tutorial'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('action_id', intval($_GET['action_id'])); |
||||
$tpl->assign('specialty_id', intval($_GET['specialty_id'])); |
||||
$tpl->assign('tutorial_id', intval($_GET['tutorial_id'])); |
||||
$info = getInfoSpecialtyTutorial(intval($_GET['tutorial_id'])); |
||||
$tpl->assign('info', $info); |
||||
$tpl->assign('new_tutorial', '0'); |
||||
if ($info['start_date'] != '0000-00-00' && $info['start_date'] != NULL) { |
||||
$tpl->assign('day_start', date("j", strtotime($info['start_date']))); |
||||
$tpl->assign('month_start', date("n", strtotime($info['start_date']))); |
||||
$tpl->assign('year_start', date("Y", strtotime($info['start_date']))); |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$startYear = date("Y", strtotime($info['start_date'])); |
||||
} else { |
||||
$startYear = date("Y"); |
||||
} |
||||
if ($info['end_date'] != '0000-00-00' && $info['end_date'] != NULL) { |
||||
$tpl->assign('day_end', date("j", strtotime($info['end_date']))); |
||||
$tpl->assign('month_end', date("n", strtotime($info['end_date']))); |
||||
$tpl->assign('year_end', date("Y", strtotime($info['end_date']))); |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} elseif (strpos($info['end_date'], '0000') === false) { |
||||
$endYear = date("Y", strtotime($info['end_date'])); |
||||
} else { |
||||
$endYear = date("Y"); |
||||
} |
||||
} |
||||
$listYears = array(); |
||||
if ($startYear > $endYear) { |
||||
$tmp = $startYear; |
||||
$startYear = $endYear; |
||||
$endYear = $tmp; |
||||
} |
||||
$startYear -= 5; |
||||
$endYear += 5; |
||||
$endRangeYear = (($startYear + 15) < $endYear) ? ($endYear + 1) : ($startYear + 15); |
||||
while ($startYear <= $endRangeYear) { |
||||
$listYears[] = $startYear; |
||||
$startYear++; |
||||
} |
||||
$tpl->assign('list_year', $listYears); |
||||
|
||||
if (isset($_SESSION['sepe_message_info'])) { |
||||
$tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||||
unset($_SESSION['sepe_message_info']); |
||||
} |
||||
if (isset($_SESSION['sepe_message_error'])) { |
||||
$tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||||
unset($_SESSION['sepe_message_error']); |
||||
} |
||||
$tpl->assign('sec_token', $token); |
||||
|
||||
$listing_tpl = 'sepe/view/specialty-tutorial-edit.tpl'; |
||||
$content = $tpl->fetch($listing_tpl); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
} else { |
||||
header('Location:'.api_get_path(WEB_PATH)); |
||||
} |
||||
|
Loading…
Reference in new issue