admin.php 4.83 KB
<?php
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Notifications;
use Tz\WordPress\Tools\Notifications\Settings;
?>

<link rel="stylesheet" href="<?php echo Tools\url('assets/css/notifications.css', __FILE__) ?>"/>
<script src="<?php echo Tools\url('assets/scripts/jquery.qtip-1.0.0-rc3.js', __FILE__) ?>"></script>


<div id="" class="wrap">
    <h2>Notifications</h2>

    <h3 class="table-caption">Scheduled Notifications</h3>
    <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
        <thead>
            <tr>
                <th scope="col" class="manage-column">Description</th>
                <th scope="col" width="200" class="manage-column">Execute Date/Time</th>
                <th scope="col" width="200" class="manage-column">Send To</th>
                <th scope="col" width="60" class="manage-column">Email</th>
                <th scope="col" width="60" class="manage-column">System</th>
                <th scope="col" width="200" class="manage-column">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($notifications['scheduled'] as $entry):
                $sendto = $entry->sendto;
                if (is_numeric($sendto)) {
                    $sendto = Notifications\getGroups($sendto)." Group";
                } else {
                    $sendto = Notifications\get_field_lookup($sendto);
                }
                ?>
                <tr>
                    <td><?php echo $entry->post_title; ?></td>
                    <td><?php echo date("M j, Y @ h:i A", strtotime($entry->execute_date)); ?></td>
                    <td><?php echo ucwords($sendto); ?></td>
                    <td><?php if ($entry->is_email): ?><img
                            src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif;?></td>
                    <td><?php if ($entry->is_system): ?><img
                            src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif;?></td>
                    <td>

                        <?php

                        if (strtotime($entry->execute_date) > current_time('timestamp')):?>
                        <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a>
                        | <a
                            href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>"
                            onclick="return confirm('Are you sure?');">delete</a></td>

                    <?php else: ?>
                        <a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a> |
                        <em>In progress....</em>
                    <?php endif; ?>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>


    <h3 class="table-caption">System Triggered Notifications</h3>
    <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;">
        <thead>
            <tr>
                <th scope="col" class="manage-column">Description</th>
                <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
                    <th scope="col" width="200" class="manage-column">Trigger/Slug</th>
                <?php endif; ?>

                <th scope="col" width="60" class="manage-column">Email</th>
                <th scope="col" width="60" class="manage-column">System</th>
                <th scope="col" width="200" class="manage-column">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($notifications['triggered'] as $entry): ?>
                <tr>
                    <td><?php echo $entry->post_title; ?></td>
                    <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
                        <td><?php echo $entry->trigger; ?></td>
                    <?php endif; ?>

                    <td><?php if ($entry->is_email): ?><img
                            src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif; ?></td>
                    <td><?php if ($entry->is_system): ?><img
                            src="<?php echo Tools\url('assets/images/accept.png', __FILE__) ?>" /><?php endif; ?></td>

                    <td><a href="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $entry->ID; ?>">edit</a>
                        <?php if (current_user_can(Settings\MANAGE_SYSTEM_NOTIFICATIONS)): ?>
                            | <a
                                href="/wp-admin/admin.php?page=notifications&action=delete&page_id=<?php echo $entry->ID; ?>"
                                onclick="return confirm('Are you sure?');">delete</a>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>


</div>