0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: edit_stockentry_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']; $stockentrydb_id=$_GET['id']; $itemname_db=$_GET['name']; $sql="select * from stockentry where user_id='$u_id' and stockentry_id='$stockentrydb_id'"; $sql1=mysql_query($sql); while($row=mysql_fetch_array($sql1)) { //1 $stockentrydate_db=$row['stockentrydate']; $iteminstock_db=$row['itemsinstock']; $description_db=$row['description']; list($stockentry_yy, $stockentry_mm, $stockentry_dd) = split('[/.-]', $stockentrydate_db); }//1 if(isset($_POST['Update'])) { //2 $error_flag=0; $edititemname=@$_POST['txtitemtname']; $editstockentryid=@$_POST['txtstockentryid']; $stockentry_mm_restore=@$_POST['cmbstockentrymm']; $stockentry_dd_restore=@$_POST['cmbstockentrydd']; $stockentry_yy_restore=@$_POST['txtstockentryyy']; $stockentry_date_restore= $stockentry_yy_restore."-".$stockentry_mm_restore."-".$stockentry_dd_restore; $edititeminstock=@$_POST['txtitemsinstock']; $editdescription=@$_POST['txtdescription']; if (!is_numeric(@$_POST['txtstockentryyy'])) { $error['year_numeric']="Only allow numbers"; $error_flag=1; } if (!is_numeric(@$_POST['txtitemsinstock'])) { $error['itemnumber_numeric']="Only allow numbers"; $error_flag=1; } if($edititemname=="") { $error['edititemname_null']="Please Enter ItemName"; $error_flag=1; } if($edititeminstock=="") { $error['edititemnumber_null']="Please Enter number of Item"; $error_flag=1; } if($stockentry_yy_restore=="") { $error['stockentry_yy__null']="Please Enter Year"; $error_flag=1; } /*if($editdescription=="") { $error['editdescription_null']="Please Enter Description"; $error_flag=1; }*/ $sql="select * from stockitem where user_id='$u_id' and item_name='$edititemname'"; mysql_query($sql); if (mysql_affected_rows()<=0) { $error['item_add']="Plz Add this item first"; $error_flag=1; } if($error_flag==1) { $url=$server_ip."/USER/search_stockentry.php?message=$message"; echo "<script>window.location='$url'</script>"; } else { $sql="update `stockentry` set `item_name`='".$edititemname."', `stockentrydate`='".$stockentry_date_restore."' , `itemsinstock`='".$edititeminstock."', `description`='".$editdescription."' where `stockentry_id`='".$editstockentryid."'"; mysql_query($sql); if(mysql_affected_rows()>0) { $message="Updation Completed successfully.."; $url=$server_ip."/USER/search_stockentry.php?message=$message"; echo "<script>window.location='$url'</script>"; } else { $message="Updation Failed.."; $url=$server_ip."/USER/search_stockentry.php?message=$message"; echo "<script>window.location='$url'</script>"; } } } ?>