<?php

/* FIRESHOP: Advanced Content Market System                         */

/* ============================================                         */

/*                                                                      */

/* Copyright (c) 2012 by Mohamad Porhaji                                */

/* http://Firedesign.ir                                                   */

/*                                                                      */

/* This program is free software.  */

/************************************************************************/

/* $Id: sendway.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */

if (stristr(htmlentities($_SERVER["PHP_SELF"]), "sendway.php")) {
    Header("Location: index.php");
    die();
}

if(isset($_POST['edit_sendway_res'])){
$id=$_POST['id'];
$title=$_POST['title'];
$maliyat=$_POST['maliyat'];
$hazine=$_POST['hazine'];
$is_active=$_POST['is_active'];
$query = $db->sql_query("UPDATE `fireshop_sendway` SET `title`='$title',`maliyat`='$maliyat', `hazine`='$hazine' ,`is_active`='$is_active'  WHERE id='$id' LIMIT 1");if($query){print('<div class="contact_active"> با موفقيت ويرايش گرديد<br/></div>');
}else{print('<div class="failed"><div class="MsgBody">خطا<br/><button onclick="javascript:history.go(-1)" class="button">بازگشت</button></div></div>');}
}
if(isset($_POST['edit_sendway'])){
$id=$_POST['id'];
$sql = $db->sql_query("SELECT * FROM fireshop_sendway WHERE id='$id'");
$row = $db->sql_fetchrow($sql);
$id = $row['id'];
$title = $row['title'];
$is_active= $row['is_active'];
$maliyat=$row['maliyat'];
$hazine=$row['hazine'];
echo"
<div align='right' style='padding:10px' dir='rtl'>
<form action='admin.php?do=sendway' method='POST'>
<div style='float:right;width:150px' for=\"name\">عنوان : <span style='color: red'>*</span></div>
<div style='float:right;'><input type='text' name=\"title\" value='$title' size='50' style='height: 20px'/></div><div class='clear'></div><br/>

<div style='float:right;width:150px' for=\"name\">ماليات يا هزينه هاي متفرقه : <span style='color: red'>*</span></div>
<div style='float:right;'><input type='text' name=\"maliyat\" value='$maliyat' size='30' style='height: 20px'/> مبلغ به تومان</div><div class='clear'></div><br/>

<div style='float:right;width:150px' for=\"name\">هزينه پستي : <span style='color: red'>*</span></div>
<div style='float:right;'><input type='text' name=\"hazine\" value='$hazine' size='30' style='height: 20px'/> مبلغ به تومان</div><div class='clear'></div><br/>

وضعيت  : <span style='color: red'>*</span> فعال <input type='radio' name='is_active' checked='checked' value='1'/> غيرفعال <input type='radio' name='is_active' value='0'/><br/><br/>
<div style='margin-right:300px'>
<input  type='hidden' size='10' name='id'  value='$id'/>
<input  type='submit' name='edit_sendway_res' value='ويرايش' />
<button onclick='javascript:history.go(-1)' class='button'>بازگشت</button>
</div><br/>
</form>
</div>";


}else{

echo"<div align='center' dir='rtl' style='padding:10px'>
<table style='background-color: #333333; font-family: tahoma; font-size: 11px; text-decoration: none; color: #CCCCCC'>
<tr>
<td style='width: 300px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>
طريقه ارسال </td>
<td style='width: 50px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>
وضعيت</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>
ماليات</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #CCCCCC;'>

هزينه پستي</td>
<td style='width: 130px;'>

اختيارات</td>

</tr>
</table>";

$sql = $db->sql_query("SELECT * FROM fireshop_sendway ORDER BY  `id` DESC");
while ($row = $db->sql_fetchrow($sql)) {
$id = $row['id'];
$title = $row['title'];
$is_active= $row['is_active'];
$maliyat=number_format($row['maliyat'], 0);
$hazine=number_format($row['hazine'], 0);
if($is_active==1){$is_active="فعال";}else{$is_active="غيرفعال";}

echo"
<table style='background-color: #CCCCCC; font-family: tahoma; font-size: 11px; text-decoration: none; color: #333333'>
<tr>
<td style='width: 300px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
 $title</td>
<td style='width: 50px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
$is_active</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
$maliyat  تومان</td>
<td style='width: 80px; border-left-style: solid; border-left-width: 1px; border-left-color: #ffffff;border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
$hazine  تومان
</td>
<td style='width: 130px; border-top-style: solid; border-top-width: 1px; border-top-color: #ffffff;'>
<div style='float:right;'><form action='admin.php?do=sendway' method='post'>
<input  type='hidden' size='10' name='id'  value='$id'/>
<input  type='submit' name='edit_sendway' value='ويرايش'/></form></div>
<div style='float:right;'><form style='float:right;' action='admin.php?do=del_sendway' method='post'>
<input  type='hidden' size='10' name='id'  value='$id'/>
<input  type='submit' name='del_sendway' value='حذف'/></form></div>
<div class=\"clear\"></div>
</td>
</tr>
</table>
";
}
echo"</div>";
}
?>