diff --git a/lib/modem-dashboard/router-sms.js b/lib/modem-dashboard/router-sms.js index f7009da..d1edfc5 100644 --- a/lib/modem-dashboard/router-sms.js +++ b/lib/modem-dashboard/router-sms.js @@ -9,10 +9,15 @@ const router = express.Router(); module.exports = router; function pageSmsIndex(req, res, next) { + if (!req.query.input_date) { + req.query.input_date = moment().format('YYYY-MM-DD'); + } + res.render( 'sms.index.html', { - page_title: 'Histori SMS' + page_title: 'Histori SMS', + input_date: req.query.input_date } ) } @@ -20,7 +25,7 @@ function pageSmsIndex(req, res, next) { function pageSmsDataTables(req, res, next) { const db = localDb.getConnection(); - const created_date = moment().format('YYYY-MM-DD'); + const created_date = req.query.input_date || moment().format('YYYY-MM-DD'); const query = "SELECT rowid, * FROM sms WHERE created_date = ? ORDER BY created DESC, rowid DESC"; db.all(query, created_date, function (err, rows) { if (err) { diff --git a/lib/modem-dashboard/views/date-selector.html b/lib/modem-dashboard/views/date-selector.html index 3e8e582..6a3797f 100644 --- a/lib/modem-dashboard/views/date-selector.html +++ b/lib/modem-dashboard/views/date-selector.html @@ -4,7 +4,7 @@ <div class="form-group"> <label for="inputDate" class="col-sm-2 control-label">Tanggal:</label> <div class="col-sm-3"> - <input type="date" class="form-control" id="inputDate" placeholder="Tanggal" name="inputDate" value="{{ inputDate }}"> + <input type="date" class="form-control" id="inputDate" placeholder="Tanggal" name="inputDate" value="{{ input_date }}"> </div> </div> diff --git a/lib/modem-dashboard/views/sms.index.html b/lib/modem-dashboard/views/sms.index.html index 47f2d72..16838f1 100644 --- a/lib/modem-dashboard/views/sms.index.html +++ b/lib/modem-dashboard/views/sms.index.html @@ -36,7 +36,7 @@ <script> $(document).ready(function() { $('#smsHistory').DataTable( { - "ajax": "/sms/datatables", + "ajax": "/sms/datatables?input_date={{ input_date}}", "language": { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Indonesian.json" }, "columns": [ { "data": "rowid" },