<script>
    var getUrl = '<?php echo URL::route('getEmailData'); ?>';
    var postUrl = '<?php echo URL::route('deleteEmail'); ?>'
</script>

<div id="tab-useremails">
    <div class="row">
        <div class="col s12" id="emailList">
            <div class="widget-holder hoverable fadeIn">
                <div class="widget-content">
                    <div class="table-wrapper">
                        <table class="bordered responsive-table">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th><?php echo Lang::get('emailList.email_date'); ?></th>
                                <th><?php echo Lang::get('emailList.email_subject'); ?></th>
                                <th><?php echo Lang::get('emailList.email_action'); ?></th>
                            </tr>
                            </thead>

                            <tbody>
                            <?php foreach($emails as $email): ?>
                            <tr id="<?php echo $email->email_id; ?>">
                                <td><?php echo $email->email_id; ?></td>
                                <td><?php echo date('d.m.Y', strtotime($email->date)); ?></td>
                                <td>
                                    <a v-on:click="getEmail(<?php echo $email->email_id; ?>)" class="icon-btn icon-btn-edit"><?php echo $email->subject; ?></a>
                                </td>
                                <td>
                                    <a v-on:click="deleteEmail(<?php echo $email->email_id; ?>)" class="icon-btn icon-btn-delete" title="<?php echo Lang::get('emailList.email_delete_email'); ?>"><i class="material-icons">delete</i></a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                        <div id="show-email" class="modal modal-fixed-footer">
                            <div class="modal-content">
                                <h4>{{ subject }}</h4>
                                <hr>
                                <p class="email-modal-text" v-html="content"></p>
                                <div v-if="image" class="email-modal-attachment">
                                    <h3><?php echo Lang::get('dashboard.email_modal_attachment'); ?>: </h3>
                                    <div class="attachment-container" v-for="imagePath in image">
                                        <img onclick="bigImage=this.src; showImage()" v-if="imagePath" :src="imagePath" alt="email-image" class="enlargale email-modal-image">
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <a href="#!" class="modal-action modal-close btn waves-effect waves-light"><?php echo Lang::get('dashboard.email_modal_close'); ?></a>
                            </div>
                        </div>

                        <div id="show-image-modal" class="modal modal-fixed-footer">
                            <div class="modal-content">
                                <img id="big-image" src="">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>