<?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 =============
$pag = $page = 1; $setLimit = 20;
if(isset($_GET["page"])) $page = (int)$_GET["page"];
$pageLimit = ($page * $setLimit) - $setLimit; 
if(isset($_GET["pag"])) $pag = (int)$_GET["pag"];
$pageLimit2 = ($pag * $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" => "", "s=s_q" => "", "s=s_c" => "", "s=s_f" => "", "s=s_p" => "");
$pageurl = strtr($pageurl,$trans);
$pageurl = str_replace('&&','&',$pageurl);
//====End ==============
define('TITLE','Notice');

if(userRole()>2) {
	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
?>
<div class="row no-m-t no-m-b">
 	<div class="col s12 m12 l12">
        <div class="card light-blue darken-4">
            <div class="card-content white-text"><?=$LANG['push_note_int']?></div>
        </div>
    </div>
 </div>
<?php  ?> 

 
<div class="row no-m-t no-m-b">
	<div class="col s12">
            
      <h5><?=$LANG['Push Notifications']?></h5>
     
     <div class="card card-white">
            <div class="card-content">
                <form action="" method="post" id="push" onSubmit="return false;">
                	<div class="row no-m-t no-m-b">   
	                     <div class="col s12 m6 l6">
                         
                         	<div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="pushTitle" type="text" required class="validate" value="<?=getSetting('pushTitle',$userID)?>" maxlength="30">
                                       <label for="pushTitle"><?=$LANG['Heading (30 characters max)']?></label>
                                 </div>
                             </div>	 
                             
                             <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <select id="pushFor" required class="validate">
                                            <option value="0" <?php if(getSetting('pushFor',$userID)=='0') echo 'selected';?>><?=$LANG['All Users']?></option>
                                             <option value="1" <?php if(getSetting('pushFor',$userID)=='1') echo 'selected';?>><?=$LANG['Only Regular Customers']?></option>
                                            <option value="2" <?php if(getSetting('pushFor',$userID)=='2') echo 'selected';?>><?=$LANG['Only Resellers']?></option>
                                       </select>
                                       <label><?=$LANG['Show Notification for']?></label>
                                 </div>
                              </div>
                              
                             <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <select id="pushPages" required class="validate">
                                            <option value="all" <?php if(getSetting('pushPages',$userID)=='all') echo 'selected';?>><?=$LANG['All Pages']?></option>
                                            <option value="dashboard" <?php if(getSetting('pushPages',$userID)=='dashboard') echo 'selected';?>><?=$LANG['Dashboard Only']?></option>
                                       </select>
                                       <label><?=$LANG['Show Notification on']?></label>
                                 </div>
                              </div>
                              
                         </div>
                    
	                     <div class="col s12 m6 l6">
                         	 <div class="row no-m-t no-m-b">
                                <div class="input-field col s12">
                                      <textarea id="pushMessage" placeholder="<?=$LANG['Type your message here or leave empty to turn off push notification']?>" class="materialize-textarea"><?=getSetting('pushMessage',$userID)?></textarea>
                                </div>
                             </div>
                    	 </div>
                    </div>     
                    
                    <div class="row no-m-t no-m-b"> 
                     <div class="col s12 card-action">
                                <button id="push-button" class="btn green darken-4" type="submit"><i class="fa fa-save"></i> <?=$LANG['Save Changes']?> </button>
                                <span id="push-spin" class="btn-flat" style="display: none;"><i class="fa fa-spinner fa-spin"></i> <strong><?=$LANG['Please wait']?>...</strong></span>
                     </div>
                    </div> 
               </form>          
     </div>
</div>   
