<?php
include("include/config.php");
include("include/protect.class.php");
include("include/jdf.php");
include('include/functions.php');
$prot=new protect();
if ($prot->showPage) {
$db=new DB($globalConfig['dbase'], $globalConfig['dbhost'],$globalConfig['dbuser'], $globalConfig['dbpass']);
mysql_query("SET NAMES utf8");
?>

<!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">
                        
                        
			<?php 
			if(isset($_GET['update'])){
			$db->execute("update configuration set phone = '".$db->safe_string($_POST['phone'])."',
													time_normal = '".$db->safe_string($_POST['time_normal'])."',
													price_normal = '".$db->safe_string($_POST['price_normal'])."',
													time_special = '".$db->safe_string($_POST['time_special'])."',
													price_special = '".$db->safe_string($_POST['price_special'])."',
													price_normal_agent = '".$db->safe_string($_POST['price_normal_agent'])."',
													price_special_agent = '".$db->safe_string($_POST['price_special_agent'])."',
													tehran = '".$db->safe_string($_POST['tehran'])."',
													shahrestan = '".$db->safe_string($_POST['shahrestan'])."',
													percent = '".$db->safe_string($_POST['percent'])."',
													gift = '".$db->safe_string($_POST['gift'])."'
												  where id = 1");

			echo debug_message('تنظیمات با موفقیت به روز رسانی شد','2','98');
		
		echo '<form action="config.php?do=discount_list" method="POST">
		<p align="center"><input type="submit" id="button" value="بازگشت"></p>
		</form>';
			}else{
				$sql = $db->query("select * from configuration where id = 1");
			$res = $db->fetchNextArray($sql);
                ?>         
                         <div class="postbox-container" style="width:98%;">
                                <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>
                                <div style="padding:10px; line-height:24px">
                               
                                <form action="config.php?update" method="post" name="addform" id="addform">
<table class="form-table">
<tbody>
<tr class="even" valign="top">
<th scope="row"><label for="phone">شماره تلفن نمایش زیر سایت</label></th>
<td><input name="phone"  id="phone" size="16" value="<?php echo $res['phone']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="odd" valign="top">
<th scope="row"><label for="time_normal">زمان آگهی معمولی</label></th>
<td><input name="time_normal"  id="time_normal" size="16" value="<?php echo $res['time_normal']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="even" valign="top">
<th scope="row"><label for="price_normal">مبلغ آگهی معمولی</label></th>
<td><input name="price_normal"  id="price_normal" size="16" value="<?php echo $res['price_normal']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="odd" valign="top">
<th scope="row"><label for="price_normal_agent">مبلغ آگهی معمولی نمایشگاه</label></th>
<td><input name="price_normal_agent"  id="price_normal_agent" size="16" value="<?php echo $res['price_normal_agent']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="even" valign="top">
<th scope="row"><label for="time_special">زمان آگهی ویژه</label></th>
<td><input name="time_special"  id="time_special" size="16" value="<?php echo $res['time_special']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="odd" valign="top">
<th scope="row"><label for="price_special">مبلغ آگهی ویژه</label></th>
<td><input name="price_special"  id="price_special" size="16" value="<?php echo $res['price_special']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="even" valign="top">
<th scope="row"><label for="price_special_agent">مبلغ آگهی ویژه نمایشگاه</label></th>
<td><input name="price_special_agent"  id="price_special_agent" size="16" value="<?php echo $res['price_special_agent']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="add" valign="top">
<th scope="row"><label for="gift">مبلغ هدیه</label></th>
<td><input name="gift"  id="gift" size="16" value="<?php echo $res['gift']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="even" valign="top">
<th scope="row"><label for="percent">درصد تخفیف</label></th>
<td><input name="percent"  id="percent" size="16" value="<?php echo $res['percent']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="odd" valign="top">
<th scope="row"><label for="tehran">هزینه ارسال تهران</label></th>
<td><input name="tehran"  id="tehran" size="16" value="<?php echo $res['tehran']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
<tr class="even" valign="top">
<th scope="row"><label for="shahrestan">هزینه ارسال شهرستان</label></th>
<td><input name="shahrestan"  id="shahrestan" size="16" value="<?php echo $res['shahrestan']; ?>" dir="ltr" class="regular-text" type="text">
</td>
</tr>
</tbody></table>


<p class="submit">
<input name="process" class="button-primary" value="ذخیره" type="submit">
</p>
</form>
                                
                                </div>

                              </div>
                            </div>
                        </div>  
                        <?php } ?>
                    </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 } ?>