<?php /* $Id */
/**
* Contacts component presentation layer
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License: http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.15 $
**/

// ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class HTML_contact {
	
	function showContacts( &$rows, &$pageNav, $search, $option ) {
?>
	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr> 
			<td width="100%" class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle" />Contact Manager</td>
			<td nowrap="nowrap">Display #</td>
			<td> <?php echo $pageNav->writeLimitBox(); ?> </td>
			<td>Search:</td>
			<td><input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" /></td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr> 
			<th width="20" nowrap="nowrap">#</th>
			<th width="20" class="title" nowrap="nowrap"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
			<th width="20%" class="title" nowrap="nowrap">Name</th>
			<th width="20%" class="title" nowrap="nowrap">Position</th>
			<th width="40%" class="title" nowrap="nowrap">Address</th>
			<th width="20%" class="title" nowrap="nowrap">E-Mail</th>
			<th width="50" class="title" nowrap="nowrap">Default</th>
			<th width="50" class="title" nowrap="nowrap">Published</th>
			<th colspan="2" nowrap="nowrap">Reorder</th>
		</tr>
<?php
		$k = 0;
		for ($i=0, $n=count($rows); $i < $n; $i++) {
			$row = $rows[$i];
			$img = $row->published ? 'tick.png' : 'publish_x.png';
			$task = $row->published ? 'unpublish' : 'publish';
?>
		<tr class="<?php echo "row$k"; ?>"> 
			<td width="20"><?php echo $i+1+$pageNav->limitstart; ?></td>
			<td width="20"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
			<td width="20%"><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->name; ?></a></td>
			<td width="20%"><?php echo $row->con_position; ?></td>
			<td width="40%"><?php echo "$row->address<br />$row->suburb $row->state $row->postcode"; ?></td>
			<td width="20%"><a href="mailto:<?php echo $row->email_to; ?>"><?php echo $row->email_to;?></a></td>
<?php		if ($row->default_con) { ?>
			<td width="50" align="center"><img src="images/tick.png"></td>
<?php		} else { ?>
			<td width="50" align="center">&nbsp;</td>
<?php		} ?>
		<td width="10%" align="center"><a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')"><img src="images/<?php echo $img;?>" width="12" height="12" border="0" alt="" /></a></td>
<td>
<?php		if ($i > 0 || ($i+$pageNav->limitstart > 0)) { ?>
        <a href="#reorder" onClick="return listItemTask('cb<?php echo $i;?>','orderup')">
        <img src="images/uparrow.png" width="12" height="12" border="0" alt="Move Up">
        </a>
        <?php		} ?>
      </td>
      <td>
<?php		if ($i < $n-1 || $i+$pageNav->limitstart < $pageNav->total-1) { ?>
        <a href="#reorder" onClick="return listItemTask('cb<?php echo $i;?>','orderdown')">
        <img src="images/downarrow.png" width="12" height="12" border="0" alt="Move Down">
        </a>
        <?php		} ?>
      </td>
		</tr>
    <?php $k = 1 - $k;
			} ?>
    <tr> 
      <th align="center" colspan="10"> <?php echo $pageNav->writePagesLinks(); ?></th>
    </tr>
    <tr> 
      <td align="center" colspan="10"> <?php echo $pageNav->writePagesCounter(); ?></td>
    </tr>
  </table>
  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
</form>
<?php }

	function editContact( &$row, &$imagelist, &$iposlist, $option, &$olist ) {
		if ($row->image == "") {
			$row->image = 'blank.png';
		}
		mosMakeHtmlSafe( $row, ENT_QUOTES, 'misc' );
?>
	<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			// do field validation
			if (form.name.value == ""){
				alert( "You must provide a name." );
			//} else if (form.contact_email.value == ""){
			//	alert( "You must provide an email address." );
			} else {
				submitform( pressbutton );
			}
		}
	</script>
	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr> 
			<td width="100%"><span class="sectionname"><?php echo $row->id ? 'Edit' : 'Add';?> Contact</span></td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr> 
			<td width="20%" align="right">Name:</td>
			<td width="20%"><input class="inputbox" type="text" name="name" size="50" maxlength="100" value="<?php echo $row->name; ?>" /></td>
		<tr> 
			<td align="right">Contact's Position:</td>
			<td><input class="inputbox" type="text" name="con_position" size="50" maxlength="50" value="<?php echo $row->con_position; ?>" /></td>
		</tr>
		<tr> 
			<td align="right">E-mail:</td>
			<td><input class="inputbox" type="text" name="email_to" size="50" maxlength="100" value="<?php echo $row->email_to; ?>" /></td>
		</tr>
		<tr> 
			<td align="right">Street Address:</td>
			<td><input class="inputbox" type="text" name="address" size="50" value="<?php echo $row->address; ?>" /></td>
		</tr>
		<tr> 
			<td align="right">Town/Suburb:</td>
			<td><input class="inputbox" type="text" name="suburb" size="50" maxlength="50" value="<?php echo $row->suburb;?>" /></td>
		</tr>
		<tr> 
			<td align="right">State/County:</td>
			<td><input class="inputbox" type="text" name="state" size="50" maxlength="20" value="<?php echo $row->state;?>" /></td>
		</tr>
		<tr> 
			<td align="right">Country:</td>
			<td><input class="inputbox" type="text" name="country" size="50" maxlength="50" value="<?php echo $row->country;?>" /></td>
		</tr>
		<tr> 
			<td align="right">Postal Code/ZIP:</td>
			<td><input class="inputbox" type="text" name="postcode" size="25" maxlength="10" value="<?php echo $row->postcode; ?>" /></td>
		</tr>
		<tr> 
			<td align="right">Telephone:</td>
			<td><input class="inputbox" type="text" name="telephone" size="25" maxlength="25" value="<?php echo $row->telephone; ?>" /></td>
		</tr>
		<tr> 
			<td align="right">Fax:</td>
			<td><input class="inputbox" type="text" name="fax" size="25" maxlength="25" value="<?php echo $row->fax; ?>" /></td>
			</tr>
		<tr> 
			<td align="right">Miscellaneous Info:</td>
			<td><textarea name="misc" rows="5" cols="50"><?php echo $row->misc; ?></textarea></td>
		</tr>
		<tr> 
		<tr> 
			<td align="right">Image:</td>
			<td><?php echo $imagelist; ?></td>
			<td rowspan="4" align="left">
				<script language="javascript" type="text/javascript">
					if (document.forms[0].image.options.value!=''){
					  jsimg='../images/stories/' + getSelectedValue( 'adminForm', 'image' );
					} else {
					  jsimg='../images/M_images/blank.png';
					}
					document.write('<img src=' + jsimg + ' name="imagelib" width="80" height="80" border="2" alt="Preview" />');
				</script>
			</td>
		</tr>
		<tr> 
			<td align="right">Image Position:</td>
			<td><?php echo $iposlist; ?></td>
		</tr>
		<tr> 
			<td align="right">Site Default:</td>
			<td><input type="checkbox" name="default_con" value="1" <?php echo $row->default_con ? "checked=\"checked\"" : ""; ?> /></td>
		</tr>
		<tr>
        <td valign="top" align="right">Ordering:</td>
        <td> <?php echo $olist; ?> </td>
        </tr>
		<tr> 
			<td colspan="2">&nbsp;</td>
		</tr>
	</table>
	<input type="hidden" name="option" value="<?php echo $option; ?>" />
	<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
	<input type="hidden" name="task" value="" />
	</form>
<?php
	}
}
?>