Location: PHPKode > projects > T-77.com Operational Management System > omis/doc_edit.php
<?php require_once('Connections/t77_connect.php'); ?>
<?php
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_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE t77_bill_bills SET order_number=%s, bill_name=%s, bill_date=%s, bill_status=%s, bill_contact=%s, bill_type=%s WHERE bill_id=%s",
                       GetSQLValueString($HTTP_POST_VARS['order_number'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['bill_name'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['bill_date'], "date"),
                       GetSQLValueString($HTTP_POST_VARS['bill_status'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['bill_contact'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['bill_type'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['bill_id'], "int"));

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

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

mysql_select_db($database_t77_connect, $t77_connect);
$query_types = "SELECT * FROM t77_bill_types";
$types = mysql_query($query_types, $t77_connect) or die(mysql_error());
$row_types = mysql_fetch_assoc($types);
$totalRows_types = mysql_num_rows($types);

mysql_select_db($database_t77_connect, $t77_connect);
$query_companies = "SELECT * FROM t77_bill_companies";
$companies = mysql_query($query_companies, $t77_connect) or die(mysql_error());
$row_companies = mysql_fetch_assoc($companies);
$totalRows_companies = mysql_num_rows($companies);

mysql_select_db($database_t77_connect, $t77_connect);
$query_contacts = "SELECT * FROM t77_bill_contacts, t77_bill_companies WHERE t77_bill_contacts.contact_company_name = t77_bill_companies.company_id";
$contacts = mysql_query($query_contacts, $t77_connect) or die(mysql_error());
$row_contacts = mysql_fetch_assoc($contacts);
$totalRows_contacts = mysql_num_rows($contacts);

mysql_select_db($database_t77_connect, $t77_connect);
$query_status = "SELECT * FROM t77_bill_status";
$status = mysql_query($query_status, $t77_connect) or die(mysql_error());
$row_status = mysql_fetch_assoc($status);
$totalRows_status = mysql_num_rows($status);

$colname_doc = "0";
if (isset($_GET['docID'])) {
  $colname_doc = (get_magic_quotes_gpc()) ? $_GET['docID'] : addslashes($_GET['docID']);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_doc = sprintf("SELECT * FROM t77_bill_bills WHERE t77_bill_bills.bill_id = %s", $colname_doc);
$doc = mysql_query($query_doc, $t77_connect) or die(mysql_error());
$row_doc = mysql_fetch_assoc($doc);
$totalRows_doc = mysql_num_rows($doc);
?>
<?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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" media="screen" href="calendar/dynCalendar.css" />
<script language="javascript" type="text/javascript" src="calendar/browserSniffer.js"></script>
<script language="javascript" type="text/javascript" src="calendar/dynCalendar.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body>
<table width="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>Edit document </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="baseline">
                  <td width="150" align="right" nowrap bgcolor="#eeeeee"><h1>Order
                      number:</h1></td>
                  <td bgcolor="#eeeeee"><input type="text" name="order_number" value="<?php echo $row_doc['order_number']; ?>" size="32">
                  </td>
                </tr>
                <tr valign="baseline">
                  <td width="150" align="right" nowrap><h1>Order name:</h1></td>
                  <td><input type="text" name="bill_name" value="<?php echo $row_doc['bill_name']; ?>" size="32">
                  </td>
                </tr>
                <tr valign="baseline">
                  <td width="150" align="right" nowrap bgcolor="#eeeeee"><h1>Order
                      date:</h1></td>
                  <td bgcolor="#eeeeee"><input type="text" name="bill_date" value="<?php echo $row_doc['bill_date']; ?>" size="20">
&nbsp;&nbsp; <script language="JavaScript" type="text/javascript">
    <!--
    function exampleCallback_ISO1(date, month, year)
    {
        if (String(month).length == 1) {
            month = '0' + month;
        }
    
        if (String(date).length == 1) {
            date = '0' + date;
        }    
        document.forms['form1'].bill_date.value = year + '-' + month + '-' + date;
    }
    calendar1 = new dynCalendar('calendar1', 'exampleCallback_ISO1');
    calendar1.setMonthCombo(true);
    calendar1.setYearCombo(true);
    //-->
            </script></td>
                </tr>
                <tr valign="baseline">
                  <td width="150" align="right" nowrap><h1>Order status:</h1></td>
                  <td>
                    <select name="bill_status">
                      <?php
do {  
?>
                      <option value="<?php echo $row_status['status_id']?>"<?php if (!(strcmp($row_status['status_id'], $row_doc['bill_status']))) {echo "SELECTED";} ?>><?php echo $row_status['status_label']?></option>
                      <?php
} while ($row_status = mysql_fetch_assoc($status));
  $rows = mysql_num_rows($status);
  if($rows > 0) {
      mysql_data_seek($status, 0);
	  $row_status = mysql_fetch_assoc($status);
  }
?>
                    </select>
                  </td>
                <tr>
                <tr valign="baseline">
                  <td width="150" align="right" nowrap bgcolor="#eeeeee"><h1>Contact:</h1></td>
                  <td bgcolor="#eeeeee">
                    <select name="bill_contact">
                      <?php
do {  
?>
                      <option value="<?php echo $row_contacts['contact_id']?>"<?php if (!(strcmp($row_contacts['contact_id'], $row_doc['bill_contact']))) {echo "SELECTED";} ?>><?php echo $row_contacts['contact_name']?></option>
                      <?php
} while ($row_contacts = mysql_fetch_assoc($contacts));
  $rows = mysql_num_rows($contacts);
  if($rows > 0) {
      mysql_data_seek($contacts, 0);
	  $row_contacts = mysql_fetch_assoc($contacts);
  }
?>
                    </select>
                  </td>
                <tr>
                <tr valign="baseline">
                  <td width="150" align="right" nowrap><h1>Type:</h1></td>
                  <td>
                    <select name="bill_type">
                      <?php
do {  
?>
                      <option value="<?php echo $row_types['bill_type']?>"<?php if (!(strcmp($row_types['bill_type'], $row_doc['bill_type']))) {echo "SELECTED";} ?>><?php echo $row_types['type_description']?></option>
                      <?php
} while ($row_types = mysql_fetch_assoc($types));
  $rows = mysql_num_rows($types);
  if($rows > 0) {
      mysql_data_seek($types, 0);
	  $row_types = mysql_fetch_assoc($types);
  }
?>
                    </select>
                  </td>
                <tr>
                <tr valign="baseline">
                  <td width="150" align="right" nowrap bgcolor="#eeeeee">&nbsp;</td>
                  <td bgcolor="#eeeeee"><input type="submit" value="Update Document">
                  </td>
                </tr>
              </table>
              <input type="hidden" name="bill_id" value="">
              <input type="hidden" name="MM_update" value="form1">
              <input type="hidden" name="bill_id" value="<?php echo $row_doc['bill_id']; ?>">
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<script language="JavaScript">
<!-- // create calendar object(s) just after form tag closed
	var cal1 = new calendar1(document.forms['form1'].elements['bill_date']);
	cal1.year_scroll = true;
	cal1.time_comp = false;
//-->
</script>
</body>
</html>
<?php
mysql_free_result($types);

mysql_free_result($companies);

mysql_free_result($contacts);

mysql_free_result($status);

mysql_free_result($doc);
?>
Return current item: T-77.com Operational Management System