Location: PHPKode > projects > T-77.com Operational Management System > omis/contacts.php
<?php require_once('Connections/t77_connect.php'); ?>
<?
$currentPage = $HTTP_SERVER_VARS["PHP_SELF"];

$maxRows_contacts = 10;
$pageNum_contacts = 0;
if (isset($HTTP_GET_VARS['pageNum_contacts'])) {
  $pageNum_contacts = $HTTP_GET_VARS['pageNum_contacts'];
}
$startRow_contacts = $pageNum_contacts * $maxRows_contacts;

if(!isset($_GET['comID'])) {
	mysql_select_db($database_t77_connect, $t77_connect);
	$query_contacts = "SELECT * FROM t77_bill_contacts, t77_bill_companies WHERE t77_bill_companies.company_id = t77_bill_contacts.contact_company_name ORDER BY t77_bill_companies.company_name";
	$query_limit_contacts = sprintf("%s LIMIT %d, %d", $query_contacts, $startRow_contacts, $maxRows_contacts);
	$contacts = mysql_query($query_limit_contacts, $t77_connect) or die(mysql_error());
	$row_contacts = mysql_fetch_assoc($contacts);
} else {
	$colname_contacts = "0";
	if (isset($_GET['comID'])) {
	  $colname_contacts = (get_magic_quotes_gpc()) ? $_GET['comID'] : addslashes($_GET['comID']);
	}
	mysql_select_db($database_t77_connect, $t77_connect);
	$query_contacts = sprintf("SELECT * FROM t77_bill_contacts, t77_bill_companies  WHERE t77_bill_companies.company_id = t77_bill_contacts.contact_company_name AND t77_bill_contacts.contact_company_name = %s ORDER BY t77_bill_contacts.contact_name", $colname_contacts);
	$query_limit_contacts = sprintf("%s LIMIT %d, %d", $query_contacts, $startRow_contacts, $maxRows_contacts);
	$contacts = mysql_query($query_contacts, $t77_connect) or die(mysql_error());
	$row_contacts = mysql_fetch_assoc($contacts);
	$totalRows_contacts = mysql_num_rows($contacts);
}


if (isset($HTTP_GET_VARS['totalRows_contacts'])) {
  $totalRows_contacts = $HTTP_GET_VARS['totalRows_contacts'];
} else {
  $all_contacts = mysql_query($query_contacts);
  $totalRows_contacts = mysql_num_rows($all_contacts);
}
$totalPages_contacts = ceil($totalRows_contacts/$maxRows_contacts)-1;

