<?php
include("include/config.php");
include("include/protect.class.php");
include("include/functions.php");
include("include/jdf.php");
$prot = new protect();
if ($prot->showPage) {
$db = new DB($globalConfig['dbase'], $globalConfig['dbhost'], $globalConfig['dbuser'],$globalConfig['dbpass']);
if (isset($_GET['do'])) {
        $action = $_GET['do'];
}
switch($action){
//-------------------------------------------------------------------------------------
        	case 'pdelete':
            if (isset($_GET['confirm'])) {
                $db->execute("delete from config where portalID = '" . (int)$_GET['id'] . "'");
            }
            header("location: configure.php");
            break;
//-------------------------------------------------------------------------------
        	case 'pinsert':
            if (isset($_POST['Insert'])) {
                $res = $db->execute("insert into config set 
													ad2_amount_1 ='" . $db->safe_string($_POST['ad2_amount_1']) . "',
													ad2_amount_2 ='" . $db->safe_string($_POST['ad2_amount_2']) . "',
													ad2_amount_3 ='" . $db->safe_string($_POST['ad2_amount_3']) . "',
													ad2_amount_6 ='" . $db->safe_string($_POST['ad2_amount_6']) . "',
													ad2_amount_12 ='" . $db->safe_string($_POST['ad2_amount_12']) . "' ");
            }
			 break;
        	case 'update':
            if (isset($_POST['Insert'])) {
                $res = $db->execute("update  config set 
													ad2_amount_1 ='" . $db->safe_string($_POST['ad2_amount_1']) . "',
													ad2_amount_2 ='" . $db->safe_string($_POST['ad2_amount_2']) . "',
													ad2_amount_3 ='" . $db->safe_string($_POST['ad2_amount_3']) . "',
													ad2_amount_6 ='" . $db->safe_string($_POST['ad2_amount_6']) . "',
													ad2_amount_12 ='" . $db->safe_string($_POST['ad2_amount_12']) . "',
													priceStar1 ='" . $db->safe_string($_POST['priceStar1']) . "',
													priceStar2 ='" . $db->safe_string($_POST['priceStar2']) . "',
													priceStar3 ='" . $db->safe_string($_POST['priceStar3']) . "'
													where config_id='".$_POST['config_id']."' ");
            }			
            header("location: configure.php");
            break;
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>مدیریت قیمت پلانها </title>
<?php include("maintemplate/mainheader.php");?>
</head>
<body>
<div id="wpwrap">
<div id="wpcontent">
	<?php include("include/menutop.php");?> 
<div id="wpbody">
	<?php include("include/header.php");?>
    <div style="overflow:hidden;" id="wpbody-content">
        <div id="screen-meta">
            <div class="wrap">
                <div id="icon-index" class="icon32"><br></div>
                <h2>مدیریت قیمت پلانها</h2>
                <div id="dashboard-widgets-wrap">
                    <div id="dashboard-widgets" class="metabox-holder">
                        <div class="postbox-container" style="width:100%;">
                            <div id="normal-sortables" class="meta-box-sortables ui-sortable"><div id="dashboard_recent_comments" class="postbox ">  
                    <div class="handlediv" title="برای جانشینی کلیک کنید"><br></div><h3 class="hndle"><span>مدیریت قیمت پلانها  </span></h3>

<?php
$sql = $db->query("select * from config where config_id = '1'");
$data=$db->fetchNextArray($sql);
$num = $db->numRows($sql);
if($_GET['act']=='edite'){
       $act = 'do=update';
}else{
		$act = 'do=update';
}
?>
<form action="configure.php?<?= $act ?>" method="post">
<table class="table1" width="600px" dir="rtl">

    
    <tr>
    	<td>هزینه هر  پلان (یک ماهه به ازای هر روز):</td><td><input name="ad2_amount_1" type="text" value="<?php echo $data['ad2_amount_1'] ?>"/>ریال</td>
	</tr>
    
    <tr>
    	<td>هزینه هر پلان (سه ماهه به ازای هر روز):</td><td><input name="ad2_amount_3" type="text" value="<?php echo $data['ad2_amount_3'] ?>"/>ریال</td>
	</tr>    
    
    <tr>
    	<td>هزینه هر پلان (شش ماهه به ازای هر روز):</td><td><input name="ad2_amount_6" type="text" value="<?=$data['ad2_amount_6']?>"/>ریال</td>
	</tr>
    
    <tr>
    	<td>هزینه هر پلان (دوازده ماهه به ازای هر روز):</td><td><input name="ad2_amount_12" type="text" value="<?php echo $data['ad2_amount_12'] ?>"/>ریال</td>
	</tr>
        
    <tr>
    	<td> ارزش  پلان برنزی:</td><td><input name="priceStar1" type="text" value="<?php echo $data['priceStar1'] ?>"/> </td>
	</tr>    
        
    <tr>
    	<td> ارزش  پلان نقره ای:</td><td><input name="priceStar2" type="text" value="<?php echo $data['priceStar2'] ?>"/> </td>
	</tr>    
        
    <tr>
    	<td> ارزش  پلان طلایی:</td><td><input name="priceStar3" type="text" value="<?php echo $data['priceStar3'] ?>"/> </td>
	</tr>            
    
    <tr>
    	<td></td>
        <td>
        	 <input type="submit" name="Insert" value="ذخیره" /> 
        	<input type="hidden" value="<?=$data['config_id']?>" name="config_id" />
        </td>
    </tr>
</table>
</form>
                           </div>
                          </div>
                        </div>                        
                    </div>
                    <div class="clear"></div>
                </div><!-- dashboard-widgets-wrap -->
            </div><!-- wrap -->
			<div class="clear"></div></div><!-- wpbody-content -->
			<div class="clear"></div></div><!-- wpbody -->
			<div class="clear"></div></div><!-- wpcontent -->
        </div>
    </div><!-- wpcontent -->
</div><!-- wpwrap -->
<?php include("include/footer.php");?>
</div>
</div>
</body>
</html><?php } ?>