<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
global $configverssion_id; global $configapp_version; global $userID; global $server; global $LANG; $resellerID = getReseller();
//=== List page stuffs =============
$page = 1; $setLimit = 30;
if(isset($_GET["page"])) $page = (int)$_GET["page"];
$pageLimit = ($page * $setLimit) - $setLimit; 
$pageurl=$_SERVER['REQUEST_URI']."?";
if(count($_GET)) { $pageurl = $_SERVER['REQUEST_URI'].'&'; }
$trans = array("s=d_o" => "", "s=d_n" => "", "s=r_h" => "", "s=r_l" => "", "s=s_r" => "", "s=s_u" => "");
$pageurl = strtr($pageurl,$trans);
$pageurl = str_replace('&&','&',$pageurl);
//====End ==============
define('TITLE','Automation');
if(userRole()>1) {
	header('location: index.php');	
}
$today = date('Y-m-d'); $time = strtotime($today.'-1 months'); $lastMonth = date("Y-m", $time); $time = strtotime($today.'-1 years'); $lastYear = date("Y", $time);
?>
<?php
    $query="SELECT * FROM crons limit $pageLimit,$setLimit";
	$result = mysqli_query($server,$query) or die(mysqli_error($server));
	$x = mysqli_num_rows($result);
 ?>

<div class="row no-m-t no-m-b">
      <div class="col s12 m12 l12">
            <div class="card blue lighten-5 ">
                   <div class="card-content black-text"><?=$LANG['auto_tip']?><br>
            </div>
      </div>
</div>	
                          
	<div class="row no-m-t no-m-b">
       <div class="col s12 m12 l12">
         <div class="card card-white">
            <div class="card-content">
            <div class="card-options">
            </div>
            <span class="card-title"></span>
            <div class="row no-m-t no-m-b">
                  <div class="col s12 m12 l12">
                        <div class="card yellow lighten-5 ">
                               <div class="card-content black-text"><h5><?=$LANG['Customized Crons']?></h5>
							   <?=$LANG['cust_cron_tip0']?><?=$LANG['cust_cron_tip']?>
                               1, <a>wget -q -O /dev/null "<?=home_base_url()?>crons.php?delay=3" > /dev/null 2>&1 </a><br>
                               2, <a>wget -q -O /dev/null "<?=home_base_url()?>crons.php?customer_id=10" > /dev/null 2>&1 </a><br>
                               3, <a>wget -q -O /dev/null "<?=home_base_url()?>crons.php?gateway_id=3" > /dev/null 2>&1 </a>
                               <?=$LANG['cust_cron_tip2']?>
                        </div>
                  </div>
            </div>	

       		<table class="highlight responsive-table">
                <thead>
                	<tr>
                        <th data-field="to"><?=$LANG['Cron']?></th>
                        <th data-field="from"><?=$LANG['Command']?></th>
                        <th data-field="to"><?=$LANG['Frequency']?></th>
                    </tr>
                 </thead>
                 <tbody>
<?php $xf=0; while ($rows = mysqli_fetch_assoc($result)) { $xf+=1; ?>
						<tr class="">
                             <td><?=$rows['description']?></td>
                             <td>curl '<?=str_replace('/system/','',BASEPATH).'/'.$rows['location']?>'
                             <strong class="red-text"><br>OR<br></strong>
                             wget -q -O /dev/null "<?=home_base_url().''.$rows['location']?>" > /dev/null 2>&1
                             </td>
                             <td><?=$rows['period']?></td>
                        </tr>
<?php } ?>
<?php if($xf<1) echo '<tr class="orange lighten-5"><td colspan=10><h5 class="center-align">'.$LANG['No records found!'].'</h5></td></tr>' ?>	
                 </tbody>
            </table>  

          </div>
        </div>          
     </div>
  </div>
 <div class="row">
 	<div class="col s12 m12 l12" style="margin-top: 5px;">
        <?php displayPagination($setLimit,$page,$query);  ?>
    </div>
 </div>                       