Esempio n. 1
0
<?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, EXTR_SKIP);
if ($extdisplay) {
    $savedtimegroup = timeconditions_timegroups_get_group($extdisplay);
    $timegroup = $savedtimegroup[0];
    $description = $savedtimegroup[1];
    $delURL = '?display=timegroups&action=del&extdisplay=' . $extdisplay;
    $timelist = timeconditions_timegroups_get_times($extdisplay);
    $usage = timeconditions_timegroups_list_usage($extdisplay);
}
$timehtml = '';
if (!empty($timelist)) {
    foreach ($timelist as $val) {
        $timehtml .= timeconditions_timegroups_drawtimeselects('times[' . $val[0] . ']', $val[1]);
    }
} else {
    $timehtml = timeconditions_timegroups_drawtimeselects('times[0]', null);
}
if (isset($usage) && !empty($usage)) {
    echo '<script>$(document).ready(function(){$("#delete").attr("disabled",true);});</script>';
    echo '<div class="alert alert-warning">';
    echo '<strong>' . _("This time group is currently in use and cannot be deleted") . '</strong><br/>';
    echo '<table class="table">';
    foreach ($usage as $key => $value) {
        echo '<tr><td><a href="' . $value['url_query'] . '">' . $value['description'] . '</a></td></tr>';
    }
    echo '</table>';
Esempio n. 2
0
function timeconditions_timegroups_configpageload()
{
    global $currentcomponent;
    $descerr = _("Description must be alpha-numeric, and may not be left blank");
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    if ($action == 'del') {
        $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Time Group") . ": {$extdisplay}" . _(" deleted!"), false), 0);
        unset($extdisplay);
    }
    //need to get page name/type dynamically
    $query = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'] : 'type=setup&display=timegroups&extdisplay=' . $extdisplay;
    $delURL = $_SERVER['PHP_SELF'] . '?' . $query . '&action=del';
    $info = '';
    if (!$extdisplay) {
        $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Time Group"), false), 0);
        $currentcomponent->addguielem(_("Time Group"), new gui_textbox('description', '', _("Description"), _("This will display as the name of this Time Group."), '!isAlphanumeric() || isWhitespace()', $descerr, false), 3);
    } else {
        $savedtimegroup = timeconditions_timegroups_get_group($extdisplay);
        $timegroup = $savedtimegroup[0];
        $description = $savedtimegroup[1];
        $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay));
        $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Edit Time Group") . ": {$description}", false), 0);
        $tlabel = sprintf(_("Delete Time Group %s"), $extdisplay);
        $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/core_delete.png"/>&nbsp;' . $tlabel . '</span>';
        $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
        $usage_list = timeconditions_timegroups_list_usage($extdisplay);
        $count = 0;
        foreach ($usage_list as $link) {
            $label = '<span><img width="16" height="16" border="0" title="' . $link['description'] . '" alt="" src="images/time_link.png"/>&nbsp;' . $link['description'] . '</span>';
            $timegroup_link = $_SERVER['PHP_SELF'] . '?' . $link['url_query'];
            $currentcomponent->addguielem(_("Used By"), new gui_link('link' . $count++, $label, $timegroup_link, true, false), 4);
        }
        $currentcomponent->addguielem(_("Time Group"), new gui_textbox('description', $description, _("Description"), _("This will display as the name of this Time Group."), '', '', false), 3);
        $timelist = timeconditions_timegroups_get_times($extdisplay);
        foreach ($timelist as $val) {
            $timehtml = timeconditions_timegroups_drawtimeselects('times[' . $val[0] . ']', $val[1]);
            $timehtml = '<tr><td colspan="2"><table>' . $timehtml . '</table></td></tr>';
            $currentcomponent->addguielem($val[1], new guielement('dest0', $timehtml, ''), 5);
        }
    }
    $timehtml = timeconditions_timegroups_drawtimeselects('times[new]', null);
    $timehtml = '<tr><td colspan="2"><table>' . $timehtml . '</table></td></tr>';
    $currentcomponent->addguielem(_("New Time"), new guielement('dest0', $timehtml, ''), 6);
    $currentcomponent->addguielem('_top', new gui_hidden('action', $extdisplay ? 'edit' : 'add'));
}