function insertLog($userID, $logLevel, $actionPerformed, $description, $tableName, $ipAddress, $pageName, $data = '') { $DB_Handle = A2Billing::DBHandle(); $pageName = basename($pageName); $pageArray = explode('?', $pageName); $pageName = array_shift($pageArray); $res = $DB_Handle->Execute("INSERT INTO cc_system_log (iduser, loglevel, action, description, tablename, pagename, ipaddress, data) " . " VALUES(?,?,?,?,?,?,?,?);", array($userID, $logLevel, $actionPerformed, $description, $tableName, $pageName, $ipAddress, $data)); if (!$res) { @syslog(LOG_WARNING, "Cannot log: " . $DB_Handle->ErrorMsg()); } }
function login($user, $pass) { global $FG_DEBUG; $DBHandle = A2Billing::DBHandle(); $user = trim($user); $pass = trim($pass); if (strlen($user) == 0 || strlen($user) >= 50 || strlen($pass) == 0 || strlen($pass) >= 50) { return false; } $nameclause = ""; if (DynConf::GetCfg(CUSTOMER_CFG, 'username_login', true)) { $nameclause = "username = %1"; } if (DynConf::GetCfg(CUSTOMER_CFG, 'useralias_login', false)) { if (!empty($nameclause)) { $nameclause .= ' OR '; } $nameclause .= "useralias = %1"; } if (DynConf::GetCfg(CUSTOMER_CFG, 'email_login', false)) { if (!empty($nameclause)) { $nameclause .= ' OR '; } $nameclause .= "email = %1"; } if (($cgrp = DynConf::GetCfg(CUSTOMER_CFG, 'cardgroup_only', null)) != null) { $group_clause = ' AND grp = %#3'; } $QUERY = str_dbparams($DBHandle, "SELECT id, username, status, currency, grp, language\n\t\t FROM cc_card WHERE ({$nameclause}) AND userpass = %2 {$group_clause} ;", array($user, $pass, $cgrp)); $res = $DBHandle->Execute($QUERY); if (!$res) { $errstr = $DBHandle->ErrorMsg(); if ($FG_DEBUG) { echo $errstr . "<br>\n"; } return 4; } if ($res->EOF) { // no such user! if ($FG_DEBUG > 1) { echo "Query: {$QUERY} <br>"; } return 1; } $row = $res->fetchRow(); if ($row['status'] != 1) { return 0 - intval($row['status']); } // if( ACTIVATEDBYUSER==1 && $row [0][7] != "t" && $row [0][7] != "1" ) { // return -2; // } return $row; }
public function sendMail($templ, $tomail, $locale, $params) { global $verbose; $dbhandle = A2Billing::DBHandle(); if ($verbose > 2) { echo "Sending {$templ} mail to {$tomail}\n"; } $res = $dbhandle->Execute("SELECT create_mail(?, ?, ?, ?);", array($templ, $tomail, $locale, arr2url($params))); if (!$res) { echo "Cannot mark mail: "; echo $dbhandle->ErrorMsg() . "\n"; } elseif ($res->EOF) { echo "Cannot send mail, no template?\n"; } $this->mail_flag = true; }
function UseLanguage() { global $language_list; global $FG_DEBUG; if (isset($_GET['language'])) { if ($FG_DEBUG > 0) { echo "<!-- lang explicitly set to " . $_GET['language'] . "-->\n"; } $_SESSION["language"] = $_GET['language']; } elseif (!isset($_SESSION["language"])) { // we have to find a lang to use.. if (isset($_SESSION["lang_db"])) { foreach ($language_list as $lang) { if ($lang['abbrev'] == $_SESSION["lang_db"]) { $_SESSION["language"] = $lang['cname']; } } if ($FG_DEBUG > 0) { trigger_error("Lang Selected by db: " . $_SESSION["language"], E_USER_NOTICE); } } else { $_SESSION["language"] = 'english'; } } define("LANGUAGE", $_SESSION["language"]); //include (FSROOT."lib/languages/".LANGUAGE.".php"); //define ("LANGUAGE_DIR",FSROOT."lib/languages/".LANGUAGE."/"); $lang_abbr = SetLocalLanguage($_SESSION["language"]); if ($FG_DEBUG > 5) { trigger_error("lang abbr: {$lang_abbr}", E_USER_NOTICE); } if (isset($_SESSION['agent_id']) && $_SESSION['cus_rights'] != 0 && isset($_SESSION["lang_db"]) && $_SESSION["lang_db"] != $lang_abbr) { $DBconn_tmp = A2Billing::DBHandle(); $QUERY = "UPDATE cc_agent SET language = " . $DBconn_tmp->Quote($lang_abbr) . ", locale = " . $DBconn_tmp->Quote(getenv("LANG")) . " WHERE id = " . $DBconn_tmp->Quote($_SESSION['agent_id']) . ';'; $res = $DBconn_tmp->query($QUERY); $_SESSION["lang_db"] = $lang_abbr; //echo $QUERY; if (!$res) { trigger_error("Set language to db failed:" . $DBconn_tmp->ErrorMsg(), E_USER_WARNING); } //DbDisconnect($DBconn_tmp); } }
function ProcessAlarm(AlmInstance $inst) { $dbhandle = A2Billing::DBHandle(); global $verbose; if ($inst->ar_id) { // we cannot handle previous instances return; } $margin = $inst->alm_params['margin']; if (!isset($margin)) { $margin = 0.0; } $qry = str_dbparams($dbhandle, "SELECT cc_agent.id, credit, name, locale, email, climit, cc_alarm_run.id AS ar_id,\n\t\t\t\tcc_alarm_run.status AS ar_status\n\t\t\tFROM cc_agent LEFT JOIN cc_alarm_run ON ( cc_alarm_run.dataid = cc_agent.id\n\t\t\t\tAND cc_alarm_run.alid = %#1) \n\t\t\tWHERE (climit + credit ) < %#2 ;", array($inst->id, $margin)); if ($verbose > 2) { echo "Query: " . $qry . "\n"; } $res = $dbhandle->Execute($qry); if (!$res) { echo $dbhandle->ErrorMsg() . "\n"; } else { if ($res->EOF) { if ($verbose > 2) { echo "All agents have credit.\n"; } $inst->Save(1); return; } } $neg_agents = array(); while ($row = $res->fetchRow()) { if ($verbose > 2) { echo "Agent " . $row['name'] . " is low on credit.\n"; } if (!empty($row['email'])) { $this->sendMail('agent-low-credit', $row['email'], $row['locale'], array(credit => $row['credit'], climit => $row['climit'])); } $neg_agents[] = $row['name'] . ": " . $row['credit'] . "/" . $row['climit']; } $this->sendSysMail('sys-agent-low-credit', $inst, array(low_agents => implode("\n", $neg_agents))); $inst->Save(); }
$tmp->Form->model[] = new TextField(_("Destination"), 'destination'); $tmp->Form->model[] = new SecondsField(_("Duration"), 'sessiontime'); end($tmp->Form->model)->fieldacr = _("Dur"); //$tmp->Form->model[] = new PKeyFieldTxt(_("ID"),'id'); $tmp->Form->model[] = new MoneyField(_("Bill"), 'sessionbill'); //one non-summed group $tmp->Form->views['list']->sums[] = array('fns' => array('starttime' => true, 'calledstation' => true, 'destination' => true, 'sessiontime' => true, 'sessionbill' => true), 'order' => 'starttime'); //Per day/destination $tmp->Form->views['list']->sums[] = array('title' => _("Sum per destination"), 'fns' => array('starttime' => false, 'destination' => true, 'sessiontime' => 'SUM', 'sessionbill' => 'SUM'), 'order' => 'sessiontime', 'sens' => 'DESC'); $tmp->Form->views['list']->sums[] = array('title' => _("Total"), 'fns' => array('calledstation' => 'COUNT', 'sessiontime' => 'SUM', 'sessionbill' => 'SUM')); $hform = new FormHandler('cc_card'); $hform->checkRights(ACX_INVOICING); $hform->init(null, false); $hform->setAction('details'); $hform->views['details'] = new DetailsView(); $hform->model[] = new FreeClauseField(str_dbparams(A2Billing::DBHandle(), 'id = (SELECT cardid FROM cc_invoices WHERE id = %#1)', array($dform->getpost_dirty('id')))); //$hform->model[] = new PKeyField(_("ID"),'id'); $hform->model[] = new TextField(_("Local number"), 'useralias'); $hform->model[] = new TextFieldN(_("First name"), 'firstname'); $hform->model[] = new TextFieldN(_("Last name"), 'lastname'); $hform->model[] = new TextAreaField(_("Address"), 'address'); $hform->model[] = new TextFieldN(_("City"), 'city'); $hform->model[] = new TextFieldN(_("State"), 'state'); $hform->model[] = new TextFieldN(_("Country"), 'country'); $hform->model[] = new TextFieldN(_("Zipcode"), 'zipcode'); //$hform->model[] = new TextFieldN(_("Phone"),'phone'); $hform->model[] = new TextFieldN(_("Fax"), 'fax'); $PAGE_ELEMS[] =& $hform; $PAGE_ELEMS[] =& $dform; if (isset($_GET['printable']) && $_GET['printable']) { require "PP_print.inc.php";
// $res= fopen($files[0],'r'); // if (!$res){ // echo "Could not open ".$files[0]." .\n"; // exit(2); // } define('DEBUG_CONF', 1); $host = A2Billing::instance()->set_def_conf($manager_section, 'host', 'localhost'); $uname = A2Billing::instance()->set_def_conf($manager_section, 'username', 'a2billing'); $password = A2Billing::instance()->set_def_conf($manager_section, 'secret', ''); if ($verbose > 2) { echo "Starting manager-eventd.\n"; } $num_tries = 0; while ($num_tries < 10) { $num_tries++; $dbh = A2Billing::DBHandle(); if (!$dbh) { echo "Cannot connect to database, exiting.."; break; } $as = new AGI_AsteriskManager(); if ($verbose < 2) { $as->nolog = true; } else { if ($verbose > 3) { $as->debug = true; } } // && CONNECTING connect($server=NULL, $username=NULL, $secret=NULL) $res = $as->connect($host, $uname, $password); if (!$res) {
<?php /** Booths xml code: Copyright (C) 2006-2008 P. Christeas <*****@*****.**> */ // We must tell the mod_php to send the correct header.. header('Content-type: text/xml'); require "lib/defines.php"; require "lib/module.access.php"; require "lib/common/BoothsXML.inc.php"; require "lib/common/Misc.inc.php"; if (!has_rights(ACX_AGENTS)) { header("HTTP/1.0 401 Unauthorized"); $dom = messageDom(_("Unauthorized: please log in again."), "msg_errror"); echo $dom->saveXML(); exit; } $aclause = ''; if (!empty($_GET['aid'])) { $aclause = str_dbparams(A2Billing::DBHandle(), 'agentid = %#1', array($_GET['aid'])); } $dom = BoothsDom($_GET['action'], $_GET['actb'], $aclause); // Let ONLY this line produce any output! echo $dom->saveXML();
} if (!session_is_registered('pr_login') || !session_is_registered('pr_password') || !session_is_registered('cus_rights') || isset($_POST["done"]) && $_POST["done"] == "submit_log") { if (!isset($_SERVER['HTTPS'])) { header("HTTP/1.0 401 Unauthorized"); header("Location: index.php?error=1"); trigger_error("Unauthorized! no ssl!", E_USER_ERROR); die; } if (!isset($unsafe_base)) { $unsafe_base = "."; } if ($FG_DEBUG == 1) { echo "<br>0. HERE WE ARE"; } if ($_POST["done"] == "submit_log") { $DBHandle = A2Billing::DBHandle(); if ($FG_DEBUG == 1) { echo "<br>1. " . $_POST["pr_login"] . $_POST["pr_password"]; } $_POST["pr_login"] = access_sanitize_data($_POST["pr_login"]); $_POST["pr_password"] = access_sanitize_data($_POST["pr_password"]); $return = login($_POST["pr_login"], $_POST["pr_password"]); if ($FG_DEBUG == 1) { print_r($return); } if ($FG_DEBUG == 1) { echo "==>" . $return[1]; } if (!is_array($return)) { sleep(2); header("HTTP/1.0 401 Unauthorized");
public function Init(array $args) { $this->args = $args; $this->dbhandle = A2Billing::DBHandle(); }
function Send_Mails($dbg = 1, $dry = false) { $dbhandle = A2Billing::DBHandle(); if ($dbg > 2) { echo "Mailer: start\n"; } $sqlTimeFmt = _("YYYY-MM-DD HH24:MI:SS TZ"); // TODO: not only select, but lock mails in 'sending' state. $qry = "SELECT cc_mailings.id AS id, mtype, fromname, fromemail, subject, \n\t\tmessage, defargs, tomail, args, to_char(tstamp,'{$sqlTimeFmt}') AS mdate\n\t\tFROM cc_templatemail, cc_mailings\n\t\tWHERE cc_mailings.tmail_id = cc_templatemail.id\n\t\tAND (state = 1 OR state = 5);"; $res = $dbhandle->Execute($qry); if (!$res) { if ($dbg > 0) { echo "Query Failed: " . $dbhandle->ErrorMsg() . "\n"; } return false; } elseif ($res->EOF) { if ($dbg > 2) { echo "No mails need to be sent.\n"; } return true; } try { while ($row = $res->fetchRow()) { if ($dbg > 2) { echo "Sending " . $row['mtype'] . " to " . $row['tomail'] . "\n"; } if (empty($row['tomail'])) { if ($dbg > 2) { echo "No recepient specified!\n"; } continue; } $mai = new Mailer(); $mai->setTo('', $row['tomail']); $mai->setFrom($row['fromname'], $row['fromemail']); // Format parameters $defargs = array(); parse_str($row['defargs'], $defargs); $defargs['mdate'] = $row['mdate']; $toargs = array(); parse_str($row['args'], $toargs); $args = array_merge($defargs, $toargs); if ($dbg > 2) { echo "Arguments:"; print_r($args); echo "\n"; } $mai->setSubject(str_alparams($row['subject'], $args), "UTF-8"); $mai->body = new Mailer_TextBody(str_alparams($row['message'], $args)); if ($dry) { $mai->PrintMail(); continue; } try { if ($dbg > 2) { echo "Sending mail.."; } $mai->SendMail(); if ($dbg > 2) { echo " done.\n"; } update_mailing($dbhandle, $row['id'], true, $dbg); } catch (Exception $ex) { if ($dbg > 2) { echo " failed.\n"; } update_mailing($dbhandle, $row['id'], false, $dbg); throw $ex; } } } catch (Exception $ex) { if ($dbg > 1) { echo "Exception: " . $ex->getMessage(); } } return true; }
function AgentMoney($agentid, &$sel_form, $intl, $rights) { global $PAGE_ELEMS; global $FG_DEBUG; $dbhandle = A2Billing::DBHandle(); $HD_Form = new FormHandler('cc_agent_money_v', _("Transactions"), _("Transaction")); $HD_Form->checkRights($rights); $HD_Form->init(null, false); $HD_Form->views['list'] = new SumMultiView(); $HD_Form->views['pay'] = $HD_Form->views['true'] = $HD_Form->views['false'] = new IdleView(); if ($FG_DEBUG) { $HD_Form->views['dump-form'] = new DbgDumpView(); } $clauses = $sel_form->buildClauses(); // $PAGE_ELEMS[] = new DbgElem(print_r($clauses,true)); $PAGE_ELEMS[] =& $HD_Form; $HD_Form->model[] = new ClauseField('agentid', $agentid); if (isset($clauses['date_from'])) { $HD_Form->model[] = new FreeClauseField($clauses['date_from']); } if (isset($clauses['date_to'])) { $HD_Form->model[] = new FreeClauseField($clauses['date_to']); } $HD_Form->model[] = new DateTimeField(_("Date"), 'date'); $HD_Form->model[] = new TextField(_("Type"), 'pay_type'); if ($intl) { end($HD_Form->model)->fieldexpr = 'gettexti(pay_type,\'' . getenv('LANG') . '\')'; } else { end($HD_Form->model)->fieldexpr = 'gettexti(pay_type,\'C\')'; } $HD_Form->model[] = new TextField(_("Description"), 'descr'); if ($intl) { end($HD_Form->model)->fieldexpr = 'gettext(descr,\'' . getenv('LANG') . '\')'; } $HD_Form->model[] = new MoneyField(_("In"), 'pos_credit'); $HD_Form->model[] = new MoneyField(_("Out"), 'neg_credit'); $HD_Form->model[] = new MoneyField(_("Sum"), 'credit'); $HD_Form->views['list']->sums[] = array('group' => false, 'fns' => array('date' => true, 'pay_type' => true, 'descr' => true, 'pos_credit' => true, 'neg_credit' => true)); $HD_Form->views['list']->sums[] = array('fns' => array('descr' => array(_("Totals")), 'pos_credit' => 'SUM', 'neg_credit' => 'SUM')); $HD_Form->views['list']->sums[] = array('fns' => array('descr' => array(_("Sum Total")), 'credit' => 'SUM')); $Totals = new SqlDetailsActionForm(); $Totals->checkRights($rights); $Totals->init(); $Totals->setAction('true'); $PAGE_ELEMS[] =& $Totals; $Totals->expectRows = false; $Totals->listclass = 'total'; $Totals->headerString = _("Agent Totals"); $Totals->successString = null; $dc2 = ''; if (isset($clauses['date_from'])) { $dc2 .= ' AND ' . str_replace('date ', 'starttime ', $clauses['date_from']); } if (isset($clauses['date_to'])) { $dc2 .= ' AND ' . str_replace('date ', 'starttime ', $clauses['date_to']); } $cardsqr = "SELECT SUM(CASE WHEN credit > 0.0 THEN credit ELSE NULL END) AS pos_credit,\n\t\t\tSUM(CASE WHEN credit < 0.0 THEN (0.0 - credit) ELSE NULL END) AS neg_credit,\n\t\t\tSUM(creditlimit) AS climit\n\t\t\tFROM cc_card, cc_card_group\n\t\t\tWHERE cc_card.grp = cc_card_group.id AND cc_card_group.agentid IS NOT NULL\n\t\t\tAND agentid = %1"; $callsqr = "SELECT SUM(sessionbill) AS calls \n\t\t\tFROM cc_call, cc_card, cc_card_group \n\t\t\tWHERE cc_call.cardid = cc_card.id AND cc_card_group.id = cc_card.grp\n\t\t\t\tAND cc_card_group.agentid = %1 " . $dc2; $dleftqr = "cc_calc_daysleft(%1,now(), interval '1 month')"; $Totals->QueryString = str_dbparams($dbhandle, "SELECT format_currency(tc.pos_credit, %2) AS total_ccredit,\n\t\t format_currency(tc.neg_credit, %2) AS total_cdebit, " . "format_currency(tc.climit, %2) AS total_cclimit,\n\t\tformat_currency(sb.calls,%2) AS total_calls, format_currency((sb.calls * cc_agent.commission), %2) AS total_com,\n\t\tformat_currency((sb.calls * (1.0 - cc_agent.commission)), %2) AS total_wh,\n\t\tformat_currency(cc_agent.credit, %2) AS agent_credit, format_currency(cc_agent.climit, %2) AS climit, dleft.days_left\n\t\t FROM ({$cardsqr}) AS tc, ({$callsqr}) AS sb, cc_agent, {$dleftqr} AS dleft\n\t\t WHERE cc_agent.id = %1;", array($agentid, A2Billing::instance()->currency)); $Totals->noRowsString = _("Totals could not be calculated!"); $Totals->rmodel[] = new MoneyField(_("Total sum credited to customers"), 'total_ccredit'); $Totals->rmodel[] = new MoneyField(_("Total sum debited from customers"), 'total_cdebit'); $Totals->rmodel[] = new MoneyField(_("Total potential debit from customers"), 'total_cclimit'); $Totals->rmodel[] = new IntField(_("Total calls made by customers"), 'total_calls'); $Totals->rmodel[] = new MoneyField(_("Wholesale price of calls"), 'total_wh'); $Totals->rmodel[] = new MoneyField(_("Estimated profit from calls"), 'total_com'); $Totals->rmodel[] = new MoneyField(_("Outstanding balance"), 'agent_credit'); $Totals->rmodel[] = new MoneyField(_("Credit Limit"), 'climit'); $Totals->rmodel[] = new IntField(_("Estimated Days left"), 'days_left'); // if ($vat>0) echo " (" .gettext("includes VAT"). "$vat %)"; }
/** One function that sets up page elems for an agent-session invoice */ function AgentSessionInvoice($sess_row, $rights, $booth_page) { global $PAGE_ELEMS; global $FG_DEBUG; $dbhandle = A2Billing::DBHandle(); $HD_Form = new FormHandler('cc_session_invoice', _("Transactions"), _("Transaction")); $HD_Form->checkRights($rights); $HD_Form->init(null, false); $HD_Form->views['list'] = new ListSumView(); $HD_Form->views['pay'] = $HD_Form->views['true'] = $HD_Form->views['false'] = new IdleView(); if ($FG_DEBUG) { $HD_Form->views['dump-form'] = new DbgDumpView(); } $PAGE_ELEMS[] =& $HD_Form; $HD_Form->model[] = new ClauseField('sid', $sess_row['sid']); $HD_Form->model[] = new DateTimeField(_("Date"), 'starttime'); $HD_Form->model[] = new TextField(_("Description"), 'descr'); end($HD_Form->model)->fieldacr = _("Descr"); $HD_Form->model[] = new TextField("", 'f2'); $HD_Form->model[] = new TextField(_("Called Number"), 'cnum'); end($HD_Form->model)->fieldacr = _("C. Num"); //end($HD_Form->model)->fieldname ='agent'; $HD_Form->model[] = new SecondsField(_("Duration"), "duration"); end($HD_Form->model)->fieldacr = _("Dur"); $HD_Form->model[] = new MoneyField(_("Credit"), "pos_charge"); $HD_Form->model[] = new MoneyField(_("Charge"), "neg_charge"); $HD_Form->views['list']->sum_fns = array('duration' => 'SUM', 'pos_charge' => 'SUM', 'neg_charge' => 'SUM'); // Per date calls.. $Sum_Form = new FormHandler('cc_session_calls', _("Per-date calls")); $Sum_Form->checkRights($rights); $Sum_Form->init(null, false); $Sum_Form->views['list'] = new SumMultiView(); $Sum_Form->views['pay'] = $Sum_Form->views['true'] = $Sum_Form->views['false'] = new IdleView(); if ($FG_DEBUG) { $Sum_Form->views['dump-form'] = new DbgDumpView(); } $PAGE_ELEMS[] =& $Sum_Form; $Sum_Form->model[] = new ClauseField('sid', $sess_row['sid']); $Sum_Form->model[] = new DateField(_("Date"), 'starttime'); end($Sum_Form->model)->fieldexpr = 'date_trunc(\'day\', starttime)'; $Sum_Form->model[] = new IntField(_("Calls"), 'cnum'); $Sum_Form->model[] = new SecondsField(_("Duration"), "duration"); //$Sum_Form->model[] = new FloatField(_("Credit"), "pos_charge"); $Sum_Form->model[] = new MoneyField(_("Charge"), "neg_charge"); if ($sess_row['has_days'] == 't') { $Sum_Form->views['list']->sums[] = array('title' => _("Per day calls"), 'fns' => array('starttime' => true, 'cnum' => 'COUNT', 'duration' => 'SUM', 'neg_charge' => 'SUM')); } $Sum_Form->views['list']->sums[] = array('title' => _("Total"), 'fns' => array('cnum' => 'COUNT', 'duration' => 'SUM', 'neg_charge' => 'SUM')); if ($sess_row['is_open'] != 't') { $PAGE_ELEMS[] = new StringElem(_("Session is closed")); } elseif ($sess_row['is_inuse'] == 't') { $PAGE_ELEMS[] = new StringElem(_("Card is in use, cannot close session now.")); } else { $pay_form = new SqlActionElem(); $pay_form->action_do = 'pay'; $pay_form->action_ask = 'list'; $pay_form->init(); $PAGE_ELEMS[] =& $pay_form; if ($sess_row['credit'] > 0) { $pay_form->ButtonStr = str_params(_("Pay back %1"), array($sess_row['credit_fmt']), 1); $pay_form->elem_success = new StringElem(_("Sesion paid back!")); } else { $pay_form->ButtonStr = str_params(_("Pay %1"), array($sess_row['credit_fmt']), 1); $pay_form->elem_success = new StringElem(_("Sesion paid!")); } $pay_form->follow_params['sum'] = $sess_row['credit']; $pay_form->follow_params['sid'] = $sess_row['sid']; $pay_form->QueryString = str_dbparams($dbhandle, 'SELECT pay_session(%1, %2, true) AS money;', array($sess_row['sid'], $_GET['sum'])); $pay_form->elem_fail = new StringElem(_("Session could not be paid!")); $pay_form->elem_success->content .= "\n<br><a href=\"{$booth_page}\">" . _("Back to booths") . "</a>"; } }
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'); $HD_Form->rmodel[] = new TextField(_('Destination'), 'destination'); $HD_Form->rmodel[] = new SecondsField(_('Max call duration'), 'tmout'); end($HD_Form->rmodel)->fieldacr = _('Tm'); $HD_Form->rmodel[] = new IntField(_('Rate/min'), 'rate5min'); // $HD_Form->rmodel[] = new TextField(_('Matched Prefix'),'prefix') ;