<?php
/**
 * UCP widget body. Vars from getWidgetDisplay():
 *   $extension, $dnd, $cf, $cfb, $cfu
 *
 * Bootstrap-toggle for DND (matches the FreePBX donotdisturb widget look).
 * Three text inputs + Save button for CF/CFB/CFU.
 *
 * All AJAX targets the customastdb UCP module with command=setDnd / setCf
 * and validates ownership server-side before any astdb write.
 */
?>
<div class="customastdb-widget" data-extension="<?php echo htmlspecialchars($extension); ?>" style="padding:8px;">

    <div style="text-align:center;margin-bottom:14px;">
        <input type="checkbox" class="customastdb-dnd-toggle"
               data-toggle="toggle"
               data-on="<?php echo _('DND On'); ?>"
               data-off="<?php echo _('DND Off'); ?>"
               data-onstyle="danger" data-offstyle="success"
               <?php echo $dnd ? 'checked' : ''; ?>>
    </div>

    <div class="form-horizontal">
        <div class="form-group" style="margin-bottom:8px;">
            <label class="col-xs-4 control-label" style="text-align:right;padding-top:4px;">CF</label>
            <div class="col-xs-8">
                <input type="text" class="form-control input-sm customastdb-cf-field" data-type="CF"
                       value="<?php echo htmlspecialchars($cf); ?>" placeholder="<?php echo _('Forward always to&hellip;'); ?>">
            </div>
        </div>
        <div class="form-group" style="margin-bottom:8px;">
            <label class="col-xs-4 control-label" style="text-align:right;padding-top:4px;">CFB</label>
            <div class="col-xs-8">
                <input type="text" class="form-control input-sm customastdb-cf-field" data-type="CFB"
                       value="<?php echo htmlspecialchars($cfb); ?>" placeholder="<?php echo _('When busy&hellip;'); ?>">
            </div>
        </div>
        <div class="form-group" style="margin-bottom:12px;">
            <label class="col-xs-4 control-label" style="text-align:right;padding-top:4px;">CFU</label>
            <div class="col-xs-8">
                <input type="text" class="form-control input-sm customastdb-cf-field" data-type="CFU"
                       value="<?php echo htmlspecialchars($cfu); ?>" placeholder="<?php echo _('When unavailable&hellip;'); ?>">
            </div>
        </div>
        <div class="form-group" style="margin-bottom:0;">
            <div class="col-xs-12 text-center">
                <button type="button" class="btn btn-sm btn-primary customastdb-save-cf">
                    <i class="fa fa-save"></i> <?php echo _('Save CF'); ?>
                </button>
                <button type="button" class="btn btn-sm btn-default customastdb-clear-cf">
                    <i class="fa fa-times"></i> <?php echo _('Clear All'); ?>
                </button>
            </div>
        </div>
    </div>

    <p class="text-muted text-center" style="font-size:10px;margin-top:8px;margin-bottom:0;">
        <?php echo _('Empty a field then Save to clear that one CF type.'); ?>
    </p>
</div>
