diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /admin/survey/classes/class.Notifications.php | |
parent | prvi-commit (diff) | |
download | 1ka-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.Notifications.php')
-rw-r--r-- | admin/survey/classes/class.Notifications.php | 310 |
1 files changed, 210 insertions, 100 deletions
diff --git a/admin/survey/classes/class.Notifications.php b/admin/survey/classes/class.Notifications.php index 1a88247..3604125 100644 --- a/admin/survey/classes/class.Notifications.php +++ b/admin/survey/classes/class.Notifications.php @@ -18,46 +18,77 @@ class Notifications { public function display($tab=0){
global $admin_type, $global_user_id, $lang;
-
+
// Prikazemo poslana sporocila
if((isset($_GET['t']) && $_GET['t']=='sent') || $tab == 1){
-
+
+ echo '<div class="notifications_content">';
+
// Izpis vseh poslanih sporocil
if($admin_type == 0){
- echo '<div class="sent_list">';
+ echo '<div class="notifications_content_left">';
+
+ echo '<div class="title">';
+ echo '<div class="title_icon"><span class="faicon inv_sent_1"></span></div>';
+ echo '<h2>'.$lang['srv_notifications_sent'].'</h2>';
+ echo '</div>';
+
$this->displaySentMessages();
echo '</div>';
// obrazec za posiljanje sporocil
+ echo '<div class="notifications_content_right">';
+
+ echo '<div class="title">';
+ echo '<div class="title_icon"><span class="faicon inv_sent_0"></span></div>';
+ echo '<h2>'.$lang['srv_inv_message_draft_new'].'</h2>';
+ echo '</div>';
+
$this->sendMessageForm();
+ echo '</div>';
+
}
else
- echo $lang['srv_notifications_admin_alert'];
+ echo $lang['srv_notifications_admin_alert'];
+
+ echo '</div>';
}
// Prikazemo prejeta sporocila
else{
+
+ echo '<div class="title">';
+ echo '<div class="title_icon"><span class="faicon fa-inbox"></span></div>';
+ echo '<h2>'.$lang['srv_notifications_recieved'].'</h2>';
+ echo '</div>';
+
+ echo '<div class="notifications_content">';
+
+ echo '<div class="notifications_content_left">';
echo '<div class="recieved_list">';
$this->displayRecievedMessages();
echo '</div>';
+ echo '</div>';
+ echo '<div class="notifications_content_right">';
echo '<div id="message" style="display:none;"></div>';
+ echo '</div>';
+
+
+ echo '</div>';
+
}
-
- echo '<div class="clr"></div>';
}
private function displayRecievedMessages($active=0){
global $admin_type, $global_user_id, $lang;
- echo '<span class="bold">'.$lang['srv_notifications_recieved'].':</span>';
-
// Napolnimo array prejetih sporocil
$recievedMessages = array();
- $sql = sisplet_query("SELECT n.id AS id, n.recipient AS recipient, n.viewed AS viewed, m.id AS message_id, m.date AS date, m.title AS title, m.text AS text
+ $sql = sisplet_query("SELECT n.id AS id, n.recipient AS recipient, n.viewed AS viewed, m.id AS message_id, m.send_time AS send_time, m.title AS title, m.text AS text
FROM srv_notifications n, srv_notifications_messages m
WHERE n.recipient='".$global_user_id."' AND n.message_id=m.id
- ORDER BY m.date DESC");
+ ORDER BY m.send_time DESC");
while($row = mysqli_fetch_array($sql)){
$recievedMessages[$row['id']] = $row;
}
@@ -67,16 +98,25 @@ class Notifications { if(count($recievedMessages) > 0){
foreach($recievedMessages as $message){
- echo '<a href="#" onclick="viewMessage(\''.$message['id'].'\'); return false;">';
- echo '<li class="'.($message['viewed'] == 0 ? ' unread':'').' '.($active > 0 && $message['id'] == $active ? ' active':'').'">';
-
- echo '<span class="bold">'.$message['title'].' <span class="italic">('.$message['date'].')</span></span>';
+ echo '<li class="'.($active > 0 && $message['id'] == $active ? ' active':'').'" onclick="viewMessage(\''.$message['id'].'\'); return false;">';
+
+ echo '<span class="faicon fa-circle '.($message['viewed'] == 0 ? ' unread':'').'"></span>';
+
+ echo '<div class="title_row">'; //sem noter pride še oznaka, če je obvestilo ali sporočilo
+ echo '<div class="subject">';
+ echo $message['title'];
+ echo '</div>';
+ echo '<div class="date">';
+ echo date('Y-m-d H:i:s', strtotime($message['send_time']));
+ echo '</div>';
+ echo '</div>';
- $text = strip_tags((strlen($message['text']) > 70) ? substr($message['text'], 0, 70).'...' : $message['text']);
- echo '<br />'.$text;
+ $text = strip_tags($message['text']);
+ echo '<div class="content">';
+ echo $text;
+ echo '</div>';
echo '</li>';
- echo '</a>';
}
}
@@ -85,43 +125,54 @@ class Notifications { private function displaySentMessages(){
global $admin_type, $global_user_id, $lang;
-
- echo '<span class="bold">'.$lang['srv_notifications_sent'].':</span>';
-
+
// Napolnimo array poslanih sporocil
$sentMessages = array();
- $sql = sisplet_query("SELECT * FROM srv_notifications_messages WHERE author='".$global_user_id."' ORDER BY date DESC");
+ $sql = sisplet_query("SELECT * FROM srv_notifications_messages WHERE author='".$global_user_id."' ORDER BY send_time DESC");
while($row = mysqli_fetch_array($sql)){
$sentMessages[$row['id']] = $row;
}
-
- echo '<ul>';
-
if(count($sentMessages) > 0){
+
+ echo '<div class="sent_list">';
+ echo '<ul>';
+
foreach($sentMessages as $message_id => $message){
- //echo '<li '.($message['viewed'] == 0 ? ' class="unread"':'').'>';
echo '<li>';
+
+ echo '<div class="title_row">'; //sem noter pride še oznaka, če je obvestilo ali sporočilo
+ echo '<div class="subject">';
+ echo $message['title'];
+ echo '</div>';
+ echo '<div class="date">';
+ echo date('Y-m-d H:i:s', strtotime($message['send_time']));
+ echo '</div>';
+ echo '</div>';
- echo '<span class="bold">'.$message['title'].' <span class="italic">('.$message['date'].')</span></span>';
-
- $text = strip_tags((strlen($message['text']) > 70) ? substr($message['text'], 0, 70).'...' : $message['text']);
- echo '<br />'.$text;
+ $text = strip_tags($message['text']);
+ echo '<div class="content">';
+ echo $text;
+ echo '</div>';
// Gumb da se sporocilo razresi vsem (kot da so ga pregledali)
$sqlN = sisplet_query("SELECT message_id FROM srv_notifications WHERE message_id='".$message_id."' AND viewed='0'");
$count = mysqli_num_rows($sqlN);
if($count > 0){
- echo '<br />';
- echo '<a href="#" onclick="resolveMessages(\''.$message_id.'\'); return false;"><span class="link">'.$lang['srv_notifications_sent_resolve'].' ('.$count.')'.'</span></a>';
+ echo '<div class="resolve" onclick="resolveMessages(\''.$message_id.'\'); return false;">';
+ echo '<span class="faicon fa-check"></span>';
+ echo $lang['srv_notifications_sent_resolve'].' ('.$count.')';
+ echo '</div>';
}
echo '</li>';
- }
+ }
+ echo '</ul>';
+ echo '</div>';
}
-
- echo '</ul>';
+ else //Ni poslanih sporočil
+ echo '<p>'.$lang['srv_notifications_sent_none'].'.</p>';
}
// Obrazec za posiljanje sporocila
@@ -129,28 +180,59 @@ class Notifications { global $admin_type, $global_user_id, $lang;
echo '<div class="send_form">';
- echo '<span class="clr bold">'.$lang['srv_notifications_send_reciever'].': </span><input type="text" name="recipient" id="recipient">';
-
- // Checkboxa za posiljenje vsem uporabnikoom (slo in ang)
- echo '<div style="padding-top:5px;"><input type="checkbox" value="1" name="recipient_all_slo" id="recipient_all_slo" onClick="recipient_all_disable_email();"> <label for="recipient_all_slo"><span class="clr bold">'.$lang['srv_notifications_send_all_slo'].'</span></label></div>';
- echo '<div style="padding-top:5px;"><input type="checkbox" value="1" name="recipient_all_ang" id="recipient_all_ang" onClick="recipient_all_disable_email();"> <label for="recipient_all_ang"><span class="clr bold">'.$lang['srv_notifications_send_all_ang'].'</span></label></div><br />';
-
- echo '<span class="clr bold">'.$lang['srv_notifications_send_title'].': </span><input type="text" name="title"><br /><br />';
- echo '<span class="clr bold">'.$lang['srv_notifications_send_text'].': </span><textarea name="notification"></textarea><br />';
+
+ //Prejemniki
+ echo '<div class="setting_holder">';
+ echo '<span class="setting_title">'.$lang['srv_notifications_send_reciever2'].':</span>';
+
+ echo '<div class="setting_item">';
+ echo '<input type="checkbox" value="1" name="recipient_all_slo" id="recipient_all_slo" onChange="recipient_toggle(\'slo\');">';
+ echo '<label for="recipient_all_slo">'.$lang['srv_notifications_send_all_slo'].'</label>';
+ echo '</div>';
+ echo '<div class="setting_item">';
+ echo '<input type="checkbox" value="1" name="recipient_all_ang" id="recipient_all_ang" onChange="recipient_toggle(\'ang\');">';
+ echo '<label for="recipient_all_ang">'.$lang['srv_notifications_send_all_ang'].'</label>';
+ echo '</div>';
+ echo '<div class="setting_item">';
+ echo '<input type="checkbox" value="1" name="recipient_custom" id="recipient_custom" onChange="recipient_toggle(\'custom\');">';
+ echo '<label for="recipient_custom">'.$lang['srv_notifications_send_custom'].'</label>';
+ echo '<input type="text" class="text large disabled" name="recipient" id="recipient">';
+ echo '</div>';
+
+ echo '</div>';
+
+ // Naslov sporocila
+ echo '<div class="setting_holder">';
+ echo $lang['srv_notifications_send_title'].':';
+ echo '<input type="text" class="text large" name="title">';
+ echo '</div>';
+
+ // Besedilo sporocila (editor)
+ echo $lang['srv_notifications_send_text'].':';
+ echo '<div class="label">';
+ echo '<textarea id="notification" name="notification" autocomplete="off"></textarea>';
+ echo '</div>';
// Avtomatsko prikaži obvestilo po prijavi
- echo '<div style="padding-top:5px;"><input type="checkbox" value="1" name="force_show" id="force_show"> <label for="force_show"><span class="clr bold">'.$lang['srv_notifications_force_show'].'</span></label></div><br />';
-
- echo '<span class="buttonwrapper floatLeft spaceRight"><a class="ovalbutton ovalbutton_orange" href="#" onclick="sendNotification(); return false;">';
- echo '<span>'.$lang['srv_notifications_send'].'</span>';
- echo '</a></span>';
-
+ echo '<div class="auto_checkbox">';
+ echo '<input type="checkbox" value="1" name="force_show" id="force_show">';
+ echo '<label for="force_show">'.$lang['srv_notifications_force_show'].'</label>';
+ echo '</div>';
+
+ //Error notes
if($note != ''){
- echo '<br /><br />';
- echo '<span class="bold red">'.$note.'</span>';
+ echo '<p class="top16">'.$note.'</p>';
}
+
+ // Gumb pošlji
+ echo '<div class="button_holder '.($note != '' ? 'top16' : '').'">';
+ echo '<button class="medium blue" onclick="sendNotification(); return false;">'.$lang['srv_notifications_send'].'</button>';
+ echo '</div>';
echo '</div>';
+
+ // Inicializiramo editor
+ echo '<script type="text/javascript">create_editor_notification(\'notification\');</script>';
}
@@ -245,7 +327,7 @@ class Notifications { if($recipient_all_slo == 1 || $recipient_all_ang == 1){
// Dodamo novo sporocilo v bazo
- $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, date, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')");
+ $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, send_time, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')");
$message_id = mysqli_insert_id($GLOBALS['connect_db']);
$note = '';
@@ -261,7 +343,7 @@ class Notifications { $sql = sisplet_query("INSERT INTO srv_notifications (message_id, recipient, viewed) VALUES ('".$message_id."', '".$rowU['id']."', '0')");
if(!$sql)
- $note .= mysqli_error($GLOBALS['connect_db']).'<br />';
+ $note .= '<span class="red">'.mysqli_error($GLOBALS['connect_db']).'</span>';
}
}
// Posiljamo na specificen mail
@@ -272,30 +354,46 @@ class Notifications { $rowU = mysqli_fetch_array($sqlU);
// Dodamo novo sporocilo v bazo
- $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, date, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')");
+ $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, send_time, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')");
$message_id = mysqli_insert_id($GLOBALS['connect_db']);
// Dodamo novo sporocilo v bazo
$sql = sisplet_query("INSERT INTO srv_notifications (message_id, recipient, viewed) VALUES ('".$message_id."', '".$rowU['id']."', '0')");
if(!$sql)
- $note = mysqli_error($GLOBALS['connect_db']);
+ $note = '<span class="red">'.mysqli_error($GLOBALS['connect_db']).'</span>';
else
- $note = 'Sporočilo je bilo uspešno poslano uporabniku '.$recipient.' ('.$rowU['name'].' '.$rowU['surname'].').';
+ $note = '<span class="faicon success blue link-right"></span>'.$lang['srv_notifications_sent_success'].' '.$recipient.' ('.$rowU['name'].' '.$rowU['surname'].').';
}
else{
- $note = 'Vnešeni email ('.$recipient.') ne pripada nobenemu uporabniku!';
+ $note = '<span class="red">'.$lang['srv_notifications_sent_nouser1'].$recipient.$lang['srv_notifications_sent_nouser1'].'</span>';
}
}
+ echo '<div class="notifications_content">';
+
// Refresh vseh poslanih sporocil
- echo '<div class="sent_list">';
+ echo '<div class="notifications_content_left">';
+
+ echo '<div class="title">';
+ echo '<div class="title_icon"><span class="faicon inv_sent_1"></span></div>';
+ echo '<h2>'.$lang['srv_notifications_sent'].'</h2>';
+ echo '</div>';
+
$this->displaySentMessages();
echo '</div>';
// Refresh obrazca za posiljanje sporocil
+ echo '<div class="notifications_content_right">';
+
+ echo '<div class="title">';
+ echo '<div class="title_icon"><span class="faicon inv_sent_0"></span></div>';
+ echo '<h2>'.$lang['srv_inv_message_draft_new'].'</h2>';
+ echo '</div>';
+
$this->sendMessageForm($note);
-
- echo '<div class="clr"></div>';
+ echo '</div>';
+
+ echo '</div>';
}
public function ajax_resolveMessages(){
@@ -320,57 +418,80 @@ class Notifications { $sql = sisplet_query("UPDATE srv_notifications SET viewed='1' WHERE id='$id'");
// Dobimo sporocilo
- $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.date AS date
+ $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.send_time AS send_time
FROM srv_notifications n, srv_notifications_messages m
WHERE n.id='$id' AND m.id=n.message_id");
$row = mysqli_fetch_array($sql);
// Refresh vseh prejetih sporocil
+ echo '<div class="title">';
+ echo '<div class="title_icon"><span class="faicon fa-inbox"></span></div>';
+ echo '<h2>'.$lang['srv_notifications_recieved'].'</h2>';
+ echo '</div>';
+
+ echo '<div class="notifications_content">';
+
+ echo '<div class="notifications_content_left">';
echo '<div class="recieved_list">';
$this->displayRecievedMessages($active=$id);
echo '</div>';
-
+ echo '</div>';
+
// Prikaz izbranega sporocila
+ echo '<div class="notifications_content_right">';
echo '<div id="message">';
- echo '<span class="bold">'.$row['title'].' <span class="italic">('.$row['date'].')</span></span>';
- echo '<p>'.nl2br($row['text']).'</p>';
+
+ echo '<div class="subject">';
+ echo $row['title'];
+ echo '</div>';
+
+ echo '<div class="date">';
+ echo '('.date('Y-m-d H:i:s', strtotime($row['send_time'])).')';
+ echo '</div>';
+
+ // Stara sporocila so brez editorja
+ $text = (strtotime($row['send_time']) < strtotime('2021-08-26')) ? nl2br($row['text']) : $row['text'];
+ echo '<div class="content">';
+ echo $text;
+ echo '</div>';
+
echo '</div>';
echo '<div class="clr"></div>';
+
+ echo '</div>'; //div.notifications_content
}
- public function ajax_viewUnreadMessages(){
+ public function ajax_viewUnreadMessages($active=0){
global $lang, $global_user_id;
- echo '<h2>'.$lang['srv_notifications_unread'].'</h2>';
+ echo '<h2><span class="faicon envelope-open"></span>'.$lang['srv_notifications_unread'].'</h2>';
- echo '<ul>';
+ echo '<div class="unread_notifications_holder">';
// Loop cez vsa neprebrana sporocila
- $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.date AS date, n.viewed AS viewed
+ $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.send_time AS send_time, n.viewed AS viewed
FROM srv_notifications n, srv_notifications_messages m
- WHERE n.recipient='".$global_user_id."' AND n.viewed='0' AND m.id=n.message_id
- ORDER BY m.date DESC");
+ WHERE n.recipient='".$global_user_id."' AND n.viewed='0' AND m.id=n.message_id
+ ORDER BY m.send_time DESC");
while($row = mysqli_fetch_array($sql)){
- echo '<li class="'.($row['viewed'] == 0 ? ' unread':'').' '.($active > 0 && $row['id'] == $active ? ' active':'').'">';
+ echo '<div class="unread_notification '.($row['viewed'] == 0 ? ' unread':'').' '.($active > 0 && $row['id'] == $active ? ' active':'').'">';
- echo '<span class="bold">'.$row['title'].' <span class="italic">('.$row['date'].')</span></span>';
+ echo '<span class="bold">'.$row['title'].' <span class="italic">('.date('Y-m-d H:i:s', strtotime($row['send_time'])).')</span></span>';
- echo '<br />'.nl2br($row['text']);
+ // Stara sporocila so brez editorja
+ $text = (strtotime($row['send_time']) < strtotime('2021-08-26')) ? nl2br($row['text']) : $row['text'];
+ echo '<br />'.$text;
- echo '</li>';
+ echo '</div>';
}
- echo '</ul>';
+ echo '</div>';
// Gumb za zapiranje
- echo '<div class="buttons_holder">';
- echo '<div class="buttonwrapper" title="'.$lang['srv_zapri'].'">';
- echo '<a class="ovalbutton ovalbutton" onclick="closeUnreadMessages(); return false;" href="#">';
- echo '<span>'.$lang['srv_zapri'].'</span>';
- echo '</a>';
- echo '</div>';
+ echo '<div class="button_holder">';
+ echo ' <button class="medium blue" onclick="closeUnreadMessages(); return false;">'.$lang['srv_zapri'].'</button>';
echo '</div>';
@@ -379,28 +500,25 @@ class Notifications { }
public function ajax_viewGDPRMessage(){
- global $lang, $global_user_id, $aai_instalacija;
-
- echo '<h2>'.$lang['srv_notifications_unread'].'</h2>';
+ global $lang, $global_user_id;
- echo '<ul>';
- echo '<li class="unread active">';
+ echo '<h2><span class="faicon envelope-open"></span>'.$lang['srv_notifications_unread'].'</h2>';
- if(isset($aai_instalacija) && $aai_instalacija == true){
+ /* if(isAAI()){
echo '<span class="bold">'.$lang['srv_gdpr_notification_title_aai'].'</span>';
}
else{
echo '<span class="bold">'.$lang['srv_gdpr_notification_title'].'</span>';
}
- echo '<br /><br />';
+ echo '<br /><br />'; */
echo $lang['srv_gdpr_notification_text1'];
echo '<br /><br />';
echo $lang['srv_gdpr_notification_question'];
- echo '<br />';
+ echo '<br /><br />';
echo '<div class="spaceLeft gdpr_popup_radio"><input type="radio" name="gdpr_agree" id="gdpr_agree_1" value="1" onClick="enableGDPRPopupButton();"> <label for="gdpr_agree_1">'.$lang['srv_gdpr_notification_da'].'</label></div>';
//echo ' <a href="#" onClick="toggleGDPRMore();"><span class="bold">'.$lang['srv_invitation_nonActivated_more'].'</span></a>';
echo '<div class="spaceLeft gdpr_popup_radio"><input type="radio" name="gdpr_agree" id="gdpr_agree_0" value="0" onClick="enableGDPRPopupButton();"> <label for="gdpr_agree_0">'.$lang['srv_gdpr_notification_ne'].'</label></div>';
@@ -409,21 +527,13 @@ class Notifications { echo '<br />';
- echo $lang['srv_gdpr_notification_pogoji'];
-
- echo '</li>';
- echo '</ul>';
+ echo $lang['srv_gdpr_notification_unsubscribe'];
// Gumb za zapiranje
- //echo '<div class="floatRight spaceRight" id="GDPR_popup_button">';
- echo '<div class="floatRight spaceRight" id="GDPR_popup_button" style="visibility: hidden;">';
- echo '<div class="buttonwrapper" title="'.$lang['save'].'">';
- echo '<a class="ovalbutton ovalbutton" onclick="saveGDPRMessage();" href="#">';
- echo '<span>'.$lang['save'].'</span>';
- echo '</a>';
- echo '</div>';
- echo '</div>';
+ echo '<div class="button_holder" id="GDPR_popup_button" style="visibility: hidden;">';
+ echo '<button class="medium blue" onclick="saveGDPRMessage(); return false;">'.$lang['save'].'</button>';
+ echo '</div>';
}
public function ajax_saveGDPRAgree(){
|