<?php error_reporting(E_ALL & ~E_NOTICE); // check for right of current admin on this module if (cfr('TARIFFS')) { $dirs = getAllDirs(); if (empty($dirs)) { $alert = ' <script type="text/javascript"> alert("' . __('Error') . ': ' . __('No traffic classes available, now you will be redirected to the module with which you can add traffic classes') . '"); </script> '; print $alert; rcms_redirect("?module=rules"); die; } function tariff_name_filter($tariffname) { $tariffname = trim($tariffname); return preg_replace("#[^a-z0-9A-Z\\-_\\.]#Uis", '', $tariffname); } function web_TariffCreateForm() { global $dirs; $dbSchema = zb_CheckDbSchema(); 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;
function billing_edittariff($tariff, $options) { $dhour = $options['dhour']; $dmin = $options['dmin']; $nhour = $options['nhour']; $nmin = $options['nmin']; $PriceDay = $options['PriceDay']; $PriceNight = $options['PriceNight']; $Fee = $options['Fee']; $Free = $options['Free']; $PassiveCost = $options['PassiveCost']; $TraffType = $options['TraffType']; if (isset($options['Period'])) { $period = $options['Period']; } else { $period = ''; } $dirs = getAllDirs(); $string = "<SetTariff name=\"{$tariff}\">"; $string .= "<Fee value=\"{$Fee}\"/>"; $string .= "<Free value=\"{$Free}\"/>"; $string .= "<PassiveCost value=\"{$PassiveCost}\"/>"; $string .= "<TraffType value=\"{$TraffType}\"/>"; if (!empty($period)) { $string .= "<period value=\"" . $period . "\"/>"; } foreach ($dirs as $dir) { $key = $dir['rulenumber']; $string .= "<Time{$key} value=\"{$dhour[$key]}:{$dmin[$key]}-{$nhour[$key]}:{$nmin[$key]}\"/>"; } foreach ($options['PriceDay'] as $key => $value) { $arr = explode('/', $value); if ($arr[0] && $arr[1]) { $PriceDayAa = $arr[0]; $PriceDayBb = $arr[1]; } else { $PriceDayAa = $value; $PriceDayBb = $value; } $PriceDayAc[$key] = $PriceDayAa; $PriceDayBc[$key] = $PriceDayBb; } if (isset($options['PriceNight'])) { foreach ($options['PriceNight'] as $key => $value) { $arr = explode('/', $value); if ($arr[0] && $arr[1]) { $PriceNightAa = $arr[0]; $PriceNightBb = $arr[1]; } else { $PriceNightAa = $value; $PriceNightBb = $value; } $PriceNightAc[$key] = $PriceNightAa; $PriceNightBc[$key] = $PriceNightBb; } } for ($i = 0; $i <= 9; $i++) { if ($PriceDayAc[$i]) { if (isset($PriceDayA)) { $sep = '/'; } $PriceDayA .= $sep . $PriceDayAc[$i]; } else { if (isset($PriceDayA)) { $sep = '/'; } $PriceDayA .= $sep . '0'; } if ($PriceDayBc[$i]) { if (isset($PriceDayB)) { $sep1 = '/'; } $PriceDayB .= $sep1 . $PriceDayBc[$i]; } else { if (isset($PriceDayB)) { $sep1 = '/'; } $PriceDayB .= $sep1 . '0'; } if ($PriceNightAc[$i]) { if (isset($PriceNightA)) { $sep2 = '/'; } $PriceNightA .= $sep2 . $PriceNightAc[$i]; } else { if (isset($PriceNightA)) { $sep2 = '/'; } $PriceNightA .= $sep . '0'; } if ($PriceNightBc[$i]) { if (isset($PriceNightB)) { $sep3 = '/'; } $PriceNightB .= $sep3 . $PriceNightBc[$i]; } else { if (isset($PriceNightB)) { $sep3 = '/'; } $PriceNightB .= $sep3 . '0'; } /////////////////////////////////////// if ($options['Threshold'][$i]) { if (isset($Threshold)) { $sep4 = '/'; } $Threshold .= $sep4 . $options['Threshold'][$i]; } else { if (isset($Threshold)) { $sep4 = '/'; } $Threshold .= $sep4 . '0'; } //////////////////////////////////////// if ($options['SinglePrice'][$i]) { if (isset($SinglePrice)) { $sep5 = '/'; } $SinglePrice .= $sep5 . $options['SinglePrice'][$i]; } else { if (isset($SinglePrice)) { $sep5 = '/'; } $SinglePrice .= $sep5 . "0"; } //////////////////////////////////////// if ($options['NoDiscount'][$i] != false) { if (isset($NoDiscount)) { $sep6 = '/'; } $NoDiscount .= $sep6 . $options['NoDiscount'][$i]; } else { if (isset($NoDiscount)) { $sep6 = '/'; } $NoDiscount .= $sep6 . '0'; } } $string .= "<PriceDayA value=\"{$PriceDayA}\"/>"; $string .= "<PriceDayB value=\"{$PriceDayB}\"/>"; $string .= "<PriceNightA value=\"{$PriceNightA}\"/>"; $string .= "<PriceNightB value=\"{$PriceNightB}\"/>"; $string .= "<SinglePrice value=\"{$SinglePrice}\"/>"; $string .= "<NoDiscount value=\"{$NoDiscount}\"/>"; $string .= "<Threshold value=\"{$Threshold}\"/>"; $string .= "</SetTariff>"; executor($string); }