<script type="text/javascript" src="/web/templates/default/admin/ckeditor/ckeditor.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css">

<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.js"></script>

<h1>News Manager</h1>


<form action="/admin/news" method="post">
    <label for="">Count News In Page</label>
    <input name="count_in_page" type="number" style="width:30px;" value="{$Config.CountInPage}">
</form>
<form action="/admin/news" method="post" >
    <table width="100%"><tr><td>
    <table id="news" class="display">
        <thead>
        <tr>
            <th>Title</th>
            <th>Date</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
        </thead>
        <tbody>
           {foreach $News item=article key=i}
               <tr>
                   <td>{$article[0]}</td>
                   <td>{$article[1]|date_format:"%D %H:%M"}</td>
                   <td><button value="{$i}" name="update_article">Update</button></td>
                   <td><button class="btn-dangerous" value="{$i}" name="delete_article">Delete</button></td>
               </tr>
           {/foreach}
        </tbody>
    </table>
            </td></tr></table>
</form>

    <h3>Add/Edit Article</h3>

    <div id="news">
        <form action="/admin/news" method="post">
            <table width="100%">
                <tr>
                    <th>Title</th>
                    <td><input type="text" placeholder="Title" value="{$Update[0]}" name="news_title"></td>
                </tr>

                <tr>
                    <th colspan="2">Description</th>
                </tr>
                <tr>
                    <td colspan="2"><textarea placeholder="Description" name="news_desc">{$Update[2]}</textarea></td>
                </tr>
                <tr>
                    <td colspan="2"><label >Format (2001-03-10 17:16:18) </label> <input type="datetime" name="news_date" placeholder="PubDate" value="{$Update[1]|date_format:"Y-m-d H:i:s"}"></td>
                </tr>
                <tr>
                    <td colspan="2"><button class="button_send"  name="news_btn" value="{$Update.Key}">Отправить</button></td>
                </tr>
            </table>
        </form>
    </div>
<script type="text/javascript">
    CKEDITOR.replace("news_desc");
    $(document).ready(function(){
        $('#news').DataTable();
    });
</script>
