<?
include_once('../../config.inc.php');
Session::Start();
include_once ("../configuration/".$_SESSION['gatewayType'].".attr");
$oreon=$_SESSION['oreon'];
$dateFormat=$oreon->phpmyprepaid['display_date_format'];
$octet_type=$oreon->phpmyprepaid['octet_type'];
if (isset($_POST['type']))
$type=$_POST['type'];
if (isset($_POST['attr'])) {
$attrr=$_POST['attr'];
$attr="Attribute='".$_POST['attr']."'";
}
if (isset($_POST['db']))
$db=$_POST['db'];
if (isset($_POST['div']))
$div=$_POST['div'];
if (isset($_POST['exp']))
$exp=$_POST['exp'];
if (isset($_POST['print_tpl']))
$tpl_name=$_POST['print_tpl'];
$accountab=split(',',$_POST['id']);
$i=0;
$tableau = array();
$query="SELECT * From cards_tpl WHERE tpl_location='".$_SESSION['locID']."' and tpl_name='".$tpl_name."'";
$result = $_SESSION["oreon"]->database->database->query($query);
while ($row = $oreon->database->database->fetch_object($result)) {
$tableau[$tpl_name] = array(7);
$tableau[$tpl_name][0]=$row->tpl_name;
$tableau[$tpl_name][1]=stripslashes($row->tpl_value);
$tableau[$tpl_name][2]=$row->tpl_location;
$tableau[$tpl_name][3]=$row->cards_x;
$tableau[$tpl_name][4]=$row->cards_y;
$tableau[$tpl_name][5]=$row->margin_top;
$tableau[$tpl_name][6]=$row->margin_cell;
}
$tplname=$tpl_name;
$fck=$tableau[$tpl_name][1];
$loc_id=$tableau[$tpl_name][2];
$cards_x=$tableau[$tpl_name][3];
$cards_y=$tableau[$tpl_name][4];
$margin_cell=$tableau[$tpl_name][6];
$margin_top=$tableau[$tpl_name][5];
if ($cards_x=='') $cards_x=2;
$html='<HTML>';
$html.='<head><TITLE>Cards printing</TITLE>';
$html.='<style type="text/css">@page { size:landscape; margin-top:20cm; margin-right:0cm; margin-left:0cm; margin-bottom: 0px; marks:cross;}</style>';
$html.='</head><body>';
$html.="<table cellspacing='".$margin_cell."' style=\"margin-top: ".$margin_top."px; margin-left: auto; margin-right: auto;\" >";
$x=0;
$siz=sizeof($accountab);
if ($debug) print " SIZE ".$siz;
if ($debug) print " SIZE ".$cards_x;
print $html;
$html='';
for ($i=0;$i<$siz;){
print '<tr>';
for ($j=0;$j<$cards_x && $i < $siz;$j++) {
$username=$accountab[$i];
$q="SELECT * FROM userinfo WHERE Username='".$username."'"; // get all the timed cards
$result = $_SESSION["oreon"]->database->database->query($q);
$row=$oreon->database->database->fetch_object($result);
$tp=$row->BillingPlan;
$activeDate=$row->activeDate;
$tp2=$row->Type;
$q2 = "SELECT Value FROM radcheck WHERE Attribute ='User-Password' and UserName='$username' "; // get all the timed cards
$result1 = $_SESSION["oreon"]->database->database->query($q2);
$row1=$oreon->database->database->fetch_array($result1);
$pass=$row1['Value'];
$pBp=get_plan_price($tp);
$dBp=get_plan_device($tp);
$nBp=get_plan_name($tp);
$q3 = "SELECT Value FROM $db WHERE $attr and UserName='$username' "; // get all the timed cards
if ($pBp=="") $pBp="none";
$result2 = $_SESSION["oreon"]->database->database->query($q3);
$row2=$oreon->database->database->fetch_array($result2);
$detail=$row2['Value'];
if ($tp2=="Subscription Expiration" or $tp2=="Expiration")
$val=date($dateFormat,strtotime($detail));
else if ($tp2 == "Hourly" or $tp2 == "Subscription Time")
$val = time2str ($detail );
else if ($tp2 == "Octets" or $tp2 == "Subscription Octets")
$val = octets2str ($detail);
$html='<td>';
$html.='<style=\"text-align: center; vertical-align: middle;\">';
$tmp=ereg_replace("%login", $username,$fck);
$tmp=ereg_replace("%password",$pass, $tmp);
$tmp=ereg_replace("%price", $pBp.' '.$dBp,$tmp);
$tmp=ereg_replace("%validity", $val,$tmp);
$tmp=ereg_replace("%location",$loc_id,$tmp);
$tmp=ereg_replace("%billingplan",$nBp,$tmp);
$html.=$tmp;
$html.='</td>';
print $html;
$i++;
}
print '</tr>';
$x++;
}
$html='</table>';
$html.='</body>';
$html.='</HTML>';
print $html;
?>