<?php 
include ('includes/json_utils.php');
include ('includes/header.php');

$page_name = 'automation_settings';


if (isset($_POST['submit']) && isset($_POST['data'])) {
    foreach ($_POST['data'] as $id => $fields) {
        updateJsonRecordByIdMulty($id, $fields);
    }

    echo "<script>window.location.href='" . $page_name . ".php?status=1'</script>";
}


?>

<div class="col-md-6 mx-auto ctmain-table">
    <div class="card-body">
        <div class="card text-white ctcard">
            <div class="card-header card-header-warning">
                <center>
                    <h2><i class="icon icon-bullhorn"></i> Automation Settings</h2>
                </center>
            </div>
            
            <div class="card-body">
                <form method="post">
                    <div class="form-group ctinput">
                      <label class="form-label"> Auto-Update Live,Movies & Series :</label>
                      <input type="hidden" name="data[14][preffile]" value="automation_channels">
                      <input type="hidden" name="data[14][preftype]" value="string">
                      <input type="hidden" name="data[14][prefname]" value="automation_channels">
                      <select name="data[14][mods]">
                        <option value="checked" <?php echo (getmodsbyid('14') == 'checked') ? 'selected' : ''; ?>>Enable</option>
                        <option value="unchecked" <?php echo (getmodsbyid('14') == 'unchecked') ? 'selected' : ''; ?>>Disable</option>
                      </select>
                    </div>


                    <div class="form-group ctinput">
                      <label class="form-label"> Auto-Update Live,Movies & Series after every :</label>
                      <input type="hidden" name="data[15][preffile]" value="automation_channels">
                      <input type="hidden" name="data[15][preftype]" value="int">
                      <input type="hidden" name="data[15][prefname]" value="automation_channels_days">
                      <select name="data[15][mods]">
                        <option value="1" <?php echo (getmodsbyid('15') == '1') ? 'selected' : ''; ?>>1 Day(s)</option>
                        <option value="2" <?php echo (getmodsbyid('15') == '2') ? 'selected' : ''; ?>>2 Day(s)</option>
                        <option value="3" <?php echo (getmodsbyid('15') == '3') ? 'selected' : ''; ?>>3 Day(s)</option>
                        <option value="4" <?php echo (getmodsbyid('15') == '4') ? 'selected' : ''; ?>>4 Day(s)</option>
                        <option value="5" <?php echo (getmodsbyid('15') == '5') ? 'selected' : ''; ?>>5 Day(s)</option>
                        <option value="6" <?php echo (getmodsbyid('15') == '6') ? 'selected' : ''; ?>>6 Day(s)</option>
                        <option value="7" <?php echo (getmodsbyid('15') == '7') ? 'selected' : ''; ?>>7 Day(s)</option>
                      </select>
                    </div>



                    <div class="form-group ctinput">
                      <label class="form-label"> Auto-Update EPG :</label>
                      <input type="hidden" name="data[16][preffile]" value="automation_epg">
                      <input type="hidden" name="data[16][preftype]" value="string">
                      <input type="hidden" name="data[16][prefname]" value="automation_epg">
                      <select name="data[16][mods]">
                        <option value="checked" <?php echo (getmodsbyid('16') == 'checked') ? 'selected' : ''; ?>>Enable</option>
                        <option value="unchecked" <?php echo (getmodsbyid('16') == 'unchecked') ? 'selected' : ''; ?>>Disable</option>
                      </select>
                    </div>


                    <div class="form-group ctinput">
                      <label class="form-label"> Auto-Update EPG after every :</label>
                      <input type="hidden" name="data[17][preffile]" value="automation_epg">
                      <input type="hidden" name="data[17][preftype]" value="int">
                      <input type="hidden" name="data[17][prefname]" value="automation_epg_days">
                      <select name="data[17][mods]">
                        <option value="1" <?php echo (getmodsbyid('17') == '1') ? 'selected' : ''; ?>>1 Day(s)</option>
                        <option value="2" <?php echo (getmodsbyid('17') == '2') ? 'selected' : ''; ?>>2 Day(s)</option>
                        <option value="3" <?php echo (getmodsbyid('17') == '3') ? 'selected' : ''; ?>>3 Day(s)</option>
                        <option value="4" <?php echo (getmodsbyid('17') == '4') ? 'selected' : ''; ?>>4 Day(s)</option>
                        <option value="5" <?php echo (getmodsbyid('17') == '5') ? 'selected' : ''; ?>>5 Day(s)</option>
                        <option value="6" <?php echo (getmodsbyid('17') == '6') ? 'selected' : ''; ?>>6 Day(s)</option>
                        <option value="7" <?php echo (getmodsbyid('17') == '7') ? 'selected' : ''; ?>>7 Day(s)</option>
                      </select>
                    </div>
                    

                    <div class="form-group ctinputform-group">
                        <center>
                            <button class="btn btn-info" name="submit" type="submit">
                                <i class="icon icon-check"></i> Submit
                            </button>
                        </center>
                    </div>
                </form>
            </div>       
        </div>
    </div>
</div>

<?php include ('includes/footer.php');?>
