diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index af8e216..c2bb131 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -24,49 +24,60 @@ class Posts $date = new \DateTime(); $now = $date->format("Y-m-d"); - $valid = $this->model->showAll([ - ['valid_at', '<=', $now], - ['status', '!=', 0] + $data = []; + + $valid_data = $this->model->showAll([ + ['valid_at', '<=', $now] ]); - if ($valid) { - foreach ($valid as $fields) { - if (is_array($fields)) { - $id = $fields['id']; - } else { - $id = $valid['id']; - } - $this->model->update(['status' => 1], $id); + if ($valid_data != false) { + if (array_key_exists(0, $valid_data)) { + $data = $valid_data; + } else { + $data[] = $valid_data; } + + foreach ($data as $fields) { + $id = $fields['id']; + } + + $this->model->update(['status' => 1], $id); + $data = []; } - $not_valid = $this->model->showAll([ - ['valid_at', '>', $now], - ['status', '!=', 0] + $notvalid_data = $this->model->showAll([ + ['valid_at', '>', $now] ]); - if ($not_valid) { - foreach ($not_valid as $fields) { - if (is_array($fields)) { - $id = $fields['id']; - } else { - $id = $not_valid['id']; - } - $this->model->update(['status' => 2], $id); + if ($notvalid_data != false) { + if (array_key_exists(0, $notvalid_data)) { + $data = $notvalid_data; + } else { + $data[] = $notvalid_data; } + + foreach ($data as $fields) { + $id = $fields['id']; + } + + $this->model->update(['status' => 2], $id); + $data = []; } - $expired = $this->model->showAll([ - ['expired_at', '<', $now], - ['status', '!=', 0] + $expired_data = $this->model->showAll([ + ['expired_at', '<', $now] ]); - if ($expired) { - foreach ($expired as $fields) { - if (is_array($fields)) { - $id = $fields['id']; - } else { - $id = $expired['id']; - } - $this->model->update(['status' => 0], $id); + if ($expired_data != false) { + if (array_key_exists(0, $expired_data)) { + $data = $expired_data; + } else { + $data[] = $expired_data; } + + foreach ($data as $fields) { + $id = $fields['id']; + } + + $this->model->update(['status' => 0], $id); + $data = []; } } @@ -318,13 +329,10 @@ class Posts foreach ($args as $key => $val) { if (strpos($val, "##date##") !== false) { $date = new \DateTime(); - $now = $date->format("Y-m-d"); $args[$key] = $now; } } - var_dump($args); - if ($this->model->update($args, $id)) { Session::flash('info', 'Data berhasil diperbarui'); Redirect::to('/'); diff --git a/App/Models/Post.php b/App/Models/Post.php index 406891b..52814f2 100644 --- a/App/Models/Post.php +++ b/App/Models/Post.php @@ -10,8 +10,8 @@ class Post extends \Core\Model [ 'id int(3) NOT NULL AUTO_INCREMENT', 'category int(3) NOT NULL', - 'created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', - 'valid_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', + 'created_at timestamp NOT NULL DEFAULT "00-00-00 00:00:00"', + 'valid_at timestamp NOT NULL DEFAULT "00-00-00 00:00:00"', 'expired_at timestamp NOT NULL', 'creator int(3) NOT NULL', 'edited_at timestamp', @@ -92,6 +92,7 @@ class Post extends \Core\Model } } + $query = $db->prepare($sql); if (count($conditions)) { diff --git a/App/Views/Data/edit_pengumuman.html b/App/Views/Data/edit_pengumuman.html index 04e4e1c..567b7f4 100644 --- a/App/Views/Data/edit_pengumuman.html +++ b/App/Views/Data/edit_pengumuman.html @@ -5,7 +5,7 @@ {% block body %}
-

Pengumuman {{ post.id }}

+

Ubah Pengumuman

diff --git a/App/Views/Data/pengumuman.html b/App/Views/Data/pengumuman.html index 65ef56a..270d396 100644 --- a/App/Views/Data/pengumuman.html +++ b/App/Views/Data/pengumuman.html @@ -13,7 +13,7 @@ {% endif %}  Keluar {% else %} - +  Masuk {% endif %} @@ -26,14 +26,14 @@ {% if privilege == "" %} {% if not posts %} -
-

Tidak ada pengumuman

+
+

Tidak ada pengumuman

{% else %}
{% for post in posts %} -
-
+
+
{{ post.content|rendermd }}
@@ -45,10 +45,10 @@
@@ -91,6 +91,7 @@
+ @@ -112,16 +113,6 @@
- {% block body %} @@ -170,6 +193,5 @@ }, 50); } - diff --git a/public/js/fitty.min.js b/public/js/fitty.min.js deleted file mode 100644 index 50cbacc..0000000 --- a/public/js/fitty.min.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - * fitty v2.2.3 - Snugly resizes text to fit its parent container - * Copyright (c) 2017 Rik Schennink (http://rikschennink.nl/) - */ -!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.fitty=n.exports}}(this,function(e,t){"use strict";function n(e,t){var n=r({},E,t),i=e.map(function(e){var t=r({},n,{element:e});return z(t),F(t),{element:e,fit:w(t,a.DIRTY),unsubscribe:T(t)}});return s(),i}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e?n(o(document.querySelectorAll(e)),t):n([e],t)[0]}Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t