<?php

/* FIRESHOP: Advanced Content Market System                         */

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

/*                                                                      */

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

/* http://Firedesign.ir                                                   */

/*                                                                      */

/* This program is free software.  */

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

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

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



if(isset($_POST['add_product'])){


if(empty($_POST['title'])
or empty($_POST['des'])
or empty($_POST['image'])
or empty($_POST['price'])
or empty($_POST['cat'])
or empty($_POST['is_active'])

){echo"پر كردن همه ي فيلد ها الزامي است";}else{

$title = $_POST['title'];
$is_active = $_POST['is_active'];
$des = $_POST['des'];
$image = $_POST['image'];
$price = $_POST['price'];
$cat = $_POST['cat'];
$is_vip = $_POST['is_vip'];
include("includes/jdate.php");
$today = jdate(" d /m /13y");
$dater = $today;
$time_stamp= time();
if($is_vip==1){
$query = $db->sql_query("UPDATE fireshop_product  SET `is_vip`= 0 WHERE `is_vip`=1");
}


$query = $db->sql_query("INSERT INTO fireshop_product (`product_title`, `product_des`, `product_pic`, `product_cat`, `product_price`, `product_date`, `product_time_stamp`, `is_vip`,`is_active`) VALUES ('$title', '$des', '$image', '$cat', '$price', '$dater', '$time_stamp', '$is_vip','$is_active')");if($query){print('<div class="contact_active">محصول با موفقيت اضافه گرديد</div>');}else{
print('<div class="failed"><div class="MsgBody">خطا</div></div>');}



}

}else{
echo"


<div style='padding:10px'  align='center' >
<form action='admin.php?do=add_product' method='post'>
<table width='100%'  dir='rtl' cellpadding='0' cellspacing='0'>
<tr>

<td>
عنوان كالا *:  <input type='text' size='30' name='title'/><br/><br/>
توضيحات *:  <br/><br/>";

wysiwyg_textarea('des', '', 'FireShopAdmin', 50, 15);

echo"<br/><br/>

لينك تصوير *:  <input type='text' name='image' size='40'/>  سايز استاندارد تصوير : 190x145 <a onclick=\"window.open('upload.php','upload','status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=380px,height=250px');\">[ آپلود تصوير ]</a><br/><br/>

قيمت *:  <input type='text' name='price' size='30'/> به تومان <br/><br/>
دسته بندي *:  <select name='cat'>";

$query = $db->sql_query("SELECT * FROM fireshop_category Where `is_a_cat`='0' ORDER BY `id` ASC");
while ($row = $db->sql_fetchrow($query)) {
$title = $row['title'];
$id_par= $row['id'];
echo"<option value='$id_par'>$title</option>";}

echo"</select><br/><br/>
وضعيت *:  <select name='is_active'><option value='1'>فعال</option>
<option value='0'>غير فعال</option>
</select><br/><br/>

محصول ويژه : (براي نمايش در صفحه اصلي)  بله :  <input type='radio' name='is_vip' value='1'/>
خير : <input type='radio' name='is_vip' value='0'  checked='checked'/>

</td>
</tr>
</table>
<div align='left' style='margin-left:20px;'>
<input  type='submit' name='add_product' value='اضافه كن'/>&nbsp;&nbsp;&nbsp;
<button onclick='javascript:history.go(-1)' class='button'>بازگشت</button></div></form></div></BODY>";

}

?>