Exemple #1
0
//Usage
$timeconditions_refs = daynight_list_timecondition($itemid);
if (!empty($timeconditions_refs)) {
    foreach ($timeconditions_refs as $ref) {
        $dmode = $ref['dmode'] == 'timeday' ? _("Forces to Normal Mode (Green/BLF off)") : _("Forces to Override Mode (Red/BLF on)");
        $timecondition_id = $ref['dest'];
        $tcURL = $_SERVER['PHP_SELF'] . '?' . "display=timeconditions&itemid={$timecondition_id}";
        $label = sprintf(_("Linked to Time Condition %s - %s"), $timecondition_id, $dmode);
        $reflist .= '<li><i class="fa fa-clock-o"></i> <a href="' . $tcURL . '">' . $label . '</a></li>';
    }
    $refhtml = '<div class="well well-info">';
    $refhtml .= '<h4>' . _("Time Condition Reference") . '</h4>';
    $refhtml .= '<ul>' . $reflist . '</ul>';
    $refhtml .= '</div>';
}
$usage_list = framework_display_destination_usage(daynight_getdest($itemid));
if (!empty($usage_list)) {
    $usehtml = '<div class="well well-info">';
    $usehtml .= '<h4>' . $usage_list['text'] . '</h4>';
    $usehtml .= '<p>' . $usage_list['tooltip'] . '</p>';
    $usehtml .= '</div>';
}
?>

<?php 
echo !empty($usehtml) ? $usehtml : "";
echo !empty($refhtml) ? $refhtml : "";
?>

