<?php

/*
	include_once("config.inc.php");
	include_once("DBConnector1.php");
	$letters = $_GET['letters'];
	
	$sql="SELECT * FROM mast_family where name like '".$letters."%'";
		$result =$db->RunQuery($sql);
			
			
			while($row = mysqli_fetch_array($result))
			{
			
			echo $row["name"];
			
			}
			
		*/	
		
		
session_start();


	include_once("connectioni.php");

if ($_GET["Command"]=="save_sto"){
	
		//echo "insert into bankmas(bcode, bbcode, bname, shname) values ('".$_GET["bcode"]."', '".$_GET["bbcode"]."', '".$_GET["bname"]."', '".$_GET["shname"]."')";
		
		
		
			$sql = mysqli_query($GLOBALS['dbinv'],"delete from s_stomas where CODE='".$_GET["store_code"]."'") or die(mysqli_error($GLOBALS['dbinv']));
			//echo "insert into s_stomas(CODE, DESCRIPTION) values ('".$_GET["store_code"]."', '".$_GET["storename"]."')";
			if ($_GET["act"]=="true"){
				$act=1;
			} else {
				$act=0;
			}
			
			$sql = mysqli_query($GLOBALS['dbinv'],"insert into s_stomas(CODE, DESCRIPTION, act) values ('".$_GET["store_code"]."', '".$_GET["storename"]."', '".$act."')") or die(mysqli_error($GLOBALS['dbinv']));
	
	
			$ResponseXML = "";
			$ResponseXML .= "<br>
                                        <table border=\"1\" cellspacing=\"0\">
                                        <tr><td width=\"39%\">Store Code</td>
              <td width=\"61%\">Store Name</td>
			  <td width=\"10%\">Activate</td>
              </tr>";
                                      
				
										$sql = mysqli_query($GLOBALS['dbinv'],"select * from s_stomas order by CODE") or die(mysqli_error($GLOBALS['dbinv']));
										while ($row = mysqli_fetch_array($sql)){
											if ($row["CODE"]!=""){
											$ResponseXML .= "<tr>
                                            	<td width=\"155\" onclick=\"stono('".$row['CODE']."', '".$row['DESCRIPTION']."');\">".$row["CODE"]."</td>
                                            	<td width=\"155\" onclick=\"stono('".$row['CODE']."', '".$row['DESCRIPTION']."');\">".$row["DESCRIPTION"]."</td>
												<td width=\"155\" onclick=\"stono('".$row['CODE']."', '".$row['act']."');\">".$row["act"]."</td></tr>";
												}
										}
										
										
                                          
                                       $ResponseXML .= " </table>";
                                       	
		
	
	echo $ResponseXML; 
}

if ($_GET["Command"]=="delete_sto"){
	
		//echo "insert into bankmas(bcode, bbcode, bname, shname) values ('".$_GET["bcode"]."', '".$_GET["bbcode"]."', '".$_GET["bname"]."', '".$_GET["shname"]."')";
		$sql = mysqli_query($GLOBALS['dbinv'],"delete from s_stomas where CODE='".$_GET["store_code"]."'") or die(mysqli_error($GLOBALS['dbinv']));
	
	
	$ResponseXML = "";
	$ResponseXML .= "<br>
                                        <table border=\"1\" cellspacing=\"0\">
                                        <tr><td width=\"39%\">Store Code</td>
              <td width=\"61%\">Store Name</td>
			  <td width=\"10%\">Activate</td>
              </tr>";
                                      
								
										$sql = mysqli_query($GLOBALS['dbinv'],"select * from s_stomas order by CODE") or die(mysqli_error($GLOBALS['dbinv']));
										while ($row = mysqli_fetch_array($sql)){
											if ($row["CODE"]!=""){
											$ResponseXML .= "<tr>
                                            	<td width=\"155\" onclick=\"stono('".$row['CODE']."', '".$row['DESCRIPTION']."');\">".$row["CODE"]."</td>
                                            	<td width=\"155\" onclick=\"stono('".$row['CODE']."', '".$row['DESCRIPTION']."');\">".$row["DESCRIPTION"]."</td>
												<td width=\"155\" onclick=\"stono('".$row['CODE']."', '".$row['act']."');\">".$row["act"]."</td></tr>";
												}
										}
										
										
                                          
                                       $ResponseXML .= " </table>";
                                       echo $ResponseXML; 	
	
	
}



?>
