[PHP]
<?
include("config.inc.php");
//error_reporting(0);
if(isset($_REQUEST['Submitstore2'])=="Delete")
{
$storeno=$_REQUEST['storeno'];
$sql_storedelete="delete from store_info where storeid='$storeno'";
mysql_query($sql_storedelete);
}
if(isset($_REQUEST['Submitstore'])=="Update")
{
$storeno=$_REQUEST['storeno'];
$storename=$_REQUEST['storename'];
$warehousename=$_REQUEST['warehousename'];
$storecontactno=$_REQUEST['contactno'];
$note=$_REQUEST['note'];
$storecontactperson=$_REQUEST['contactperson'];
if($storeno!="" && $storename!="" && $warehousename!="" && $storecontactno!="" && $note!="" && $storecontactperson!="")
{
$sql_storeupdate="UPDATE `store_info` SET `storename`='$storename', `warehouse`='$warehousename', `contactperson`='$storecontactperson', `contactno`='$storecontactno',`note`='$note' WHERE `storeid`='$storeno'";
//echo $sql_storeupdate;
mysql_query($sql_storeupdate);
$msg="updated";
}
else
{
$msg="error";
}
}
?>[/PHP][HTML]
<html>
<head><title>store Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="<?php echo $NF_config['css_file'];?>" rel="stylesheet" type="text/css">
<link href="_css/nf_style.css" rel="stylesheet" type="text/css">
<style type="text/css">
.style1 {font-size: 9}
</style>
<link href="../../_css/nf_style.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">[/HTML]
Expand|Select|Wrap|Line Numbers
- function loadIndividual(form) {
- var gifName=form.storeimageupload.value;
- document.getElementById('hidimg').value=gifName;
- //alert(gifName);
- document.getElementById('storeimage').src=gifName;
- }
- function backtomain()
- {
- window.location="http://localhost/sugarcub_erp/sugarcub_inventory/in.php";
- }
- //problem in this ajax functions
- function ajaxfunctionstore(text){
- var ajaxRequest; // The variable that makes Ajax possible!
- try{
- // Opera 8.0+, Firefox, Safari
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- // Internet Explorer Browsers
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- // Something went wrong
- alert("Your browser broke!");
- return false;
- }
- }
- }
- // Create a function that will receive data sent from the server
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var x=ajaxRequest.responseText;
- //alert(x);
- var gettype=x.split("*");
- var getlen=gettype.length;
- getlen=getlen-1;
- document.forms['store_update_form_entry'].storeno.value = gettype[0];
- document.forms['store_update_form_entry'].storename.value = gettype[1];
- document.forms['store_update_form_entry'].warehousename.value = gettype[2];
- document.forms['store_update_form_entry'].contactperson.value = gettype[3];
- document.forms['store_update_form_entry'].contactno.value = gettype[4];
- document.forms['store_update_form_entry'].note.value = gettype[5];
- }
- }
- var username=text;
- //var wpm = document.getElementById('wpm').value;
- //var sex = document.getElementById('sex').value;
- var queryString = "?username=" + username;
- //alert(queryString);
- ajaxRequest.open("POST","http://localhost/sugarcub_erp/sugarcub_inventory/storeupdateno.php" + queryString, true);
- ajaxRequest.send(null);
- }
- function ajaxfunctionstorename(text){
- var ajaxRequest; // The variable that makes Ajax possible!
- try{
- // Opera 8.0+, Firefox, Safari
- ajaxRequest = new XMLHttpRequest();
- } catch (e){
- // Internet Explorer Browsers
- try{
- ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try{
- ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e){
- // Something went wrong
- alert("Your browser broke!");
- return false;
- }
- }
- }
- // Create a function that will receive data sent from the server
- ajaxRequest.onreadystatechange = function(){
- if(ajaxRequest.readyState == 4){
- var x=ajaxRequest.responseText;
- //alert(x);
- var gettype=x.split("*");
- var getlen=gettype.length;
- getlen=getlen-1;
- document.forms['store_update_form_entry'].storeno.value = gettype[0];
- document.forms['store_update_form_entry'].storename.value = gettype[1];
- document.forms['store_update_form_entry'].warehousename.value = gettype[2];
- document.forms['store_update_form_entry'].contactperson.value = gettype[3];
- document.forms['store_update_form_entry'].contactno.value = gettype[4];
- document.forms['store_update_form_entry'].note.value = gettype[5];
- }
- }
- var username=text;
- //var wpm = document.getElementById('wpm').value;
- //var sex = document.getElementById('sex').value;
- var queryString = "?username=" + username;
- //alert(queryString);
- ajaxRequest.open("POST","http://localhost/sugarcub_erp/sugarcub_inventory/storeupdatename.php" + queryString, true);
- ajaxRequest.send(null);
- }//problem in this ajax functions//
- function setstoregrade(text)
- {
- document.getElementById('storegrade').value=text;
- }
- function showstoreno()
- {
- document.getElementById('storenoimage').style.display='inline';
- document.getElementById('storeselect_div').style.display='inline';
- document.getElementById('storeno_div').style.display='inline';
- document.getElementById('storenameimage').style.display='none';
- document.getElementById('storename_div').style.display='none';
- document.getElementById('storenameselect_div').style.display='none';
- }
- function showstorename()
- {
- document.getElementById('storenoimage').style.display='none';
- document.getElementById('storeselect_div').style.display='none';
- document.getElementById('storeno_div').style.display='none';
- document.getElementById('storenameimage').style.display='inline';
- document.getElementById('storename_div').style.display='inline';
- document.getElementById('storenameselect_div').style.display='inline';
- }
- function setwarehousename(text)
- {
- document.getElementById('warehousename').value=text;
- }
</script>
</head>
<body alink="#FFFFFF" vlink="#FFFFFF" link="#FFFFFF" >
<form name="store_update_form_entry" id="store_update_form_entry" action="" method="post" onSubmit="return check(document.department_form_entry)" >
<input type="hidden" name="hidimg" id="hidimg" >
<table width="528" height="370" border="0" align="center" cellpadding="0" cellspacing="0">
<? if($msg=="updated"){?>
<tr>
<td align="center" colspan="2"><font color="#FF0000">store Detail is Updated </font></td>
</tr><? } ?>
<? if($msg=="error"){?>
<tr><td align="center" colspan="2"><font color="#FF0000"><img src="_images/errormessage.gif">Some field not not Filled</font></td></tr><? } ?>
<tr><td>
<table align="right" bgcolor="#A8D3FF" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="font-size:18px; font-weight:bold">EDIT LOCATION </td>
</tr>
</table></td></tr>
<tr><td align="left" colspan="2"><div id="searchstorediv"><fieldset style="border-color:#006699">
<legend class="sugarcube_logo11">Store Search</legend>
<table width="524">
<tr>
<td class="sugarcube_logo11"> Search store BY: </td>
//here i call the ajax functions
<td style="font-size:13px; font-weight:bold;cursor:pointer"><font color="#003366"><b onClick="showstorename();">Store Name</b></font><img name="storenameimage" id="storenameimage" src="_images/gif/tick.gif" style="display:none"><b style="font-size:18px">/</b><font color="#003366"><b onClick="showstoreno();">Store No.</b></font><img name="storenoimage" id="storenoimage" src="_images/gif/tick.gif" style="display:none"></td>
</tr>
<tr>
<td width="218" class="sugarcube_logo11"><div id="storename_div" style="display:inline"> Store Name</div>
<div id="storeno_div" style="display:none">Store No.</div>.</td>
<td width="294"><div id="storeselect_div" style="display:none"><select name="storenosearch" id="storenosearch" onChange="ajaxfunctionstore(this.value)"><option value="">Select store NO.</option><? echo getstoreno(); ?></select></div>
<div id="storenameselect_div" style="display:inline">
<select name="storesearchname" id="storesearchname" onChange="ajaxfunctionstorename(this.value)">
<option value="">Select store Name</option>
<? echo getstorename(); ?>
</select>
</div></td></tr></table>
</fieldset></div></td></tr>
<tr><td width="528" height="335" valign="top"><fieldset style="border-color:#006699">
<legend class="salary_text21">Store Details</legend>
<table width="524" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="524" height="186" colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5" colspan="3"></td>
</tr>
<tr>
<td height="20" class="sugarcube_logo11"> Store No.:</td>
<td width="135"><input name="storeno" id="storeno" type="text" class="style1"></td>
<td width="162"> </td>
</tr>
<tr>
<td height="20" class="sugarcube_logo11"> Store Name:</td>
<td><input name="storename" id="storename" type="text" class="style1"></td>
<td> </td>
</tr>
<tr>
<td width="227" height="20" class="sugarcube_logo11"> Warehouse Name :</td>
<td><input name="warehousename" id="warehousename" type="text" class="style1" readonly></td>
<td><select name="warehouseselect" id="warehouseselect" style="width:120px" onChange="setwarehousename(this.value);">
<option value="select">Select Warehouse</option>
<?=getwarehousename();?>
</select></td>
</tr>
<tr>
<td width="227" height="20" class="sugarcube_logo11"> Contact Person: </td>
<td><input name="contactperson" id="contactperson" type="text" class="style1"></td>
<td> </td>
</tr>
<tr>
<td width="227" height="20" class="sugarcube_logo11"> Contact No :</td>
<td><input name="contactno" id="contactno" type="text" class="style1"></td>
<td> </td>
</tr>
<tr>
<td height="69" class="sugarcube_logo11"> Note:</td>
<td colspan="2"><textarea name="note" id="note" cols="40" rows="4"></textarea></td>
</tr>
<tr bordercolor="#006699">
<td colspan="3" align="RIGHT"><input type="submit" name="Submitstore" id="Submitstore" value="Update"> <input type="submit" name="Submitstore2" id="Submitstore2" value="Delete"> <input type="button" name="back" id="back" value="Back To Main Page" onClick="backtomain();"></td>
</tr>
</table></td>
</tr>
</table>
</fieldset>
</td>
</table>
</form>
<div align="center">[/HTML]
Expand|Select|Wrap|Line Numbers
- <script language="javascript">
- function check(frm)
- {
- var out="";
- if(frm.department_name.value==""){
- document.getElementById('department_name_text_error').innerHTML='•Please Fill Department Name';
- out=1
- }
- if(frm.department_id.value==""){
- document.getElementById('department_id_text_error').innerHTML='•Please Fill Department Id';
- out=1
- }
- if(frm.department_role.value==""){
- document.getElementById('department_role_text_error').innerHTML='•Please Fill Department Role';
- out=1
- }
- if(frm.department_date.value==""){
- document.getElementById('department_date_text_error').innerHTML='•Please Fill Department Date';
- out=1
- }
- if(frm.department_by.value==""){
- document.getElementById('department_by_text_error').innerHTML='•Please Fill Department By';
- out=1
- }
- if(out=="")
- return true;
- else
- return false;
- }
</script>
</div>
</body>
</html>[/HTML][PHP]
<?
function getstoreno()
{
$sql="select * from store_info";
$query=mysql_query($sql);
while($fetch=mysql_fetch_assoc($query))
{
$select="";
$str.="<option value='".trim($fetch['storeid'])."'$select>".$fetch['storeid']."</option>";
}
return $str;
}
function getstorename()
{
$sql="select * from store_info";
$query=mysql_query($sql);
while($fetch=mysql_fetch_assoc($query))
{
$select="";
$str.="<option value='".trim($fetch['storename'])."'$select>".$fetch['storename']."</option>";
}
return $str;
}
function getwarehousename()
{
$sql="select * from warehouse_info";
$query=mysql_query($sql);
while($fetch=mysql_fetch_assoc($query))
{
$select="";
$str.="<option value='".trim($fetch['warehousename'])."'$select>".$fetch['warehousename']."</option>";
}
return $str;
}
?>
and this the the php file used in ajax function:
Storeupdatename:
<?
global $str;
$storename=$_REQUEST['username'];
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("sugarcub_inventory");
$sql="select * from store_info where storename='$storename'";
$rs=mysql_query($sql) or die("ERROR - ".mysql_error());
while($fetch=mysql_fetch_array($rs))
{
$str.=$fetch['storeid']."*".$fetch['storename']."*".$fetch['warehouse']."*".$fetch['contactperson']."*".$fetch['contactno']."*".$fetch['note']."*";
}
echo $str;
?>
Storeupdateno:
<?
global $str;
$storeno=$_REQUEST['username'];
$link=mysql_connect("localhost","root","");
$db=mysql_select_db("sugarcub_inventory");
$sql="select * from store_info where storeid='$storeno'";
$rs=mysql_query($sql) or die("ERROR - ".mysql_error());
while($fetch=mysql_fetch_array($rs))
{
$str.=$fetch['storeid']."*".$fetch['storename']."*".$fetch['warehouse']."*".$fetch['contactperson']."*".$fetch['contactno']."*".$fetch['note']."*";
}
echo $str;
?>[/PHP]