$queryString_contacts = "";
if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $params = explode("&", $HTTP_SERVER_VARS['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_contacts") == false && 
        stristr($param, "totalRows_contacts") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_contacts = "&" . implode("&", $newParams);
  }
}
$queryString_contacts = sprintf("&totalRows_contacts=%d%s", $totalRows_contacts, $queryString_contacts);
?>
<?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%" 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>Contacts</strong></p>
                    </td>
                    <td><table border="0" align="right" cellpadding="0" cellspacing="0">
                        <tr>
                          <td><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')"><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><table width="100%" border="0" cellspacing="0" cellpadding="20">
            <tr>
              <td align="left" valign="top"><?php do { ?>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableBorder">
                      <tr>
                        <td class="tableTop"><table width="100%" border="0" cellspacing="0" cellpadding="5">
                          <tr>
                            <td><h1><?php echo $row_contacts['contact_name']; ?></h1>
                            </td>
                            <td valign="middle"><table border="0" align="right" cellpadding="0" cellspacing="0">
                                <tr>
                                  <td width="17"><a href="javascript:;" onClick="MM_openBrWindow('contact_edit.php?ref=<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>&amp;conID=<?php echo $row_contacts['contact_id']; ?>','contactEdit','resizable=yes,width=600,height=500')" onMouseOver="MM_displayStatusMsg('bewerk <?php echo $row_contacts['contact_name']; ?>');return document.MM_returnValue"><img src="images/toolbar/edit_small.gif" alt="Bewerk contactpersoon" width="17" height="17" border="0" /></a></td>
                                  <td width="10">&nbsp;</td>
                                  <td width="17"><a href="delete.php?delete=contact&conID=<?php echo $row_contacts['contact_id']; ?>&ref=<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>&amp;quer=<? echo $_SERVER['QUERY_STRING']; ?>" onClick="GP_popupConfirmMsg('Weet u zeker dat u <?php echo $row_contacts['contact_name']; ?> wilt wissen? Dit is niet ongedaan te maken.');return document.MM_returnValue" onMouseOver="MM_displayStatusMsg('wis <?php echo $row_contacts['contact_name']; ?>');return document.MM_returnValue"><img src="images/toolbar/delete_small.gif" alt="Wis contactpersoon" width="17" height="17" border="0" /></a></td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table></td>
                        </tr>
                      <tr>
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                <tr bgcolor="#eeeeee">
                                  <td width="30%" align="left" nowrap="nowrap"><p>Company
                                      name :</p>
                                  </td>
                                  <td width="70%"><h1><?php echo $row_contacts['company_name']; ?></h1>
                                  </td>
                                </tr>
                                <tr>
                                  <td width="30%" align="left" nowrap="nowrap"><p>Contact
                                      person:</p>
                                  </td>
                                  <td width="70%"><h1><?php echo $row_contacts['contact_title']; ?>&nbsp;<?php echo $row_contacts['contact_person']; ?> </h1>
                                  </td>
                                </tr>
                                <tr bgcolor="#eeeeee">
                                  <td width="30%" align="left" nowrap="nowrap" bgcolor="#eeeeee"><p>Number
                                      + street: </p>
                                  </td>
                                  <td width="70%"><h1><?php echo $row_contacts['contact_company_address']; ?></h1>
                                  </td>
                                </tr>
                                <tr>
                                  <td width="30%" align="left" nowrap="nowrap"><p>Postal
                                      code + city </p>
                                  </td>
                                  <td width="70%"><h1><?php echo $row_contacts['contact_company_zip']; ?>&nbsp;&nbsp;<?php echo $row_contacts['contact_company_city']; ?> </h1>
                                  </td>
                                </tr>
                                <tr bgcolor="#eeeeee">
                                  <td align="left" nowrap="nowrap"><p>Country:</p></td>
                                  <td><h1><?php echo $row_contacts['contact_country']; ?></h1></td>
                                </tr>
                              </table></td>
                              <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
                                <tr bgcolor="#eeeeee">
                                  <td width="20%" align="left"><p>Tel:</p>
                                  </td>
                                  <td width="80%"><h1><?php echo $row_contacts['contact_telephone']; ?></h1>
                                  </td>
                                </tr>
                                <tr>
                                  <td width="20%" align="left"><p>Fax:</p>
                                  </td>
                                  <td width="80%"><h1><?php echo $row_contacts['contact_fax']; ?></h1>
                                  </td>
                                </tr>
                                <tr bgcolor="#eeeeee">
                                  <td width="20%" align="left"><p>Mobile:</p>
                                  </td>
                                  <td width="80%"><h1><?php echo $row_contacts['mobile']; ?></h1>
                                  </td>
                                </tr>
                                <tr>
                                  <td width="20%" align="left"><p>Email:</p>
                                  </td>
                                  <td width="80%"><h1><a href="mailto:<?php echo $row_contacts['contact_email']; ?>"><?php echo $row_contacts['contact_email']; ?></a></h1>
                                  </td>
                                </tr>
                                <tr bgcolor="#eeeeee">
                                  <td align="left">&nbsp;</td>
                                  <td>&nbsp;</td>
                                </tr>
                              </table></td>
                            </tr>
                          </table></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                </table>
                <?php } while ($row_contacts = mysql_fetch_assoc($contacts)); ?></td>
            </tr>
            <tr>
              <td align="left" valign="top">
                <table border="0" width="100%" align="left">
                  <tr>
                    <td width="14%" align="left">
                      <p>
                        <?php if ($pageNum_contacts > 0) { // Show if not first page ?>
                        <a href="<?php printf("%s?pageNum_contacts=%d%s", $currentPage, 0, $queryString_contacts); ?>">First</a>
                        <?php } // Show if not first page ?>
                      </p></td>
                    <td width="14%" align="left">
                      <p>
                        <?php if ($pageNum_contacts > 0) { // Show if not first page ?>
                        <a href="<?php printf("%s?pageNum_contacts=%d%s", $currentPage, max(0, $pageNum_contacts - 1), $queryString_contacts); ?>">Previous</a>
                        <?php } // Show if not first page ?>
                      </p></td>
                    <td width="14%" align="center" nowrap="nowrap"><p>&nbsp; Contacts <?php echo ($startRow_contacts + 1) ?> to <?php echo min($startRow_contacts + $maxRows_contacts, $totalRows_contacts) ?> from <?php echo $totalRows_contacts ?> </p></td>
                    <td width="14%" align="right">
                      <p>
                        <?php if ($pageNum_contacts < $totalPages_contacts) { // Show if not last page ?>
                        <a href="<?php printf("%s?pageNum_contacts=%d%s", $currentPage, min($totalPages_contacts, $pageNum_contacts + 1), $queryString_contacts); ?>">Next</a>
                        <?php } // Show if not last page ?>
                      </p></td>
                    <td width="14%" align="right">
                      <p>
                        <?php if ($pageNum_contacts < $totalPages_contacts) { // Show if not last page ?>
                        <a href="<?php printf("%s?pageNum_contacts=%d%s", $currentPage, $totalPages_contacts, $queryString_contacts); ?>">Last</a>
                        <?php } // Show if not last page ?>
                      </p></td>
                  </tr>
                </table></td>
            </tr>
          </table>
        </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($contacts);
?>
Return current item: T-77.com Operational Management System