Exemplo n.º 1
0
<?php

require_once "./lib/defines.php";
require_once "./lib/module.access.php";
require_once "a2blib/Form.inc.php";
require_once "a2blib/Form/Class.SqlActionForm.inc.php";
require_once "a2blib/Class.HelpElem.inc.php";
/*require_once ("a2blib/Form/Class.RevRef.inc.php");*/
require_once "a2blib/Form/Class.TimeField.inc.php";
require_once "a2blib/Form/Class.SqlRefField.inc.php";
require_once "a2blib/Class.JQuery.inc.php";
$menu_section = 'menu_ratecard';
// HelpElem::DoHelp(gettext("*-*"),'vcard.png');
$HD_Form = new SqlTableActionForm();
$HD_Form->checkRights(ACX_RATECARD);
$HD_Form->init();
$PAGE_ELEMS[] =& $HD_Form;
$HD_Form->model[] = new SqlRefField(_("Card Group"), "grp", "cc_card_group", "id", "name", _("The call is made using a card of this group."));
$HD_Form->model[] = new TextField(_("Dial"), 'dialstring', _("The number we wish to dial. It will be at the card's numplan"));
$HD_Form->model[] = new DateTimeField(_("Time"), 'curtime', _("The date/time the call is supposed to take place. This helps us predict tomorrow's rates"));
end($HD_Form->model)->def_date = 'now';
$HD_Form->model[] = new FloatField(_("Credit"), 'money', _("Credit the customer will have for that call. Used to calculate the timeout"));
end($HD_Form->model)->def_value = 10.0;
/* Note: the secondary tables (sellrate, buyrate) *must* be queried inline, in the fields clause,
 (rather than the tables clause), because we have to preserve the order of Re3 rows. */
$HD_Form->QueryString = 'SELECT re3.*, (SELECT destination FROM cc_buyrate WHERE id = re3.brid) AS brid_destination,
		(SELECT destination FROM cc_sellrate WHERE id = re3.srid) AS srid_destination
	FROM RateEngine3((SELECT tariffgroup FROM cc_card_group WHERE id = %#grp), 
		%dialstring, (SELECT numplan FROM cc_card_group WHERE id = %#grp), %curtime, %money) AS re3 ;';
// Wrong one: FROM ...,
// 	   cc_buyrate, cc_sellrate
Exemplo n.º 2
0
<?php

require_once "./lib/defines.php";
require_once "./lib/module.access.php";
require_once DIR_COMMON . "Form.inc.php";
require_once DIR_COMMON . "Form/Class.SqlActionForm.inc.php";
require_once DIR_COMMON . "Class.HelpElem.inc.php";
/*require_once (DIR_COMMON."Form/Class.RevRef.inc.php");*/
require_once DIR_COMMON . "Form/Class.TimeField.inc.php";
require_once DIR_COMMON . "Form/Class.SqlRefField.inc.php";
$menu_section = 'menu_simulator';
if (!DynConf::GetCfg(CUSTOMER_CFG, 'menu_simulator', true)) {
    exit;
}
HelpElem::DoHelp(_("Here you can simulate a phone call and see how much it would cost"), 'vcard.png');
$HD_Form = new SqlTableActionForm();
$HD_Form->checkRights(ACX_ACCESS);
$HD_Form->init();
$PAGE_ELEMS[] =& $HD_Form;
$HD_Form->model[] = new TextField(_("Dial"), 'dialstring', _("The number you wish to dial."));
$HD_Form->QueryString = str_dbparams(A2Billing::DBHandle(), 'SELECT re.*, %%dialstring AS init_dial, cc_sellrate.rateinitial,
	format_currency(sell_calc_fwd(INTERVAL \'5 min\', cc_sellrate.*)/5.0, %3) AS rate5min
	FROM (SELECT * FROM RateEngine3((SELECT tariffgroup FROM cc_card_group WHERE id = %#1), ' . '%%dialstring, (SELECT numplan FROM cc_card_group WHERE id = %#1), now(), 
		(SELECT credit FROM cc_card WHERE id = %#2)) LIMIT 1) AS re, cc_sellrate
		WHERE cc_sellrate.id = re.srid ;', array($_SESSION['card_grp'], $_SESSION['card_id'], $_SESSION['currency']));
$HD_Form->expectRows = true;
$HD_Form->submitString = _("Calculate!");
$HD_Form->successString = '';
$HD_Form->noRowsString = _("No rates/destinations found!");
//$HD_Form->contentString = 'Generated:<br>';
$HD_Form->rmodel[] = new TextField(_('Dial'), 'init_dial');