Location: PHPKode > projects > T-77.com Operational Management System > omis/item_insert.php
<?php require_once('Connections/t77_connect.php'); ?>
<?php
//error_reporting(E_ALL);

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO t77_bill_items (bill_id, item_name, item_description, item_price, item_order) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($HTTP_POST_VARS['bill_id'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['item_name'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['item_description'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['item_price'], "double"),
					   GetSQLValueString($HTTP_POST_VARS['item_order'], "int"));

  mysql_select_db($database_t77_connect, $t77_connect);
  $Result1 = mysql_query($insertSQL, $t77_connect) or die(mysql_error());

  $insertGoTo = "close.php?ref=" . $_GET['ref'] . "quer=" . $_GET['quer'];
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

$colname_billid = "0";
if (isset($_GET['ordernr'])) {
  $colname_billid = (get_magic_quotes_gpc()) ? $_GET['ordernr'] : addslashes($_GET['ordernr']);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_billid = sprintf("SELECT * FROM t77_bill_bills WHERE t77_bill_bills.order_number = '%s'", $colname_billid);
$billid = mysql_query($query_billid, $t77_connect) or die(mysql_error());
$row_billid = mysql_fetch_assoc($billid);
$totalRows_billid = mysql_num_rows($billid);
?>
<?php 
// ================================================
// SPAW PHP WYSIWYG editor control
// ================================================
// Control usage demonstration file
// ================================================
// Developed: Alan Mendelevich, hide@address.com
// Copyright: Solmetra (c)2003 All rights reserved.
// ------------------------------------------------
//                                www.solmetra.com
// ================================================
// $Revision: 1.3 $, $Date: 2003/04/29 17:12:04 $
// ================================================

// this part determines the physical root of your website
// it's up to you how to do this
if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT']))
  $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/';
else
  $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];

define('DR', $_root);
unset($_root);

// set $spaw_root variable to the physical path were control resides
// don't forget to modify other settings in config/spaw_control.config.php
// namely $spaw_dir and $spaw_base_url most likely require your modification
$spaw_root = $omis_path . 'spaw/';

// include the control file
include $spaw_root.'spaw_control.class.php';

// here we add some styles to styles dropdown
$spaw_dropdown_data['style']['default'] = 'No styles';
$spaw_dropdown_data['style']['style1'] = 'Style no. 1';
$spaw_dropdown_data['style']['style2'] = 'Style no. 2';

?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Item invoegen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<script language=JavaScript src="calculator/calculator.js"></script>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="31"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="20"><img src="images/tabletopstart.gif" width="20" height="31" /></td>
          <td><table width="100%" height="30" border="0" cellpadding="5" cellspacing="0">
              <tr>
                <td><p><strong>Insert item</strong></p>
                </td>
                <td>&nbsp;</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="20">
        <tr>
          <td align="left" valign="top">
		  <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table width="100%" align="center" cellpadding="5" cellspacing="0" class="tableBorder">
    <tr valign="top" bgcolor="#eeeeee">
      <td width="125" align="right" nowrap><h1>Item name:</h1></td>
      <td><input type="text" name="item_name" value="" size="45">
      </td>
    </tr>
    <tr valign="top">
      <td width="125" align="right" nowrap><h1>Item description:</h1></td>
      <td><textarea name="item_description" cols="40" rows="10" id="item_description"></textarea>
	  <?php 
				  		//$sw = new SPAW_Wysiwyg('item_description' /*name*/,$row_items['item_description']/*value*/, 'en' /*language*/, 'mini' /*toolbar mode*/, '' /*theme*/, '100%' /*width*/, '300px' /*height*/);
						//$sw->show();
					?>
      </td>
    </tr>
    <tr valign="top" bgcolor="#eeeeee">
      <td width="125" align="right" nowrap><h1>Item price:</h1></td>
      <td><input type="text" name="item_price" value="" size="10">&nbsp;&nbsp; <a href="javascript:TCR.TCRPopup(document.forms['form1'].elements['item_price'])"><img width="15" height="13" border="0" alt="Klik hier om de calculator weer te geven" src="calculator/calc.gif"></a></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap><h1>Item order:</h1></td>
      <td><input name="item_order" type="text" id="item_order" size="4" maxlength="4" /></td>
    </tr>
    <tr valign="baseline">
      <td width="125" align="right" nowrap>&nbsp;</td>
      <td><input type="submit" value="Insert item" /></td>
    </tr>
  </table>
  <input type="hidden" name="bill_id" value="<?php echo $row_billid['bill_id']; ?>">
  <input type="hidden" name="MM_insert" value="form1">
</form></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($billid);
?>
Return current item: T-77.com Operational Management System