Location: PHPKode > projects > T-77.com Operational Management System > omis/doc_list.php
<?php require_once('Connections/t77_connect.php'); ?>
<?php
$colname_DocType = "3";
if (isset($_GET['typeID'])) {
  $colname_DocType = (get_magic_quotes_gpc()) ? $_GET['typeID'] : addslashes($_GET['typeID']);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_DocType = sprintf("SELECT * FROM t77_bill_types WHERE t77_bill_types.bill_type = %s", $colname_DocType);
$DocType = mysql_query($query_DocType, $t77_connect) or die(mysql_error());
$row_DocType = mysql_fetch_assoc($DocType);
$totalRows_DocType = mysql_num_rows($DocType);

if(isset($_GET['comID'])) {

	$colname2_Docs = "1";
	if (isset($_GET['comID'])) {
 	$colname2_Docs = (get_magic_quotes_gpc()) ? $_GET['comID'] : addslashes($_GET['comID']);
	}
	$colname_Docs = "1";
	if (isset($_GET['typeID'])) {
 	$colname_Docs = (get_magic_quotes_gpc()) ? $_GET['typeID'] : addslashes($_GET['typeID']);
	}
	mysql_select_db($database_t77_connect, $t77_connect);
	$query_Docs = sprintf("SELECT * FROM t77_bill_bills, t77_bill_status, t77_bill_contacts WHERE  t77_bill_status.status_id = t77_bill_bills.bill_status AND t77_bill_bills.bill_contact = t77_bill_contacts.contact_id AND t77_bill_bills.bill_type = %s AND t77_bill_contacts.contact_company_name = %s ORDER BY t77_bill_bills.bill_date", $colname_Docs,$colname2_Docs);
	$Docs = mysql_query($query_Docs, $t77_connect) or die(mysql_error());
	$row_Docs = mysql_fetch_assoc($Docs);
	$totalRows_Docs = mysql_num_rows($Docs);

}
	
if(isset($_GET['conID'])) {

	$colname2_Docs = "1";
	if (isset($_GET['conID'])) {
 	$colname2_Docs = (get_magic_quotes_gpc()) ? $_GET['conID'] : addslashes($_GET['conID']);
	}
	$colname_Docs = "1";
	if (isset($_GET['typeID'])) {
 	$colname_Docs = (get_magic_quotes_gpc()) ? $_GET['typeID'] : addslashes($_GET['typeID']);
	}
	mysql_select_db($database_t77_connect, $t77_connect);
	$query_Docs = sprintf("SELECT * FROM t77_bill_bills, t77_bill_status, t77_bill_contacts WHERE  t77_bill_status.status_id = t77_bill_bills.bill_status AND t77_bill_bills.bill_contact = t77_bill_contacts.contact_id AND t77_bill_bills.bill_type = %s AND t77_bill_contacts.contact_id = %s ORDER BY t77_bill_bills.bill_date", $colname_Docs,$colname2_Docs);
	$Docs = mysql_query($query_Docs, $t77_connect) or die(mysql_error());
	$row_Docs = mysql_fetch_assoc($Docs);
	$totalRows_Docs = mysql_num_rows($Docs);
	
}	

if(!isset($_GET['conID']) && !isset($_GET['comID'])) {

	$colname_Docs = "3";
	if (isset($_GET['typeID'])) {
  	$colname_Docs = (get_magic_quotes_gpc()) ? $_GET['typeID'] : addslashes($_GET['typeID']);
	}
	mysql_select_db($database_t77_connect, $t77_connect);
	$query_Docs = sprintf("SELECT * FROM t77_bill_bills, t77_bill_status, t77_bill_contacts WHERE t77_bill_bills.bill_type = %s AND t77_bill_status.status_id = t77_bill_bills.bill_status AND t77_bill_bills.bill_contact = t77_bill_contacts.contact_id ORDER BY t77_bill_bills.bill_date", $colname_Docs);
	$Docs = mysql_query($query_Docs, $t77_connect) or die(mysql_error());
	$row_Docs = mysql_fetch_assoc($Docs);
	$totalRows_Docs = mysql_num_rows($Docs);
}

mysql_select_db($database_t77_connect, $t77_connect);
$query_settings = "SELECT * FROM t77_bill_settings";
$settings = mysql_query($query_settings, $t77_connect) or die(mysql_error());
$row_settings = mysql_fetch_assoc($settings);
$totalRows_settings = mysql_num_rows($settings);

$stotal = 0;
?>
<?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" />
<style type="text/css">
<!--
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>

<?
if(isset($_GET['reload'])) {
	if($_GET['reload'] == 'yes') {
		$command = "MM_goToURL('parent.frames[\'menu\']','menu/menu.htm');return document.MM_returnValue";
	} 
} ?>
	
<body onLoad="<? echo $command; ?>">


<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="lineleft">
  <tr>
    <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="31" align="left" valign="top"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="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><?php echo $row_DocType['type_description']; ?></strong></p>
                    </td>
                    <td><table border="0" align="right" cellpadding="0" cellspacing="0">
                        <tr>
                            <td><a href="javascript:;" onClick="MM_openBrWindow('new_bill.php?ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>','docAdd','scrollbars=yes,width=600,height=320')"><img src="images/toolbar/add_small.gif" alt="nieuw item op deze order zetten" width="20" height="20" border="0" /></a></td>
                          </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="20">
          <tr>
            <td>
			<? if($totalRows_Docs > 0) { ?>
			      <table width="100%" border="0" cellpadding="3" cellspacing="0" class="tableBorder">
                    <tr>
                      <td class="tableTop"><h1>data</h1></td>
                      <td class="tableTop"><h1>Order number</h1></td>
                      <td class="tableTop"><h1>Order name</h1></td>
                      <td class="tableTop"> <h1 align="right">Total&nbsp;&nbsp;&nbsp;</h1></td>
                      <td class="tableTop"> <h1>Status</h1></td>
                      <td width="120" class="tableTop">&nbsp;</td>
                    </tr>
                    <?php 
				$i = 0;
				?>
<?php do { 
				$i++;
				if(is_int($i/2)) {
					$bgcolor = "#eeeeee";
				} else {
					$bgcolor = "#ffffff";
				}
				$colname_items = $row_Docs['bill_id'];
				if (isset($row_Docs['bill_id'])) {
				  $colname_items = (get_magic_quotes_gpc()) ? $row_Docs['bill_id'] : addslashes($row_Docs['bill_id']);
				}
				mysql_select_db($database_t77_connect, $t77_connect);
				$query_items = sprintf("SELECT t77_bill_items.bill_id, t77_bill_items.item_price FROM t77_bill_items WHERE t77_bill_items.bill_id = %s", $colname_items);
				$items = mysql_query($query_items, $t77_connect) or die(mysql_error());
				$row_items = mysql_fetch_assoc($items);
				$totalRows_items = mysql_num_rows($items);
				
				$total = 0;
				do {
      				$total = $total + $row_items['item_price'];
     			} while ($row_items = mysql_fetch_assoc($items)); 
				
				$stotal = $stotal + $total;
				
				if($total < 0) {
					$fcolor = "#ff0000";
				} else {
					$fcolor = "#000033";
				}					
				?>
                    <tr bgcolor="<? echo $bgcolor; ?>">
                      <td bgcolor="<? echo $bgcolor; ?>"><h1><?php echo DateAndTime($row_Docs['bill_date']); ?></h1></td>
                      <td bgcolor="<? echo $bgcolor; ?>"><p><b><?php echo $row_Docs['order_number']; ?></b></p></td>
                      <td align="left"><p><?php echo $row_Docs['bill_name']; ?></p></td>
                      <td align="left"> 
                      <p align="right"><b><font color="<? echo $fcolor; ?>">&nbsp;<? echo number_format($total,2,',','.'); ?>&nbsp;&nbsp;&nbsp;</font></b></p></td>
                      <td align="right"><p align="left"> 
                          <?php echo $row_Docs['status_label']; ?></p></td>
                      <td width="120" align="right">
<table border="0" align="right" cellpadding="0" cellspacing="0">
                          <tr>
                            <td width="24"><a href="pdf/pdf.php?id=<?php echo $row_Docs['bill_id']; ?>&file=yes"><img src="images/toolbar/pdf.gif" width="16" height="16" border="0" /></a></td>
                            <td width="22"><a href="javascript:;" onclick="MM_openBrWindow('premail.php?id=<?php echo $row_Docs['bill_id']; ?>&amp;ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>','mail','width=600,height=450')"><img src="images/toolbar/mail.gif" width="16" height="13" border="0" /></a></td>
                            <td width="23"><a href="javascript:;" onClick="MM_openBrWindow('print.php?id=<?php echo $row_Docs['bill_id']; ?>','print','toolbar=yes,scrollbars=yes,resizable=yes,width=700,height=500')"><img src="images/toolbar/printer.gif" width="17" height="17" border="0" /></a></td>
                            <td width="22"><a href="javascript:;" onClick="MM_openBrWindow('doc_edit.php?ref=<? echo $_SERVER['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>&amp;docID=<?php echo $row_Docs['bill_id']; ?>','docedit','scrollbars=yes,width=600,height=350')"><img src="images/toolbar/edit_small_white.gif" alt="nieuw item op deze order zetten" width="17" height="17" border="0" /></a></td>
                            <td width="22"><a href="items.php?id=<?php echo $row_Docs['bill_id']; ?>"><img src="images/toolbar/add_small_white.gif" width="17" height="17" border="0"></a></td>
                            <td width="17"><a href="delete.php?docID=<?php echo $row_Docs['bill_id']; ?>&delete=doc" onClick="GP_popupConfirmMsg('Are you sure you want to delete <?php echo $row_Docs['order_number']; ?> - <?php echo $row_Docs['bill_name']; ?>? This cannot be undone.');return document.MM_returnValue"><img src="images/toolbar/delete_small_white.gif" width="17" height="17" border="0" /></a></td>
                          </tr>
                        </table></td>
                    </tr>
                    <?php 
					mysql_free_result($items); 
					} while ($row_Docs = mysql_fetch_assoc($Docs)); ?>
                    <? $i++; 
						if(is_int($i/2)) {
							$bgcolor = "#eeeeee";
						} else {
							$bgcolor = "#ffffff";
						}?>
                    <tr bgcolor="<? echo $bgcolor; ?>">
                      <td bgcolor="<? echo $bgcolor; ?>">&nbsp;</td>
                      <td bgcolor="<? echo $bgcolor; ?>">&nbsp;</td>
                      <td align="left">&nbsp;</td>
                      <td align="left">&nbsp;</td>
                      <td align="right">&nbsp;</td>
                      <td width="120" align="right">&nbsp;</td>
                    </tr>
                    <? $i++; 
						if(is_int($i/2)) {
							$bgcolor = "#eeeeee";
						} else {
							$bgcolor = "#ffffff";
						}
						if($stotal < 0) {
							$fcolor = "#ff0000";
						} else {
							$fcolor = "#000033";
						}
						?>
                    <tr bgcolor="<? echo $bgcolor; ?>">
                      <td bgcolor="<? echo $bgcolor; ?>">&nbsp;</td>
                      <td bgcolor="<? echo $bgcolor; ?>">&nbsp;</td>
                      <td align="left">&nbsp;</td>
                      <td align="left"><h1 align="right"><b><font color="<? echo $fcolor; ?>">&nbsp;<? echo number_format($stotal,2,',','.'); ?>&nbsp;&nbsp;&nbsp;</font></b></h1></td>
                      <td align="right">&nbsp;</td>
                      <td width="120" align="right">&nbsp;</td>
                    </tr>
                  </table>
                  <? } else { ?>
                  <h1>No documents found </h1>
                  <? } ?></td>
          </tr>
        </table></td>
      </tr>
    </table>
   </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($DocType);

mysql_free_result($Docs);

mysql_free_result($settings);

?>
Return current item: T-77.com Operational Management System