<form name="prompt" id="prompt" class="fpbx-submit" action="?display=daynight" method="post" onsubmit="return prompt_onsubmit();" data-fpbx-delete="?display=daynight&itemid=<?php 
echo $itemid;
Exemple #2
0
function daynight_show_edit($post, $add = "")
{
    global $db;
    global $itemid;
    $fcc = new featurecode('daynight', 'toggle-mode-' . $itemid);
    $code = $fcc->getCodeActive();
    unset($fcc);
    $dests = daynight_get_obj($itemid);
    $password = isset($dests['password']) ? $dests['password'] : '';
    $fc_description = isset($dests['fc_description']) ? $dests['fc_description'] : '';
    $state = isset($dests['state']) ? $dests['state'] : 'DAY';
    $day_recording_id = isset($dests['day_recording_id']) ? $dests['day_recording_id'] : '';
    $night_recording_id = isset($dests['night_recording_id']) ? $dests['night_recording_id'] : '';
    ?>
	<div class="content">
	<h2><?php 
    echo _("Day / Night Mode Control");
    ?>
</h2>
<?php 
    if ($itemid != "") {
        $delURL = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '&action=delete';
        $tlabel = sprintf(_("Delete Day/Night Feature Code %s"), $code);
        $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/core_delete.png"/>&nbsp;' . $tlabel . '</span>';
        ?>
		<a href="<?php 
        echo $delURL;
        ?>
"><?php 
        echo $label;
        ?>
</a><br />
<?php 
        $usage_list = framework_display_destination_usage(daynight_getdest($itemid));
        if (!empty($usage_list)) {
            ?>
			<a href="#" class="info"><?php 
            echo $usage_list['text'] . '<br />';
            ?>
<span><?php 
            echo $usage_list['tooltip'];
            ?>
</span></a>
<?php 
        }
        $timeconditions_refs = daynight_list_timecondition($itemid);
        if (!empty($timeconditions_refs)) {
            echo "<br />";
            foreach ($timeconditions_refs as $ref) {
                $dmode = $ref['dmode'] == 'timeday' ? _("Forces to Day  Mode") : _("Forces to Night Mode");
                $timecondition_id = $ref['dest'];
                $tcURL = $_SERVER['PHP_SELF'] . '?' . "display=timeconditions&itemid={$timecondition_id}";
                $label = '<span><img width="16" height="16" border="0" title="' . sprintf(_("Linked to Time Condition %s - %s"), $timecondition_id, $dmode) . '" alt="" src="images/clock_link.png"/>&nbsp;' . sprintf(_("Linked to Time Condition %s - %s"), $timecondition_id, $dmode) . '</span>';
                ?>
				<a href="<?php 
                echo $tcURL;
                ?>
"><?php 
                echo $label;
                ?>
</a><br />
<?php 
            }
        }
    }
    ?>
	<form name="prompt" action="<?php 
    $_SERVER['PHP_SELF'];
    ?>
" method="post" onsubmit="return prompt_onsubmit();">
	<input type="hidden" name="action" value="edited" />
	<input type="hidden" name="display" value="daynight" />
	<input name="Submit" type="submit" style="display:none;" value="save" />
	<table>
	<tr>
		<td colspan=2><hr />
		</td>
	</tr>
	<tr>
		<td colspan="2">	
		<input name="Submit" type="submit" value="<?php 
    echo _("Save");
    ?>
">
		<?php 
    if ($itemid != '') {
        echo "&nbsp " . sprintf(_("Use feature code: %s to toggle DAY/NIGHT mode"), "<strong>" . $code . "</strong>");
    }
    ?>
		</td>
	</tr>
	<tr>
		<td colspan=2>
		<hr />
		</td>
	</tr>
	<tr>
		<td><a href="#" class="info"><?php 
    echo _("Day/Night Feature Code Index:");
    ?>
		<span><?php 
    echo _("There are a total of 10 Feature code objects, 0-9, each can control a call flow and be toggled using the day/night feature code plus the index.");
    ?>
		</span></a>
		</td>
		<td>
<?php 
    if ($add == "add" && $itemid == "") {
        ?>
			<select name="itemid" tabindex="<?php 
        echo ++$tabindex;
        ?>
">
			<?php 
        $ids = daynight_get_avail();
        foreach ($ids as $id) {
            echo '<option value="' . $id . '" >' . $id . '</option>';
        }
        ?>
			</select>
<?php 
    } else {
        ?>
		<input readonly="yes" size="1" type="text" name="itemid" value="<?php 
        echo $itemid;
        ?>
">
<?php 
    }
    ?>
		</td>
	</tr>
	<tr>
		<td><a href="#" class="info"><?php 
    echo _("Description");
    ?>
:<span><?php 
    echo _("Description for this Day/Night Control");
    ?>
</span></a></td>
		<td><input size="40" type="text" name="fc_description" value="<?php 
    echo $fc_description;
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
">
		</td>
	</tr>
	<tr>
		<td><a href="#" class="info"><?php 
    echo _("Current Mode:");
    ?>
		<span><?php 
    echo _("This will change the current state for this Day/Night Mode Control, or set the initial state when creating a new one.");
    ?>
		</span></a>
		</td>
		<td>
			<select name="state" tabindex="<?php 
    echo ++$tabindex;
    ?>
">
				<option value="DAY" <?php 
    echo $state == 'DAY' ? 'SELECTED' : '';
    ?>
 ><?php 
    echo _("Day");
    ?>
</option> 
				<option value="NIGHT" <?php 
    echo $state == 'NIGHT' ? 'SELECTED' : '';
    ?>
 ><?php 
    echo _("Night");
    ?>
</option> 
			</select>
		</td>
	</tr>

<?php 
    if (function_exists('recordings_list')) {
        //only include if recordings are enabled
        ?>
	<tr>
		<td><a href="#" class="info"><?php 
        echo _("Recording for Day Mode");
        ?>
<span><?php 
        echo _("Message to be played.<br>To add additional recordings use the \"System Recordings\" MENU to the left");
        ?>
</span></a></td>
		<td>
			<select name="day_recording_id"  tabindex="<?php 
        echo ++$tabindex;
        ?>
">
			<?php 
        $tresults = recordings_list();
        $default = isset($day_recording_id) ? $day_recording_id : '';
        echo '<option value="0">' . _("Default") . "</option>\n";
        if (isset($tresults[0])) {
            foreach ($tresults as $tresult) {
                echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $default ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n";
            }
        }
        ?>
			</select>
		</td>
	</tr>
	<tr>
		<td><a href="#" class="info"><?php 
        echo _("Recording for Night Mode");
        ?>
<span><?php 
        echo _("Message to be played.<br>To add additional recordings use the \"System Recordings\" MENU to the left");
        ?>
</span></a></td>
		<td>
			<select name="night_recording_id"  tabindex="<?php 
        echo ++$tabindex;
        ?>
">
			<?php 
        $default = isset($night_recording_id) ? $night_recording_id : '';
        echo '<option value="0">' . _("Default") . "</option>\n";
        if (isset($tresults[0])) {
            foreach ($tresults as $tresult) {
                echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $default ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n";
            }
        }
        ?>
			</select>
		</td>
	</tr>

<?php 
    }
    ?>

	<tr>
		<td><a href="#" class="info"><?php 
    echo _("Optional Password");
    ?>
:<span><?php 
    echo _('You can optionally include a password to authenticate before toggling the day/night mode. If left blank anyone can use the feature code and it will be un-protected');
    ?>
</span></a></td>
		<td><input size="12" type="text" name="password" value="<?php 
    echo $password;
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
">
		</td>
	</tr>
	<tr>
		<td colspan=2>
		<hr />
		</td>
	</tr>
<?php 
    // Draw the destinations
    // returns an array, $dest['day'], $dest['night']
    // and puts null if nothing set
    drawdestinations(0, _("DAY"), isset($dests['day']) ? $dests['day'] : '');
    drawdestinations(1, _("NIGHT"), isset($dests['night']) ? $dests['night'] : '');
    //TODO: Check to make sure a destination radio button was checked, and if custom, that it was not blank
    //
    ?>
	<tr>
		<td colspan=2>	
		<input name="Submit" type="submit" value="<?php 
    echo _("Save");
    ?>
">
		<?php 
    if ($itemid != '') {
        echo "&nbsp " . sprintf(_("Use feature code: %s to toggle DAY/NIGHT mode"), "<strong>" . $code . "</strong>");
    }
    ?>
		</td>
	</tr>
	<tr>
		<td colspan=2>
		<hr />
		</td>
	</tr>
	</table>

	<script language="javascript">
	<!--
	var theForm = document.prompt;

	function prompt_onsubmit() {
		var msgInvalidPassword = "******";

		defaultEmptyOK = true;
		if (!isInteger(theForm.password.value))
			return warnInvalid(theForm.password, msgInvalidPassword);
		return true;
	}
	//-->
	</script>

	</form>
<?php 
}