init
This commit is contained in:
511
module/learning/learning.inc.php
Normal file
511
module/learning/learning.inc.php
Normal file
@@ -0,0 +1,511 @@
|
||||
<?
|
||||
|
||||
global $parentSort;
|
||||
$parentSort = array();
|
||||
|
||||
switch ($_GET["action"]) {
|
||||
case "moveup_learning":
|
||||
moveup_learning();
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
case "movedown_learning":
|
||||
movedown_learning();
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
case "moveleft_learning":
|
||||
moveleft_learning();
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
case "moveright_learning":
|
||||
moveright_learning();
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
case "reorder_learning":
|
||||
reorder_learning();
|
||||
break;
|
||||
case "delete_learning":
|
||||
delete_learning();
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
case "edit_learning":
|
||||
edit_learning();
|
||||
break;
|
||||
case "save_learning":
|
||||
save_learning($site, $language);
|
||||
break;
|
||||
case "new_learning":
|
||||
require_once("learning_cardform.inc.php");
|
||||
break;
|
||||
case 'delete_image':
|
||||
delete_image();
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
default:
|
||||
require_once("learning_listform.inc.php");
|
||||
break;
|
||||
}
|
||||
|
||||
function update_children( $_parentId, $_list, $_level ) {
|
||||
global $parentSort;
|
||||
|
||||
foreach ($_list as $site) {
|
||||
if (!array_key_exists($_parentId, $parentSort)) {
|
||||
$parentSort[$_parentId] = 1;
|
||||
}
|
||||
$query = "UPDATE learning_category SET parent_id = " . $_parentId . ", level = " . $_level . ", sorting = " . $parentSort[$_parentId] . " WHERE id = " . (int)$site['id'];
|
||||
mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$parentSort[$_parentId]++;
|
||||
if (isset($site['children']) && count($site['children'])) {
|
||||
update_children($site['id'], $site['children'], $_level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reorder_learning() {
|
||||
global $parentSort;
|
||||
$list = $_POST['list'];
|
||||
if (!is_array($list) || count($list) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$level = 1;
|
||||
foreach ($list as $site) {
|
||||
if (!array_key_exists(0, $parentSort)) {
|
||||
$parentSort[0] = 1;
|
||||
}
|
||||
$query = "UPDATE learning_category SET parent_id = 0, level = 1, sorting = " . $parentSort[0] . " WHERE id = " . (int)$site['id'];
|
||||
mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$parentSort[0]++;
|
||||
if (isset($site['children']) && count($site['children'])) {
|
||||
update_children($site['id'], $site['children'], $level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit_learning( $_id = "", $messages = array() ) {
|
||||
if ((int)$_id > 0) {
|
||||
$input_id = $_id;
|
||||
} else {
|
||||
$input_id = $_REQUEST["input_learning_id"];
|
||||
}
|
||||
if ($input_id <> '') {
|
||||
$query = "SELECT * FROM learning_category WHERE id = '" . $input_id . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$input_learning = @mysqli_fetch_array($result);
|
||||
require_once("learning_cardform.inc.php");
|
||||
}
|
||||
} else {
|
||||
require_once("learning_listform.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
function delete_learning() {
|
||||
if ($_POST["input_learning_id"] <> '') {
|
||||
$query = "DELETE FROM learning_category WHERE id = '" . $_POST["input_learning_id"] . "' LIMIT 1";
|
||||
if (@mysqli_query($GLOBALS['mysql_con'], $query)) {
|
||||
@mysqli_query($GLOBALS['mysql_con'], "UPDATE learning_category SET parent_id = 0, level = level -1 WHERE parent_id = '" . $_POST["input_learning_id"] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function save_learning( $site, $language ) {
|
||||
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$messages = array();
|
||||
|
||||
$input_id = "";
|
||||
$input_active = ($_POST["input_active"] == "on") ? 1 : 0;
|
||||
$description = $_POST["input_description"];
|
||||
$tags = $_POST["input_tags"];
|
||||
|
||||
if ($_POST["input_learning_id"] <> '') {
|
||||
$query = "UPDATE learning_category SET
|
||||
description = '" . $description . "',
|
||||
active = '" . $input_active . "',
|
||||
tags = '" . $tags . "'
|
||||
WHERE id = '" . $_POST["input_learning_id"] . "' LIMIT 1";
|
||||
|
||||
$inserted = FALSE;
|
||||
$input_id = $_REQUEST["input_learning_id"];
|
||||
} else {
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], "SELECT * FROM learning_category WHERE main_site_id = '" . $site["id"] . "' AND main_language_id = '" . $language["id"] . "' AND level = 1 ORDER BY sorting DESC LIMIT 1");
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$curr_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$query = "INSERT INTO learning_category (main_site_id,main_language_id,parent_id,sorting,level,description,tags,active)
|
||||
VALUES (
|
||||
" . $site["id"] . ",
|
||||
" . $language["id"] . ",
|
||||
0,
|
||||
" . ($curr_learning["sorting"] + 1) . ",
|
||||
1,
|
||||
'" . $description . "',
|
||||
'" . $tags . "',
|
||||
" . $input_active . "
|
||||
)";
|
||||
|
||||
$inserted = TRUE;
|
||||
}
|
||||
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], "SELECT * FROM learning_category WHERE main_site_id = '" . $site["id"] . "' AND main_language_id = '" . $language["id"] . "' AND code = '" . $_POST["input_code"] . "'");
|
||||
if ((@mysqli_num_rows($result) <> 0) && ($_POST["input_learning_id"] == '')) {
|
||||
$messages[] = "<div class=\"errorbox\">" . $translation->get("error_textkey_exists") . "</div>\n";
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
if ($inserted == TRUE) {
|
||||
$input_id = mysqli_insert_id($GLOBALS['mysql_con']);
|
||||
$messages[] = '<div class="successbox">' . $translation->get("learning_msg_success1") . '</div>';
|
||||
} else {
|
||||
$messages[] = '<div class="successbox">' . $translation->get("learning_msg_success2") . '</div>';
|
||||
}
|
||||
|
||||
// saveImg
|
||||
|
||||
$mandant_ids = $_POST['select_mandant'];
|
||||
$mandant = explode(',', $mandant_ids);
|
||||
if(!empty($mandant) && gettype($mandant) == 'array') {
|
||||
$deleteLink = @mysqli_query($GLOBALS["mysql_con"], "DELETE FROM learning_category_mandant_link WHERE learning_category_id ='".$input_id."'");
|
||||
foreach($mandant as $key => $mandant_value){
|
||||
$query = "INSERT INTO learning_category_mandant_link
|
||||
(learning_category_id, main_mandant_id)
|
||||
VALUES (
|
||||
" . $input_id . ",
|
||||
" . $mandant_value . "
|
||||
)";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_FILES) && !empty($_FILES) && $_FILES['input_image']['size'] != 0 ){
|
||||
$fileName = saveImage('input_image', $input_id);
|
||||
|
||||
$query = "UPDATE learning_category SET
|
||||
image = '" . $fileName. "'
|
||||
WHERE id = '" . $input_id . "' LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'],$query);
|
||||
}
|
||||
|
||||
// SaveImag
|
||||
|
||||
edit_learning($input_id, $messages);
|
||||
} else {
|
||||
header('EDIT_ERROR: 1');
|
||||
$query = "SELECT * FROM learning_category WHERE id = '" . $_POST["input_learning_id"] . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$input_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$input_learning["description"] = $_REQUEST["input_description"];
|
||||
$input_learning["tags"] = $_REQUEST["input_tags"];
|
||||
$input_learning["active"] = $input_active;
|
||||
require_once("learning_cardform.inc.php");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function count_posts($category_id){
|
||||
$query = "SELECT * FROM learning_collection_link WHERE learning_category_id = ".$category_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$count = 0;
|
||||
while($posts = @mysqli_fetch_array($result)) {
|
||||
$query2 = "SELECT * FROM main_collection_read WHERE main_collection_id = ".$posts['main_collection_id']. " AND main_contact_id = ".$GLOBALS['main_contact']['id'];
|
||||
$result2 = @mysqli_query($GLOBALS['mysql_con'], $query2);
|
||||
$count++;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
function show_learning( $site, $language ) {
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
|
||||
$result = mysqli_query($GLOBALS['mysql_con'], "SELECT * FROM learning_category WHERE main_site_id = '" . $site["id"] . "' AND main_language_id = '" . $language["id"]."'");
|
||||
$num_rows = mysqli_num_rows($result);
|
||||
if ($num_rows > 0) {
|
||||
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"linklist\"><tr>";
|
||||
echo "<td><div>" . $translation->get("name") . "</div></td>";
|
||||
echo "<td width=\"150\" align=\"left\"><div></div></td>";
|
||||
echo "<td class=\"code\" width=\"300\" align=\"left\"><div>" . $translation->get("linked_posts") . "</div></td>";
|
||||
echo "<td class=\"status\" width=\"100\" align=\"left\"><div>" . $translation->get("state") . "</div></td>";
|
||||
echo "</tr>";
|
||||
echo "<tr>";
|
||||
echo "<td class=\"linklist_seperator\"></td>";
|
||||
echo "<td class=\"linklist_seperator\"></td>";
|
||||
echo "<td class=\"linklist_seperator\"></td>";
|
||||
echo "<td class=\"linklist_seperator\"></td>";
|
||||
echo "</tr>";
|
||||
|
||||
echo "</table>";
|
||||
|
||||
show_learning_rek($site, $language, 0, 1, 0, $num_rows);
|
||||
|
||||
|
||||
} else {
|
||||
echo "<div class=\"infobox\">" . $translation->get("no_rows_found") . "</div>";
|
||||
}
|
||||
echo "\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
function show_learning_rek( $site, $language, $parent_id, $level, $input_counter, $num_rows ) {
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$parent_id_query = ($parent_id == 0) ? " AND parent_id = 0" : " AND parent_id = '" . $parent_id."'";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], "SELECT * FROM learning_category WHERE main_site_id = '" . $site["id"] . "' AND main_language_id = '" . $language["id"]."'" . $parent_id_query . " ORDER BY sorting ASC");
|
||||
if (@mysqli_num_rows($result) > 0) {
|
||||
if ($parent_id == 0) {
|
||||
echo "<ol class=\"linklist sortable\">";
|
||||
} else {
|
||||
echo "<ol>";
|
||||
}
|
||||
|
||||
while ($learning = @mysqli_fetch_array($result)) {
|
||||
$parentclass = "";
|
||||
if ($level > 1) {
|
||||
$parentclass = " data-tt-parent-id=\"{$learning['parent_id']}\"";
|
||||
}
|
||||
|
||||
$checkedRow = "false";
|
||||
if (isset($_REQUEST['input_learning_id']) && $_REQUEST['input_learning_id'] == $learning['id']) {
|
||||
$checkedRow = "true";
|
||||
}
|
||||
|
||||
echo "<li id=\"list_{$learning['id']}\">";
|
||||
echo "<div data-inputid=\"" . $learning['id'] . "\" data-action=\"edit_learning\" data-inputname=\"input_learning_id\" data-checked=\"" . $checkedRow . "\" class=\"linklist_content dd-handle\"><span class=\"disclose\"><span> </span></span>" . htmlentities($learning["description"], ENT_COMPAT, "UTF-8") . "<div class=\"dd-icon\"></div>";
|
||||
echo "<div class=\"dd-code\">" . count_posts($learning['id']) . " Beiträge</div>";
|
||||
echo "<div class=\"dd-status\">" . ($learning["active"] == 1 ? $translation->get("active") : $translation->get("inactive")) . "</div>";
|
||||
$input_counter++;
|
||||
$input_counter = show_learning_rek($site, $language, $learning["id"], ($level + 1), $input_counter, $num_rows);
|
||||
echo "</li>";
|
||||
}
|
||||
echo "</ol>";
|
||||
}
|
||||
|
||||
return $input_counter;
|
||||
}
|
||||
|
||||
function moveup_learning() {
|
||||
move_learning_vertical("<", "DESC", $_POST["input_learning_id"]);
|
||||
}
|
||||
|
||||
function movedown_learning() {
|
||||
move_learning_vertical(">", "ASC", $_POST["input_learning_id"]);
|
||||
}
|
||||
|
||||
function move_learning_vertical( $way, $order, $learning_id ) {
|
||||
$query = "SELECT * FROM learning_category WHERE id = '" . $learning_id . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$curr_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$parent_query = ($curr_learning["parent_id"] <> '') ? " parent_id = '" . $curr_learning["parent_id"]."'" : " parent_id = 0";
|
||||
$query = "SELECT * FROM learning_category WHERE main_site_id = '" . $curr_learning["main_site_id"] . "' AND main_language_id = '" . $curr_learning["main_language_id"] . "' AND" . $parent_query . " AND sorting " . $way . " " . $curr_learning["sorting"] . " ORDER BY sorting " . $order . " LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$change_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
if (($curr_learning["id"] <> '') && ($change_learning["id"] <> '')) {
|
||||
$query = "UPDATE learning_category SET sorting = " . $change_learning["sorting"] . " WHERE id = " . $curr_learning["id"];
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$query = "UPDATE learning_category SET sorting = " . $curr_learning["sorting"] . " WHERE id = " . $change_learning["id"];
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
|
||||
function moveleft_learning() {
|
||||
$query = "SELECT * FROM learning_category WHERE id = '" . $_POST["input_learning_id"] . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$curr_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$query = "SELECT * FROM learning_category WHERE id = '" . $curr_learning["parent_id"] . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$parent_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$query = "SELECT * FROM learning_category WHERE parent_id = '" . $curr_learning["parent_id"] . "' ORDER BY sorting DESC LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$last_child_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
|
||||
if (($curr_learning["id"] <> '') && ($parent_learning["id"] <> '')) {
|
||||
// Eigentlichen Menüeintrag aktualisieren
|
||||
if ($parent_learning["parent_id"] == '') {
|
||||
$parent_learning["parent_id"] = "0";
|
||||
}
|
||||
$query = "UPDATE learning_category SET parent_id = " . $parent_learning["parent_id"] . ", level = " . $parent_learning["level"] . ", sorting = " . ($parent_learning["sorting"] + 1) . " WHERE id = " . $curr_learning["id"];
|
||||
if (@mysqli_query($GLOBALS['mysql_con'], $query)) {
|
||||
// Level der ursprünglichen Untermenüpunkte aktualisieren
|
||||
update_learning_children($curr_learning["id"], "-");
|
||||
// Parent-ID und Sortierung der neuen Untermenüpunkte aktualisieren
|
||||
$parent_query = ($curr_learning["parent_id"] <> '') ? " parent_id = '" . $curr_learning["parent_id"]."'" : " parent_id = 0";
|
||||
$query = "SELECT * FROM learning_category WHERE" . $parent_query . " AND sorting > " . $curr_learning["sorting"] . " AND main_site_id = '" . $GLOBALS["site"]["id"] . "' AND main_language_id = '" . $GLOBALS["language"]["id"]."'";
|
||||
$new_sorting = 1;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) > 0) {
|
||||
while ($learning = @mysqli_fetch_array($result)) {
|
||||
$query = "UPDATE learning_category SET parent_id = " . $curr_learning["id"] . ", sorting = " . $new_sorting . " WHERE id = " . $learning["id"] . " LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$new_sorting++;
|
||||
}
|
||||
}
|
||||
// Sortierung der neuen Nachfolger aktualisieren
|
||||
$new_sorting = $parent_learning["sorting"] + 1;
|
||||
$parent_query = ($parent_learning["parent_id"] <> '0') ? " parent_id = '" . $parent_learning["parent_id"]."'" : " parent_id = 0";
|
||||
$query = "SELECT * FROM learning_category WHERE" . $parent_query . " AND id <> " . $curr_learning["id"] . " AND sorting >= " . $new_sorting . " AND main_site_id = " . $GLOBALS["site"]["id"] . " AND main_language_id = " . $GLOBALS["language"]["id"];
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) > 0) {
|
||||
while ($learning = @mysqli_fetch_array($result)) {
|
||||
$new_sorting++;
|
||||
$query = "UPDATE learning_category SET sorting = " . $new_sorting . " WHERE id = " . $learning["id"] . " LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function moveright_learning() {
|
||||
$query = "SELECT * FROM learning_category WHERE id = '" . $_POST["input_learning_id"] . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$curr_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$parent_query = ($curr_learning["parent_id"] <> '') ? " parent_id = '" . $curr_learning["parent_id"]."'" : " parent_id = 0";
|
||||
$query = "SELECT * FROM learning_category WHERE" . $parent_query . " AND sorting < " . $curr_learning["sorting"] . " AND main_site_id = " . $GLOBALS["site"]["id"] . " AND main_language_id = " . $GLOBALS["language"]["id"] . " ORDER BY sorting DESC LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$pre_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
$query = "SELECT * FROM learning_category WHERE parent_id = '" . $pre_learning["id"] . "' ORDER BY sorting DESC LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$lastprechild_learning = @mysqli_fetch_array($result);
|
||||
}
|
||||
if (($curr_learning["id"] <> '') && ($pre_learning["id"] <> '')) {
|
||||
// Eigentlichen Menüeintrag aktualisieren
|
||||
if ($lastprechild_learning["sorting"] == '') {
|
||||
$lastprechild_learning["sorting"] = 0;
|
||||
}
|
||||
$query = "UPDATE learning_category SET parent_id = " . $pre_learning["id"] . ", level = " . ($curr_learning["level"] + 1) . ", sorting = " . ($lastprechild_learning["sorting"] + 1) . " WHERE id = " . $curr_learning["id"] . " AND main_site_id = " . $GLOBALS["site"]["id"] . " AND main_language_id = " . $GLOBALS["language"]["id"];
|
||||
if (@mysqli_query($GLOBALS['mysql_con'], $query)) {
|
||||
// Level der ursprünglichen Untermenüpunkte aktualisieren
|
||||
update_learning_children($curr_learning["id"], "+");
|
||||
|
||||
// Sortierung der neuen Nachfolger aktualisieren
|
||||
$new_sorting = $curr_learning["sorting"];
|
||||
$parent_query = ($curr_learning["parent_id"] <> '') ? " parent_id = " . $curr_learning["parent_id"] : " parent_id = 0";
|
||||
$query = "SELECT * FROM learning_category WHERE" . $parent_query . " AND sorting >= " . $new_sorting . " AND main_site_id = " . $GLOBALS["site"]["id"] . " AND main_language_id = " . $GLOBALS["language"]["id"];
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) > 0) {
|
||||
while ($learning = @mysqli_fetch_array($result)) {
|
||||
$query = "UPDATE learning_category SET sorting = " . $new_sorting . " WHERE id = " . $learning["id"] . " LIMIT 1";
|
||||
$new_sorting++;
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function update_learning_children( $learning_id, $way ) {
|
||||
$query = "SELECT * FROM learning_category WHERE parent_id = '" . $learning_id."'";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) > 0) {
|
||||
while ($learning = @mysqli_fetch_array($result)) {
|
||||
$query = "UPDATE learning_category SET level = level " . $way . " 1 WHERE id = " . $learning["id"] . " LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
update_learning_children($learning["id"], $way);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveImage($filekey = 'input_image', $input_id) {
|
||||
delete_image();
|
||||
|
||||
$erlaubte_endungen = array("jpg", "jpeg", "gif", "png", "svg", "webp");
|
||||
$filename = strtolower($_FILES[$filekey]['name']);
|
||||
$filename_expl = explode(".", $filename);
|
||||
if (!in_array($filename_expl[count($filename_expl) - 1], $erlaubte_endungen)) {
|
||||
$messages = "<div class='errorbox'>" . $translation->get("error_slideshow_line2") . "</div>\n";
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
$saveFilename = $input_id . "_" . time() . "_" . cleanFilename($_FILES[$filekey]['name']);
|
||||
define("PATH_NAVIGATON", "../../userdata/learning/");
|
||||
move_uploaded_file($_FILES[$filekey]['tmp_name'], PATH_NAVIGATON . $saveFilename);
|
||||
|
||||
return $saveFilename;
|
||||
|
||||
}
|
||||
function delete_image() {
|
||||
$learning_id = $_POST['input_learning_id'];
|
||||
$query = "SELECT * FROM learning_category WHERE id =".$learning_id." LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$learning = @mysqli_fetch_array($result);
|
||||
if(!empty($learning)){
|
||||
$filename = $learning['image'];
|
||||
define("PATH_NAVIGATON", "../../userdata/learning/");
|
||||
|
||||
if (file_exists(PATH_NAVIGATON . $filename)) {
|
||||
unlink(PATH_NAVIGATON . $filename);
|
||||
}
|
||||
$query = "UPDATE learning_category SET
|
||||
image = ''
|
||||
WHERE id = '" . $learning_id . "' LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
|
||||
function create_mandant_select($category_id){
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$query = "SELECT * FROM main_mandant";
|
||||
$mandant_result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
$preselect = array();
|
||||
|
||||
$query = "SELECT * FROM learning_category_mandant_link WHERE learning_category_id = ".$category_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
while($row = @mysqli_fetch_array($result)){
|
||||
array_push($preselect,$row['main_mandant_id']);
|
||||
}
|
||||
$allselect = array();
|
||||
?>
|
||||
<div class="label"><?php echo $translation->get("mandant")?></div>
|
||||
<div class="mandant bc-select-ui ui fluid multiple search selection dropdown" style="clear:both;display:inline-block;">
|
||||
<input type="hidden" name="select_mandant">
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text"><?php echo $translation->get("mandant")?></div>
|
||||
<div class="menu">
|
||||
<?
|
||||
while($mandant = @mysqli_fetch_array($mandant_result)) {
|
||||
array_push($allselect,$mandant['id']);
|
||||
echo "<div class=\"item\" data-value=\"{$mandant['id']}\">".$mandant["description"]."</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='all_mandants' ><?php echo $translation->get("all_mandants")?></div>
|
||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
|
||||
<script>
|
||||
var $y = jQuery.noConflict();
|
||||
|
||||
$y( document ).ready(function() {
|
||||
$y('.mandant.ui.fluid.multiple.dropdown').dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
});
|
||||
|
||||
$(".all_mandants").click(function() {
|
||||
$y('.mandant.ui.fluid.multiple.dropdown').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||
});
|
||||
|
||||
</script>
|
||||
<?
|
||||
}
|
||||
66
module/learning/learning_cardform.inc.php
Normal file
66
module/learning/learning_cardform.inc.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?
|
||||
$formname = "form_learning_card";
|
||||
$main_layout_id = $GLOBALS["language"]["main_layout_id"];
|
||||
$learning_id = $input_learning["id"];
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
?>
|
||||
|
||||
<div id="overlaycrumb">
|
||||
<?php if ($input_learning["id"] == "") {
|
||||
echo $translation->get("new_menuitem_headline");
|
||||
} else {
|
||||
echo $translation->get("edit_menuitem");
|
||||
}
|
||||
?>
|
||||
<div id="closeoverlay" onclick="disableOverlay();"></div>
|
||||
</div>
|
||||
|
||||
<ul class="toolbar_menu">
|
||||
<?= button("save", $translation->get("save"), $formname, "loadCard('save_learning', true)"); ?>
|
||||
<?= button("save", $translation->get("save_and_close"), $formname, "loadCard('save_learning', true, '', true)"); ?>
|
||||
<li>
|
||||
<ul>
|
||||
<?= button("delete", $translation->get("delete"), $formname, "loadCard('delete_learning', true, '{$translation->get('delete_navitem_confirm')}', true)", "", FALSE); ?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<?php
|
||||
if ($messages !== null) {
|
||||
if (count($messages)) {
|
||||
echo '<div id="overlayMessages">' . join("\r\n", $messages) . '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
|
||||
<input name="input_learning_id" type="hidden" value="<?= $input_learning["id"] ?>">
|
||||
<input name="input_main_layout_id" type="hidden" value="<?= $main_layout_id ?>">
|
||||
|
||||
<table class="cardform" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class="w-100">
|
||||
<? input($translation->get("name"), "input_description", "text", $input_learning["description"], 100) ?>
|
||||
<? input($translation->get("tags"), "input_tags", "text", $input_learning["tags"], 100) ?>
|
||||
<? input($translation->get("image"), "input_image", "file", $input_learning["image"], 45, $disabled);
|
||||
$valFile = '';
|
||||
if($input_learning['image'] != '' && $input_learning['image'] != NULL){
|
||||
$valFile = $input_learning['image'];
|
||||
}
|
||||
?>
|
||||
<input type="hidden" name="input_image_old" value="<?=$valFile;?>">
|
||||
<?php
|
||||
if($input_learning["image"] != NULL && $input_learning["image"] != ''){
|
||||
echo "<div class='img_container learning_image'><img class='img-fluid' src='/userdata/learning/".$input_learning["image"]."'></div>";
|
||||
echo button("delete", $translation->get("delete_image"), $formname, "loadCard('delete_image', true, '{$translation->get('delete_image')}', false)", "", FALSE);
|
||||
}
|
||||
?>
|
||||
<div class="learning_active">
|
||||
<? input($translation->get("active"), "input_active", "checkbox", $input_learning["active"]) ?>
|
||||
</div>
|
||||
<?= create_mandant_select($input_learning['id']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
62
module/learning/learning_contact_listform.inc.php
Normal file
62
module/learning/learning_contact_listform.inc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$formname = "form_contact_list";
|
||||
$inputname = "input_id";
|
||||
$input_page_id = (isset($_REQUEST["input_page_id"]) ? $_REQUEST["input_page_id"] : "");
|
||||
$input_component_id = (isset($_REQUEST["input_component_id"]) ? $_REQUEST["input_component_id"] : "");
|
||||
|
||||
function load_contact_list($input_id){
|
||||
$query = "SELECT * FROM main_contact WHERE active = 1 ORDER BY name ASC";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
while($row = @mysqli_fetch_array($result)) {
|
||||
$query2 = "SELECT * FROM learning_unit_submit WHERE learning_unit_id = '".$input_id."' AND main_contact_id = ".$row['id']." ORDER BY id DESC LIMIT 1";
|
||||
$result2 = @mysqli_query($GLOBALS['mysql_con'], $query2);
|
||||
$row2 = @mysqli_fetch_array($result2);
|
||||
|
||||
$query_mandant = "SELECT * FROM main_mandant WHERE id = ".$row['master_mandant_id'];
|
||||
$result_mandant = @mysqli_query($GLOBALS['mysql_con'], $query_mandant);
|
||||
$row_mandant = @mysqli_fetch_array($result_mandant);
|
||||
|
||||
$query_active = "SELECT * FROM learning_unit_contact WHERE learning_unit_id= '".$input_id."' AND main_contact_id = ".$row['id'];
|
||||
$result_active = @mysqli_query($GLOBALS['mysql_con'], $query_active);
|
||||
$row_active = @mysqli_fetch_array($result_active);
|
||||
|
||||
$datetime = "";
|
||||
if($row2['datetime']){
|
||||
$datetime = new DateTime($row2['datetime']);
|
||||
$datetime = $datetime->format('d.m.Y');
|
||||
}
|
||||
$done = "";
|
||||
$active = "";
|
||||
$class = "";
|
||||
if(isset($row_active) && $row_active['active'] == 1){
|
||||
$active = "checked='checked'";
|
||||
}
|
||||
if($row2['correct'] == 1){
|
||||
$done = "checked='checked'";
|
||||
$class = "checked";
|
||||
}
|
||||
?>
|
||||
<tr class='<?= $class ?>'>
|
||||
<input type='hidden' name='contact_<?= $row['id']?>'>
|
||||
<td><input type='checkbox' class='checkbox' name='done_<?= $row['id']?>' <?= $done?>></td>
|
||||
<td><?= $row['name'] ?></td>
|
||||
<td><?= $row_mandant['description'] ?></td>
|
||||
<td><?= $datetime?></td>
|
||||
<td><input type='checkbox' class='checkbox' name='active_<?= $row['id']?>' <?= $active?>></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h2>Benutzerliste</h2>
|
||||
<table class='learning_unit_user_list'>
|
||||
<tr>
|
||||
<th>Erledigt</th>
|
||||
<th>Benutzer</th>
|
||||
<th>Mandant</th>
|
||||
<th>Ausstellungsdatum</th>
|
||||
<th>Aktiv</th>
|
||||
</tr>
|
||||
<?= load_contact_list($input_id);?>
|
||||
</table>
|
||||
100
module/learning/learning_listform.inc.php
Normal file
100
module/learning/learning_listform.inc.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$formname = "form_learning_list";
|
||||
?>
|
||||
|
||||
<ul class="toolbar_menu">
|
||||
<?= button("new", $translation->get("new"), $formname, "loadCard('new_learning', true)"); ?>
|
||||
</ul>
|
||||
|
||||
<div id="mainContent">
|
||||
<?php echo current_website_language($site, $language); ?>
|
||||
<h1><?php echo get_translation('learning_category'); ?></h1>
|
||||
|
||||
<form id="<?php echo $formname; ?>" name="<?php echo $formname; ?>" method="post">
|
||||
<div class="requestLoader"></div>
|
||||
<input type="hidden" class="selected_linklist_row" name="input_learning_id" value="" />
|
||||
<div class="requestLoader"></div>
|
||||
<div id="page_linklist" class="learning_list_view">
|
||||
<?
|
||||
show_learning($site, $language);
|
||||
?>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var reorderCall = null;
|
||||
var dragEnabled = false;
|
||||
|
||||
function toggleDragDrop( _aTag ) {
|
||||
if (dragEnabled === false) {
|
||||
dragEnabled = true;
|
||||
$('ol.sortable').addClass("enabled");
|
||||
$('ol.sortable').nestedSortable("option", "disabled", false);
|
||||
$(_aTag).html("<?php echo $translation->get('disable_drag_drop'); ?>");
|
||||
} else {
|
||||
dragEnabled = false;
|
||||
$('ol.sortable').removeClass("enabled");
|
||||
$('ol.sortable').nestedSortable("option", "disabled", true);
|
||||
$(_aTag).html("<?php echo $translation->get('enable_drag_drop'); ?>");
|
||||
}
|
||||
}
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle : '.dd-icon',
|
||||
helper : 'clone',
|
||||
items : 'li',
|
||||
opacity : .6,
|
||||
placeholder : 'placeholder',
|
||||
revert : 250,
|
||||
tabSize : 25,
|
||||
tolerance : 'pointer',
|
||||
toleranceElement : '> div',
|
||||
maxLevels : 5,
|
||||
isTree : true,
|
||||
expandOnHover : 1000,
|
||||
cookieIndex : 'nestedSortable_expanded2',
|
||||
startCollapsed : true,
|
||||
stop : function ( event, ui ) {
|
||||
reorder_learning();
|
||||
store_expanded();
|
||||
},
|
||||
disabled : false
|
||||
});
|
||||
|
||||
$('.disclose').click(function () {
|
||||
$(this).closest('li').toggleClass('mjs-nestedSortable-collapsed').toggleClass('mjs-nestedSortable-expanded');
|
||||
store_expanded();
|
||||
});
|
||||
|
||||
function store_expanded() {
|
||||
var list = [];
|
||||
$('ol.sortable').find('li.mjs-nestedSortable-expanded').each(function () {
|
||||
list.push($(this).attr("id"));
|
||||
});
|
||||
$.cookie('nestedSortable_expanded2', list.join(','));
|
||||
}
|
||||
|
||||
function reorder_learning() {
|
||||
if (reorderCall !== null) {
|
||||
reorderCall.abort();
|
||||
}
|
||||
|
||||
serialized = $('ol.sortable').nestedSortable('serialize');
|
||||
arraied = $('ol.sortable').nestedSortable('toHierarchy', {startDepthCount: 0});
|
||||
var parameter = {
|
||||
list: arraied
|
||||
};
|
||||
reorderCall = jQuery.post("?action=reorder_learning", parameter, function ( output, status, xhr ) {
|
||||
if (xhr.getResponseHeader('REQUIRES_AUTH') == 1) {
|
||||
window.location.replace("/mysyde/");
|
||||
} else {
|
||||
console.log(output);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
410
module/learning/learning_unit.inc.php
Normal file
410
module/learning/learning_unit.inc.php
Normal file
@@ -0,0 +1,410 @@
|
||||
<?
|
||||
switch ($_GET["action"]) {
|
||||
case 'edit':
|
||||
edit_unit();
|
||||
break;
|
||||
case 'delete':
|
||||
delete_unit($unit['id']);
|
||||
break;
|
||||
case 'new':
|
||||
require_once("learning_unit_cardform.inc.php");
|
||||
break;
|
||||
case 'save':
|
||||
save_unit();
|
||||
break;
|
||||
case 'save_line_unit':
|
||||
save_line_unit();
|
||||
break;
|
||||
case 'new_line_unit':
|
||||
require_once("learning_unit_line_cardform.inc.php");
|
||||
break;
|
||||
case 'edit_line_unit':
|
||||
edit_line_unit();
|
||||
break;
|
||||
case 'delete_line_unit':
|
||||
delete_line_unit();
|
||||
break;
|
||||
case 'moveup_line_unit':
|
||||
moveup_line_unit();
|
||||
edit_unit();
|
||||
break;
|
||||
case 'movedown_line_unit':
|
||||
movedown_line_unit();
|
||||
edit_unit();
|
||||
break;
|
||||
case 'open_card':
|
||||
open_card();
|
||||
default:
|
||||
require_once("learning_unit_listform.inc.php");
|
||||
break;
|
||||
}
|
||||
|
||||
function open_card() {?>
|
||||
<script type="text/javascript">
|
||||
openCardOnStart = true;
|
||||
openCardAction = 'new';
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
function edit_unit( $_id = "", $messages = array() ) {
|
||||
if ((int)$_id > 0) {
|
||||
$input_id = $_id;
|
||||
} else {
|
||||
$input_id = $_POST["input_id"];
|
||||
}
|
||||
|
||||
if ($input_id <> '') {
|
||||
|
||||
$pdoHost = getenv('MAIN_MYSQL_DB_HOST');
|
||||
$pdoPort = getenv('MAIN_MYSQL_DB_PORT');
|
||||
$pdoUser = getenv('MAIN_MYSQL_DB_USER');
|
||||
$pdoPass = getenv('MAIN_MYSQL_DB_PASS');
|
||||
$pdoSchema = getenv('MAIN_MYSQL_DB_SCHEMA');
|
||||
|
||||
$pdo = new \DynCom\mysyde\common\classes\PDOQueryWrapper($pdoHost, $pdoPort, $pdoSchema, $pdoUser, $pdoPass);
|
||||
|
||||
$prepStatement = " SELECT * FROM learning_unit WHERE id = :id LIMIT 1 ";
|
||||
$params = [
|
||||
[':id', $input_id, PDO::PARAM_STR],
|
||||
];
|
||||
$pdo->setQuery($prepStatement);
|
||||
$pdo->prepareQuery();
|
||||
$pdo->bindParameters($params);
|
||||
$pdo->executePreparedStatement();
|
||||
$result = $pdo->getResultArray();
|
||||
|
||||
if (count($result) == 1) {
|
||||
$input_unit = $result[0];
|
||||
require_once("learning_unit_cardform.inc.php");
|
||||
}
|
||||
} else {
|
||||
$input_unit = array();
|
||||
require_once("learning_unit_cardform.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
function delete_unit($curr_unit_id) {
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
if ($_POST["input_id"] <> '') {
|
||||
if ($_POST["input_id"] <> $curr_unit_id) {
|
||||
$query = "DELETE FROM learning_unit WHERE id = '" . $_POST["input_id"] . "' LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
} else {
|
||||
header('EDIT_ERROR: 1');
|
||||
$messages[] = "<div class=\"errorbox\">" . $translation->get("unit_error5") . "</div>";
|
||||
edit_unit($_POST["input_id"], $messages);
|
||||
}
|
||||
}
|
||||
require_once("learning_unit_listform.inc.php");
|
||||
}
|
||||
|
||||
function save_unit() {
|
||||
$messages = array();
|
||||
$error = FALSE;
|
||||
$input_id = "";
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
|
||||
if ($_POST["input_id"] <> '') {
|
||||
$inserted = FALSE;
|
||||
$input_id = $_POST["input_id"];
|
||||
$query = "UPDATE learning_unit
|
||||
SET title = '" . $_POST['input_title'] . "',
|
||||
description = '" . $_POST['input_description'] . "',
|
||||
link = '" . $_POST['input_link'] . "'
|
||||
WHERE id = '" . $_POST["input_id"] . "' LIMIT 1";
|
||||
} else {
|
||||
$query = "INSERT INTO learning_unit (id, title, description, link) VALUES (
|
||||
NULL,
|
||||
'" . $_POST['input_title'] . "',
|
||||
'" . $_POST['input_description'] . "',
|
||||
'" . $_POST['input_link'] . "'
|
||||
)";
|
||||
$inserted = TRUE;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if ($inserted == TRUE) {
|
||||
$input_id = mysqli_insert_id($GLOBALS['mysql_con']);
|
||||
$messages[] = '<div class="successbox">' . $translation->get("unit_msg_success1") . '</div>';
|
||||
} else {
|
||||
$messages[] = '<div class="successbox">' . $translation->get("unit_msg_success2") . '</div>';
|
||||
}
|
||||
save_mandant_link($input_id);
|
||||
save_category_link($input_id);
|
||||
save_unit_contact_list($input_id);
|
||||
edit_unit($input_id, $messages);
|
||||
} else {
|
||||
header('EDIT_ERROR: 1');
|
||||
$input_unit["id"] = $_POST["input_id"];
|
||||
$input_unit["name"] = $_POST["input_name"];
|
||||
$input_unit["email"] = $_POST["input_email"];
|
||||
$input_unit["login"] = $_POST["input_login"];
|
||||
require_once("learning_unit_cardform.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
function save_unit_contact_list($unit_id){
|
||||
$datetime = new DateTime();
|
||||
$query = "SELECT * FROM main_contact WHERE active = 1 ORDER BY name ASC";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
while($row = @mysqli_fetch_array($result)) {
|
||||
$done = ($_POST["done_".$row['id']] == "on") ? 1 : 0;
|
||||
$active = ($_POST["active_".$row['id']] == "on") ? 1 : 0;
|
||||
$deleteActive = @mysqli_query($GLOBALS["mysql_con"], "DELETE FROM learning_unit_contact WHERE learning_unit_id=".$unit_id." AND main_contact_id = ".$row['id']);
|
||||
if($active == 1){
|
||||
$query_active = "INSERT INTO learning_unit_contact (learning_unit_id, main_contact_id, active)
|
||||
VALUES (
|
||||
'".$unit_id."',
|
||||
'".$row['id']."',
|
||||
'".$active."'
|
||||
)";
|
||||
$result_active = @mysqli_query($GLOBALS['mysql_con'], $query_active);
|
||||
}
|
||||
|
||||
$query2 = "SELECT * FROM learning_unit_submit WHERE learning_unit_id = ".$unit_id." AND main_contact_id = ".$row['id']. " ORDER BY id DESC LIMIT 1";
|
||||
$result2 = @mysqli_query($GLOBALS['mysql_con'], $query2);
|
||||
$row2 = @mysqli_fetch_array($result2);
|
||||
$query3 = "";
|
||||
if($row2 != NULL){
|
||||
if($row2['correct'] != $done){
|
||||
$query3 = "UPDATE learning_unit_submit SET correct = ".$done.", datetime = '".$datetime->format('Y-m-d H:i:s')."' WHERE id = ".$row2['id'];
|
||||
}
|
||||
}else{
|
||||
if($done == 1){
|
||||
$query3 = "INSERT INTO learning_unit_submit (learning_unit_id, main_contact_id, datetime, correct)
|
||||
VALUES (
|
||||
'".$unit_id."',
|
||||
'".$row['id']."',
|
||||
'".$datetime->format('Y-m-d H:i:s')."',
|
||||
'".$done."'
|
||||
)";
|
||||
}
|
||||
}
|
||||
$result3 = @mysqli_query($GLOBALS['mysql_con'], $query3);
|
||||
}
|
||||
}
|
||||
|
||||
function save_mandant_link($unit_id){
|
||||
$deleteLink = @mysqli_query($GLOBALS["mysql_con"], "DELETE FROM learning_unit_mandant_link WHERE learning_unit_id=".$unit_id);
|
||||
|
||||
$mandant_id = $_POST['select_mandant'];
|
||||
$mandante = explode(',', $mandant_id);
|
||||
if(!empty($mandant_id) && gettype($mandante) == 'array') {
|
||||
foreach($mandante as $key => $mandant){
|
||||
$query = "INSERT INTO learning_unit_mandant_link
|
||||
(learning_unit_id, main_mandant_id)
|
||||
VALUES (
|
||||
" . $unit_id . ",
|
||||
'" . $mandant . "'
|
||||
)";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function save_category_link($unit_id){
|
||||
$deleteLink = @mysqli_query($GLOBALS["mysql_con"], "DELETE FROM learning_unit_link WHERE learning_unit_id=".$unit_id);
|
||||
|
||||
$ids = $_POST['select_category'];
|
||||
$categories = explode(',', $ids);
|
||||
if(!empty($categories) && gettype($categories) == 'array') {
|
||||
foreach($categories as $key => $category){
|
||||
$query = "INSERT INTO learning_unit_link
|
||||
(learning_unit_id, learning_category_id)
|
||||
VALUES (
|
||||
" . $unit_id . ",
|
||||
'" . $category . "'
|
||||
)";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function create_mandant_select($unit_id){
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
|
||||
$query = "SELECT * FROM main_mandant";
|
||||
$result_mandant = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
if (@mysqli_num_rows($result_mandant) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$preselect = array();
|
||||
|
||||
$query = "SELECT * FROM learning_unit_mandant_link WHERE learning_unit_id = ".$unit_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
while($row = @mysqli_fetch_array($result)){
|
||||
array_push($preselect,$row['main_mandant_id']);
|
||||
}
|
||||
$allselect = array();
|
||||
?>
|
||||
<div class="websites bc-select-ui ui fluid multiple search selection dropdown" style="clear:both;display:inline-block;">
|
||||
<input type="hidden" name="select_mandant">
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text"><?php echo $translation->get("top_mandant")?></div>
|
||||
<div class="menu">
|
||||
<?
|
||||
while($mandant = @mysqli_fetch_array($result_mandant)) {
|
||||
array_push($allselect,$mandant['id']);
|
||||
echo "<div class=\"item\" data-value=\"{$mandant['id']}\">".$mandant["description"]."</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='all_mandate' ><?php echo $translation->get("all_mandate")?></div>
|
||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
|
||||
<script>
|
||||
var $y = jQuery.noConflict();
|
||||
$y( document ).ready(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown').dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
});
|
||||
$(".all_mandate").click(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function create_category_select($unit_id){
|
||||
$query = "SELECT * FROM learning_category";
|
||||
$unit_result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
if (@mysqli_num_rows($unit_result) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$preselect = array();
|
||||
|
||||
$query = "SELECT * FROM learning_unit_link WHERE learning_unit_id = ".$unit_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
while($row = @mysqli_fetch_array($result)){
|
||||
array_push($preselect,$row['learning_category_id']);
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="label">Kategorie auswählen</div>
|
||||
<div class="unit bc-select-ui ui fluid multiple search selection dropdown" style="clear:both;display:inline-block;">
|
||||
<input type="hidden" name="select_category">
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Kategorie auswählen</div>
|
||||
<div class="menu">
|
||||
<?
|
||||
while($unit_category = @mysqli_fetch_array($unit_result)) {
|
||||
echo "<div class=\"item\" data-value=\"{$unit_category['id']}\">".$unit_category["description"]."</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
|
||||
<script>
|
||||
var $y = jQuery.noConflict();
|
||||
$y( document ).ready(function() {
|
||||
$y('.unit.ui.fluid.multiple.dropdown').dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
});
|
||||
</script>
|
||||
<?
|
||||
}
|
||||
|
||||
function delete_line_unit() {
|
||||
if ($_REQUEST["input_line_id"] <> '') {
|
||||
$query = "DELETE FROM learning_unit_question WHERE id = '" . $_REQUEST["input_line_id"] . "' LIMIT 1";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$queryDelete = "DELETE FROM learning_unit_answer WHERE question_id = '" .$_REQUEST["input_line_id"]."'";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $queryDelete);
|
||||
}
|
||||
edit_unit();
|
||||
}
|
||||
|
||||
function edit_line_unit( $_id = "" ) {
|
||||
if ((int)$_id > 0) {
|
||||
$line_id = $_id;
|
||||
} else {
|
||||
$line_id = $_REQUEST["input_line_id"];
|
||||
}
|
||||
|
||||
if ($line_id <> '') {
|
||||
$query = "SELECT * FROM learning_unit_question WHERE id = '" . $line_id . "' LIMIT 1";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 1) {
|
||||
$input_line = @mysqli_fetch_array($result);
|
||||
}
|
||||
}
|
||||
require_once("learning_unit_line_cardform.inc.php");
|
||||
}
|
||||
|
||||
function save_line_unit() {
|
||||
if ($_POST["input_line_id"] <> '') {
|
||||
$inserted = FALSE;
|
||||
$input_line_id = $_POST["input_line_id"];
|
||||
$query = "UPDATE learning_unit_question
|
||||
SET learning_unit_id = '" . $_POST['input_id'] . "',
|
||||
description = '" . $_POST['input_description'] . "',
|
||||
image = '" . $_POST['input_image'] . "',
|
||||
question_type = '" . $_POST['input_question_type'] . "'
|
||||
WHERE id = '" . $input_line_id . "' LIMIT 1";
|
||||
} else {
|
||||
$query = "INSERT INTO learning_unit_question (id, learning_unit_id, description, image, question_type) VALUES (
|
||||
NULL,
|
||||
'" . $_POST['input_id'] . "',
|
||||
'" . $_POST['input_description'] . "',
|
||||
'" . $_POST['input_image'] . "',
|
||||
'" . $_POST['input_question_type'] . "'
|
||||
)";
|
||||
$inserted = TRUE;
|
||||
}
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if ($inserted == TRUE) {
|
||||
$input_line_id = mysqli_insert_id($GLOBALS['mysql_con']);
|
||||
}
|
||||
|
||||
$deleteLink = @mysqli_query($GLOBALS["mysql_con"], "DELETE FROM learning_unit_answer WHERE question_id=".$input_line_id);
|
||||
|
||||
$num_inputs = 0;
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (strpos($key, 'input_answer_') === 0) {
|
||||
$num_inputs++;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $num_inputs; $i++) {
|
||||
$input_correct = ($_POST["input_correct_".$i] == "on") ? 1 : 0;
|
||||
|
||||
$query = "INSERT INTO learning_unit_answer (id, question_id, description, correct) VALUES (
|
||||
NULL,
|
||||
'" . $input_line_id . "',
|
||||
'" . $_POST['input_answer_'.$i] . "',
|
||||
'" . $input_correct . "'
|
||||
)";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
|
||||
edit_unit();
|
||||
}
|
||||
|
||||
function unit_answers($question_id){
|
||||
$query = "SELECT * FROM learning_unit_answer WHERE question_id = ".$question_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$i = 1;
|
||||
while($answer = @mysqli_fetch_array($result)) {
|
||||
$correct = ($answer['correct'] == "1") ? 'checked="checked"' : '';
|
||||
?>
|
||||
<div class='answer_wrapper' data-id='<?= $i?>'>
|
||||
<label for='input_answer_"+count+"'><?= $i?>.</label>
|
||||
<input type='text' class='text' name='input_answer_<?= $i?>' id='input_answer_<?= $i?>' value='<?= $answer['description']?>'>
|
||||
<input type='checkbox' class='checkbox' name='input_correct_<?= $i?>' name='input_correct_<?= $i?>' <?= $correct?>>
|
||||
<div class='delete_answer'>X</div>
|
||||
</div>
|
||||
<?php
|
||||
$i++;
|
||||
}
|
||||
return $i;
|
||||
}
|
||||
109
module/learning/learning_unit_cardform.inc.php
Normal file
109
module/learning/learning_unit_cardform.inc.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
$formname = "form_unit_card";
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$inputname = "input_id";
|
||||
?>
|
||||
|
||||
<div id="overlaycrumb">
|
||||
<?php if ($input_unit["id"] == "") {
|
||||
echo $translation->get("new_unit");
|
||||
} else {
|
||||
echo $translation->get("edit_unit");
|
||||
}
|
||||
?>
|
||||
<div id="closeoverlay" onclick="disableOverlay();"></div>
|
||||
</div>
|
||||
<ul class="toolbar_menu">
|
||||
<?= button("save", $translation->get("save"), $formname, "loadCard('save', true)"); ?>
|
||||
<?= button("save", $translation->get("save_and_close"), $formname, "loadCard('save', true, '', true)"); ?>
|
||||
<li>
|
||||
<ul>
|
||||
<?= button("delete", $translation->get("delete"), $formname, "loadCard('delete', true, '{$translation->get('delete_user_confirm')}', true)", "", FALSE); ?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if ($messages !== null) {
|
||||
if (count($messages)) {
|
||||
echo '<div id="overlayMessages">' . join("\r\n", $messages) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
|
||||
<input name="input_id" type="hidden" value="<?= $input_unit["id"] ?>">
|
||||
<input name="input_line_id" type="hidden" value="<?= $input_unit["id"] ?>" />
|
||||
<table class="cardform" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr class="certificate_table_row">
|
||||
<td class="w-100">
|
||||
<? input($translation->get("title"), "input_title", "text", $input_unit["title"], 255) ?>
|
||||
<? input($translation->get("description"), "input_description", "textarea", $input_unit["description"]) ?>
|
||||
<div class="iframe_input">
|
||||
<div class="label pfusch">iFrame Link</div>
|
||||
<div class="input_note">
|
||||
<?= $translation->get("iframe_note") ?> <a href="https://support.microsoft.com/de-de/office/einbetten-von-dateien-direkt-in-ihre-website-oder-einen-blog-ed07dd52-8bdb-431d-96a5-cbe8a80b7418">Link</a>
|
||||
</div>
|
||||
<? input($translation->get("link"), "input_link", "textarea", $input_unit["link"]) ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-100">
|
||||
<div class="basic_settings">
|
||||
<div class="toggle_headline opened">
|
||||
<h3><?= $translation->get("basic_settings") ?></h3>
|
||||
<div class="chevron"></div>
|
||||
</div>
|
||||
<div class="toggle_area">
|
||||
<div class="basic_setting_inputs">
|
||||
<div class="choose_mandants">
|
||||
<div class="label"><?= $translation->get("choose_mandants") ?></div>
|
||||
<?php
|
||||
create_mandant_select($input_unit['id']);
|
||||
?>
|
||||
</div>
|
||||
<div class="choose_category">
|
||||
<?php
|
||||
create_category_select($input_unit['id']);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php
|
||||
if ($input_unit['id'] != "") {
|
||||
require_once 'learning_contact_listform.inc.php';
|
||||
} ?>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#input_recurring').change(function(){
|
||||
if(this.checked){
|
||||
$('.recurring_select').show();
|
||||
}
|
||||
else{
|
||||
$('.recurring_select').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$(".toggle_headline").click(function() {
|
||||
$(this).next().slideToggle();
|
||||
$(this).toggleClass("opened");
|
||||
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<?
|
||||
if ($input_unit['id'] != "") {
|
||||
require_once 'learning_unit_line_listform.inc.php';
|
||||
}
|
||||
84
module/learning/learning_unit_line_cardform.inc.php
Normal file
84
module/learning/learning_unit_line_cardform.inc.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?
|
||||
$formname = "form_line_card";
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$inputname = "input_id";
|
||||
|
||||
?>
|
||||
|
||||
<div id="overlaycrumb">
|
||||
<?php if ($input_line["id"] == "") {
|
||||
echo $translation->get("create_question");
|
||||
} else {
|
||||
echo $translation->get("edit_question");
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<ul class="toolbar_menu">
|
||||
<?php
|
||||
// Zurueck zur uebersicht
|
||||
button("left", $translation->get("back"), $formname, "loadCard('edit', true)");
|
||||
|
||||
// Speichern buttons
|
||||
button("save", $translation->get("save_and_close"), $formname, "jQuery('#save_and_close', jQuery('#" . $formname . "')).val(1);loadCard('save_line_unit', true)");
|
||||
|
||||
if ($input_line["id"] != "") {
|
||||
echo button("delete", $translation->get("delete"), $formname, "loadCard('delete_line_unit', true, '{$translation->get('delete_line_confirm')}')");
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if ($messages !== null) {
|
||||
if (count($messages)) {
|
||||
echo '<div id="overlayMessages">' . join("\r\n", $messages) . '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
|
||||
<input name="input_line_id" type="hidden" value="<?= $input_line["id"] ?>" />
|
||||
<input name="input_id" type="hidden" value="<?= $_REQUEST['input_id'] ?>">
|
||||
<input name="save_and_close" id="save_and_close" type="hidden" value="0" />
|
||||
|
||||
<table class="cardform" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class="w-100">
|
||||
<?php
|
||||
$types = [
|
||||
'0' => "Multiple-Choice",
|
||||
];
|
||||
$preselect = 0;
|
||||
if(isset($input_question['question_type']) ){
|
||||
$preselect = $input_line['question_type'];
|
||||
}
|
||||
?>
|
||||
<?php input_select($translation->get("question_type"), "input_question_type", $values = array_keys($types), $value_names = array_values($types), $preselect, FALSE, FALSE); ?>
|
||||
<? input($translation->get("question"), "input_description", "text", $input_line["description"], 255) ?>
|
||||
<? //input($translation->get("image"), "input_image", "text", $input_line["image"], 255) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class='unit_answers'>
|
||||
<?php
|
||||
$count_answers = unit_answers($input_line['id']);
|
||||
?>
|
||||
</div>
|
||||
<div class="new_answer_button">
|
||||
<?= button("new_answer", $translation->get("new_answer"), $formname, "create_answer()");?>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
count = <?= $count_answers ?>;
|
||||
function create_answer(){
|
||||
var svg = "<div class='delete_answer'>X</div>";
|
||||
var newInput = $("<div class='answer_wrapper' data-id='"+count+"'><label for='input_answer_"+count+"'>"+count+".</label><input type='text' class='text' name='input_answer_"+count+"' id='input_answer_"+count+"'><input type='checkbox' class='checkbox' name='input_correct_"+count+"' name='input_correct_"+count+"'>"+svg+"</div>");
|
||||
$('.unit_answers').append(newInput);
|
||||
count++;
|
||||
}
|
||||
$(".delete_answer").click(function(){
|
||||
$(this).parent().remove();
|
||||
count--;
|
||||
});
|
||||
</script>
|
||||
33
module/learning/learning_unit_line_listform.inc.php
Normal file
33
module/learning/learning_unit_line_listform.inc.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$formname = "form_line_list";
|
||||
$inputname = "input_id";
|
||||
$input_page_id = (isset($_REQUEST["input_page_id"]) ? $_REQUEST["input_page_id"] : "");
|
||||
?>
|
||||
|
||||
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
|
||||
<input name="input_id" type="hidden" value="<?= $input_id ?>">
|
||||
<input type="hidden" class="selected_linklist_row" name="input_line_id" value="" />
|
||||
<input type="hidden" name="input_page_id" value="<?php echo $input_page_id; ?>" />
|
||||
|
||||
|
||||
<h2><?php echo $translation->get("questions"); ?></h2>
|
||||
<ul class="toolbar_menu">
|
||||
<?= button("new", $translation->get("new"), $formname, "loadCard('new_line_unit', true)", "", FALSE); ?>
|
||||
<?= button("edit", $translation->get("edit"), $formname, "loadCard('edit_line_unit')", "", FALSE); ?>
|
||||
<?= button("delete", $translation->get("delete"), $formname, "loadCard('delete_line_unit', false, '{$translation->get('delete_unit_field_confirm')}')", "", FALSE); ?>
|
||||
|
||||
<?= button("up", $translation->get("go_up"), $formname, "loadCard('moveup_line_unit')", "", FALSE); ?>
|
||||
<?= button("down", $translation->get("go_down"), $formname, "loadCard('movedown_line_unit')", "", FALSE); ?>
|
||||
|
||||
</ul>
|
||||
|
||||
<?
|
||||
$query = "SELECT id, description AS '" . $translation->get("question") . "', question_type AS '" . $translation->get("question_type") . "' FROM learning_unit_question WHERE learning_unit_id = '" . $input_id . "'";
|
||||
$format = array('option', 'text', 'text', 'text', 'boolean');
|
||||
if ($result = @mysqli_query($GLOBALS['mysql_con'], $query)) {
|
||||
linklist($result, $formname, $format, "input_line_id", "edit_line_unit", TRUE, "update_sortorder_unit", "loadCard('delete_line_unit', false, '{$translation->get('delete_unit_field_confirm')}')", TRUE);
|
||||
}
|
||||
?>
|
||||
|
||||
</form>
|
||||
28
module/learning/learning_unit_listform.inc.php
Normal file
28
module/learning/learning_unit_listform.inc.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
|
||||
$formname = "form_unit_list";
|
||||
$inputname = "input_id";
|
||||
?>
|
||||
<ul class="toolbar_menu">
|
||||
<?= button("new", $translation->get("new"), $formname, "loadCard('new', true)"); ?>
|
||||
</ul>
|
||||
|
||||
<div id="mainContent">
|
||||
|
||||
<?php echo current_website_language($site, $language); ?>
|
||||
<h1><?php echo get_translation('top_unit'); ?></h1>
|
||||
|
||||
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
|
||||
<input type="hidden" class="selected_linklist_row" name="input_id" value="" />
|
||||
|
||||
<div class="requestLoader"></div>
|
||||
<?
|
||||
$query = "SELECT id, title AS '" . $translation->get("name") . "', description AS '" . $translation->get("description") . "', (SELECT COUNT(*) FROM learning_unit_question WHERE learning_unit_id = learning_unit.id) AS " . $translation->get("questions") . " FROM learning_unit";
|
||||
$format = array("option", "text", "text", "text");
|
||||
if ($result = mysqli_query($GLOBALS['mysql_con'], $query)) {
|
||||
linklist($result, "form_unit_list", $format);
|
||||
}
|
||||
?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
141
module/learning/show_learning.inc.php
Normal file
141
module/learning/show_learning.inc.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
try {
|
||||
//code...
|
||||
|
||||
|
||||
|
||||
$category_id = 0;
|
||||
if(isset($_GET['category'])){
|
||||
$category_id = $_GET['category'];
|
||||
}
|
||||
|
||||
if(isset($_GET['collection_id'])){
|
||||
$unit_id = $_GET['collection_id'];
|
||||
require_once("show_unit.inc.php");
|
||||
return;
|
||||
}
|
||||
|
||||
function count_posts($category_id){
|
||||
$value = array();
|
||||
$query = "SELECT * FROM learning_unit_link WHERE learning_category_id = ".$category_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
$count = 0;
|
||||
$read = 0;
|
||||
while($unit = @mysqli_fetch_array($result)) {
|
||||
$query_active = "SELECT * FROM learning_unit_contact WHERE learning_unit_id = ".$unit['learning_unit_id']. " AND main_contact_id = ".$GLOBALS['main_contact']['id']. " AND active = 1";
|
||||
$result_active = @mysqli_query($GLOBALS['mysql_con'], $query_active);
|
||||
if (@mysqli_num_rows($result_active) == 1) {
|
||||
$query2 = "SELECT * FROM learning_unit_submit WHERE learning_unit_id = ".$unit['learning_unit_id']. " AND main_contact_id = ".$GLOBALS['main_contact']['id']. " AND correct = 1";
|
||||
$result2 = @mysqli_query($GLOBALS['mysql_con'], $query2);
|
||||
if (@mysqli_num_rows($result2) == 1) {
|
||||
$read++;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if ($count !== 0) {
|
||||
$percent = ($read / $count) * 100;
|
||||
$percent = round($percent, 2);
|
||||
if($count == 0 && $read == 0){
|
||||
$percent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$value['percent'] = $percent;
|
||||
$value['count'] = $count;
|
||||
return $value;
|
||||
}
|
||||
|
||||
function get_categories($category_id){
|
||||
$if_query = "learning_category_id IS NOT NULL AND main_mandant_id = '".$GLOBALS['main_contact']['current_mandant_id']."'";
|
||||
$query = "SELECT learning_category.* FROM learning_category LEFT JOIN learning_category_mandant_link ON learning_category.id = learning_category_mandant_link.learning_category_id WHERE active = 1 AND parent_id = ".$category_id." AND ((".$if_query.") OR learning_category_id IS NULL) ORDER BY sorting ASC";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 0) {
|
||||
return;
|
||||
}
|
||||
echo "<div class='el_category_list'>";
|
||||
echo "<div class='row'>";
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo "<div class='el_category_line_list'>";
|
||||
while($category = @mysqli_fetch_array($result)) {
|
||||
$count = count_posts($category['id']);
|
||||
?>
|
||||
<a class="el_category_link" href='?category=<?= $category['id']?>'>
|
||||
<div class='el_category'>
|
||||
<img class='el_img' src='/userdata/learning/<?= $category['image']?>'>
|
||||
<div class="el_content">
|
||||
<div class="el_textcontent">
|
||||
<h3 class='el_title'><?= $category['description']?></h3>
|
||||
<p class='el_tags'>Beinhaltet <?= $count['count'] ?> Videos</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="percent">
|
||||
<svg>
|
||||
<circle cx="105" cy="105" r="100"></circle>
|
||||
<circle cx="105" cy="105" r="100" style="--percent: <?= $count['percent']?>"></circle>
|
||||
</svg>
|
||||
<div class="number">
|
||||
<h3><?= $count['percent']?><span>%</span></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<?php }
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
function get_posts($category_id){
|
||||
$if_query = "learning_unit_mandant_link.learning_unit_id IS NOT NULL AND main_mandant_id = ".$GLOBALS['main_contact']['current_mandant_id'];
|
||||
$query = "SELECT learning_unit.* FROM learning_unit LEFT JOIN learning_unit_link ON learning_unit_link.learning_unit_id = learning_unit.id LEFT JOIN learning_unit_mandant_link ON learning_unit.id = learning_unit_mandant_link.learning_unit_id LEFT JOIN learning_unit_contact ON learning_unit_contact.learning_unit_id = learning_unit.id WHERE ((".$if_query.") OR learning_unit_mandant_link.learning_unit_id IS NULL) AND learning_unit_link.learning_category_id = ".$category_id." AND learning_unit_contact.active = 1 AND main_contact_id = ".$GLOBALS['main_contact']['id'];
|
||||
// var_dump($query);
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
if (@mysqli_num_rows($result) == 0) {
|
||||
return;
|
||||
}
|
||||
$query_category = "SELECT * FROM learning_category WHERE id = ".$category_id;
|
||||
$result_category = @mysqli_query($GLOBALS['mysql_con'], $query_category);
|
||||
$category = @mysqli_fetch_array($result_category);
|
||||
echo "<div class='el_category_list'>";
|
||||
echo "<div class='row'>";
|
||||
?>
|
||||
<h3 class='el_current_category'><?= $category['description']?></h3>
|
||||
<?php
|
||||
echo "<div class='el_category_line_list'>";
|
||||
while($post = @mysqli_fetch_array($result)) {
|
||||
$link = get_link_to_navigation(7) . get_collection_rewrite($post['title'], $post['id']);
|
||||
?>
|
||||
<a class="el_post_link" href='<?= $link?>'>
|
||||
<div class='el_post'>
|
||||
<h4 class='el_post_title'><?= $post['title']?></h4>
|
||||
<svg id="chevron-right" xmlns="https://www.w3.org/2000/svg" width="6.442" height="10.736" viewBox="0 0 6.442 10.736">
|
||||
<path id="Pfad_73" data-name="Pfad 73" d="M15.879,8.467l1.073-1.072,5.368,5.367-5.368,5.368-1.073-1.073,4.294-4.295L15.878,8.467Z" transform="translate(-15.878 -7.395)"/>
|
||||
</svg>
|
||||
</div>
|
||||
</a>
|
||||
<?php }
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "<div class='el_group_container'>";
|
||||
if(isset($_GET["category"]) || isset($_GET['search'])) {
|
||||
echo "<div class='el_back_button'>";
|
||||
echo "<button class='back_button' onclick='history.back()'>Zurück</button>";
|
||||
echo "</div>";
|
||||
}
|
||||
if(!isset($_GET['search'])){
|
||||
get_posts($category_id);
|
||||
get_categories($category_id);
|
||||
}
|
||||
echo "</div>";
|
||||
} catch (\Throwable $th) {
|
||||
echo $th;
|
||||
}
|
||||
243
module/learning/show_unit.inc.php
Normal file
243
module/learning/show_unit.inc.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
if(isset($_POST['input_submit'])){
|
||||
$query = "SELECT learning_unit_answer.* FROM learning_unit_answer LEFT JOIN learning_unit_question ON learning_unit_question.id = learning_unit_answer.question_id WHERE learning_unit_id = ".$unit_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$correct_answers = 0;
|
||||
while($answers = @mysqli_fetch_array($result)){
|
||||
$answer_post = ($_POST['input_answer_'.$answers['id']] == "on") ? 1 : 0;
|
||||
if($answers['correct'] == $answer_post){
|
||||
$correct_answers++;
|
||||
}
|
||||
}
|
||||
$datetime = new DateTime();
|
||||
|
||||
if (@mysqli_num_rows($result) == $correct_answers) {
|
||||
$query_select = "SELECT * FROM main_certificate WHERE learning_unit_id = ".$unit_id;
|
||||
$result_select = @mysqli_query($GLOBALS['mysql_con'], $query_select);
|
||||
if (@mysqli_num_rows($result_select) >= 1) {
|
||||
$row = @mysqli_fetch_array($result_select);
|
||||
$query = "INSERT INTO certificate_contact_link (id, certificate_id, main_contact_id, issue_date, active) VALUES (
|
||||
NULL,
|
||||
'" . $row['certificate_id'] . "',
|
||||
'" . $GLOBALS['main_contact']['id'] . "',
|
||||
'" . $datetime->format('Y-m-d') . "',
|
||||
'1'
|
||||
)";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
}
|
||||
$correct = 1;
|
||||
}else{
|
||||
$correct = 0;
|
||||
}
|
||||
|
||||
$query = "INSERT INTO learning_unit_submit (id, learning_unit_id, main_contact_id, datetime, correct) VALUES (
|
||||
NULL,
|
||||
'" . $unit_id . "',
|
||||
'" . $GLOBALS['main_contact']['id'] . "',
|
||||
'" . $datetime->format('Y-m-d H:i:s') . "',
|
||||
'" . $correct . "'
|
||||
)";
|
||||
@mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$uri = $_SERVER["REDIRECT_URL"];
|
||||
echo "<script type='text/javascript'>window.location.href = 'https://".$host.$uri."';</script>";
|
||||
}
|
||||
|
||||
function load_questions($unit_id){
|
||||
$query = "SELECT * FROM learning_unit_question WHERE learning_unit_id = ".$unit_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
while($question = @mysqli_fetch_array($result)){
|
||||
echo "<div class='certificate_question'>";
|
||||
echo "<h3 class='certificate_question_headline'>".$question['description']."</h3>";
|
||||
load_answers($question['id']);
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
function load_answers($question_id){
|
||||
$query = "SELECT * FROM learning_unit_answer WHERE question_id = ".$question_id. " ORDER BY RAND()";
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
echo "<div class='answer_input_group'>";
|
||||
while($answer = @mysqli_fetch_array($result)){
|
||||
echo "<div class='answer_input'>";
|
||||
echo input($answer['description'], "input_answer_".$answer['id'], "checkbox");
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
function load_submit_mask($submit){
|
||||
$datetime = new DateTime($submit['datetime']);
|
||||
if($submit['correct'] == 1){
|
||||
echo "<div class='learning_success_modal'>";
|
||||
echo "<div class='learning_success'>";
|
||||
?>
|
||||
<div class="success-animation">
|
||||
<svg class="checkmark" xmlns="https://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" /><path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" /></svg>
|
||||
</div>
|
||||
<?php
|
||||
echo "<h3>Du hast diese Einheit am ".$datetime->format('d.m.Y')." erfolgreich abgeschlossen.</h3>";
|
||||
?>
|
||||
<div class="button_group">
|
||||
<a href="#" id="close_overlay" class=""><button>Video erneut ansehen</button></a>
|
||||
<a href="/intranet/de/e-learning/" class=""><button>zum E-Learning</button></a>
|
||||
</div>
|
||||
<?php
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
}else{
|
||||
echo "<div class='learning_success_modal'>";
|
||||
echo "<div class='learning_error'>";
|
||||
?>
|
||||
|
||||
<div class="ui-error">
|
||||
<svg viewBox="0 0 87 87" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink">
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group-2" transform="translate(2.000000, 2.000000)">
|
||||
<circle id="Oval-2" stroke="rgba(252, 191, 191, .5)" stroke-width="4" cx="41.5" cy="41.5" r="41.5"></circle>
|
||||
<circle class="ui-error-circle" stroke="#F74444" stroke-width="4" cx="41.5" cy="41.5" r="41.5"></circle>
|
||||
<path class="ui-error-line1" d="M22.244224,22 L60.4279902,60.1837662" id="Line" stroke="#F74444" stroke-width="3" stroke-linecap="square"></path>
|
||||
<path class="ui-error-line2" d="M60.755776,21 L23.244224,59.8443492" id="Line" stroke="#F74444" stroke-width="3" stroke-linecap="square"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo "<h3>Du kannst erst morgen wieder versuchen, diese Einheit abzuschließen.</h3>";
|
||||
?>
|
||||
<div class="button_group">
|
||||
<a href="#" id="close_overlay" class=""><button>Video erneut ansehen</button></a>
|
||||
<a href="/intranet/de/e-learning/" class=""><button>zum E-Learning</button></a>
|
||||
</div>
|
||||
<?php
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM learning_unit WHERE id = ".$unit_id;
|
||||
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
$unit = @mysqli_fetch_array($result);
|
||||
|
||||
$current_date = new DateTime();
|
||||
$query_submit = "SELECT * FROM learning_unit_submit WHERE learning_unit_id = ".$unit_id." AND main_contact_id = ".$GLOBALS['main_contact']['id'] . " ORDER BY id DESC LIMIT 1";
|
||||
$result_submit = @mysqli_query($GLOBALS['mysql_con'], $query_submit);
|
||||
$row_submit = @mysqli_fetch_array($result_submit);
|
||||
?>
|
||||
|
||||
<!-- <div class='el_back_button'>
|
||||
<button class='back_button' onclick='history.back()'>Zurück</button>
|
||||
</div> -->
|
||||
<div class="certificate_container">
|
||||
<h2 class="certificate_title"><?= $unit['title']?></h2>
|
||||
<p class="certificate_paragraph"><?= $unit['description']?></p>
|
||||
<div class='certificate_frame'>
|
||||
<?= $unit['link'] ?>
|
||||
</div>
|
||||
|
||||
<?php if(@mysqli_num_rows($result_submit) >= 1){
|
||||
load_submit_mask($row_submit);
|
||||
}else{ ?>
|
||||
<button class="to_the_questions">zu den Fragen</button>
|
||||
<div class='certificate_questions' style="display:none;">
|
||||
<form id="certificate_questions_form"method='post'>
|
||||
<?php load_questions($unit_id); ?>
|
||||
<div class="question_nav">
|
||||
<div class="prev">Vorherige Frage</div>
|
||||
<div class="next">Nächste Frage</div>
|
||||
<input class="submit_answers" type='submit' value="Meine Antworten absenden"name='input_submit'>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// Zählt alle divs mit der Klasse certificate_question
|
||||
|
||||
var currentIndex = 0;
|
||||
var maxIndex = $('.certificate_question').length - 1;
|
||||
|
||||
$('.certificate_question').eq(currentIndex).addClass('active');
|
||||
|
||||
|
||||
if (currentIndex === 0) {
|
||||
$('.prev').css('opacity', '0');
|
||||
}
|
||||
|
||||
$('.next').click(function() {
|
||||
if (currentIndex < maxIndex) {
|
||||
$('.certificate_question').eq(currentIndex).removeClass('active');
|
||||
currentIndex++;
|
||||
$('.certificate_question').eq(currentIndex).addClass('active');
|
||||
|
||||
if (currentIndex === 1) {
|
||||
$('.prev').css('opacity', '1');
|
||||
$('.submit_answers').css('display', 'none');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Überprüfe, ob wir uns im letzten Schritt befinden, und blende den "Weiter"-Button aus
|
||||
if (currentIndex === maxIndex) {
|
||||
|
||||
$('.next').css('display', 'none');
|
||||
$('.submit_answers').css('display', 'block');
|
||||
}
|
||||
});
|
||||
|
||||
$('.prev').click(function() {
|
||||
|
||||
if (currentIndex > 0) {
|
||||
$('.certificate_question').eq(currentIndex).removeClass('active');
|
||||
currentIndex--;
|
||||
$('.certificate_question').eq(currentIndex).addClass('active');
|
||||
|
||||
if (currentIndex === 0) {
|
||||
$('.prev').css('opacity', '0');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Überprüfe, ob wir uns nicht mehr im letzten Schritt befinden, und blende den "Weiter"-Button ein
|
||||
if (currentIndex < maxIndex) {
|
||||
$('.next').css('display', 'block');
|
||||
$('.submit_answers').css('display', 'none');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const form = document.getElementById('certificate_questions_form');
|
||||
|
||||
// form.addEventListener('submit', (event) => {
|
||||
// event.preventDefault(); // Verhindert das Standardverhalten des Formulars (neu laden der Seite)
|
||||
|
||||
// if (window.confirm('Sicher, dass die Fragen abgesendet werden sollen?')) {
|
||||
// // Popup-Bestätigung erhalten
|
||||
// form.submit(); // Sendet das Formular
|
||||
// } else {
|
||||
// // Popup-Bestätigung abgelehnt
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
$(document).ready(function() {
|
||||
// Wenn die Checkbox angeklickt wird
|
||||
$('.answer_input input[type="checkbox"]').click(function() {
|
||||
// Wenn die Checkbox angeklickt wurde und ausgewählt ist
|
||||
if ($(this).is(':checked')) {
|
||||
// Füge der Umrandung des div die Klasse "checked" hinzu
|
||||
$(this).closest('.answer_input').addClass('checked');
|
||||
} else {
|
||||
// Entferne die Klasse "checked", wenn die Checkbox abgewählt wird
|
||||
$(this).closest('.answer_input').removeClass('checked');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
88
module/learning/show_unit_contact.inc.php
Normal file
88
module/learning/show_unit_contact.inc.php
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user