0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: edit_stockitem_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; include( "../lib/config.php"); include_once("../model/defaults_mdl.php"); require_once "../model/defaultValues_mdl.php"; $p_id=@$_SESSION['project_id']; $u_id=@$_SESSION['user_id']; $itemdb_id=$_GET['id']; $sql="select * from stockitem where user_id='$u_id' and item_id='$itemdb_id'"; $sql1=mysql_query($sql); while($row=mysql_fetch_array($sql1)) { //1 $itemname=$row['item_name']; $description=$row['description']; $category=$row['category_name']; }//1 $sql="select * from stockcategory where user_id='$u_id'"; $sql=mysql_query($sql); $i=0; while($row=mysql_fetch_array($sql)) { $stockcategory=$row['category_name']; $i=$i+1; $stockcategory_array[$i]=$stockcategory; } $stockcategory_restore=@$_POST['cmbstockcategory']; $category_name=$stockcategory_array[$stockcategory_restore]; if(isset($_POST['Update'])) { //2 $error_flag=0; $edititemname=@$_POST['txtitemtname']; $edititemid=@$_POST['txtitemid']; $editdescription=@$_POST['txtdescription']; if($edititemname=="") { $error['edititemname_null']="Please EnteraccountName"; $error_flag=1; } if($editdescription=="") { $error['editdescription_null']="Please EnteraccountName"; $error_flag=1; } $sql="select `item_name` from stockitem where user_id='$u_id' and item_name='$edititemname' and item_id<>'$edititemid'"; mysql_query($sql); if (mysql_affected_rows()>0) { $error['item_exist']="Itemname already exists"; $error_flag=1; } if($error_flag==1) { include("edit_stockitem.php"); exit(); } else { $p_id=@$_SESSION['project_id']; $u_id=@$_SESSION['user_id']; $sql="select * from stockitem where user_id='$u_id' and item_id='$edititemid'"; $sql1=mysql_query($sql); while($row=mysql_fetch_array($sql1)) { //1 $olditemname=$row['item_name']; }//1 $sql="update `stockitem` set `item_name`='".$edititemname."', `category_name`='".$category_name."' , `description`='".$editdescription."' where `item_id`='".$edititemid."'"; mysql_query($sql); $sql="update `stockentry` set `item_name`='".$edititemname."' where `item_name`='".$olditemname."'"; mysql_query($sql); $sql="update `stockusage_entry` set `item_name`='".$edititemname."' where `item_name`='".$olditemname."'"; mysql_query($sql); if(mysql_affected_rows()>0) { $message="Updation Completed successfully.."; $url=$server_ip."/USER/search_stockitem.php?message=$message"; echo "<script>window.location='$url'</script>"; } else { $message="Updation Failed.."; $url=$server_ip."/USER/search_stockitem.php?message=$message"; echo "<script>window.location='$url'</script>"; } } } ?>