<div class="wrap">
   <div id="smpush-icon-archive" class="icon32"><br></div>
   <h2><?php echo get_admin_page_title();?><a href="<?php echo esc_url($pageurl);?>&empty=1&noheader=1" class="smio-delete add-new-h2"><?php echo esc_html__('Delete All Campaigns', 'smio-push-notification')?></a><img src="<?php echo smpush_imgpath.'/wpspin_light.gif';?>" alt="" class="smpush_service_-1_loading" style="display:none" /></h2>
   <div id="col-container">
      <div id="col-left" style="width: 100%">
      <form action="<?php echo esc_url($pageurl);?>" method="get">
      <input type="hidden" name="page" value="<?php echo esc_attr($pagname);?>" />
      <input type="hidden" name="noheader" value="1" id="smpush-noheader-value" />
         <div class="col-wrap">
          <p class="search-box">
              <label class="screen-reader-text"><?php echo esc_html__('Search Messages:', 'smio-push-notification')?></label>
              <input type="search" name="query" value="<?php echo (!empty($_GET['query']))?$_GET['query']:'';?>">
              <input type="submit" id="search-submit" class="button" value="<?php echo esc_html__('Search Messages', 'smio-push-notification')?>">
           </p>
          <div class="tablenav top">
      		<div class="alignleft actions bulkactions">
                <select name="doaction">
                  <option value="0"><?php echo esc_html__('Bulk Actions', 'smio-push-notification')?></option>
                  <option value="delete"><?php echo esc_html__('Delete', 'smio-push-notification')?></option>
                  <option value="active"><?php echo esc_html__('Activate', 'smio-push-notification')?></option>
                  <option value="deactive"><?php echo esc_html__('Deactivate', 'smio-push-notification')?></option>
                </select>
                <input type="submit" name="apply" class="button action" value="<?php echo esc_html__('Apply', 'smio-push-notification')?>">
        	</div>
            <div class="alignleft actions smpush-canhide">
              <select name="type">
                <option value="0"><?php echo esc_html__('Show all types', 'smio-push-notification')?></option>
                <option value="now" <?php if($_GET['type'] == 'now'){?>selected="selected"<?php }?>><?php echo esc_html__('Instant', 'smio-push-notification')?></option>
                <option value="time" <?php if($_GET['type'] == 'time'){?>selected="selected"<?php }?>><?php echo esc_html__('Schedule', 'smio-push-notification')?></option>
                <option value="geofence" <?php if($_GET['type'] == 'geofence'){?>selected="selected"<?php }?>><?php echo esc_html__('Geo-Fence', 'smio-push-notification')?></option>
                <option value="template" <?php if($_GET['type'] == 'template'){?>selected="selected"<?php }?>><?php echo esc_html__('Template', 'smio-push-notification')?></option>
                <option value="custom" <?php if($_GET['type'] == 'custom'){?>selected="selected"<?php }?>><?php echo esc_html__('Auto Event', 'smio-push-notification')?></option>
                <option value="custom" <?php if($_GET['type'] == 'autoresponder'){?>selected="selected"<?php }?>><?php echo esc_html__('Auto Responder', 'smio-push-notification')?></option>
                <option value="feedback" <?php if($_GET['type'] == 'feedback'){?>selected="selected"<?php }?>><?php echo esc_html__('Feedback Log', 'smio-push-notification')?></option>
              </select>
              <select name="status">
                <option value="0"><?php echo esc_html__('Show all status', 'smio-push-notification')?></option>
                <option value="1" <?php if($_GET['status'] == 1) echo 'selected="selected"';?>><?php echo esc_html__('Active', 'smio-push-notification')?></option>
                <option value="2" <?php if($_GET['status'] == 2) echo 'selected="selected"';?>><?php echo esc_html__('Not Active', 'smio-push-notification')?></option>
              </select>
              <input type="text" name="query" placeholder="Query" value="<?php echo (!empty($_GET['query']))?$_GET['query']:'';?>">
              <input type="submit" id="post-query-submit" class="button" value="<?php echo esc_html__('Filter', 'smio-push-notification')?>">
            </div>
            <div class="tablenav-pages one-page"><span class="displaying-num"><?php echo self::$paging['result'];?> <?php echo esc_html__('items', 'smio-push-notification')?></span></div>
        	<br class="clear">
        	</div>
             <table class="wp-list-table widefat fixed tags" cellspacing="0" <?php if(get_bloginfo('version') < 3.8){?>style="table-layout: auto"<?php }?>>
                <thead>
                   <tr>
                      <th scope="col" id="cb" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-1"><?php echo esc_html__('Select All', 'smio-push-notification')?></label><input id="cb-select-all-1" type="checkbox"></th>
                      <th scope="col" class="manage-column" style="width:50px"><span><?php echo esc_html__('ID', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column"><span><?php echo esc_html__('Campaign', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column"><span><?php echo esc_html__('Message', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center" style="width:80px"><span><?php echo esc_html__('Type', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center" style="width:80px"><span><?php echo esc_html__('Repeat', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Start Time', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Last Finish Time', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center" style="width:50px"><span><?php echo esc_html__('Status', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column column-categories" style="width:250px"><?php echo esc_html__('Action', 'smio-push-notification')?><span></span></th>
                   </tr>
                </thead>
                <tfoot>
                   <tr>
                      <th scope="col" id="cb" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-1"><?php echo esc_html__('Select All', 'smio-push-notification')?></label><input id="cb-select-all-1" type="checkbox"></th>
                      <th scope="col" class="manage-column"><span><?php echo esc_html__('ID', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column"><span><?php echo esc_html__('Campaign', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column"><span><?php echo esc_html__('Message', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Type', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Repeat', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Start Time', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Last Finish Time', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column smpush-center"><span><?php echo esc_html__('Status', 'smio-push-notification')?></span></th>
                      <th scope="col" class="manage-column column-categories"><?php echo esc_html__('Action', 'smio-push-notification')?><span></span></th>
                   </tr>
                </tfoot>
                <tbody id="push-token-list">
                <?php if($archives){$counter = 0;foreach($archives AS $archive){$counter++;?>
                   <tr id="smpush-service-tab-<?php echo esc_attr($archive->id);?>" class="smpush-service-tab <?php if($counter%2 == 0){echo 'alternate';}?>">
                      <th scope="row" class="check-column">
                        <label class="screen-reader-text"></label>
                        <input type="checkbox" name="archive[]" value="<?php echo esc_attr($archive->id);?>">
                        <div class="locked-indicator"></div>
                      </th>
                      <td class="name column-name"><strong><?php echo esc_attr($archive->id);?></strong></td>
                      <td class="name column-name"><span title="<?php echo str_replace('"', '`', esc_attr($archive->name));?>"><?php echo self::ShortString(esc_attr($archive->name), 200);?></span></td>
                      <td class="name column-name"><span title="<?php echo str_replace('"', '`', esc_attr($archive->message));?>"><?php echo self::ShortString(esc_attr($archive->message), 200);?></span></td>
                      <td class="name column-name smpush-center">
                        <?php if(esc_attr($archive->send_type) == 'feedback'):?>
                        <?php echo esc_html__('Feedback Log', 'smio-push-notification')?>
                        <?php elseif(esc_attr($archive->send_type) == 'now' || esc_attr($archive->send_type) == 'live'):?>
                        <?php echo esc_html__('Instant', 'smio-push-notification')?>
                        <?php elseif(esc_attr($archive->send_type) == 'geofence'):?>
                        <?php echo esc_html__('Geo-Fence', 'smio-push-notification')?>
                        <?php elseif(esc_attr($archive->send_type) == 'time'):?>
                        <?php echo esc_html__('Schedule', 'smio-push-notification')?>
                        <?php elseif(esc_attr($archive->send_type) == 'autoresponder'):?>
                        <?php echo esc_html__('Auto Responder', 'smio-push-notification')?>
                        <?php elseif(esc_attr($archive->send_type) == 'template'):?>
                        <?php echo esc_html__('Template', 'smio-push-notification')?>
                        <?php elseif(esc_attr($archive->send_type) == 'custom'):?>
                        <?php echo esc_html__('Auto Event', 'smio-push-notification')?>
                        <?php endif;?>
                      </td>
                      <td class="name column-name smpush-center">
                        <?php if(esc_attr($archive->repeat_interval) > 0): echo esc_html__('Every', 'smio-push-notification').' '.esc_attr($archive->repeat_interval).' '.esc_attr($archive->repeat_age); endif;?>
                      </td>
                      <td class="name column-name smpush-center">
                        <?php if(in_array(esc_attr($archive->send_type), ['feedback','template'])):?>
                        <?php echo '--'?>
                        <?php elseif(esc_attr($archive->send_type) == 'autoresponder'):?>
                          <?php echo '#'.esc_attr($archive->resp_sort) ?>
                        <?php else: echo gmdate(self::$wpdateformat, strtotime(esc_attr($archive->starttime)));?>
                        <?php endif;?>
                      </td>
                      <td class="name column-name smpush-center">
                        <?php if(in_array(esc_attr($archive->send_type), ['feedback','template','autoresponder'])):?>
                        <?php echo '--'?>
                        <?php elseif(empty(esc_attr($archive->endtime))):?>
                        <?php echo esc_html__('Not finished yet', 'smio-push-notification')?>
                        <?php else: echo gmdate(self::$wpdateformat, strtotime(esc_attr($archive->endtime)));?>
                        <?php endif;?>
                      </td>
                      <td class="name column-name smpush-center">
                        <?php if(esc_attr($archive->status) == 1):?>
                        <?php echo esc_html__('Active', 'smio-push-notification')?>
                        <?php else:?>
                        <?php echo esc_html__('Not Active', 'smio-push-notification')?>
                        <?php endif;?>
                      </td>
                      <td class="description column-categories">
                        <?php if(esc_attr($archive->send_type) != 'feedback'):?>
                        <a href="<?php echo esc_url($pageurl);?>&action=reports&msgid=<?php echo esc_attr($archive->id);?>" class="button action"><?php echo esc_html__('Reports', 'smio-push-notification')?></a>
                        <a href="<?php echo esc_url($pageurl)?>&action=edit&id=<?php echo esc_attr($archive->id);?>" class="button action"><?php echo esc_html__('Edit', 'smio-push-notification')?></a>
                          <?php if(esc_attr($archive->send_type) != 'custom'):?>
                          <a href="<?php echo esc_url($pageurl)?>&action=clone&id=<?php echo esc_attr($archive->id);?>" class="button action"><?php echo esc_html__('Clone', 'smio-push-notification')?></a>
                          <?php endif;?>
                        <?php endif;?>
                        <input type="button" class="button action smpush-open-btn" value="<?php echo esc_html__('Delete', 'smio-push-notification')?>" onclick="smpush_delete_service(<?php echo esc_attr($archive->id);?>)" />
                        <img src="<?php echo smpush_imgpath.'/wpspin_light.gif';?>" alt="" class="smpush_service_<?php echo esc_attr($archive->id);?>_loading" style="display:none" />
                      </td>
                   </tr>
                <?php }}else{?>
                <tr class="no-items"><td class="colspanchange smpush-center" colspan="10"><?php echo esc_html__('No items found.', 'smio-push-notification')?></td></tr>
                <?php }?>
                </tbody>
             </table>
             <div class="tablenav bottom">
        		<div class="alignleft actions bulkactions">
                <select name="doaction2">
                  <option value="0"><?php echo esc_html__('Bulk Actions', 'smio-push-notification')?></option>
                  <option value="delete"><?php echo esc_html__('Delete', 'smio-push-notification')?></option>
                  <option value="active"><?php echo esc_html__('Activate', 'smio-push-notification')?></option>
                  <option value="deactive"><?php echo esc_html__('Deactivate', 'smio-push-notification')?></option>
                </select>
                <input type="submit" name="apply" class="button action" value="<?php echo esc_html__('Apply', 'smio-push-notification')?>">
            	</div>
                <div class="tablenav-pages"><span class="displaying-num"><?php echo self::$paging['result'];?> items</span>
                  <span class="pagination-links">
                  <?php echo paginate_links($paging_args);?>
                  </span>
                </div>
                <br class="clear">
                <p class="description smpush-canhide" style="color:red"><?php echo esc_html__('Notice: To use this feature first please enable the cron-job service, Look', 'smio-push-notification')?> <a href="https://smartiolabs.com/product/push-notification-system/documentation#cron-job" target="_blank"><?php echo esc_html__('here', 'smio-push-notification')?></a> <?php echo esc_html__('for further information', 'smio-push-notification')?></p>
             </div>
         </div>
      </form>
      </div>
   </div>
</div>
<script type="text/javascript">
var smpush_pageurl = '<?php echo esc_url($pageurl);?>';
</script>
