Commit bdf66d49 authored by Franco Fichtner's avatar Franco Fichtner

firewall: pimp schedule layout

parent a818fb3f
...@@ -114,33 +114,32 @@ $main_buttons = array( ...@@ -114,33 +114,32 @@ $main_buttons = array(
<div class="row"> <div class="row">
<?php if (isset($savemsg)) print_info_box($savemsg); ?> <?php if (isset($savemsg)) print_info_box($savemsg); ?>
<section class="col-xs-12"> <section class="col-xs-12">
<div class="content-box content-box-main "> <div class="content-box tab-content">
<form action="firewall_schedule.php" method="post" name="iform" id="iform"> <form action="firewall_schedule.php" method="post" name="iform" id="iform">
<input type="hidden" id="id" name="id" value="" /> <input type="hidden" id="id" name="id" value="" />
<input type="hidden" id="action" name="act" value="" /> <input type="hidden" id="action" name="act" value="" />
<div class="table-responsive"> <table class="table table-striped">
<table class="table table-striped"> <thead>
<thead> <tr>
<tr> <td><?=gettext("Name");?></td>
<td><?=gettext("Name");?></td> <td><?=gettext("Time Range(s)");?></td>
<td><?=gettext("Time Range(s)");?></td> <td><?=gettext("Description");?></td>
<td><?=gettext("Description");?></td> <td></td>
<td></td> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <?php $i = 0; foreach ($a_schedules as $schedule): ?>
<?php $i = 0; foreach ($a_schedules as $schedule): ?> <tr ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';">
<tr ondblclick="document.location='firewall_schedule_edit.php?id=<?=$i;?>';"> <td>
<td> <?=$schedule['name'];?>
<?=$schedule['name'];?>
<?php <?php
if (filter_get_time_based_rule_status($schedule)):?> if (filter_get_time_based_rule_status($schedule)):?>
<span data-toggle="tooltip" title="<?=gettext("Schedule is currently active");?>" class="fa fa-clock-o"></span> <span data-toggle="tooltip" title="<?=gettext("Schedule is currently active");?>" class="fa fa-clock-o"></span>
<?php <?php
endif;?> endif;?>
</td> </td>
<td> <td>
<table class="table table-condensed table-striped"> <table class="table table-condensed table-striped">
<?php <?php
foreach($schedule['timerange'] as $timerange) { foreach($schedule['timerange'] as $timerange) {
$firstprint = false; $firstprint = false;
...@@ -227,32 +226,32 @@ $main_buttons = array( ...@@ -227,32 +226,32 @@ $main_buttons = array(
?><tr><td><?=$dayFriendly;?></td><td><?=$timeFriendly;?></td><td><?=$description;?></td></tr><?php ?><tr><td><?=$dayFriendly;?></td><td><?=$timeFriendly;?></td><td><?=$description;?></td></tr><?php
} }
}//end for?></table> }//end for?></table>
</td> </td>
<td> <td>
<?=$schedule['descr'];?> <?=$schedule['descr'];?>
</td> </td>
<td> <td>
<a href="firewall_schedule_edit.php?id=<?=$i;?>" data-toggle="tooltip" title="<?=gettext("edit schedule");?>" class="btn btn-default btn-xs"> <a href="firewall_schedule_edit.php?id=<?=$i;?>" data-toggle="tooltip" title="<?=gettext("edit schedule");?>" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-pencil"></span> <span class="glyphicon glyphicon-pencil"></span>
</a> </a>
<a id="del_<?=$i;?>" title="<?=gettext("delete schedule"); ?>" data-toggle="tooltip" class="act_delete btn btn-default btn-xs"> <a id="del_<?=$i;?>" title="<?=gettext("delete schedule"); ?>" data-toggle="tooltip" class="act_delete btn btn-default btn-xs">
<span class="fa fa-trash text-muted"></span> <span class="fa fa-trash text-muted"></span>
</a> </a>
<a href="firewall_schedule.php?dup=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("clone schedule");?>"> <a href="firewall_schedule.php?dup=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("clone schedule");?>">
<span class="fa fa-clone text-muted"></span> <span class="fa fa-clone text-muted"></span>
</a> </a>
</td> </td>
</tr> </tr>
<?php <?php
$i++; $i++;
endforeach; ?> endforeach; ?>
</tbody> <tr>
</table> <td colspan="4">
</div> <?=gettext("Schedules act as placeholders for time ranges to be used in Firewall Rules.");?>
<div class="container-fluid"> </td>
<span class="text-danger"><strong><?=gettext("Note:");?><br /></strong></span> </tr>
<?=gettext("Schedules act as placeholders for time ranges to be used in Firewall Rules.");?> </tbody>
</div> </table>
</form> </form>
</div> </div>
</section> </section>
......
...@@ -780,58 +780,57 @@ function removeRow(el) { ...@@ -780,58 +780,57 @@ function removeRow(el) {
<div class="row"> <div class="row">
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
<div class="content-box content-box-main"> <div class="content-box tab-content">
<form action="firewall_schedule_edit.php" method="post" name="iform" id="iform"> <form action="firewall_schedule_edit.php" method="post" name="iform" id="iform">
<input type="hidden" name="schedlabel" value="<?=$pconfig['schedlabel'];?>"/> <input type="hidden" name="schedlabel" value="<?=$pconfig['schedlabel'];?>"/>
<div class="table-responsive"> <table class="table table-striped">
<table class="table table-striped"> <tbody>
<tbody> <tr>
<tr> <td width="15%"><strong><?=gettext("Schedule information");?></strong></td>
<td width="15%"><strong><?=gettext("Schedule information");?></strong></td> <td width="85%" align="right">
<td width="85%" align="right"> <small><?=gettext("full help"); ?> </small>
<small><?=gettext("full help"); ?> </small> <i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i> </td>
</td> </tr>
</tr> <tr>
<tr> <td><a id="help_for_name" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Schedule Name");?></td>
<td><a id="help_for_name" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Schedule Name");?></td> <td>
<td>
<?php <?php
if(is_schedule_inuse($pconfig['name']) == true):?> if(is_schedule_inuse($pconfig['name']) == true):?>
<input name="name" type="hidden" id="name" value="<?=htmlspecialchars($pconfig['name']);?>" /> <input name="name" type="hidden" id="name" value="<?=htmlspecialchars($pconfig['name']);?>" />
<?=$pconfig['name']; ?> <?=$pconfig['name']; ?>
<p> <p>
<?=gettext("NOTE: This schedule is in use so the name may not be modified!");?> <?=gettext("NOTE: This schedule is in use so the name may not be modified!");?>
</p> </p>
<?php <?php
else: ?> else: ?>
<input name="name" type="text" id="name" value="<?=$pconfig['name'];?>" /> <input name="name" type="text" id="name" value="<?=$pconfig['name'];?>" />
<div class="hidden" for="help_for_name"> <div class="hidden" for="help_for_name">
<?=gettext("The name of the alias may only consist of the characters a-z, A-Z and 0-9");?> <?=gettext("The name of the alias may only consist of the characters a-z, A-Z and 0-9");?>
</div> </div>
<?php <?php
endif; ?> endif; ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_description" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description");?></td> <td><a id="help_for_description" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Description");?></td>
<td> <td>
<input name="descr" type="text" id="descr" value="<?=$pconfig['descr'];?>" /><br /> <input name="descr" type="text" id="descr" value="<?=$pconfig['descr'];?>" /><br />
<div class="hidden" for="help_for_name"> <div class="hidden" for="help_for_name">
<?=gettext("You may enter a description here for your reference (not parsed).");?> <?=gettext("You may enter a description here for your reference (not parsed).");?>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_month" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Month");?></td> <td><a id="help_for_month" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Month");?></td>
<td> <td>
<select name="monthsel" class="selectpicker" data-width="auto" data-live-search="true" id="monthsel" onchange="update_month();"> <select name="monthsel" class="selectpicker" data-width="auto" data-live-search="true" id="monthsel" onchange="update_month();">
<?php <?php
$monthcounter = date("n"); $monthcounter = date("n");
$monthlimit = $monthcounter + 12; $monthlimit = $monthcounter + 12;
$yearcounter = date("Y"); $yearcounter = date("Y");
for ($k=0; $k<12; $k++){?> for ($k=0; $k<12; $k++){?>
<option value="<?= $monthcounter;?>"><?=date("F_y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></option> <option value="<?= $monthcounter;?>"><?=date("F_y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></option>
<?php <?php
if ($monthcounter == 12) { if ($monthcounter == 12) {
$monthcounter = 1; $monthcounter = 1;
...@@ -840,8 +839,8 @@ function removeRow(el) { ...@@ -840,8 +839,8 @@ function removeRow(el) {
$monthcounter++; $monthcounter++;
} }
} ?> } ?>
</select> </select>
<br /><br /> <br /><br />
<?php <?php
$firstmonth = TRUE; $firstmonth = TRUE;
$monthcounter = date("n"); $monthcounter = date("n");
...@@ -858,21 +857,21 @@ function removeRow(el) { ...@@ -858,21 +857,21 @@ function removeRow(el) {
$lasttr = FALSE; $lasttr = FALSE;
$positioncounter = 1;//7 for Sun, 1 for Mon, 2 for Tues, etc $positioncounter = 1;//7 for Sun, 1 for Mon, 2 for Tues, etc
?> ?>
<div id="<?=date("F_y",mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?>" style=" position:relative; display:<?= $firstmonth ? "block" : "none";?>"> <div id="<?=date("F_y",mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?>" style=" position:relative; display:<?= $firstmonth ? "block" : "none";?>">
<table border="1" cellspacing="1" cellpadding="1" id="calTable<?=$monthcounter . $yearcounter;?>" class="table table-condensed" summary="month"> <table border="1" cellspacing="1" cellpadding="1" id="calTable<?=$monthcounter . $yearcounter;?>" class="table table-condensed" summary="month">
<thead> <thead>
<tr><td colspan="7" align="center"><?= date("F_Y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></td></tr> <tr><td colspan="7" align="center"><?= date("F_Y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></td></tr>
<tr> <tr>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p1');"><u><?=gettext("Mon");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p1');"><u><?=gettext("Mon");?></u></td>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p2');"><u><?=gettext("Tue");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p2');"><u><?=gettext("Tue");?></u></td>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p3');"><u><?=gettext("Wed");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p3');"><u><?=gettext("Wed");?></u></td>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p4');"><u><?=gettext("Thu");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p4');"><u><?=gettext("Thu");?></u></td>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p5');"><u><?=gettext("Fri");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p5');"><u><?=gettext("Fri");?></u></td>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p6');"><u><?=gettext("Sat");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p6');"><u><?=gettext("Sat");?></u></td>
<td align="center" style="cursor: pointer;" onclick="daytoggle('w1p7');"><u><?=gettext("Sun");?></u></td> <td align="center" style="cursor: pointer;" onclick="daytoggle('w1p7');"><u><?=gettext("Sun");?></u></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$firstmonth = FALSE; $firstmonth = FALSE;
while ($daycounter<=$numberofdays){ while ($daycounter<=$numberofdays){
...@@ -888,7 +887,7 @@ function removeRow(el) { ...@@ -888,7 +887,7 @@ function removeRow(el) {
$firstdayprinted = TRUE; $firstdayprinted = TRUE;
echo "</td>"; echo "</td>";
} elseif ($firstdayprinted == TRUE && $daycounter <= $numberofdays){?> } elseif ($firstdayprinted == TRUE && $daycounter <= $numberofdays){?>
<td align="center" style="cursor: pointer;" class="listr" id="w<?=$weekcounter;?>p<?=$positioncounter;?>" onclick="daytoggle('w<?=$weekcounter;?>p<?=$positioncounter;?>-m<?=$monthcounter;?>d<?=$daycounter;?>');"> <td align="center" style="cursor: pointer;" class="listr" id="w<?=$weekcounter;?>p<?=$positioncounter;?>" onclick="daytoggle('w<?=$weekcounter;?>p<?=$positioncounter;?>-m<?=$monthcounter;?>d<?=$daycounter;?>');">
<?php echo $daycounter; <?php echo $daycounter;
$daycounter++; $daycounter++;
echo "</td>"; echo "</td>";
...@@ -903,9 +902,9 @@ function removeRow(el) { ...@@ -903,9 +902,9 @@ function removeRow(el) {
$positioncounter++; $positioncounter++;
} }
}//end while loop?> }//end while loop?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
if ($monthcounter == 12) { if ($monthcounter == 12) {
$monthcounter = 1; $monthcounter = 1;
...@@ -915,262 +914,251 @@ function removeRow(el) { ...@@ -915,262 +914,251 @@ function removeRow(el) {
} }
} //end for loop } //end for loop
?> ?>
<div class="hidden" for="help_for_month"> <div class="hidden" for="help_for_month">
<br /> <br />
<?=gettext("Click individual date to select that date only. Click the appropriate weekday Header to select all occurrences of that weekday.");?> <?=gettext("Click individual date to select that date only. Click the appropriate weekday Header to select all occurrences of that weekday.");?>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_time" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Time");?></td> <td><a id="help_for_time" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Time");?></td>
<td> <td>
<table cellspacing="2" class="tabcont" summary="time"> <table cellspacing="2" class="tabcont" summary="time">
<tr> <tr>
<td><?=gettext("Start Time");?></td> <td><?=gettext("Start Time");?></td>
<td><?=gettext("Stop Time");?></td> <td><?=gettext("Stop Time");?></td>
</tr> </tr>
<tr> <tr>
<td> <td>
<div class="input-group"> <div class="input-group">
<select name="starttimehour" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="starttimehour"> <select name="starttimehour" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="starttimehour">
<?php <?php
for ($i=0; $i<24; $i++):?> for ($i=0; $i<24; $i++):?>
<option value="<?=$i;?>"><?=$i;?> </option> <option value="<?=$i;?>"><?=$i;?> </option>
<?php <?php
endfor; ?> endfor; ?>
</select> </select>
<select name="starttimemin" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="starttimemin"> <select name="starttimemin" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="starttimemin">
<option value="00">00</option> <option value="00">00</option>
<option value="15">15</option> <option value="15">15</option>
<option value="30">30</option> <option value="30">30</option>
<option value="45">45</option> <option value="45">45</option>
<option value="59">59</option> <option value="59">59</option>
</select> </select>
</div> </div>
</td> </td>
<td> <td>
<div class="input-group"> <div class="input-group">
<select name="stoptimehour" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="stoptimehour"> <select name="stoptimehour" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="stoptimehour">
<?php <?php
for ($i=0; $i<24; $i++):?> for ($i=0; $i<24; $i++):?>
<option value="<?=$i;?>"><?=$i;?> </option> <option value="<?=$i;?>"><?=$i;?> </option>
<?php <?php
endfor; ?> endfor; ?>
</select> </select>
<select name="stoptimemin" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="stoptimemin"> <select name="stoptimemin" class="selectpicker form-control" data-width="auto" data-size="5" data-live-search="true" id="stoptimemin">
<option value="00">00</option> <option value="00">00</option>
<option value="15">15</option> <option value="15">15</option>
<option value="30">30</option> <option value="30">30</option>
<option value="45">45</option> <option value="45">45</option>
<option value="59" selected="selected">59</option> <option value="59" selected="selected">59</option>
</select> </select>
</div> </div>
</td> </td>
</tr>
</table>
<div class="hidden" for="help_for_time">
<br />
<?=gettext("Select the time range for the day(s) selected on the Month(s) above. A full day is 0:00-23:59.")?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_timerange_desc" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Time Range Description")?></td>
<td>
<input name="timerangedescr" type="text" id="timerangedescr"/>
<div class="hidden" for="help_for_timerange_desc">
<?=gettext("You may enter a description here for your reference (not parsed).")?>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="button" value="<?=gettext("Add Time");?>" class="btn btn-default" onclick="javascript:processEntries();" />&nbsp;&nbsp;&nbsp;
<input type="button" value="<?=gettext("Clear Selection");?>" class="btn btn-default" onclick="javascript:clearCalendar(); clearTime(); clearDescr();" />
</td>
</tr>
<tr>
<th colspan="2" valign="top" class="listtopic"><?=gettext("Schedule repeat");?></td>
</tr>
<tr>
<td><?=gettext("Configured Ranges");?></td>
<td>
<table id="scheduletable" summary="range">
<tbody>
<tr>
<td width="35%"><?=gettext("Day(s)");?></td>
<td width="12%"><?=gettext("Start Time");?></td>
<td width="11%"><?=gettext("Stop Time");?></td>
<td width="42%"><?=gettext("Description");?></td>
</tr> </tr>
</table> <?php
<div class="hidden" for="help_for_time"> if (isset($pconfig['timerange'])){
<br /> $counter = 0;
<?=gettext("Select the time range for the day(s) selected on the Month(s) above. A full day is 0:00-23:59.")?> foreach($pconfig['timerange'] as $timerange) {
</div> $tempFriendlyTime = "";
</td> $tempID = "";
</tr> if ($timerange){
<tr> $dayFriendly = "";
<td><a id="help_for_timerange_desc" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Time Range Description")?></td>
<td>
<input name="timerangedescr" type="text" id="timerangedescr"/>
<div class="hidden" for="help_for_timerange_desc">
<?=gettext("You may enter a description here for your reference (not parsed).")?>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="button" value="<?=gettext("Add Time");?>" class="btn btn-default" onclick="javascript:processEntries();" />&nbsp;&nbsp;&nbsp;
<input type="button" value="<?=gettext("Clear Selection");?>" class="btn btn-default" onclick="javascript:clearCalendar(); clearTime(); clearDescr();" />
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<table class="table table-striped">
<thead>
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("Schedule repeat");?></td>
</tr>
</thead>
<tbody>
<tr>
<td><?=gettext("Configured Ranges");?></td>
<td>
<table id="scheduletable" summary="range">
<tbody>
<tr>
<td width="35%"><?=gettext("Day(s)");?></td>
<td width="12%"><?=gettext("Start Time");?></td>
<td width="11%"><?=gettext("Stop Time");?></td>
<td width="42%"><?=gettext("Description");?></td>
</tr>
<?php
if (isset($pconfig['timerange'])){
$counter = 0;
foreach($pconfig['timerange'] as $timerange) {
$tempFriendlyTime = ""; $tempFriendlyTime = "";
$tempID = ""; $timedescr = $timerange['rangedescr'];
if ($timerange){ //get hours
$dayFriendly = ""; $temptimerange = $timerange['hour'];
$tempFriendlyTime = ""; $temptimeseparator = strrpos($temptimerange, "-");
$timedescr = $timerange['rangedescr'];
//get hours $starttime = substr ($temptimerange, 0, $temptimeseparator);
$temptimerange = $timerange['hour']; $stoptime = substr ($temptimerange, $temptimeseparator+1);
$temptimeseparator = strrpos($temptimerange, "-"); $currentDay = "";
$firstDay = "";
$starttime = substr ($temptimerange, 0, $temptimeseparator); $nextDay = "";
$stoptime = substr ($temptimerange, $temptimeseparator+1); $foundEnd = false;
$currentDay = ""; $firstDayFound = false;
$firstDay = ""; $firstPrint = false;
$nextDay = ""; $firstprint2 = false;
$foundEnd = false;
$firstDayFound = false; if (!empty($timerange['month'])){
$firstPrint = false; $tempmontharray = explode(",", $timerange['month']);
$firstprint2 = false; $tempdayarray = explode(",",$timerange['day']);
$arraycounter = 0;
if (!empty($timerange['month'])){ foreach ($tempmontharray as $monthtmp){
$tempmontharray = explode(",", $timerange['month']); $month = $tempmontharray[$arraycounter];
$tempdayarray = explode(",",$timerange['day']); $day = $tempdayarray[$arraycounter];
$arraycounter = 0; $daypos = date("w", mktime(0, 0, 0, date($month), date($day), date("Y")));
foreach ($tempmontharray as $monthtmp){ //if sunday, set position to 7 to get correct week number. This is due to php limitations on ISO-8601. When we move to php5.1 we can change this.
$month = $tempmontharray[$arraycounter]; if ($daypos == 0){
$day = $tempdayarray[$arraycounter]; $daypos = 7;
$daypos = date("w", mktime(0, 0, 0, date($month), date($day), date("Y"))); }
//if sunday, set position to 7 to get correct week number. This is due to php limitations on ISO-8601. When we move to php5.1 we can change this. $weeknumber = date("W", mktime(0, 0, 0, date($month), date($day), date("Y")));
if ($daypos == 0){ $weeknumber = ltrim($weeknumber, "0");
$daypos = 7; if ($firstPrint) {
$tempID .= ",";
}
$tempID .= "w" . $weeknumber . "p" . $daypos . "-m" . $month . "d" . $day;
$firstPrint = true;
if (!$firstDayFound) {
$firstDay = $day;
$firstmonth = $month;
$firstDayFound = true;
}
$currentDay = $day;
$nextDay = $tempdayarray[$arraycounter+1];
$currentDay++;
if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
if ($firstprint2) {
$tempFriendlyTime .= ", ";
} }
$weeknumber = date("W", mktime(0, 0, 0, date($month), date($day), date("Y"))); $currentDay--;
$weeknumber = ltrim($weeknumber, "0"); if ($currentDay != $firstDay) {
if ($firstPrint) { $tempFriendlyTime .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
$tempID .= ","; } else {
$tempFriendlyTime .= $monthArray[$month-1] . " " . $day;
} }
$tempID .= "w" . $weeknumber . "p" . $daypos . "-m" . $month . "d" . $day; $firstDayFound = false;
$firstPrint = true; $firstprint2 = true;
}
$arraycounter++;
}
} else {
$dayFriendly = $timerange['position'];
$tempID = $dayFriendly;
}
$tempTime = $tempID . "||" . $starttime . "-" . $stoptime . "||" . $timedescr;
//following code makes the days friendly appearing, IE instead of Mon, Tues, Wed it will show Mon - Wed
$foundEnd = false;
$firstDayFound = false;
$firstprint = false;
$tempFriendlyDayArray = explode(",", $dayFriendly);
$currentDay = "";
$firstDay = "";
$nextDay = "";
$i = 0;
if (empty($timerange['month'])) {
foreach ($tempFriendlyDayArray as $day){
if ($day != ""){
if (!$firstDayFound) { if (!$firstDayFound) {
$firstDay = $day; $firstDay = $tempFriendlyDayArray[$i];
$firstmonth = $month;
$firstDayFound = true; $firstDayFound = true;
} }
$currentDay =$tempFriendlyDayArray[$i];
$currentDay = $day; //get next day
$nextDay = $tempdayarray[$arraycounter+1]; $nextDay = $tempFriendlyDayArray[$i+1];
$currentDay++; $currentDay++;
if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){ if ($currentDay != $nextDay){
if ($firstprint2) { if ($firstprint){
$tempFriendlyTime .= ", "; $tempFriendlyTime .= ", ";
} }
$currentDay--; $currentDay--;
if ($currentDay != $firstDay) { if ($currentDay != $firstDay) {
$tempFriendlyTime .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ; $tempFriendlyTime .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
} else { } else {
$tempFriendlyTime .= $monthArray[$month-1] . " " . $day; $tempFriendlyTime .= $dayArray[$firstDay-1];
} }
$firstDayFound = false; $firstDayFound = false;
$firstprint2 = true; $firstprint = true;
}
$arraycounter++;
}
} else {
$dayFriendly = $timerange['position'];
$tempID = $dayFriendly;
}
$tempTime = $tempID . "||" . $starttime . "-" . $stoptime . "||" . $timedescr;
//following code makes the days friendly appearing, IE instead of Mon, Tues, Wed it will show Mon - Wed
$foundEnd = false;
$firstDayFound = false;
$firstprint = false;
$tempFriendlyDayArray = explode(",", $dayFriendly);
$currentDay = "";
$firstDay = "";
$nextDay = "";
$i = 0;
if (empty($timerange['month'])) {
foreach ($tempFriendlyDayArray as $day){
if ($day != ""){
if (!$firstDayFound) {
$firstDay = $tempFriendlyDayArray[$i];
$firstDayFound = true;
}
$currentDay =$tempFriendlyDayArray[$i];
//get next day
$nextDay = $tempFriendlyDayArray[$i+1];
$currentDay++;
if ($currentDay != $nextDay){
if ($firstprint){
$tempFriendlyTime .= ", ";
}
$currentDay--;
if ($currentDay != $firstDay) {
$tempFriendlyTime .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
} else {
$tempFriendlyTime .= $dayArray[$firstDay-1];
}
$firstDayFound = false;
$firstprint = true;
}
$i++;
} }
$i++;
} }
} }
}
?> ?>
<tr> <tr>
<td> <td>
<span><?=$tempFriendlyTime; ?></span> <span><?=$tempFriendlyTime; ?></span>
</td> </td>
<td> <td>
<input type='text' readonly='readonly' name='starttime<?=$counter; ?>' id='starttime<?=$counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?=$starttime; ?>' /> <input type='text' readonly='readonly' name='starttime<?=$counter; ?>' id='starttime<?=$counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?=$starttime; ?>' />
</td> </td>
<td> <td>
<input type='text' readonly='readonly' name='stoptime<?=$counter; ?>' id='stoptime<?=$counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?=$stoptime; ?>' /> <input type='text' readonly='readonly' name='stoptime<?=$counter; ?>' id='stoptime<?=$counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?=$stoptime; ?>' />
</td> </td>
<td> <td>
<input type='text' readonly='readonly' name='timedescr<?=$counter; ?>' id='timedescr<?=$counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?=$timedescr; ?>' /> <input type='text' readonly='readonly' name='timedescr<?=$counter; ?>' id='timedescr<?=$counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?=$timedescr; ?>' />
</td> </td>
<td> <td>
<a onclick='editRow("<?=$tempTime; ?>",this); return false;' href='#' class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a> <a onclick='editRow("<?=$tempTime; ?>",this); return false;' href='#' class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
</td> </td>
<td> <td>
<a onclick='removeRow(this); return false;' href='#' class="btn btn-default"><span class="fa fa-trash text-muted"></span></a> <a onclick='removeRow(this); return false;' href='#' class="btn btn-default"><span class="fa fa-trash text-muted"></span></a>
</td> </td>
<td> <td>
<input type='hidden' id='schedule<?=$counter; ?>' name='schedule<?=$counter; ?>' value='<?=$tempID; ?>' /> <input type='hidden' id='schedule<?=$counter; ?>' name='schedule<?=$counter; ?>' value='<?=$tempID; ?>' />
</td> </td>
</tr> </tr>
<?php <?php
$counter++; $counter++;
}//end if }//end if
} // end foreach } // end foreach
}//end if }//end if
?> ?>
</tbody> </tbody>
</table> </table>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<input id="submit" name="submit" type="submit" onclick="return checkForRanges();" class="btn btn-primary" value="<?=gettext("Save"); ?>" /> <input id="submit" name="submit" type="submit" onclick="return checkForRanges();" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firewall_schedule.php');?>'" /> <input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firewall_schedule.php');?>'" />
<?php if (isset($id)): ?> <?php if (isset($id)): ?>
<input name="id" type="hidden" value="<?=$id;?>" /> <input name="id" type="hidden" value="<?=$id;?>" />
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
</form> </form>
</div> </div>
</section> </section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment