コード例 #1
0
ファイル: form.php プロジェクト: ringfreejohn/pbxframework
<?php

//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2015 Sangoma Technologies.
extract($request);
$itemid = isset($itemid) ? $itemid : "";
$dests = daynight_get_obj($itemid);
extract($dests);
$indexopts = '';
$ids = daynight_get_avail();
if (empty($ids) && $itemid == '') {
    ?>
	<div class="alert alert-danger" role="alert"><?php 
    echo _('You have reached the maximum limit for flow controls. Delete one to add a new one');
    ?>
</div>
	<?php 
    return;
}
if (!empty($ids) && is_array($ids)) {
    foreach ($ids as $id) {
        $indexopts .= '<option value=' . $id . '>' . $id . '</option>';
    }
}
if ($itemid == '') {
    $indexinput = '<select class="form-control" id="itemid" name="itemid">';
    $indexinput .= isset($indexopts) ? $indexopts : "";
    $indexinput .= '</select>';
} else {
    $indexinput = '<input type="text"  class="form-control" name="itemid" id="itemid" value="' . $itemid . '" readonly>';
}
コード例 #2
0
function daynight_get_config($engine)
{
    global $ext;
    switch ($engine) {
        case "asterisk":
            $id = "app-daynight";
            // The context to be included
            $list = daynight_list();
            foreach ($list as $item) {
                $dests = daynight_get_obj($item['ext']);
                $ext->add($id, $item['ext'], '', new ext_gotoif('$["${DB(DAYNIGHT/C${EXTEN})}" = "NIGHT"]', $dests['night'], $dests['day']));
            }
            daynight_toggle();
            break;
    }
}
コード例 #3
0
ファイル: page.daynight.php プロジェクト: hardikk/HNH
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 
}
コード例 #4
0
ファイル: grid.php プロジェクト: ringfreejohn/pbxframework
		<th data-sortable="true"><?php 
echo _("State");
?>
</th>
		<th><?php 
echo _("Actions");
?>
</th>
	</tr>
</thead>
<tbody>
	<?php 
foreach ($daynightcodes as $row) {
    $fcc = new featurecode('daynight', 'toggle-mode-' . $row['ext']);
    $fc = $fcc->getCode();
    $dnobj = daynight_get_obj($row['ext']);
    ?>
		<tr>
			<td><?php 
    echo $fcc->getCode();
    ?>
</td>
			<td><?php 
    echo $row['dest'];
    ?>
</td>
			<td><span class="label label-<?php 
    echo $dnobj['state'] == 'DAY' ? "success" : "danger";
    ?>
"><?php 
    echo $dnobj['state'];