<?php
/*
  $Id: catalog/admin/proforma.php, 20:57:52 NCB Exp $
 	Proforma v1.0 PLUS (Shareware Version)
 	COPYRIGHT (c) 2008 OPEN SOURCE SERVICES. ALL RIGHTS RESERVED.
  Support and Forum at http://www.open-source-services.com/Forum/Proforma-PF-v1.0-PLUS-Shareware-Version-osCommerce/
  Upgrade at http://www.open-source-services.com/Products/OSS-Premium-Add-Ons/Proforma-v1.0-PLUS.html?flypage=0
*/
require('includes/application_top.php');
require(DIR_WS_FUNCTIONS . 'proforma.php');
include_once("includes/fckeditor/fckeditor.php") ;
  
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
$head_template = $head_c = $poscode = $fm_name = $arr_all_pos = $arr_all_grps = $arr_all_fms = $unit_name = $oprod_name = $newsl_name = $pnot_name = '';
$show_values = $show_unit_settings = $show_units = $new_unit = false;
$no_errors = true;
$errors = array();

if($_SESSION['pf_units'] == 1){
	$show_units = true;
}
	
if (tep_not_null($action)) {
 	switch ($action) {
 		
 		case 'new_unit':
 			$show_unit_settings = $new_unit = true;
 			$show_units = false;
 			if(isset($HTTP_GET_VARS['errors'])){
 				$no_errors = false;
 			}
 			
 		break;
 		
 		case 'edit_unit':
 			$HTTP_GET_VARS['pf_name'] = str_replace('_', ' ',$HTTP_GET_VARS['pf_name']);
 			$show_unit_settings = $show_values = true;
 			if(isset($HTTP_GET_VARS['pf_name'])) {
 				$unit_name = $HTTP_GET_VARS['pf_name'];
 			} else if(isset($HTTP_GET_VARS['oprod_name'])) {
 				$oprod_name = $HTTP_GET_VARS['oprod_name'];
 			} else if (isset($HTTP_GET_VARS['newsl_name'])){
 				$newsl_name = $HTTP_GET_VARS['newsl_name'];
 			} else if (isset($HTTP_GET_VARS['pnot_name'])){
 				$pnot_name = $HTTP_GET_VARS['pnot_name'];
 			} 

 			if(isset($HTTP_POST_VARS['quickfind'])){
 				$type = substr($HTTP_POST_VARS['quickfind'], 0, strpos($HTTP_POST_VARS['quickfind'], '__'));
 				if($type == 'oscProduct'){
 					$oprod_name = substr($HTTP_POST_VARS['quickfind'], strpos($HTTP_POST_VARS['quickfind'], '__') + 2);
 				} else if($type == 'oscNewsletter'){
 					$newsl_name = substr($HTTP_POST_VARS['quickfind'], strpos($HTTP_POST_VARS['quickfind'], '__') + 2);
 				} else if($type == 'oscProdNotification'){
 					$pnot_name = substr($HTTP_POST_VARS['quickfind'], strpos($HTTP_POST_VARS['quickfind'], '__') + 2);
 				} else {
 					$unit_name = substr($HTTP_POST_VARS['quickfind'], strpos($HTTP_POST_VARS['quickfind'], '__') + 2);
 				}
 				
 			}
 		break;
 		
 		case 'new_pos':
 		
  		if(isset($HTTP_POST_VARS['pos_name']) && ($HTTP_POST_VARS['pos_name']!='')) {
  			
  			$poscode = getPosCode($HTTP_POST_VARS['pos_name']); 				
				saveNewPos($HTTP_POST_VARS['pos_name']);	
				tep_redirect(tep_href_link('proforma.php', 'action=pos_man'));		
  		}
  		
 		break;
 		
 		case 'del_pos':
 			
 			$chk_no = $HTTP_POST_VARS['chk_count'];
			$pos_to_delete = array();

  		for($i = 0; $i < $chk_no; $i++) {
  			$checkbox_id = 'check' . $i;
  			if(isset($HTTP_POST_VARS[$checkbox_id])) {
  				$pos_to_delete[] = $HTTP_POST_VARS[$checkbox_id];
  			}
  		}
  		
  		for($a = 0; $a < count($pos_to_delete); $a++) {
  			delPos($pos_to_delete[$a]);
  		}

	    tep_redirect(tep_href_link('proforma.php', 'action=pos_man'));
	    		
 		break;
 		
 		case 'pos_man':
 
 			$arr_all_pos = getAllPos();
 			if(isset($HTTP_GET_VARS['getCode'])) {
 				$poscode = getPosCode($HTTP_GET_VARS['pf_name']);
 			}			 			
 		break;
 		
 		case 'grp_man':
 			
 			$arr_all_grps = 1;
 		break;

 		case 'delete_units':
    	
	    	if(isset($HTTP_POST_VARS['chk_count'])){
	    		$units_to_del = array();
	    		$chk_no = $HTTP_POST_VARS['chk_count'];
					
	    		for($i = 0; $i < $chk_no; $i++) {
	    			$checkbox_id = 'check' . $i;
	    			if(isset($HTTP_POST_VARS[$checkbox_id])) {
	    				$units_to_del[] = $HTTP_POST_VARS[$checkbox_id];
	    			}
	    		} 

	    		if(count($units_to_del) > 0) {
	    			for($x=0; $x < count($units_to_del); $x++) {
	    				$unit_name = tep_db_prepare_input($units_to_del[$x]);
	    				deleteUnit($unit_name);
	    			}
					}					
	    	}    		
    	break;   	
    	
 		case 'create_ed':
  		if((strlen($HTTP_POST_VARS['pf_name']) < 4) || (strlen($HTTP_POST_VARS['pf_name']) > 99)) {
    			$no_errors = false;
    			$errors[] = PF_ERROR_NAME_LENGTH;
    		}

    		if($HTTP_POST_VARS['active'] == PF_PLEASE_SELECT) {
    			$no_errors = false;
    			$errors[] = PF_ERROR_SET_ACTIVE;
    		}
    		
    		if((strlen($HTTP_POST_VARS['pages']) < 2) || (strlen($HTTP_POST_VARS['pages']) > 299)) {
    			$no_errors = false;
    			$errors[] = PF_ERROR_SET_PAGES;
    		}
    		
    		if($HTTP_POST_VARS['position'] == PF_PLEASE_SELECT) {
    			$no_errors = false;
    			$errors[] = PF_ERROR_SET_POSITION;
    		}
    		
    		if($HTTP_POST_VARS['pf_type'] == PF_PLEASE_SELECT) {
    			$no_errors = false;
    			$errors[] = PF_ERROR_SET_UNIT_TYPE;
    		}
  		
  			if($no_errors) {
  				saveSettings($HTTP_POST_VARS);
  			}
  			
  			if(isset($HTTP_POST_VARS['pf_type'])){
	 				if(($HTTP_POST_VARS['pf_type'] == PF_FORM)&&($no_errors)){
	 					saveFmName($HTTP_POST_VARS['pf_name']);
	 				}
	 			}		
  			
  			if(!$no_errors){
  				tep_redirect(tep_href_link('proforma.php', 'action=new_unit&errors=true'));
  			} else {
					tep_redirect(tep_href_link('proforma.php', 'action=edit_unit&pf_name=' . str_replace(' ', '_', $HTTP_POST_VARS['pf_name'])));
 				}
 				
 		break;
 		
 		case 'save_form':

 			if(isset($HTTP_POST_VARS['name'])) {
 				saveEdContent($HTTP_POST_VARS['name'], mysql_real_escape_string($HTTP_POST_VARS['editor_content']));
 				if(isset($HTTP_GET_VARS['frm_man'])){
 					tep_redirect(tep_href_link('proforma.php', 'action=frm_man&get_hcode=true&frm_name='.$HTTP_POST_VARS['name']));
 				} else {
 					tep_redirect(tep_href_link('proforma.php', 'action=edit_unit&pf_name='.$HTTP_POST_VARS['name']));
 				}
 			} 
 				
 		break;
 		
 		case 'display_set':
 			if(($HTTP_POST_VARS['pf_units']) == 1){
 				$_SESSION['pf_units'] = '1';
 			} else {
 				$_SESSION['pf_units'] = '0';
 			}
 		
 		break;
 		
 		case 'order_by':
 			
 			if(isset($HTTP_POST_VARS['order_by'])){
 				$order_by = '';
	 			$field = $HTTP_POST_VARS['order_by'];
	 			if($field == TABLE_HEADING_PF_NAME)$order_by = 'pf_name';
	 			if($field == TABLE_HEADING_PF_GROUP)$order_by = 'pf_group';
	 			if($field == TABLE_HEADING_PF_POSITION)$order_by = 'position';
	 			if($field == TABLE_HEADING_PF_PAGES)$order_by = 'pages';
	 			if($field == TABLE_HEADING_PF_PLACEMENT)$order_by = 'placement';
	 			if($field == TABLE_HEADING_PF_TYPE)$order_by = 'pf_type';
	 			if($field == TABLE_HEADING_PF_ACTIVE)$order_by = 'active';
				$_SESSION['order_by'] = $order_by;
				$_SESSION['order_by_val'] = $field;
			}
			if(isset($HTTP_POST_VARS['asc_dec'])){
				$_SESSION['asc_dec'] = $HTTP_POST_VARS['asc_dec'];
			}
			if(isset($HTTP_POST_VARS['row_num'])){
				$_SESSION['row_num'] = $HTTP_POST_VARS['row_num'];
			}
 		break;
 		
 		case 'frm_man':
 			
 			$arr_all_fms = 1;
 			
 		break;
 		
 	}	
} 
 	
  if(!isset($_SESSION['order_by']))$_SESSION['order_by'] = 'pf_name';
	if(!isset($_SESSION['order_by_val']))$_SESSION['order_by_val'] = TABLE_HEADING_PF_NAME;
	if(!isset($_SESSION['asc_dec']))$_SESSION['asc_dec'] = PF_ASCENDING;
	if(!isset($_SESSION['row_num']))$_SESSION['row_num'] = 10;
	
	$arr_all_units = getAllUnits();
	if($_SESSION['pf_units'] == 1){
		$show_units = true;
	}
	if(($action == 'pos_man')||($action == 'frm_man')||($action == 'grp_man')||($action == 'new_unit')||($action == 'edit_unit'))$show_units = false;
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/proforma.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top">
    	<table border="0" width="100%" cellspacing="0" cellpadding="0">
    	<tr>
					<td width="100%">
					<table width="100%">
					<tr>
					<td align="left">
					<form name="ads_list" action="<?php echo tep_href_link('proforma.php', 'action=display_set', 'NONSSL'); ?>" method="post">
						<table class="pfTable" border="1" rules="none" frame="box">
							<tr><td align="center" class="smallText"><u><b><?php echo PF_DISP_OPTS; ?></b></u></td>
							</tr>
							<tr><td class="smallText"><input type="checkbox" name="pf_units" value="1" onClick="submit();" <?php if($_SESSION['pf_units']) echo 'CHECKED'; ?>><?php echo PF_PROFORMA_UNITS; ?></td>
							</tr>
							<tr><td class="smallText"><input type="checkbox" name="p_desc" value="1" onClick="submit();" <?php if($_SESSION['p_desc']) echo 'CHECKED'; ?> disabled><?php echo PF_INC_PROD_DESCS; ?></td>
							</tr>
							<tr><td class="smallText"><input type="checkbox" name="newsl" value="1" onClick="submit();" <?php if($_SESSION['newsl']) echo 'CHECKED'; ?> disabled><?php echo PF_INC_NEWSLETTERS; ?></td>
							</tr>
							<tr><td class="smallText"><input type="checkbox" name="p_nots" value="1" onClick="submit();" <?php if($_SESSION['p_nots']) echo 'CHECKED'; ?> disabled><?php echo PF_INC_PROD_NOTS; ?></td>
							</tr>
						</table>
					</form>
					</td>
					<td width="55%" align="center" class="pageHeading"><?php echo PF_TITLE; ?>
					</td>
					<td valign="top" align="right">
  					<table class="pfTable" border="1" rules="none" frame="box">
  					<tr><td align="center" class="smallText"><u><b><?php echo PF_OPTS; ?></b></u></td>
							</tr>
  						<tr><td><a href="<?php echo tep_href_link('proforma.php', 'action=new_unit', 'NONSSL'); ?>"><?php echo PF_CREATE_NEW; ?></a></td>
  						</tr>
  						<tr><td><a href="<?php echo tep_href_link('proforma.php', 'action=pos_man', 'NONSSL'); ?>"><?php echo PF_POS_MAN; ?></a></td>
  						</tr>
  						<tr><td><a href="<?php echo tep_href_link('proforma.php', 'action=grp_man', 'NONSSL'); ?>"><?php echo PF_GRP_MAN; ?></a></td>
  						</tr>
  						<tr><td><a href="<?php echo tep_href_link('proforma.php', 'action=frm_man', 'NONSSL'); ?>"><?php echo PF_FORM_MAN; ?></a></td>
  						</tr>
  						<tr><td><a target="_blank" href="http://www.open-source-services.com/Forum/Proforma-PF-v1.0-PLUS-Shareware-Version-osCommerce/"><?php echo PF_SUPPORT; ?></a></td>
  						</tr> 
  						<tr><td><a target="_blank" href="http://www.open-source-services.com/Products/OSS-Premium-Add-Ons/Proforma-v1.0-PLUS.html?flypage=0">Upgrade</a></td>
  						</tr>						
  					</table>
  				</td>
  				</tr>
  				</table>
  				</td>
				</tr>
