예제 #1
0
    function web_TariffEditForm($tariffname)
    {
        global $dirs;
        $tariffdata = billing_gettariff($tariffname);
        $dbSchema = zb_CheckDbSchema();
        if ($tariffdata['TraffType'] == 'up') {
            $s1 = "SELECTED";
        }
        if ($tariffdata['TraffType'] == 'down') {
            $s2 = "SELECTED";
        }
        if ($tariffdata['TraffType'] == 'up+down') {
            $s3 = "SELECTED";
        }
        if ($tariffdata['TraffType'] == 'max') {
            $s4 = "SELECTED";
        }
        if ($dbSchema > 0) {
            $availOpts = array('month' => __('Month'), 'day' => __('Day'));
            $periodCells = wf_TableCell(__('Period'));
            $periodCells .= wf_TableCell(wf_Selector("options[Period]", $availOpts, '', $tariffdata['period']));
            $periodRows = wf_TableRow($periodCells);
            $periodControls = $periodRows;
        } else {
            $periodControls = '';
        }
        $form = wf_Link("?module=tariffs", __('Back'), true, 'ubButton');
        $form .= '<form method="POST" action="">
    <table>
        <tr>
            <td>' . __('Tariff name') . '</td><td><input  type="text" name="options[TARIFF]" DISABLED value="' . $tariffdata['name'] . '"></td>
        </tr>
        <tr>
            <td>' . __('Fee') . '</td><td><input size="2" type="text" name="options[Fee]" value="' . $tariffdata['Fee'] . '"></td>
        </tr>
        ' . $periodControls . '
        <tr>
            <td>' . __('Prepaid traffic') . '</td><td><input size="2" type="text" name="options[Free]" value="' . $tariffdata['Free'] . '"></td>
        </tr>
        <tr>
            <td>' . __('Counting traffic') . '</td><td>
                <select name="options[TraffType]">
                    <option ' . $s1 . '>up</option>
                    <option ' . $s2 . '>down</option>
                    <option ' . $s3 . '>up+down</option>
                    <option ' . $s4 . '>max</option>
                    </select>
            </td>
        </tr>
        <tr>
            <td>' . __('Cost of freezing') . '</td><td><input size="2" type="text" name="options[PassiveCost]" value="' . $tariffdata['PassiveCost'] . '"></td>
        </tr>

    </table>';
        foreach ($dirs as $dir) {
            $arrTime = explode('-', $tariffdata["Time{$dir['rulenumber']}"]);
            $day = explode(':', $arrTime[0]);
            $night = explode(':', $arrTime[1]);
            $tariffdata['Time'][$dir[rulenumber]]['Dmin'] = $day[1];
            $tariffdata['Time'][$dir[rulenumber]]['Dhour'] = $day[0];
            $tariffdata['Time'][$dir[rulenumber]]['Nmin'] = $night[1];
            $tariffdata['Time'][$dir[rulenumber]]['Nhour'] = $night[0];
            if ($tariffdata["NoDiscount{$dir['rulenumber']}"] == 1) {
                $ns[$dir[rulenumber]] = "CHECKED";
            }
            if ($tariffdata["SinglePrice{$dir['rulenumber']}"] == 1) {
                $sp[$dir[rulenumber]] = "CHECKED";
            }
            $form .= '<fieldset><legend><b>' . $dir['rulename'] . '</b></legend>

        <table>
            <tr>
                <td>' . __('Hours') . '</td><td>' . __('Minutes') . '</td>
            </tr>
            <tr>
                <td>
                    <select id="dhour' . $dir['rulenumber'] . '"  name="options[dhour][' . $dir['rulenumber'] . ']">
                        <option>00</option>';
            $form .= tariff_time(24, $tariffdata['Time'][$dir[rulenumber]]['Dhour']);
            $form .= '</select>
                        </td>
                        <td>
                            <select id="dmin' . $dir['rulenumber'] . '"  name="options[dmin][' . $dir['rulenumber'] . ']">
                                <option>00</option>';
            $form .= tariff_time(60, $tariffdata['Time'][$dir[rulenumber]]['Dmin']);
            $form .= '</select>

                                    <br>

                                </td>
                                <td>' . __('Day') . '</td>


                                <td><input size="3" type="text" name="options[PriceDay][' . $dir['rulenumber'] . ']" value="' . tariff_price($tariffdata["PriceDayA{$dir['rulenumber']}"], $tariffdata["PriceDayB{$dir['rulenumber']}"]) . '"></td>
                                <td>' . __('Price day') . '</td>

                                <td><input id="thr' . $dir['rulenumber'] . '"  size="3" type="text" name="options[Threshold][' . $dir['rulenumber'] . ']" value="' . $tariffdata["Threshold{$dir['rulenumber']}"] . '"> ' . __('Threshold') . ' (' . __('Mb') . ')</td>
                            </tr>
                            <tr>
                                <td>
                                    <select id="nhour' . $dir['rulenumber'] . '"  name="options[nhour][' . $dir['rulenumber'] . ']">
                                        <option  SELECTED>00</option>';
            $form .= tariff_time(24, $tariffdata['Time'][$dir[rulenumber]]['Nhour']);
            $form .= '</select>
                                        </td>
                                        <td>
                                            <select id="nmin' . $dir['rulenumber'] . '"  name="options[nmin][' . $dir['rulenumber'] . ']">
                                                <option SELECTED>00</option>';
            $form .= tariff_time(60, $tariffdata['Time'][$dir[rulenumber]]['Nmin']);
            $form .= '                    </select>

                </td>
                <td>' . __('Night') . '</td>
                <td><input  id="pricenight' . $dir['rulenumber'] . '"  size="3" type="text" name="options[PriceNight][' . $dir['rulenumber'] . ']" value="' . tariff_price($tariffdata["PriceNightA{$dir['rulenumber']}"], $tariffdata["PriceNightB{$dir['rulenumber']}"]) . '"></td>
                <td>' . __('Price night') . '</td>
                <td><input id="no0" OnClick="hide(0,\'no\')" name="options[NoDiscount][' . $dir['rulenumber'] . ']" value="1" ' . $ns[$dir[rulenumber]] . ' type="checkbox" > ' . __('Without threshold') . '</td>
            </tr>
        </table>
        <input id="single' . $dir['rulenumber'] . '" OnClick="hide(0,\'si\')" name="options[SinglePrice][' . $dir['rulenumber'] . ']" type="checkbox" ' . $sp[$dir[rulenumber]] . ' value="1" > ' . __('Price does not depend on time') . '
    </fieldset>';
        }
        $form .= '<input type="submit" id="save" name="save" value="' . __('Edit') . '">
</form>';
        return $form;
    }
예제 #2
0
/**
 * Returns array of Stargazer tariffs payment periods
 * 
 * @return array
 */
function zb_TariffGetPeriodsAll()
{
    $result = array();
    $dbSchema = zb_CheckDbSchema();
    if ($dbSchema > 0) {
        //stargazer >= 2.409
        $query = "SELECT `name`,`period` from `tariffs`";
        $all = simple_queryall($query);
        if (!empty($all)) {
            foreach ($all as $io => $eachtariff) {
                $result[$eachtariff['name']] = $eachtariff['period'];
            }
        }
    } else {
        //stargazer 2.408
        $query = "SELECT `name` from `tariffs`";
        $all = simple_queryall($query);
        if (!empty($all)) {
            foreach ($all as $io => $eachtariff) {
                $result[$eachtariff['name']] = 'month';
            }
        }
    }
    return $result;
}