/admin/them_hanghoa.php
PHP | 165 lines | 149 code | 11 blank | 5 comment | 25 complexity | 6ab0592593f9a0f0995ace9602a547d6 MD5 | raw file
- <?php
- ob_start();
- session_start();
- ob_clean();
- if(isset($_SESSION['username'])&&$_SESSION['level']==2){
- require("../includes/config.php");
- if(isset($_POST['ok'])){
- if($_POST['slloaihang'] == -1){
- echo "<div align='center'>Lŕm ?n ch?n lo?i hŕng</div>";
- }else{
- $sllh=$_POST['slloaihang'];
- }
- if($_POST['slcongty'] == -1){
- echo "<div align='center'>Lŕm ?n ch?n công ty</div>";
- }else{
- $slct=$_POST['slcongty'];
- }
-
- if($_POST['txtname'] == NULL){
- echo "<div align='center'>Lŕm ?n nh?p tęn m?t hŕng vŕo</div>";
- }else{
- $tenhang=$_POST['txtname'];
- }
- ////////////
- if($_POST['txtdongia'] == NULL){
- echo "<div align='center'>Lŕm ?n nh?p ??n giá vŕo</div>";
- }else{
- $dg=$_POST['txtdongia'];
- }
- if($_POST['txtmota'] == NULL){
- $mota="none";
- }else{
- $mota=$_POST['txtmota'];
- }
- if($_POST['txtghichu'] == NULL){
- $ghichu="none";
- }else{
- $ghichu=$_POST['txtghichu'];
- }
- ////////////
- if($_POST['filehinh']!=NULL){
- move_uploaded_file($_FILES['filehinh']['tmp_name'],"../images/".$_FILES['filehinh']['name']);
- $image="images/".$_FILES['filehinh']['name'];
- }else{
- $image="none";
- }
-
- if($tenhang && $slct && $sllh && $dg && $image && $mota && $ghichu){
- $sql="insert into hanghoa(idcongty,tenhang,mota,ngaycapnhat,dongia,urlhinh,ghichu) values('$slct','$tenhang','$mota','".$_POST['txtngaycapnhat']."','$dg','.$image.','$ghichu')";
- mysql_query($sql);
- mysql_close($conn);
- header("location:hanghoa.php");
- exit();
- }
- }
- ///////////////////////////// l?y th?i gian hi?n hŕnh////////////////////
- $now = time();
- $nowstr = date("d-m-Y", $now);
- $nowstr1 = date("Y-m-d", $now);
-
- ////////////////////// l?y giá tr? lo?i hŕng ???c ch?n trong select//////////////////////////////
- $sql="select * from loaihang where idloaihang='".$_GET["idloaihang"]."'";
- $query=mysql_query($sql);
- if (mysql_num_rows($query)>0)
- {
- $row=mysql_fetch_array($query);
- $idloaihang=$row["idloaihang"];
- }
- else
- {
- $idloaihang="";
- }
- ///////////////////////////////////////////////////
-
-
- ?>
- <link href="style.css" rel="stylesheet" name="text/css" />
- <form action="them_hanghoa.php" method="post">
- <center><font size="5">Thęm Hŕng Hóa</font>
- <table width="400">
- <tr>
- <td width="200">Lo?i hŕng:
- <td width="200">
- <select name="slloaihang" onChange="location.href='them_hanghoa.php?idloaihang='+this.value;">
- <option value="-1">Ch?n Lo?i Hŕng</option>
-
- <?php
- $sql="select * from loaihang order by tenloai ASC";
- $query=mysql_query($sql);
-
- while($row=mysql_fetch_assoc($query))
- {
- if($idloaihang==$row['idloaihang'])
- echo "<option value='".$row['idloaihang']."' selected>".$row['tenloai']."</option>";
- else
- echo "<option value='".$row['idloaihang']."'>".$row['tenloai']."</option>";
- }
- ?>
-
- </select>
- </td>
- </tr>
- <tr>
- <td width="200">Công Ty:
- <td width="200">
- <select name="slcongty" >
- <?php
- $sql="select * from congty where idloaihang='".$idloaihang."'order by tencongty ASC";
- $query=mysql_query($sql);
- if( mysql_num_rows($query)!=0)
- {
- echo "<option value='-1'>Ch?n Công Ty</option>";
- while($row=mysql_fetch_assoc($query))
- {
- echo "<option value='".$row['idcongty']."' >".$row['tencongty']."</option>";
- }
- }
- else
- echo "<option value='-1'>Không có công ty</option>";
-
- ?>
-
- </select>
- </td>
- </tr>
-
- <tr>
- <td width="200">Tęn M?t Hŕng:
- <td width="200"><input type="text" name="txtname" size="25" /> </td>
- </tr>
- <tr>
- <td width="200">Mô T?:
- <td width="200"><textarea name="txtmota" cols=25 rows=10 ></textarea></td>
- </tr>
- <tr>
- <td width="200">Ngŕy c?p nh?t:
- <td width="200"><input type="text" name="txtngaycapnhat1" size="25" disabled="disabled" value="<?php echo $nowstr;?>" /> </td>
- <td><input type="hidden" name="txtngaycapnhat" size="25" value="<?php echo $nowstr1;?>" /> </td>
- </tr>
- <tr>
- <td width="200">??n giá:
- <td width="200"><input type="text" name="txtdongia" size="25" /> </td>
- </tr>
- <tr>
- <td width="200">Hěnh:
- <td width="200"><input type="file" name="filehinh" id="filehinh" size="20" /> </td>
- </tr>
- <tr>
- <td width="200">Ghi chú:
- <td width="200"><input type="text" name="txtghichu" size="25" /> </td>
- </tr>
- <tr>
- <td colspan="2" align="center"> <input type="submit" name="ok" value="Thęm" /> <a href=hanghoa.php> <input type="button" name="btnhanghoa" value="Quay L?i" /></a> </td>
- </tr>
- </table>
- </center>
- </form>
- <?php
- }
- else
- {
- header("location:login.php");
- exit();
- }
- ?>