<?php
/**
 *
 * Copyright (C) 2007,2008  Arie Nugraha (dicarve@yahoo.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
/* by Heru Subekti,2014 (heroe_soebekti@yahoo.co.id)
/* Gammu application configuration */

// key to authenticate
define('INDEX_AUTH', '1');
// key to get full database access
define('DB_ACCESS', 'fa');

if (!defined('SB')) {
    // main system configuration
    require '../../../sysconfig.inc.php';
    // start the session
    require SB.'admin/default/session.inc.php';
}
// IP based access limitation
require LIB.'ip_based_access.inc.php';
do_checkIP('smc');
do_checkIP('smc-system');

// only administrator have privileges to change global settings
if ($_SESSION['uid'] != 1) {
    header('Location: '.MWB.'system/content.php');
    die();
}

require SB.'admin/default/session_check.inc.php';
require SIMBIO.'simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php';
require LIB.'gammu/config.inc.php';

if(isset($_POST['stop'])){
    $sms = new gammu();
    $status = $sms->stop();
    utility::jsAlert($status); //mfc
    echo '<script type="text/javascript">parent.$(\'#mainContent\').simbioAJAX(parent.$.ajaxHistory[0].url);</script>';
}

if(isset($_POST['start'])){
    $sms = new gammu();
    $status = $sms->start();
    utility::jsAlert('Gammu Service Installed'); //mfc
    echo '<script type="text/javascript">parent.$(\'#mainContent\').simbioAJAX(parent.$.ajaxHistory[0].url);</script>';
}
?>

<fieldset class="menuBox">
  <div class="menuBoxInner systemIcon">
    <div class="per_title">
      <h2><?php echo __('Gammu Service Configuration'); ?></h2>
    </div>
    <div class="infoBox">
      <?php echo __('Modify Gammu Service'); ?>   
    <div class="sub_section">
      <div class="btn-group">
        <?php
       $sms = new gammu();
        if($sms->status() == true){
            $msg = 'Gammu Service Running';
            echo '<a href="#" onclick="confSubmit(\'stopGammu\',\''.__('Stop Gammu Service?').'\')" class="notAJAX btn btn-default"><i class="glyphicon glyphicon-download"></i>&nbsp;'.__('Stop Gammu Service').'</a>';
            echo '<form action="'.MWB.'sms_gateway/index.php" id="stopGammu" target="blindSubmit" method="post" style="display: inline;"><input type="hidden" name="stop" value="true" /></form>';
        }else{
            $msg = 'Gammu Service Not Installed';
            echo '<a href="#" onclick="confSubmit(\'startGammu\',\''.__('Start Gammu Service?').'\')" class="notAJAX btn btn-default"><i class="glyphicon glyphicon-download"></i>&nbsp;'.__('Start Gammu Service').'</a>';
            echo '<form action="'.MWB.'sms_gateway/index.php" id="startGammu" target="blindSubmit" method="post" style="display: inline;"><input type="hidden" name="start" value="true" /></form>';
         }
    ?>
    </div>
  </div><?php echo $msg; ?>
</div>
</fieldset>
</body>
</html>
