summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/class.VprasanjeDeleted.php
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
commit75160b12821f7f4299cce7f0b69c83c1502ae071 (patch)
tree27e25e4ccaef45f0c58b22831164050d1af1d4db /admin/survey/classes/class.VprasanjeDeleted.php
parentprvi-commit (diff)
download1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip
Diffstat (limited to 'admin/survey/classes/class.VprasanjeDeleted.php')
-rw-r--r--admin/survey/classes/class.VprasanjeDeleted.php185
1 files changed, 185 insertions, 0 deletions
diff --git a/admin/survey/classes/class.VprasanjeDeleted.php b/admin/survey/classes/class.VprasanjeDeleted.php
new file mode 100644
index 0000000..11c42c6
--- /dev/null
+++ b/admin/survey/classes/class.VprasanjeDeleted.php
@@ -0,0 +1,185 @@
+<?php
+
+/**
+*
+* Pobrisana vprasanja - pred brisanjem se vprasanje kopira med pobrisane - podobno kot knjiznica
+*
+*/
+
+class VprasanjeDeleted {
+
+ var $ank_id; // trenutna anketa
+
+
+ public function __construct ($anketa = 0) {
+
+ if (isset ($_GET['anketa']))
+ $this->ank_id = $_GET['anketa'];
+ elseif (isset ($_POST['anketa']))
+ $this->ank_id = $_POST['anketa'];
+ elseif ($anketa != 0)
+ $this->ank_id = $anketa;
+ }
+
+
+ // Prikazemo seznam pobrisanih vprasanj uporabnika
+ private function displayDeletedVprasanja(){
+ global $lang;
+ global $global_user_id;
+ global $admin_type;
+
+
+ // Naslov v oknu
+ echo '<h2><span class="faicon delete"></span>'.$lang['srv_deleted_vprasanja'].'</h2>';
+ echo '<div class="popup_close"><a href="#" onclick="popupClose();">✕</a></div>';
+
+
+ // Vsebina
+ echo '<div id="vprasanje_deleted_content" class="content">';
+
+
+ // Seznam vseh pobrisanih vprasanj
+ echo '<div class="question_list">';
+
+ // Loop po vseh pobrisanih vprasanjih v anketi
+ $sql = sisplet_query("SELECT sd.*, s.naslov
+ FROM srv_spremenljivka_deleted sd, srv_spremenljivka s
+ WHERE sd.ank_id='".$this->ank_id."' AND sd.spr_id=s.id
+ ORDER BY sd.delete_time DESC
+ ");
+
+ while($row = mysqli_fetch_array($sql)){
+
+ echo '<div id="question_item_holder_'.$row['spr_id'].'" class="question_item_holder" onClick="selectVprasanjeDeletedItem(\''.$row['spr_id'].'\');">';
+
+ echo ' <input type="checkbox" id="question_item_check_'.$row['spr_id'].'" class="question_item_check" onClick="selectVprasanjeDeletedItem(\''.$row['spr_id'].'\');"><label for="question_item_check_'.$row['spr_id'].'"></label>';
+
+ echo ' <div id="question_item_info_'.$row['spr_id'].'" item-id="'.$row['spr_id'].'" class="question_item_info">';
+
+ echo ' <div>';
+ echo ' <span class="faicon list"></span>';
+ echo ' <span class="title">'.substr(strip_tags($row['naslov']), 0, 40).'</span>';
+ echo ' <span class="date">('.date("G:i d.m.Y", strtotime($row['delete_time'])).')</span>';
+ echo ' </div>';
+
+ echo ' <span class="faicon monitor" title="'.$lang['srv_predogled_spremenljivka'].'" onClick="previewVprasanje(\''.$row['spr_id'].'\');"></span>';
+
+ echo ' </div>';
+
+ echo '</div>';
+ }
+
+ echo '</div>';
+
+
+ // Item counter
+ echo '<div class="selected_items">'.$lang['srv_library_item_counter'].': <span id="selected_item_counter">0</span></div>';
+
+
+ // Gumbi na dnu
+ echo '<div class="button_holder">';
+ echo ' <button class="medium white-blue" onClick="popupClose();">'.$lang['edit1338'].'</button>';
+ echo ' <button id="insert_vprasanje_deleted_button" class="medium blue" disabled="disabled" onClick="insertVprasanjeDeletedItemsIntoSurvey();">'.$lang['srv_library_survey_add'].'</button>';
+ echo '</div>';
+
+
+ echo '</div>';
+ }
+
+
+ // Pri brisanju najprej skopiramo vprasanje ki ga brisemo
+ public function createDeletedVprasanje($spr_id){
+ global $global_user_id;
+
+ // Skopiramo spremenljivko
+ $b = new Branching($this->ank_id);
+ $new_spr_id = $b->nova_spremenljivka(-3, 0, 0, $spr_id);
+
+ // Zabelezimo v bazi povezavo z anketo in cas brisanja
+ $sql1 = sisplet_query("INSERT INTO srv_spremenljivka_deleted (spr_id, ank_id, delete_time) VALUES ('".$new_spr_id."', '".$this->ank_id."', NOW())");
+ }
+
+ // Vrnemo stevilo pobrisanih vprasanj v anketi
+ public function countDeletedVprasanja(){
+
+ $sql = sisplet_query("SELECT COUNT(id) AS cnt FROM srv_spremenljivka_deleted WHERE ank_id='".$this->ank_id."'");
+ $row = mysqli_fetch_array($sql);
+
+ return $row['cnt'];
+ }
+
+
+ // Dokoncno brisanje vprasanja
+ public static function permanentDeleteVprasanje($spremenljivka){
+
+ if ($spremenljivka > 0) {
+
+ $rowg = Cache::srv_spremenljivka($spremenljivka);
+
+ // pri brisanju multiple grid vprasanja, moramo pobrisate tudi vse child spremenljivke (ker kljuci niso nastavljeni)
+ if ($rowg['tip'] == 24) {
+ $sqld = sisplet_query("SELECT spr_id FROM srv_grid_multiple WHERE parent='$spremenljivka'");
+ while ($rowd = mysqli_fetch_array($sqld)) {
+ sisplet_query("DELETE FROM srv_spremenljivka WHERE id='$rowd[spr_id]'");
+ }
+ }
+
+ $sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spremenljivka'");
+ $sql = sisplet_query("DELETE FROM srv_grid WHERE spr_id='$spremenljivka'");
+ $sql = sisplet_query("DELETE FROM srv_spremenljivka WHERE id='$spremenljivka'");
+ }
+ }
+
+
+ /**
+ * @desc pohendla ajax klice
+ */
+ public function ajax () {
+ global $lang;
+ global $global_user_id;
+
+
+ // Odpremo popup s pobrisanimi vprasanji
+ if ($_GET['a'] == 'displayVprasanjeDeletedPopup') {
+ $this->displayDeletedVprasanja();
+
+ // Div za dodaten popup za preview
+ echo '<div id="vprasanje_preview" class="displayNone"></div>';
+ }
+
+ // Dodajanje pobrisanega vprasanja nazaj v vprasalnik
+ elseif ($_GET['a'] == 'addIntoSurvey') {
+
+ $items = $_POST['items'];
+
+ $b = new Branching($this->ank_id);
+ $ba = new BranchingAjax($this->ank_id);
+
+ foreach(array_reverse($items) as $item_id){
+
+ $last_spr = $b->find_last_spr();
+
+ // Dodamo vprasanje v anketo
+ $ba->spremenljivka_new($spremenljivka=$last_spr, $if=0, $endif=0, $copy=$item_id, $drop=0);
+ }
+
+ Common::getInstance()->Init($this->ank_id);
+ Common::getInstance()->prestevilci(0, $all=true);
+
+ $b->branching_struktura();
+ }
+
+
+ // Dokoncen izbris pobrisanega vprasanja
+ elseif ($_GET['a'] == 'deleteItem') {
+
+ $item_id = $_POST['item_id'];
+
+ if($item_id != '' && $item_id > 0){
+ sisplet_query("DELETE FROM srv_spremenljivka WHERE id='".$item_id."'AND folder!='0'");
+ }
+ }
+ }
+}
+
+?> \ No newline at end of file