prepare($zone_q); $zone_res = $db->execute($zone_st,array($token,$rate)); if(handleError($zone_res)) { while($zone_res->fetchInto($zone_row)) { $zones[] = $zone_row; } } //get the tariff entry $rate_q = "SELECT * FROM rate WHERE rt_channel_out = ? AND rt_callrate = ?"; $rate_st = $db->prepare($rate_q); $rate_res = $db->execute($rate_st,array($token,$rate)); if(handleError($rate_res)) { while($rate_res->fetchInto($rate_row)) { $rates[] = $rate_row; } } //get the time entries $tpl->assign('zones',$zones); $tpl->assign('rates',$rates); } } if($LU->checkRight(ADMIN)) { //get a hierarchical select of the TOKEN -> RATE $tpl->setTPL("show_bill_form.tpl"); $form = new HTML_QuickForm("NewForm"); $token_q = "SELECT DISTINCT(zn_channel_out) as zone_chan FROM zone UNION SELECT DISTINCT(rt_channel_out) as zone_chan FROM rate "; $token_res = $db->query($token_q); $hsel_main = array(); $hsel_sec = array(); if(handleError($token_res)) { $rate_q = "SELECT DISTINCT(zn_callrate) AS rate FROM zone WHERE zn_channel_out = ? UNION SELECT DISTINCT(rt_callrate) AS rate FROM rate WHERE rt_channel_out = ?"; $rate_st = $db->prepare($rate_q); while($token_res->fetchInto($token_row)) { //get the callrates that correspond $rate_res = $db->execute($rate_st,array($token_row['zone_chan'],$token_row['zone_chan'])); if(handleError($rate_res)) { $rates = array(); while($rate_res->fetchInto($rate_row)) { $rates[$rate_row['rate']] = $rate_row['rate']; } asort($rates); $hsel_main[$token_row['zone_chan']] = $token_row['zone_chan']; $hsel_sec[$token_row['zone_chan']] = $rates; } } } $hsel = $form->addElement('hierselect','token_sel','Select: ',null); asort($hsel_main); $hsel->setOptions(array($hsel_main,$hsel_sec)); //{{{ validate form if($form->validate()) { $result = $form->process('process_data','false'); } else { if(isset($_SESSION['token'])&&isset($_SESSION['rate'])) { $args = array( 'token_sel' => array($_SESSION['token'],$_SESSION['rate']) ); process_data($args); $form->setDefaults(array('token_sel'=>array($_SESSION['token'],$_SESSION['rate']))); } } //}}} } //{{{ assign form to tpl and display form $tpl->display(&$form); //}}} ?>