<?php  

    	    	
if($show_units){ 
$all_rows = array(array());
if($_SESSION['pf_units']){
		@mysql_data_seek($arr_all_units,0);
	  while ($pf = tep_db_fetch_array($arr_all_units)) {

	  	$all_rows[] = array('pf_name' => $pf['pf_name'], 
	  											'pf_group' => $pf['pf_group'],
	  											'position' => $pf['position'],
	  											'pages' => $pf['pages'],
	  											'placement' => $pf['placement'],
	  											'pf_type' => $pf['pf_type'],
	  											'active' => $pf['active']) ;
	  }
}

$chbx_counter = 0;
if(count($all_rows) > 1){
	if($_SESSION['order_by'] != ''){
		if($_SESSION['asc_dec'] == PF_DESCENDING) {
			$all_rows = vsort($all_rows, $_SESSION['order_by'], false);
		} else {
		  $all_rows = vsort($all_rows, $_SESSION['order_by']);
		}
	} else {
		$all_rows = vsort($all_rows, 'pf_name');
		$_SESSION['asc_dec'] = PF_ASCENDING;
	}
?>
<tr>
	<td align="center" class="smallText">
		<?php echo PF_QUICKFIND;?>
      <form name="quickfind" action="<?php echo tep_href_link('proforma.php', 'action=edit_unit', 'NONSSL'); ?>" method="post">
      	<select onChange="submit();" name="quickfind">
							<option value="<?php echo PF_SELECT; ?>"><?php echo PF_SELECT; ?></option>
							<?php
							for($i = 1; $i < count($all_rows);$i++){
							?>					
						<option value="<?php echo $all_rows[$i]['position'] . '__' . $all_rows[$i]['pf_name']; ?>"><?php echo $all_rows[$i]['pf_name']; ?></option>												
						<?php } ?>
						</select>
			</select>
			</form>
	</td>
</tr>
<tr>
<td align="center" class="smallText">
	<?php
		echo PF_LIST_NAV;
    $per_page = $_SESSION['row_num'];
    $option_page = '';
    if (!isset($HTTP_GET_VARS['option_page'])) {
      $option_page = 1;
    } else {
    	$option_page = $HTTP_GET_VARS['option_page'];
  	}
    $prev_option_page = $option_page - 1;
    $next_option_page = $option_page + 1;
    $option_page_start = ($per_page * $option_page) - $per_page;
    $num_rows = count($all_rows);

    if ($num_rows <= $per_page) {
      $num_pages = 1;
    } else if (($num_rows % $per_page) == 0) {
      $num_pages = ($num_rows / $per_page);
    } else {
      $num_pages = ($num_rows / $per_page) + 1;
    }
    $num_pages = (int) $num_pages;

    if ($prev_option_page)  {
      echo '<a href="' . tep_href_link('proforma.php', 'option_page=' . $prev_option_page) . '"> &lt;&lt; </a> | ';
    }

    for ($i = 1; $i <= $num_pages; $i++) {
      if ($i != $option_page) {
        echo '<a href="' . tep_href_link('proforma.php', 'option_page=' . $i) . '">' . $i . '</a> | ';
      } else {
        echo '<b><font color=red>' . $i . '</font></b> | ';
      }
    }

    if ($option_page != $num_pages) {
      echo '<a href="' . tep_href_link('proforma.php', 'option_page=' . $next_option_page) . '"> &gt;&gt; </a>';
    }
?>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <?php echo PF_ORDER_BY;?>
                <form name="order_dropdown" action="<?php echo tep_href_link('proforma.php', 'action=order_by', 'NONSSL'); ?>" method="post">
                	<select onChange="submit();" name="order_by">
												<option value="<?php echo PF_SELECT; ?>"><?php echo PF_SELECT; ?></option>
												<?php
												$pf_lst_flds = getAllListingFields();
												for($i = 0; $i < count($pf_lst_flds);$i++){
												?>
										
											<option <?php if((isset($_SESSION['order_by_val'])) && ($_SESSION['order_by_val'] == $pf_lst_flds[$i])) echo 'SELECTED';?> value="<?php echo $pf_lst_flds[$i]; ?>"><?php echo $pf_lst_flds[$i]; ?></option>												
											<?php } ?>
											</select>
								</select>
								</form>
								
								<form name="asc_dec" action="<?php echo tep_href_link('proforma.php', 'action=order_by', 'NONSSL'); ?>" method="post">
                	<select onChange="submit();" name="asc_dec">
                	
											<option <?php if((isset($_SESSION['asc_dec'])) && ($_SESSION['asc_dec'] == PF_ASCENDING)) echo 'SELECTED';?> value="<?php echo PF_ASCENDING; ?>"><?php echo PF_ASCENDING; ?></option>												
											<option <?php if((isset($_SESSION['asc_dec'])) && ($_SESSION['asc_dec'] == PF_DESCENDING)) echo 'SELECTED';?> value="<?php echo PF_DESCENDING; ?>"><?php echo PF_DESCENDING; ?></option>												
									</select>
								</select>
								</form>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<form name="row_num" action="<?php echo tep_href_link('proforma.php', 'action=order_by', 'NONSSL'); ?>" method="post">
									<?php echo PF_NUM_ROWS; ?>
									<input value=<?php echo $_SESSION['row_num']; ?> name="row_num" type="text" size="3" maxlength="3" onchange="submit();"/>
								</form>
                </td>
</tr>
		<tr>
        <td><form name="ads_list" action="<?php echo tep_href_link('proforma.php', 'action=delete_units', 'NONSSL'); ?>" method="post">
        	<table class="pfTable" align="center" border="0" width="90%" cellspacing="0" cellpadding="0">	 
        	      
	          <tr>
	            <td valign="top"><table border="1" width="100%" cellspacing="0" cellpadding="2" rules="none" frame="box">
	              <tr class="pfEditTableHeading">
	                <td align="center"><?php echo TABLE_HEADING_PF_NAME; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_PF_GROUP; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_PF_POSITION; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_PF_PAGES; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_PF_PLACEMENT; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_PF_TYPE; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_PF_ACTIVE; ?></td>
	                <td align="center"><?php echo TABLE_HEADING_EDIT; ?></td>
	                <td align="center"><img src='images/icons/delete.gif'/></td>
	              </tr>
<?php
for($i = 1 + ($per_page * ($option_page - 1)); $i <= ($per_page * $option_page); $i++){ 
	if($i >= count($all_rows))break;
	$a = 0;
	if($_SESSION['asc_dec'] == PF_DESCENDING){
		$a = $i - 1;
	}else{
		$a = $i;
	}
	?>
	<tr class="pfTableData">
	              	<td align="center"><?php echo $all_rows[$a]['pf_name']; ?></td>
	              	<td align="center"><?php echo 'None'; ?></td>
	              	<td align="center"><?php echo $all_rows[$a]['position']; ?></td>
	              	<td align="center"><?php echo $all_rows[$a]['pages']; ?></td>
	              	<td align="center"><?php echo $all_rows[$a]['placement']; ?></td>
	              	<td align="center"><?php echo $all_rows[$a]['pf_type']; ?></td>
	              	<td align="center"><?php echo $all_rows[$a]['active']; ?></td>
	  <?php if($all_rows[$a]['position'] == 'oscProduct') { ?>
	  	<td align="center" class="dataTableContent"><?php echo '<a class="headerLink" href="proforma.php?action=edit_unit&oprod_name=' . $all_rows[$a]['pf_name'] . '"><img style="border: none;" src="images/icons/preview.gif"/></a>'; ?></td>
	  	<td align="center" class="dataTableContent"><input type="checkbox" DISABLED /></td>
	  <?php } else if($all_rows[$a]['position'] == 'oscNewsletter') { ?>
	  	<td align="center" class="dataTableContent"><?php echo '<a class="headerLink" href="proforma.php?action=edit_unit&newsl_name=' . $all_rows[$a]['pf_name'] . '"><img style="border: none;" src="images/icons/preview.gif"/></a>'; ?></td>
	  	<td align="center" class="dataTableContent"><input type="checkbox" DISABLED /></td>
	  <?php } else if($all_rows[$a]['position'] == 'oscProdNotification') { ?>
	  	<td align="center" class="dataTableContent"><?php echo '<a class="headerLink" href="proforma.php?action=edit_unit&pnot_name=' . $all_rows[$a]['pf_name'] . '"><img style="border: none;" src="images/icons/preview.gif"/></a>'; ?></td>
	  	<td align="center" class="dataTableContent"><input type="checkbox" DISABLED /></td>
	  <?php } else { ?>
	  	<td align="center" class="dataTableContent"><?php echo '<a class="headerLink" href="proforma.php?action=edit_unit&pf_name=' . $all_rows[$a]['pf_name'] . '"><img style="border: none;" src="images/icons/preview.gif"/></a>'; ?></td>
			<td align="center" class="dataTableContent"><?php echo '<input type="checkbox" name="check' . $chbx_counter . '" value="' . $all_rows[$a]['pf_name'] . '" />';?></td>
		<?php $chbx_counter++; } ?>
	   </tr>	
<?php } ?>          
	          <tr>
				   			<td colspan="9" align="right">
				   				<input type="hidden" name="chk_count" value="<?php echo $chbx_counter; ?>">
				   				<a href="<?php echo DIR_WS_INCLUDES . 'docs/pf_help.html#'; ?>" target="_blank"><img align="left" title="<?php echo PF_HELP; ?>" alt="<?php echo PF_HELP; ?>" style="border: none;" src="<?php echo DIR_WS_ICONS . 'help1.gif'; ?>"></a>
				   				<div align="right"><?php echo tep_image_submit('pf_button_delete.gif', IMAGE_DELETE); ?></div>				   				
				   			</td>
				   		</tr>
	        </table></form>
	      </td>
	    </tr>
<?php }} 
 if($HTTP_GET_VARS['action'] == 'frm_man') { ?>
 	<tr>
			<td align="center">
				<table class="pfTable" align="center" border="1" rules="none" frame="box">
		<tr class="pfEditTableHeading">
			<td colspan="2" align="center"><?php echo PF_FORM_MAN; ?>
			</td>
		</tr>
<?php if($arr_all_fms != 0) { ?>
		<tr>
			<td align="center">
				<form name="delete_pos" action="<?php echo tep_href_link('proforma.php', '', 'NONSSL'); ?>" method="post">
					<table class="pfTable" align="center" border="1" rules="none" frame="box">
						<tr class="pfEditTableHeading">
							<td class="pfEditTableHeading" align="center" colspan="5"><?php echo PF_CUR_FMS; ?></td>
						</tr>
						<tr class="pfEditTableHeading">
							<td align="center"><?php echo TABLE_HEADING_PF_FRM_NAME; ?></td>
							<td align="center"><?php echo TABLE_HEADING_PF_FRM_TARGET; ?></td>
							<td align="center"><?php echo TABLE_HEADING_PF_FRM_QUERY_STR; ?></td>
							<td><?php echo TABLE_HEADING_PF_GET_HEAD_CD; ?></td>
							<td align="center"><img src='images/icons/delete.gif'/></td>
						</tr>

						<tr class="pfTableData">
							<td align="center"><?php echo 'Feedback Form'; ?></td>
							<td align="center"><?php echo 'product_info.php'; ?></td>
							<td align="center"><?php echo 'action=send'; ?></td>
							<td align="center"><?php echo '<img style="border: none;" src="images/icons/preview.gif"/>'; ?></td>
							<td align="center"><?php echo '<input type="checkbox" disabled />';?></td>
						</tr>

						<tr>
							<td colspan="5">
							<input type="hidden" name="chk_count" value="<?php echo $rows; ?>">
							<a href="<?php echo DIR_WS_INCLUDES . 'docs/proforma_help.html#list_box'; ?>" target="_blank"><img align="left" title="<?php echo PF_HELP; ?>" alt="<?php echo PF_HELP; ?>" style="border: none;" src="<?php echo DIR_WS_ICONS . 'help1.gif'; ?>"></a>
				<div align="right">
				<a class="headerLink" href="proforma.php"><?php echo tep_image_button('pf_button_cancel.gif', PF_CANCEL, PF_CANCEL); ?></a>
							&nbsp;&nbsp;<?php echo tep_image_submit('pf_button_delete.gif', IMAGE_DELETE); ?></div>
							</td>
						</tr>
					</table>
				</form>
			</td>
 		</tr>
 		</table>
 		</td>
 		</tr>
<?php } else { ?>
		<tr>
			<td><?php echo PF_NO_FMS; ?></td>
		</tr>
<?php } ?>
 		<tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php } if($show_unit_settings) {
					if(!$new_unit) { 
						if($unit_name != ''){
							mysql_data_seek($arr_all_units,0);
							while($arrdetail = tep_db_fetch_array($arr_all_units)) {
								if($arrdetail['pf_name'] == $unit_name)break;
							}
						}
					}
			?>
      <tr class="pfTableData">
<?php if ($unit_name != '') { ?>
				<td align="center"><?php echo PF_CONTENT_FOR . ': '; ?><b><?php echo stripslashes($unit_name); ?></b>...</td>
<?php } else if($oprod_name != '') { ?>
				<td align="center"><?php echo PF_CONTENT_FOR . ': '; ?><b><?php echo stripslashes($oprod_name); ?></b>...</td>
<?php } else if($newsl_name != '') { ?>
				<td align="center"><?php echo PF_CONTENT_FOR . ': '; ?><b><?php echo stripslashes($newsl_name); ?></b>...</td>
<?php } else if($pnot_name != '') { ?>
				<td align="center"><?php echo PF_CONTENT_FOR . ': '; ?><b><?php echo stripslashes($pnot_name); ?></b>...</td>
<?php }?>
      </tr>
<?php if((($unit_name != '')||($new_unit))&&($HTTP_GET_VARS['action'] != 'frm_man')){ ?>
	
		<?php if(!$no_errors) { ?>
			<tr>
		<td align="center"><?php echo PF_ERRORS; ?>
			<ul>
			<li><?php echo PF_ERROR_NAME_LENGTH; ?></li>
			<li><?php echo PF_ERROR_SET_ACTIVE; ?></li>
			<li><?php echo PF_ERROR_SET_PAGES; ?></li>
			<li><?php echo PF_ERROR_SET_POSITION; ?></li>
			<li><?php echo PF_ERROR_SET_UNIT_TYPE; ?></li>
			</ul>
		</td>
		</tr>
<?php } ?>
		<tr>
    		<td>
    			<form action="<?php echo tep_href_link('proforma.php', 'action=create_ed', 'NONSSL'); ?>" method="post">
							<table class="pfTable" align="center" border="1" rules="none" frame="box">
								<tr class="pfEditTableHeading">
									<td align="right" colspan="2"><?php echo PF_SETTINGS; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="smallText"><?php echo PF_REQUIRED; ?></span></td>							
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_NAME . ": "; ?></td>
									<td><input type="text" name="pf_name" value="<?php if($show_values) echo $arrdetail['pf_name']; ?>" />*</td>
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_ACTIVE . ": "; ?></td>
									<td><select name="active">
												<option value="<?php echo PF_PLEASE_SELECT; ?>"><?php echo PF_PLEASE_SELECT; ?></option>
												<option <?php if(($show_values) && ($arrdetail['active'] == PF_YES)) echo 'SELECTED'; ?> value="<?php echo PF_YES; ?>"><?php echo PF_YES; ?></option>
												<option <?php if(($show_values) && ($arrdetail['active'] == PF_NO)) echo 'SELECTED'; ?> value="<?php echo PF_NO; ?>"><?php echo PF_NO; ?></option>
											</select>*
									</td>
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_GROUP . ": "; ?></td>
									<td><select name="pf_group" disabled>
												<option value="<?php echo PF_NO_GROUP; ?>"><?php echo PF_NO_GROUP; ?></option>
											</select>
									</td>
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_DESCRIPTION . ": "; ?></td>
									<td><textarea name="description"><?php if($show_values) echo $arrdetail['description']; ?></textarea></td>
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_PAGES . ": "; ?></td>
									<td><input type="textarea" name="pages" value="<?php if($show_values) echo $arrdetail['pages']; ?>"/>*</td>
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_POSITION . ": "; ?></td>
									<td><select name="position">
												<option value="<?php echo PF_PLEASE_SELECT; ?>"><?php echo PF_PLEASE_SELECT; ?></option>
												<?php
												$pf_all_pos = getAllPos();
												while ($pf_pos = tep_db_fetch_array($pf_all_pos)) {
												?>
												<option <?php if(($show_values) && ($pf_pos['pos_name'] == $arrdetail['position'])) echo 'SELECTED'; ?> value="<?php echo $pf_pos['pos_name']; ?>"><?php echo $pf_pos['pos_name']; ?></option>																								
											<?php } ?>
											</select>*
									</td>
								</tr>
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_PLACEMENT . ": "; ?></td>
									<td><input type="text" name="placement" value="<?php if($show_values) echo $arrdetail['placement']; ?>"/></td>
								</tr>							
								<tr class="pfTableData">
									<td><?php echo TABLE_HEADING_PF_TYPE . ": "; ?></td>
									<td>
										<select name="pf_type">
											<option value="<?php echo PF_PLEASE_SELECT; ?>"><?php echo PF_PLEASE_SELECT; ?></option>
											<option value="<?php echo PF_CONTENT; ?>" selected><?php echo PF_CONTENT; ?></option>		
										</select>*
									</td>
								</tr>
								<tr>
									<td>
									<a href="<?php echo DIR_WS_INCLUDES . 'docs/proforma_help.html#cncu1'; ?>" target="_blank"><img align="left" title="<?php echo PF_HELP; ?>" alt="<?php echo PF_HELP; ?>" style="border: none;" src="<?php echo DIR_WS_ICONS . 'help1.gif'; ?>"></a>
									</td>
									<td align="right">
									<a href="proforma.php"><?php echo tep_image_button('pf_button_cancel.gif', PF_CANCEL, PF_CANCEL); ?></a>&nbsp;&nbsp;<?php echo tep_image_submit('pf_button_save.gif', IMAGE_SAVE); ?></td>
								</tr>
							</table>
						</form>
						</td>						
						</tr>
<?php } else { 
	if($HTTP_GET_VARS['action'] == 'edit_unit') {?>
				<tr><td align="center"><br><a class="headerLink" href="proforma.php"><?php echo tep_image_button('pf_button_cancel.gif', PF_CANCEL, PF_CANCEL); ?></a>
				</td></tr>
<?php } } ?>    	
    		<tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php if(isset($arrdetail['pf_name'])) { ?>
<tr><td>
	<?php if(isset($HTTP_GET_VARS['get_hcode'])){ ?>
		<form action="<?php echo tep_href_link('proforma.php', 'action=save_form&frm_man=true', 'NONSSL'); ?>" method="post">
	<?php } else { ?>
		<form action="<?php echo tep_href_link('proforma.php', 'action=save_form', 'NONSSL'); ?>" method="post">
	<?php } 
$oFCKeditor = new FCKeditor('editor_content');
$oFCKeditor->BasePath = 'includes/fckeditor/';
if($show_values){
$oFCKeditor->Value = stripslashes($arrdetail['content']);
} else {
$oFCKeditor->Value = PF_DEFAULT_CONT;
}
$oFCKeditor->Height = '450';
$oFCKeditor->Create() ;

if($unit_name != ''){ ?>
	<input type="hidden" name="name" value="<?php echo $arrdetail['pf_name']; ?>">
<?php } ?>
</form>
</td></tr>
<tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php }} if($HTTP_GET_VARS['action'] == 'pos_man') { ?>
		<tr>
			<td align="center">
				<table class="pfTable" align="center" border="1" rules="none" frame="box">
		<tr class="pfEditTableHeading">
			<td colspan="2" align="center"><?php echo PF_POS_MAN; ?>
			</td>
		</tr>
		<tr>
<?php if($arr_all_pos != 0){ ?>
			<td valign="top" align="center">
				<form name="delete_pos" action="<?php echo tep_href_link('proforma.php', 'action=del_pos', 'NONSSL'); ?>" method="post">
					<table class="pfTable" align="center" border="1" rules="none" frame="box">
						<tr class="pfEditTableHeading">
							<td align="center" colspan="5"><?php echo PF_CUR_POS; ?></td>
						</tr>
						<tr class="pfEditTableHeading">
							<td><?php echo TABLE_HEADING_PF_POSITION; ?></td>
							<td><?php echo TABLE_HEADING_PF_DEPLOYED; ?></td>
							<td><?php echo TABLE_HEADING_PF_IN_USE; ?></td>
							<td><?php echo TABLE_HEADING_PF_GET_CODE; ?></td>
							<td align="center"><img src='images/icons/delete.gif'/></td>
						</tr>
<?php 
$chbx_counter = 0;
$rows = 0;
while($pos_details = tep_db_fetch_array($arr_all_pos)){ 
	$rows++;	
	if(posInUse($pos_details['pos_name'])){
		$pos_details['in_use'] = PF_YES;
	} else {
		$pos_details['in_use'] = PF_NO;
	} ?>
						<tr class="pfTableData">
							<td><?php echo $pos_details['pos_name']; ?></td>
							<td align="center"><?php echo $pos_details['deployed']; ?></td>
							<td align="center"><?php echo $pos_details['in_use']; ?></td>
							<td align="center"><?php echo '<a class="headerLink" href="proforma.php?action=pos_man&pf_name=' . $pos_details['pos_name'] . '&getCode=true"><img style="border: none;" src="images/icons/preview.gif"/></a>'; ?></td>
<?php if($pos_details['in_use'] == PF_YES) { ?>
							<td><input type="checkbox" DISABLED /></td>
<?php } else { ?>							
							<td align="center"><?php echo '<input type="checkbox" name="check' . $chbx_counter . '" value="' . $pos_details['pos_name'] . '" />';?></td>
<?php } ?>
						</tr>
<?php $chbx_counter++; } ?>
						<tr>
							<td colspan="5">
							<a href="<?php echo DIR_WS_INCLUDES . 'docs/proforma_help.html#pm'; ?>" target="_blank"><img align="left" title="<?php echo PF_HELP; ?>" alt="<?php echo PF_HELP; ?>" style="border: none;" src="<?php echo DIR_WS_ICONS . 'help1.gif'; ?>"></a>
							<input type="hidden" name="chk_count" value="<?php echo $rows; ?>">
							<div align="right">
							<?php echo tep_image_submit('pf_button_delete.gif', IMAGE_DELETE); ?></div>		
							</td>
						</tr>
					</table>
				</form>
			</td>
<?php } ?>			
			<td align="center" valign="top">
				<table>
					<tr>
						<td valign="top">
				<form action="<?php echo tep_href_link('proforma.php', 'action=new_pos', 'NONSSL'); ?>" method="post">
					<table class="pfTable" valign="top" align="center" border="1" rules="none" frame="box">
						<tr class="pfEditTableHeading">
							<td valign="top" colspan="2" align="center"><?php echo PF_NEW_POS; ?></td>
						</tr>
						<tr class="pfTableData">
							<td><?php echo PF_NEW_POS_NAME; ?></td>
							<td><input type="text" name="pos_name" size="20" maxlength="20"/>
							</td>
						</tr>
						<tr>
							<td align="right" colspan="2">
							<?php echo tep_image_submit('pf_button_sv_pos.gif', IMAGE_GEN_C); ?></td>
						</tr>						
					</table>
				</form>
				</td>
				</tr>
				<?php if($poscode!='') { ?>
				<tr class="pfTableData">
				<td><?php echo PF_POS_CODE; ?></td>
				</tr>
				<tr>
				<td align="center"><textarea cols="50" rows="2"><?php echo $poscode; ?></textarea></td>
				</tr>
			<?php } ?>
			<tr><td align="center"><br><a class="headerLink" href="proforma.php"><?php echo tep_image_button('pf_button_cancel.gif', PF_CANCEL, PF_CANCEL); ?></a></td></tr>
				</table>				
			</td>
		</tr>
		</table>
		</td>
		</tr>
<?php	} if($HTTP_GET_VARS['action'] == 'grp_man') { ?>
		<tr>
			<td align="center">
				<table class="pfTable" align="center" border="1" rules="none" frame="box">
		<tr class="pfEditTableHeading">
			<td colspan="2" align="center"><?php echo PF_GRP_MAN; ?>
			</td>
		</tr>
		<tr>
<?php if($arr_all_grps != 0){ ?>
			<td valign="top" align="center">
				<form name="delete_pos" action="<?php echo tep_href_link('proforma.php', '', 'NONSSL'); ?>" method="post">
					<table class="pfTable" align="center" border="1" rules="none" frame="box">
						<tr class="pfEditTableHeading">
							<td align="center" colspan="3"><?php echo PF_CUR_GRPS; ?></td>
						</tr>
						<tr class="pfEditTableHeading">
							<td><?php echo TABLE_HEADING_PF_GRP_NAME; ?></td>
							<td><?php echo TABLE_HEADING_PF_IN_USE; ?></td>
							<td align="center"><img src='images/icons/delete.gif'/></td>
						</tr>

						<tr class="pfTableData">
							<td><?php echo 'Miscellaneous'; ?></td>
							<td><?php echo 'No'; ?></td>
							<td><input type="checkbox" DISABLED /></td>
						</tr>

						<tr>
							<td colspan="3">
							<a href="<?php echo DIR_WS_INCLUDES . 'docs/proforma_help.html#gm'; ?>" target="_blank"><img align="left" title="<?php echo PF_HELP; ?>" alt="<?php echo PF_HELP; ?>" style="border: none;" src="<?php echo DIR_WS_ICONS . 'help1.gif'; ?>"></a>
							<input type="hidden" name="chk_count" value="<?php echo $rows; ?>">
							<div align="right">
							<?php echo tep_image_submit('pf_button_delete.gif', IMAGE_DELETE); ?></div>			
							</td>
						</tr>
					</table>
				</form>
			</td>
<?php } ?>			
			<td align="center" valign="top">
				<table>
					<tr>
						<td valign="top">
				<form action="<?php echo tep_href_link('proforma.php', '', 'NONSSL'); ?>" method="post">
					<table class="pfTable" valign="top" align="center" border="1" rules="none" frame="box">
						<tr class="pfEditTableHeading">
							<td valign="top" colspan="2" align="center"><?php echo PF_NEW_GRP; ?></td>
						</tr>
						<tr class="pfTableData">
							<td><?php echo PF_NEW_GRP_NAME; ?>
							</td>
							<td><input type="text" disabled size="20" maxlength="20"/>
							</td>
						</tr>
						<tr>
							<td><?php echo PF_NEW_GRP_PAR_NAME; ?>
							</td>
							<td><select disabled>
												<option value="<?php echo PF_NO_GROUP; ?>"><?php echo PF_NO_GROUP; ?></option>
											</select>
							</td>
						</tr>
						<tr>
							<td align="right" colspan="2"><?php echo tep_image_submit('pf_button_sv_grp.gif', IMAGE_GEN_C); ?></td>
						</tr>
					</table>
				</form>
				</td>
				</tr>
				<tr><td align="center"><br><br><a class="headerLink" href="proforma.php"><?php echo tep_image_button('pf_button_cancel.gif', PF_CANCEL, PF_CANCEL); ?></a></td></tr>
				</table>				
			</td>
		</tr>
		</table>
		</td>
		</tr>	
<?php }
?>	 
 		</table>
 		</td>
 		</tr>
</table>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>