Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/display/add_unit.php
<?php

include('../../config.inc.php');
if (!isset($_SESSION['oreon'])) Session::Start();
$oreon=$_SESSION['oreon'];
if (isset($_POST['type']))
	        $type=$_POST['type'];

if (isset($_POST['attr']))
	        $attr=$_POST['attr'];

if (isset($_POST['dbname']))
	        $dbname=$_POST['dbname'];



include_once ("../configuration/".$_SESSION['gatewayType'].".attr");
if (isset($_POST['add_unit_text']) and ($_POST['add_unit_text']!="") and isset($_POST['phpmyprepaid']) )
{
	$usernametab =split(',',$_POST['ID']);
	echo " USERNAMMMMMMMME ".$usernametab;
	//////////////////////////////////////////////////////////
	for($i=0;$i<sizeof($usernametab);$i++) {
	$usernametmp=$usernametab[$i];
	$cval=get_user_value($usernametmp,$type);
	$timeCount=$_POST['TimeCount'];	
	if ($debug) echo "VALUE BEFORE ".$cval;
	if ($debug) echo "TYPE ".$type;
	if ($debug) echo "Username Tmp ".$usernametmp;
	if ($debug) echo " MAX ".$maxs." USERNAME :".$usernametmp;
	$timeCount=$_POST['TimeCount'];
	$maxs =$_POST['add_unit_text'];
	if ( $type=="Subscription Time" or  $type=="Hourly") $typeof='Time';
	else if ( $type=="Subscription Octets" or  $type=="Octets") $typeof='Octet';

	$maxs=get_conversion($maxs,$timeCount,$typeof);
	print '<br> J4AI CONVERTIS '.$maxs;
	if ( $type=="Subscription Expiration" or  $type=="Expiration" or $type=="Subscription Mac")
		modify_user($usernametmp,"",$maxs,"",$attr,$type,$_SESSION['gatewayType'],$dbname,NULL,$oreon->phpmyprepaid['crypt']);
	else
		modify_user($usernametmp,"",$maxs+$cval,"",$attr,$type,$_SESSION['gatewayType'],$dbname,NULL,$oreon->phpmyprepaid['crypt']);
	}
	if (!$debug) echo '<script language="JavaScript">window.opener.document.getElementById("event_id").submit();self.close();</script>';
}
else
{
if (isset($_POST['id'])) {
$usernametmp =$_POST['id'];
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="STYLESHEET" type="text/css" href="../../style/popup.css">
<title> Add unit to user </title>
</head>
<body onblur="window.focus">
<table border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr><td>';
 if ($debug) echo " TYPE ".$type;
 if ($debug) echo " DB ".$db;
 if ($debug) echo " OCTET TYPE ".$oreon->phpmyprepaid['octet_type'];
 
echo "<form action=add_unit.php method=\"post\" >";
if ( $type=="Subscription Expiration" or $type=="Expiration" )
{
	echo '<em>Change the date  :</em><br>';
	$datef=date($dateFormat);
	echo "</td><td class=\"fieldcell\" style=\"text-align: left\"><input type=text size=15 class=text  name=\"add_unit_text\" value=\"$datef\"></td>";
}
else if ($type=="Hourly" or $type=="Subscription Time")
{
	echo '<em>Select the value you would like to add :</em><br>';
	echo '</td><td class="fieldcell" style="text-align: left">';
	echo ("<table><tr><td><input type=text id='valuesub' size=10 class=text name=\"add_unit_text\" value=\"$val\"></td><td>");
		echo '<select name="TimeCount">';

		$tabv=split(";",$timeCount);
	   for ($i=0;$i<sizeof($tabv);$i++) {
	       if ($defaultTimeCount == $tabv[$i])
		echo ("<option selected=\"selected\" value=\"".$tabv[$i]."\">".$tabv[$i]);
	      else
		echo ("<option value=\"".$tabv[$i]."\">".$tabv[$i]);
	      echo ("</option>'");
	    }
	    echo '</select> 
			</td>';
			
    echo '</tr></table></td>';

}
else if ($type=="Octets" or $type=="Subscription Octets") {
        echo '<em>Select the value, you would like to add :</em><br>';
       echo '</td><td class="fieldcell" style="text-align: left">';
	echo ("<table><tr><td><input type=text id='valuesub' size=10 class=text name=\"add_unit_text\" value=\"$val\"></td><td>");
	echo '<select name="TimeCount">';

		$tabv=split(";",$octetCount);
	   for ($i=0;$i<sizeof($tabv);$i++) {
	       if ($defaultOctetCount == $tabv[$i])
		echo ("<option selected=\"selected\" value=\"".$tabv[$i]."\">".$tabv[$i]);
	      else
		echo ("<option value=\"".$tabv[$i]."\">".$tabv[$i]);
	      echo ("</option>'");
	    }
	    echo '</select> 
			</td>';
			
	    echo '</tr></table>';
}

    echo '<td style="text-align: center; width: 25px; height: 25px;">';
    echo("<input type=\"hidden\" name=\"ID\" value=\"".$usernametmp."\">");
    echo("<input type=\"hidden\" name=\"phpmyprepaid\" value=\"".session_id()."\">");
    echo("<input type=\"hidden\" name=\"dbname\" value=\"".$dbname."\">");
    echo("<input type=\"hidden\" name=\"type\" value=\"$type\">");
    echo("<input type=\"hidden\" name=\"attr\" value=\"$attr\">");
    printf('<input type="image" style="width: 24px; height: 25px;" value="submit" name="add_unit" alt="Add unit to user" title="Add unit to user" src="../../images/insert_unit.png" valign="middle">');
    printf('</form>');
    echo "</td>";
  


echo '    </tr>
  </tbody>
</table>
</body>
</html>';
}
}
?>

Return current item: phpMyPrepaid