Location: PHPKode > projects > T-77.com Operational Management System > omis/new_bill.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_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO t77_bill_bills (order_number, bill_name, bill_date, bill_status, bill_contact, bill_type) VALUES (%s, %s, %s, %s, %s, %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"));

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

$onr = urlencode($HTTP_POST_VARS['order_number']);

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

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);
?>
<?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>Add d ocument</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 action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
            <table width="100%" align="center" cellpadding="5" cellspacing="0" class="tableBorder">
              <tr valign="baseline" bgcolor="#eeeeee">
                <td width="150" align="right" nowrap="nowrap" bgcolor="#eeeeee"><h1>orde
                    rnumber:</h1>
                </td>
                <td><input type="text" name="order_number" value="" size="32" />
                </td>
              </tr>
              <tr valign="baseline">
                <td width="150" align="right" nowrap="nowrap"><h1>order name:</h1>
                </td>
                <td><input type="text" name="bill_name" value="" size="32" />
                </td>
              </tr>
              <tr valign="baseline" bgcolor="#eeeeee">
                <td width="150" align="right" nowrap="nowrap"><h1>order date:</h1>
                </td>
                <td><input type="text" name="bill_date" value="" 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="nowrap"><h1>order status:</h1>
                </td>
                <td>
                  <select name="bill_status">
                    <?php
do {  
?>
                    <option value="<?php echo $row_status['status_id']?>"><?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" bgcolor="#eeeeee">
                <td width="150" align="right" nowrap="nowrap"><h1>Contact:</h1>
                </td>
                <td>
                  <p>
  <select name="bill_contact">
                        <?php 
do {  
?>
                        <option value="<?php echo $row_contacts['contact_id']?>" ><?php echo $row_contacts['contact_name']?></option>
                        <?php
} while ($row_contacts = mysql_fetch_assoc($contacts));
?>
                    </select>
&nbsp;&nbsp; <a href="javascript:;" onClick="MM_openBrWindow('contact_add.php?ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>','contact','resizable=yes,width=600,height=500')">[clik
here to add a new contact]</a></p></td>
              </tr>
              <tr> </tr>
              <tr valign="baseline">
                <td width="150" align="right" nowrap="nowrap"><h1>Type:</h1>
                </td>
                <td>
                  <select name="bill_type">
                    <?php 
do {  
?>
                    <option value="<?php echo $row_types['bill_type']?>" ><?php echo $row_types['type_description']?></option>
                    <?php
} while ($row_types = mysql_fetch_assoc($types));
?>
                  </select>
                </td>
              </tr>
              <tr> </tr>
              <tr valign="baseline" bgcolor="#eeeeee">
                <td width="150" align="right" nowrap="nowrap">&nbsp;</td>
                <td><input name="submit" type="submit" value="Insert document" />
                </td>
              </tr>
            </table>
            <input type="hidden" name="MM_insert" value="form1" />
          </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);
?>
Return current item: T-77.com Operational Management System