diff --git a/DATABASE.sql b/DATABASE.sql deleted file mode 100644 index 40b05b1..0000000 --- a/DATABASE.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO `badminton_coach`.`setting` (`set_name`, `set_setting_type_st_id`) VALUES ('E-mail küldés log', '3'); - -INSERT INTO `badminton_coach`.`setting_value` (`setv_id`, `setv_set_date`, `setv_setting_set_id`, `setv_varchar`) VALUES (NULL, '2017-03-14 00:00:00', '7', 'emails'); diff --git a/_class/class_page.php b/_class/class_page.php index 29f7d11..c4620f0 100644 --- a/_class/class_page.php +++ b/_class/class_page.php @@ -255,6 +255,14 @@ class page { # email log details include('include_email.php'); break; + case 'notifications': + # értesítések + include('include_notifications.php'); + break; + case 'delete_notification': + # ÉRTESÍTÉS TÖRLÉS (NULLÁZÁS) + include('include_delete_notification.php'); + break; case 'delete_training_type': # EDZÉS TÍPUS TÖRLÉS include('include_delete_training_type.php'); diff --git a/_class/class_sql.php b/_class/class_sql.php index 23fd381..17f0207 100644 --- a/_class/class_sql.php +++ b/_class/class_sql.php @@ -50,7 +50,7 @@ class sql extends mysqli { $i++; } $this->_query = 'insert into ' . $table . ' (' . $fields . ') values (' . $values . ');'; - var_dump($this->_query); + //var_dump($this->_query); self::query($this->_query); return $this->insert_id; } diff --git a/_css/default.css b/_css/default.css index 60a9fb2..d612f11 100644 --- a/_css/default.css +++ b/_css/default.css @@ -174,6 +174,13 @@ td.create a { font-size: 18px; } +.list.noti { + display: flex; +} + +a.addbutton.noti { + margin-left: 10px; +} .list_item table.money { width: 100%; @@ -387,6 +394,10 @@ table.log tr.delete:hover { background-color: #f02a2a; } +table.email.log tr:hover { + cursor: pointer; +} + .date_separator img { width: 20px; float: right; diff --git a/_include/include_delete_notification.php b/_include/include_delete_notification.php new file mode 100644 index 0000000..136689d --- /dev/null +++ b/_include/include_delete_notification.php @@ -0,0 +1,9 @@ +is_id()) { + $sql->update_table('user_kid', array('uk_last_notification' => 'null'), array('uk_id' => $this->get_id())); + header("Location: /admin/notifications"); +} + + +?> diff --git a/_include/include_email.php b/_include/include_email.php index abe2113..a0922ce 100644 --- a/_include/include_email.php +++ b/_include/include_email.php @@ -7,7 +7,7 @@ if ($this->is_id()) { $email_log = new email_log(); $email_log->set_el_data_by_id($this->get_id()); - $smarty->assign('email_log', $email_log); + $smarty->assign('email', $email_log); $smarty->display('email.tpl'); } else { diff --git a/_include/include_emails.php b/_include/include_emails.php index 2566b59..c417fe2 100644 --- a/_include/include_emails.php +++ b/_include/include_emails.php @@ -5,7 +5,7 @@ if ($this->is_id()) { # EMAIL LISTA (50 / oldal) $all_emails_query = "SELECT count(DISTINCT el_id) FROM email_log"; - $emails_query = "SELECT * FROM email_log LIMIT ".($this->is_id()?($this->get_id()-1) * 50:"0").",50"; + $emails_query = "SELECT * FROM email_log ORDER BY el_sent_date DESC LIMIT ".($this->is_id()?($this->get_id()-1) * 50:"0").",50"; $el_assoc_array = $sql->assoc_array($emails_query); $el_count = $sql->single_variable($all_emails_query); $next_link = true; diff --git a/_include/include_lock_training.php b/_include/include_lock_training.php index c030cd8..58ada09 100644 --- a/_include/include_lock_training.php +++ b/_include/include_lock_training.php @@ -7,7 +7,6 @@ if ($this->is_id()) { # EDZÉS ZÁROLÁS/FELOLDÁS $locked = $sql->single_variable('select tr_locked from training where tr_id =' . $this->get_id()); - /* $sql->update_table('training', array( 'tr_locked' => ($locked?0:1) ), @@ -16,7 +15,6 @@ if ($this->is_id()) { ) ); log::register(($locked?'training_open':'training_close'), $this->get_id()); - */ //SEND NOTIFICATION if (!$locked) { @@ -83,8 +81,9 @@ if ($this->is_id()) { $mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings - $mail->SMTPDebug = 2; // Enable verbose debug output + $mail->SMTPDebug = 0; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP + $mail->CharSet = PHPMailer::CHARSET_UTF8; // UTF-8 $mail->Host = 'mail.gginternet.com '; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'hirlevel@tollaslabda.info'; // SMTP username @@ -94,8 +93,8 @@ if ($this->is_id()) { //Recipients $mail->setFrom($emailTemplate->get_et_from_email(), $emailTemplate->get_et_from_name()); + $mail->addBCC($kid->get_uk_notify_email(), $kid->get_uk_notify_name()); $mail->addBCC('tricsusz@gmail.com', 'Tóth Richárd'); // TEST - //$mail->addBCC($kid->get_uk_notify_email(), $kid->get_uk_notify_name()); //Content @@ -104,7 +103,8 @@ if ($this->is_id()) { $mail->Body = $personalizedMessage; $mail->AltBody = 'Az Ön levelezője nem támogatja a HTML tartalom megjelenítését!'; - //$mail->send(); + //send mail + $mail->send(); //LOG SUCCESS email_log::create_email_log( $personalizedMessage, @@ -114,7 +114,8 @@ if ($this->is_id()) { $emailTemplate->get_et_id() ); - //TODO: Update kids last noti date + //Update kids last noti date + $sql->update_table('user_kid', array('uk_last_notification' => date('Y-m-d H:i:s')), array('uk_id' => $kid->get_uk_id())); } catch (Exception $e) { //LOG ERROR @@ -124,7 +125,7 @@ if ($this->is_id()) { $kid->get_uk_notify_name(), $kid->get_uk_notify_email(), $emailTemplate->get_et_id(), - $e + mysql_escape_string($e) ); } @@ -132,7 +133,7 @@ if ($this->is_id()) { } } - //header('Location: /admin/presence/' . $this->get_id()); + header('Location: /admin/presence/' . $this->get_id()); } ?> diff --git a/_include/include_notifications.php b/_include/include_notifications.php new file mode 100644 index 0000000..b15d155 --- /dev/null +++ b/_include/include_notifications.php @@ -0,0 +1,36 @@ +is_id()) { + +} +else { + # ÉRTESÍTÉSEK + + //hány óránként küldünk emailt + $notify_hours = $sql->single_variable(' SELECT + setv_int + FROM + setting_value + JOIN + setting ON setv_setting_set_id = set_id + WHERE + set_name = "Értesítések közt eltelt idő"; + ;'); + + //akiket értesítettünk az elmúlt x órában + $notifiedKids = $sql->assoc_array('select * from user_kid WHERE DATE_SUB(CURDATE(),INTERVAL '.$notify_hours.' HOUR) <= uk_last_notification order by uk_name ASC;'); + + $kid_array = array(); + foreach ($notifiedKids as $key => $kid) { + $new_kid = new user_kid(); + $new_kid->set_user_data_by_id($kid['uk_id']); + $kid_array[] = $new_kid; + } + $smarty->assign('kid_array', $kid_array); + $smarty->display('notifications.tpl'); + +} + +?> diff --git a/template/templates/city_list.tpl b/template/templates/city_list.tpl index 9e3562d..b288cd1 100644 --- a/template/templates/city_list.tpl +++ b/template/templates/city_list.tpl @@ -1,24 +1,24 @@
-
- - - {foreach $scc_assoc_array as $scc} -
-
- - - Törlés -
-
+ + + + {foreach $scc_assoc_array as $scc} +
+
+ + + Törlés +
+
- - {/foreach} -
-
- -
-
-
-
\ No newline at end of file + + {/foreach} +
+
+ +
+
+ + diff --git a/template/templates/email.tpl b/template/templates/email.tpl new file mode 100644 index 0000000..4eb92dd --- /dev/null +++ b/template/templates/email.tpl @@ -0,0 +1,37 @@ +
+
+ +
{$email->get_el_to_name()}
<{$email->get_el_to_email()}>
+
+
+ +
{$email->get_el_subject()}
+
+
+ +
{$email->get_el_sent_date()}
+
+
+ +
{$email->get_el_message()}
+
+ + {if $email->get_el_exception()} +
+ +
{$email->get_el_exception()}
+
+ {/if} + + +
diff --git a/template/templates/emails.tpl b/template/templates/emails.tpl index df8b298..ee9833b 100644 --- a/template/templates/emails.tpl +++ b/template/templates/emails.tpl @@ -24,7 +24,7 @@ {/if}
- +
@@ -34,7 +34,7 @@ {foreach $el_array as $log} - + @@ -67,3 +67,9 @@ {/if} + + diff --git a/template/templates/notifications.tpl b/template/templates/notifications.tpl new file mode 100644 index 0000000..d669d34 --- /dev/null +++ b/template/templates/notifications.tpl @@ -0,0 +1,14 @@ +
+ {if !count($kid_array)} + Nincs találat! + {/if} + {foreach $kid_array as $kid} +
+ +
{$kid->get_uk_last_notification()}
+
+ Törlés + {/foreach} +
diff --git a/template/templates/presence.tpl b/template/templates/presence.tpl index 0997515..47ded6c 100644 --- a/template/templates/presence.tpl +++ b/template/templates/presence.tpl @@ -9,64 +9,64 @@
-
- -
- {$training->get_tr_date()|substr:0:4}. - {$months[$training->get_tr_date()|substr:5:2]} - {$training->get_tr_date_day()}. - {$days[$training->get_tr_date_day_of_week()]} - {$training->get_tr_date_time()} +
+ +
+ {$training->get_tr_date()|substr:0:4}. + {$months[$training->get_tr_date()|substr:5:2]} + {$training->get_tr_date_day()}. + {$days[$training->get_tr_date_day_of_week()]} + {$training->get_tr_date_time()} +
-
-
- -
- {$training->get_tr_type_name_by_id()} +
+ +
+ {$training->get_tr_type_name_by_id()} +
-
-
- -
{$training->get_tr_duration()} perc
-
- -{if $trc_coaches} -
- -
- {foreach $trc_coaches as $coach} - {$coach->get_ua_name()}
- {/foreach} - {foreach $trc_helpers as $coach} - {$coach->get_ua_name()}
- {/foreach} +
+ +
{$training->get_tr_duration()} perc
-
-{/if} -
- -
- {$headcount} fő -
-
+ {if $trc_coaches} +
+ +
+ {foreach $trc_coaches as $coach} + {$coach->get_ua_name()}
+ {/foreach} + {foreach $trc_helpers as $coach} + {$coach->get_ua_name()}
+ {/foreach} +
+
+ {/if} + +
+ +
+ {$headcount} fő +
+
@@ -88,9 +88,9 @@ {/if}
-
{$user->get_uk_name()}
-
- +
{$user->get_uk_name()}
+
+ {/foreach}
@@ -100,7 +100,7 @@ {foreach $rest_users as $rest_user}
-
{$rest_user->get_uk_name()}
+
{$rest_user->get_uk_name()}
{/foreach}
@@ -151,7 +151,7 @@ $('.name_tag').click(function() { url: '/_ajax/update_presence.php', data: { checked : checked, user_id : user_id, tr_id : tr_id, admin_id : admin_id}, success: function(data) { - + } }); @@ -181,13 +181,13 @@ $('.name_tag_checked').click(function() { //alert(checked); var admin_id = $("#admin_id").val(); - + $.ajax({ type: "POST", url: '/_ajax/update_presence.php', data: { checked : checked, user_id : user_id, tr_id : tr_id, admin_id : admin_id}, success: function(data) { - + } }); @@ -205,4 +205,4 @@ function hexc(colorval) { } - \ No newline at end of file +
#ID CímzettHibaüzenet