<?php
/*

  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd 
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );

  require('includes/application_top.php');

  // #CP - local dir to the template directory where you are uploading the company logo
  $disp_class="";
  $format=(isset($HTTP_POST_VARS['exportformat'])?$HTTP_POST_VARS['exportformat']:'');
  $form_action=(isset($HTTP_POST_VARS['form_action'])?$HTTP_POST_VARS['form_action']:'');
  $format=$format[0];
  if($format!="")
  { 
  	switch($format)
	{
		case "F": //freeway
			break;
		case "O":  //osocmmrece
			$server=$HTTP_POST_VARS['osc_server'];
			$username=$HTTP_POST_VARS['osc_username'];
			$password=$HTTP_POST_VARS['osc_password'];
			$dbname=$HTTP_POST_VARS['osc_dbname'];
			$oscomm_link=mysql_connect($server, $username, $password,true);
			mysql_select_db($dbname,$oscomm_link);
			break;
		case "Z":  //zencart
			$server=$HTTP_POST_VARS['zen_server'];
			$username=$HTTP_POST_VARS['zen_username'];
			$password=$HTTP_POST_VARS['zen_password'];
			$dbname=$HTTP_POST_VARS['zen_dbname'];
			$zencart_link=mysql_connect($server, $username, $password,true);
			mysql_select_db($dbname,$zencart_link);
			break;
		case "E": //easy populate
			//require('easypopulate.php');
			//exit;
			break;
	}
  }
 
 if($form_action=="export")
 {
 	$text_content=""; 
	switch($format)
	{
	   case "F":
		   $filename="freeway_prod.csv";
		   if($db_link){
		   		tep_export_category(0);	
			//	tep_export_options($db_link);
				}
		    break;
	   case "O":
		    $filename="oscommrece_prod.csv";
		    if($oscomm_link){
		   		tep_export_category(0);	
			//	tep_export_options($oscomm_link);
				}
		    break;
	   case "Z":
		    $filename="zencart_prod.csv";
		    if($zencart_link)
		   		tep_export_category(0);	
		    break;
	}
 
	if($text_content!="")
	{
		
		  $handle=fopen($filename, "wb");
		  fwrite($handle,$text_content);
		  // Close file
		  fclose($handle);
		  // Download file
		  $size=filesize($filename);
		  header("Pragma: public");
		  header("Cache-Control: private");
		   header("Content-type: text/csv");
		  header("Content-Disposition: attachment; filename=$filename");
		  header("Content-length: " . strlen($text_content));
		  echo $text_content;
		  exit();
	  }
 }
 tep_get_last_access_file();
function tep_export_options($connection_string){
	global $format,$languages_id,$oscomm_link,$text_content;
	//if($format=="O"){
		$options=array();
		$sql = "select po.products_options_name,pov.products_options_values_name from products_options po,products_options_values pov,products_options_values_to_products_options popo where po.products_options_id=popo.products_options_id and pov.products_options_values_id=popo.products_options_values_id and pov.language_id='" . $languages_id . "' and po.language_id = '" . $languages_id  . "' ";
		$get_options_query = mysql_query($sql,$connection_string);
		if(tep_db_num_rows($get_options_query)>0){
			$options_name='';
			while($result_array=tep_db_fetch_array($get_options_query)){
				$pos=strpos($options_name,$result_array['products_options_name']);
				
				  if(is_numeric(strpos($options_name,$result_array['products_options_name']))){
					 $options_name .= $result_array['products_options_values_name'] .',';
					 }else{ 
					 	 if($options_name=='') $options_name .= $result_array['products_options_name'].'#';
					  	 else
						  	$options_name .= '^'.$result_array['products_options_name'].'#';
						 $options_name .= $result_array['products_options_values_name'].',';
					  }
				  	//$options[]=array('products_options_name'=>$result_array['products_options_name'],'products_options_values_name'=>$result_array['products_options_values_name']);
			}
		}
		$text_content.=chr(14).$options_name;
	//}
} 
 
function tep_export_category($parent_id)
{
	global $HTTP_POST_VARS,$format,$languages_id,$oscomm_link;
	$sel_array=isset($HTTP_POST_VARS['chk_cat' . $parent_id])?$HTTP_POST_VARS['chk_cat' . $parent_id]:'';
	if(is_array($sel_array))
	{
		while (list($key, $val) = each($sel_array)) 
		{
			write_category_details($val);
			tep_export_product($val);
			tep_export_category($val);
		}
	}
	
}
function tep_export_product($category_id)
{
	global $HTTP_POST_VARS;
	$sel_array=isset($HTTP_POST_VARS['chk' . $category_id . '_prd'])?$HTTP_POST_VARS['chk' . $category_id . '_prd']:'';
	if(is_array($sel_array))
	{
		while (list($key, $val) = each($sel_array)) 
		{
			write_product_details($val);
		}
	}
}

function write_category_details($category_id)
{
   global $format,$text_content,$oscomm_link,$zencart_link,$db_link,$languages_id,$HTTP_POST_VARS;
   switch($format)
   {
   		case "O":
			$img_path=$HTTP_POST_VARS['osc_imgpath'];
			$sql="select cd.categories_name,cd1.categories_name as parent_name,concat('$img_path','/',c.categories_image) as categories_image from categories_description cd,categories c left join categories_description cd1 on c.parent_id=cd1.categories_id and cd1.language_id=" . $languages_id . " where c.categories_id=cd.categories_id and cd.language_id=" . $languages_id . " and c.categories_id=" . $category_id;
			$result=mysql_query($sql,$oscomm_link);
			break;
		case "F":
			$protocol=(getenv('HTTPS') == 'on'?"https://":"http://");
			$host=$_SERVER["HTTP_HOST"];
			$domain_url=$protocol . str_replace("//","/",$host . str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']));
			$img_path=str_replace("/admin",'',$domain_url) .images;
			//$img_path="http://localhost:81/freeway/images"; //$HTTP_POST_VARS['osc_imgpath'];
			$sql="select cd.categories_name,cd1.categories_name as parent_name,cd.categories_description,concat('".DIR_FS_CATALOG_IMAGES."','/',c.categories_image) as categories_image from categories_description cd,categories c left join categories_description cd1 on c.parent_id=cd1.categories_id and cd1.language_id=" . $languages_id . " where c.categories_id=cd.categories_id and cd.language_id=" . $languages_id . " and c.categories_id=" . $category_id;
		//	$sql="select cd.categories_name,cd1.categories_name as parent_name,cd.categories_description,concat('$img_path','/',c.categories_image) as categories_image from categories_description cd,categories c left join categories_description cd1 on c.parent_id=cd1.categories_id and cd1.language_id=" . $languages_id . " where c.categories_id=cd.categories_id and cd.language_id=" . $languages_id . " and c.categories_id=" . $category_id;
			$result=mysql_query($sql,$db_link);
			break;
		case "Z":
			$img_path=$HTTP_POST_VARS['zen_imgpath'];
			$sql="select cd.categories_name,cd1.categories_name as parent_name,cd.categories_description,concat('$img_path','/',c.categories_image) as categories_image from categories_description cd,categories c left join categories_description cd1 on c.parent_id=cd1.categories_id and cd1.language_id=" . $languages_id . " where c.categories_id=cd.categories_id and cd.language_id=" . $languages_id . " and c.categories_id=" . $category_id;
			$result=mysql_query($sql,$zencart_link);
			break;
   }
   if(mysql_num_rows($result))
   {
		if($row=tep_db_fetch_array($result))
			$text_content.="category," . implode(",", $row) . chr(13);
   }
}
function write_product_details($product_id)
{
   global $format,$text_content,$oscomm_link,$zencart_link,$db_link,$languages_id,$HTTP_POST_VARS;
   switch($format)
   {
   		case "O":
			$img_path=$HTTP_POST_VARS['osc_imgpath'];
			$sql="select cd.categories_name,prd.products_name,prd.products_description,p.products_model,concat('$img_path','/',p.products_image) as products_image,p.products_price,p.products_date_available,p.products_weight,p.products_status,p.products_tax_class_id,p.manufacturers_id,p.products_quantity from products_description prd,products p,categories_description cd,products_to_categories p2c where p.products_id=prd.products_id and prd.language_id=" . $languages_id . " and p2c.products_id=p.products_id and cd.categories_id=p2c.categories_id and cd.language_id=" . $languages_id . " and p.products_id=" . $product_id;
			$result=mysql_query($sql,$oscomm_link);
			break;
		case "F":
			$protocol=(getenv('HTTPS') == 'on'?"https://":"http://");
			$host=$_SERVER["HTTP_HOST"];
			$domain_url=$protocol . str_replace("//","/",$host . str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']));
			$img_path=str_replace("/admin",'',$domain_url) .images;
			/*$sql="select cd.categories_name,prd.products_name,p.products_model,concat('$img_path','/',p.products_image_1) as products_image_1,concat('$img_path','/',p.products_image_2) as products_image_2,concat('$img_path','/',p.products_image_3) as products_image_3,concat('$img_path','/',p.products_image_4) as products_image_4,concat('$img_path','/',p.products_image_5) as products_image_5,p.products_title_1,p.products_title_2,p.products_title_3,p.products_title_4,p.products_title_5,p.products_price,p.products_date_available,p.products_weight,p.products_status,p.products_tax_class_id,p.manufacturers_id,p.products_sort_order,p.products_quantity,p.is_attributes,p.products_sku,p.author_name,p.is_subscription,p.products_price_break from products_description prd,products p,categories_description cd,products_to_categories p2c where p.products_id=prd.products_id and prd.language_id=" . $languages_id . " and p2c.products_id=p.products_id and cd.categories_id=p2c.categories_id and cd.language_id=" . $languages_id . " and p.products_id=" . $product_id;*/
			$sql="select cd.categories_name,prd.products_name,prd.products_description,p.products_model,concat('". DIR_FS_CATALOG_IMAGES ."','small/',p.products_image_1) as products_image_1,concat('$img_path','/',p.products_image_2) as products_image_2,concat('$img_path','/',p.products_image_3) as products_image_3,concat('$img_path','/',p.products_image_4) as products_image_4,concat('$img_path','/',p.products_image_5) as products_image_5,p.products_title_1,p.products_title_2,p.products_title_3,p.products_title_4,p.products_title_5,p.products_price,p.products_date_available,p.products_weight,p.products_status,p.products_tax_class_id,p.manufacturers_id,p.products_sort_order,p.products_quantity,p.is_attributes,p.products_sku,p.author_name,p.is_subscription,p.products_price_break from products_description prd,products p,categories_description cd,products_to_categories p2c where p.products_id=prd.products_id and prd.language_id=" . $languages_id . " and p2c.products_id=p.products_id and cd.categories_id=p2c.categories_id and cd.language_id=" . $languages_id . " and p.products_id=" . $product_id;
			
			$result=mysql_query($sql,$db_link);
			break;
		case "Z":
			$img_path=$HTTP_POST_VARS['zen_imgpath'];
			$sql="select cd.categories_name,prd.products_name,prd.products_description,p.products_model,concat('$img_path','/',p.products_image) as products_image,p.products_price,p.products_date_available,p.products_weight,p.products_status,p.products_tax_class_id,p.manufacturers_id,p.products_sort_order,p.products_quantity from products_description prd,products p,categories_description cd,products_to_categories p2c where p.products_id=prd.products_id and prd.language_id=" . $languages_id . " and p2c.products_id=p.products_id and cd.categories_id=p2c.categories_id and cd.language_id=" . $languages_id . " and p.products_id=" . $product_id;
			$result=mysql_query($sql,$zencart_link);
			break;
   }
   if(mysql_num_rows($result))
   {
   	if($row=tep_db_fetch_array($result))
	{ 
		if(empty($row['products_date_available'])) 	 $row['products_date_available']='0000-00-00 00:00:00';
		if($row['products_description']){
			$row['products_description'] = str_replace(chr(10),'<br/>',$row['products_description']);
			$row['products_description'] = str_replace(',','~',$row['products_description']);
		}
		$text_content.="product," . implode(",", $row) . chr(13);
		write_attribute_details($product_id);
		if($format=="F") write_price_break_details($product_id);
	}
  }
}
function write_attribute_details($product_id)
{
   global $format,$text_content,$oscomm_link,$zencart_link,$db_link,$languages_id;
   switch($format)
   {
   		case "O":
			$sql="select prd.products_name,at.options_id,at.options_values_id,at.options_values_price,at.price_prefix,po.products_options_name,pov.products_options_values_name from products_description prd,products_attributes at,products_options po,products_options_values pov where at.products_id=prd.products_id and at.options_id=po.products_options_id and at.options_values_id=pov.products_options_values_id and po.language_id=" . $languages_id . " and pov.language_id=" . $languages_id . " and prd.language_id=" . $languages_id . " and at.products_id=" . $product_id;
		//	$sql="select prd.products_name,at.options_id,at.options_values_id,at.options_values_price,at.price_prefix from products_description prd,products_attributes at where at.products_id=prd.products_id and prd.language_id=" . $languages_id . " and at.products_id=" . $product_id;
			//echo $sql.'<br>';
			$result=mysql_query($sql,$oscomm_link);
			break;
		case "F":
 			$sql="select prd.products_name,at.options_id,at.options_values_id,at.options_values_price,at.price_prefix,at.products_options_sort_order,at.product_attributes_one_time,at.products_attributes_weight,at.products_attributes_weight_prefix,at.products_attributes_units,at.products_attributes_units_price,po.products_options_name,pov.products_options_values_name from products_description prd,products_attributes at,products_options po,products_options_values pov where at.products_id=prd.products_id and at.options_id=po.products_options_id and at.options_values_id=pov.products_options_values_id and po.language_id=" . $languages_id . " and pov.language_id=" . $languages_id . " and prd.language_id=" . $languages_id . " and at.products_id=" . $product_id;
			$result=mysql_query($sql,$db_link);
		 	break;
		case "Z":
 			$sql="select prd.products_name,at.options_id,at.options_values_id,at.options_values_price,at.price_prefix,at.products_options_sort_order,at.products_attributes_weight,at.products_attributes_weight_prefix from products_description prd,products_attributes at where at.products_id=prd.products_id and prd.language_id=" . $languages_id . " and at.products_id=" . $product_id;
			$result=mysql_query($sql,$zencart_link);
			break;
   }
     if(mysql_num_rows($result))
     {
		while($row=tep_db_fetch_array($result))
		 $text_content.="attribute," . implode(",", $row) . chr(13);
		}
}
function write_price_break_details($product_id){
	global $text_content,$languages_id;
	
	$sql="select pbd.quantity,pbd.discount_per_item,pd.products_name from products_price_break pbd,products p,products_description pd where p.products_id=pbd.products_id and p.products_id=pd.products_id and p.products_id='". $product_id ."' and pd.language_id='". $languages_id ."' ";
	$price_break_query = tep_db_query($sql);
	if(tep_db_num_rows($price_break_query)>0){
	  while($row=tep_db_fetch_array($price_break_query)){
	  		$products_price_break .= $row['quantity'].'^'.(int)$row['discount_per_item'].'#';
			$products_name= $row['products_name'];
	  }
	  $products_price_break = substr($products_price_break,0,-1).'@'.$products_name;
	  $text_content .="price_break,". $products_price_break . chr(13);
	}
	 
}
function tep_list_category($new_conn,$parent_id,$level)
{
    global $languages_id,$$new_conn,$disp_class;
	if(mysql_error())
	{
		echo mysql_error();
		return;
	}
	$categories_sql = "select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name";
	$result=mysql_query($categories_sql,$$new_conn);
	while($row=tep_db_fetch_array($result))
	{
		if($disp_class=="dataTableRowOdd")
			$disp_class="dataTableRowEven";
		else
			$disp_class="dataTableRowOdd";
		echo '<tr class=' . $disp_class . ' onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"><td class="dataTableContent" colspan=3>' ;
		for($i=0;$i<$level;$i++)
			echo '&nbsp;&nbsp;&nbsp;';
		echo  tep_draw_checkbox_field("chk_cat" . $parent_id . "[]",$row['categories_id'],true,'','onclick=javascript:check_select(this);') . '&nbsp;' . $row['categories_name'] . "</td></tr>";
		tep_list_products($new_conn,$row['categories_id'],$level+1);
		tep_list_category($new_conn,$row['categories_id'],$level+1);
	}
}
function tep_list_products($new_conn,$category_id,$level)
{
    global $languages_id,$$new_conn,$disp_class;
	if(mysql_error())
	{
		echo mysql_error();
		return;
	}
	$product_sql = "select pd.products_name, p.products_price,p.products_id,p.products_date_available from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd," . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id=pd.products_id  and p2c.categories_id= '" . (int)$category_id . "' order by pd.products_name";
	$result=mysql_query($product_sql,$$new_conn);
	if(mysql_num_rows($result)>0)
	{
		//echo '<tr class="dataTableRowOdd"><td class="dataTableContent">';
		echo '<tr class="' . $disp_class . '"><td class="dataTableContent">';
		for($i=0;$i<$level;$i++)
				echo '&nbsp;&nbsp;&nbsp;';
		echo '<b>Product Name</b></td><td class="dataTableContent"><b>Price</b></td><td class="dataTableContent"><b>Date_available</b></td></tr>' ;
		while($row=tep_db_fetch_array($result))
		{
			echo '<tr class="' . $disp_class .'" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"><td class="dataTableContent">' ;
			for($i=0;$i<$level;$i++)
				echo '&nbsp;&nbsp;&nbsp;';
			echo  tep_draw_checkbox_field("chk" . $category_id . "_prd[]",$row['products_id'],true) . '&nbsp;' . $row['products_name'] . "</td><td class='dataTableContent'>" .$row['products_price'] . "</td><td class='dataTableContent'>" . $row['products_date_available']. "</td></tr>";
		}
		//echo "</table></td></tr>";
	}
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<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/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript">
function check_select(item,setval)
{
   var icnt;
   if(!setval)
	  setval=!item.checked;
   chkval=item.value;
   //--for products
   check_products(chkval,setval);
   //--for categories
   var chk=document.export_products.elements["chk_cat" + chkval + "[]"];
   if(!chk) return;
   if(chk.length>0)
  {
	 for (icnt=0;icnt<chk.length;icnt++){
	 	chk[icnt].disabled=setval;
		check_products(chk[icnt].value,setval);
		if(document.export_products.elements["chk_cat" + chk[icnt].value + "[]"])
			check_select(chk[icnt],setval);
	 }
  }
  else
  	chk.disabled=setval;
}
 function check_products(val,setval)
 {
   var icnt;
   var chk=document.export_products.elements["chk" + val + "_prd[]"];
   if(!chk) return;
   if(chk.length>0)
   {
	 for (icnt=0;icnt<chk.length;icnt++){
	 	chk[icnt].disabled=setval;
	 }
   }
   else
  	chk.disabled=setval;
 }
 function checkformatSell(item)
 {
 	document.export_products.form_action.value='';
		var exportformat=document.export_products.elements["exportformat[]"];
		for (icnt=0;icnt<exportformat.length;icnt++){	
			if (exportformat[icnt].checked && exportformat[icnt].value!=item.value) {
				exportformat[icnt].checked=false;
				break;
			}
		}
		document.getElementById('zen_db_details').style.display="none";
		document.getElementById('osc_db_details').style.display="none";
		if(item.value=="O")
			document.getElementById('osc_db_details').style.display="";
		else if(item.value=="Z")
 			document.getElementById('zen_db_details').style.display="";
}
 function toggleBox(szDivID) {
  if (document.layers) { // NN4+
    if (document.layers[szDivID].visibility == 'visible') {
      document.layers[szDivID].visibility = "hide";
      document.layers[szDivID].display = "none";
      document.layers[szDivID+"SD"].fontWeight = "normal";
    } else {
      document.layers[szDivID].visibility = "show";
      document.layers[szDivID].display = "inline";
      document.layers[szDivID+"SD"].fontWeight = "bold";
    }
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
    var obj = document.getElementById(szDivID);
    var objSD = document.getElementById(szDivID+"SD");

    if (obj.style.visibility == 'visible') {
      obj.style.visibility = "hidden";
      obj.style.display = "none";
      objSD.style.fontWeight = "normal";
    } else {
      obj.style.visibility = "visible";
      obj.style.display = "inline";
      objSD.style.fontWeight = "bold";
    }
  } else if (document.all) { // IE 4
    if (document.all[szDivID].style.visibility == 'visible') {
      document.all[szDivID].style.visibility = "hidden";
      document.all[szDivID].style.display = "none";
      document.all[szDivID+"SD"].style.fontWeight = "normal";
    } else {
      document.all[szDivID].style.visibility = "visible";
      document.all[szDivID].style.display = "inline";
      document.all[szDivID+"SD"].style.fontWeight = "bold";
    }
  }
}

</script>
<script language="javascript">
function check_form(){
	var exportformat=document.export_products.elements["exportformat[]"];
		for (icnt=0;icnt<exportformat.length;icnt++){	
			if (exportformat[icnt].checked && exportformat[icnt].value) {
				if(exportformat[icnt].value=='F') document.export_products.submit();
				if(exportformat[icnt].value=='Z'){
					if(document.export_products.zen_server.value=='' || document.export_products.zen_username.value=='' || document.export_products.zen_dbname.value=='' || document.export_products.zen_imgpath.value=='')
					   alert('Input Field should not be empty');
					 else document.export_products.submit();   
				}
				if(exportformat[icnt].value=='O'){ 
					if(document.export_products.osc_server.value=='' || document.export_products.osc_username.value=='' || document.export_products.osc_dbname.value=='' || document.export_products.osc_imgpath.value=='')
					   alert('Input Field should not be empty');
					 else document.export_products.submit();   
				}
				break;
			}
		}
}
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr> 
	<!-- body_text //-->
	    <td width="100%" valign="top">
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
			<tr>
				<td>
				<table border="0" width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
						<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
					</tr>
					<tr>
						<td colspan="2">
						<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<td>
								<?php echo tep_draw_form('export_products',FILENAME_PRODUCTS_EXPORT);
										echo tep_draw_hidden_field('form_action','');?>
								<table cellpadding="5" cellspacing="2" border="0" width="100%">
									<tr>
										<td>
										<table width="100%" cellpading="0" cellspacing="0">
											<tr><td class="dataTableContent"><?php echo tep_draw_checkbox_field("exportformat[]","F",($format=="F" || $format=='')?true:false,'','onclick="javascript:checkformatSell(this)"');?>&nbsp;<?php echo TEXT_FREEWAY;?></td></tr>
											<tr><td class="dataTableContent"><?php echo tep_draw_checkbox_field("exportformat[]","O",($format=="O")?true:false,'','onclick="javascript:checkformatSell(this)"');?>&nbsp;<?php echo TEXT_OSCOMMRECE;?></td></tr>
											<tr>
												<td class="dataTableContent" align="left" id="osc_db_details" style="<?php echo ($format!="O")?'display:none':'';?>">
												<table width="90%" border="0"  align=right cellpadding="0">
													<tr>
														<td width="10%" valign="top" class="dataTableContent"><?php echo TEXT_DATABASE_SERVER;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('osc_server'); ?>
														<img src="images/icon_info.gif" onClick="toggleBox('dbHost');" align="absmiddle"><br>
														<div id="dbHostSD">Hostame or IP-address of the database server</div>
														<div id="dbHost" class="dataTableContent" style="display:none">The database server can be in the form of a hostname, such as db1.myserver.com, or as an IP-address, such as 192.168.0.1</div>
														</td>
													</tr>
													<tr>
														<td width="10%" valign="top" class="dataTableContent" nowrap><?php echo TEXT_DATABASE_SERVER_USERNAME;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('osc_username'); ?>
														<img src="images/icon_info.gif"  onClick="toggleBox('dbUser');" align="absmiddle"><br>
														<div id="dbUserSD">Database username</div>
														<div id="dbUser" class="dataTableContent" style="display:none">The username used to connect to the database server. An example username is 'mysql_10'.<br><br>
														Note: Create and Drop permissions <b>are not required</b> for the general 
														use of osCommRes.</div>
														</td>
													</tr>
													<tr>
														<td width="10%" class="dataTableContent" valign="top" nowrap><?php echo TEXT_DATABASE_SERVER_PASSWORD;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_password_field('osc_password',$password); ?>
														<img src="images/icon_info.gif" onClick="toggleBox('dbPass');" align="absmiddle"><br>
														<div id="dbPassSD">Database password</div>
														<div id="dbPass" class="dataTableContent" style="display:none">The password is used together with the username, which forms the database user account.</div>
														</td>
													</tr>
													<tr>
														<td width="10%" class="dataTableContent" valign="top"><?php echo TEXT_DATABASE;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('osc_dbname'); ?>
														<img src="images/icon_info.gif" onClick="toggleBox('dbName');" align="absmiddle"><br>
														<div id="dbNameSD">Database Name</div>
														<div id="dbName" class="dataTableContent" style="display:none">The database used to hold the 
														data. An example database name is 'osCommerce'.</div>
														</td>
													</tr>
													<tr>
														<td width="10%" class="dataTableContent" valign="top"><?php echo TEXT_IMAGE_PATH;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('osc_imgpath','','size=30'); ?>
														</td>
													</tr>
												</table>
												</td>
											</tr>
											<tr><td class="dataTableContent"><?php echo tep_draw_checkbox_field("exportformat[]","Z",($format=="Z")?true:false,'','onclick="javascript:checkformatSell(this)"');?>&nbsp;<?php echo TEXT_ZENCART;?></td></tr>
											<tr>
												<td class="dataTableContent" align="left" id="zen_db_details" style="<?php echo ($format!="Z")?'display:none':'';?>">
												<table width="90%" border="0" align=right cellpadding="0" cellspacing="0">
													<tr>
														<td width="10%" valign="top" class="dataTableContent"><?php echo TEXT_DATABASE_SERVER;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('zen_server'); ?>
														<img src="images/icon_info.gif" onClick="toggleBox('dbHost1');" align="absmiddle"><br>
														<div id="dbHost1SD">Hostame or IP-address of the database server</div>
														<div id="dbHost1" class="dataTableContent" style="display:none">The database server can be in the form of a hostname, such as db1.myserver.com, or as an IP-address, such as 192.168.0.1</div>
														</td>
													</tr>	
													<tr>
														<td width="10%" valign="top" class="dataTableContent" nowrap><?php echo TEXT_DATABASE_SERVER_USERNAME;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('zen_username'); ?>
														<img src="images/icon_info.gif"  onClick="toggleBox('dbUser1');" align="absmiddle"><br>
														<div id="dbUser1SD">Database username</div>
														<div id="dbUser1" class="dataTableContent" style="display:none">The username used to connect to the database server. An example username is 'mysql_10'.<br><br>
														Note: Create and Drop permissions <b>are not required</b> for the general 
														use of osCommRes.</div>
														</td>
													</tr>
													<tr>
														<td width="10%" class="dataTableContent" valign="top" nowrap><?php echo TEXT_DATABASE_SERVER_PASSWORD;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_password_field('zen_password',$password); ?>
														<img src="images/icon_info.gif" onClick="toggleBox('dbPass1');" align="absmiddle"><br>
														<div id="dbPass1SD">Database password</div>
														<div id="dbPass1" class="dataTableContent" style="display:none">The password is used together with the username, which forms the database user account.</div>
														</td>
													</tr>
													<tr>
														<td width="10%" class="dataTableContent" valign="top"><?php echo TEXT_DATABASE;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('zen_dbname'); ?>
														<img src="images/icon_info.gif" onClick="toggleBox('dbName1');" align="absmiddle"><br>
														<div id="dbName1SD">Database Name</div>
														<div id="dbName1" class="dataTableContent" style="display:none">The database used to hold the 
														data. An example database name is 'zenCart'.</div>
														</td>
													</tr>
													<tr>
														<td width="10%" class="dataTableContent" valign="top"><?php echo TEXT_IMAGE_PATH;?></td>
														<td width="70%" class="dataTableContent">
														<?php echo tep_draw_input_field('zen_imgpath','','size=30'); ?>
														</td>
													</tr>
												</table>
												</td>
											</tr>
											<tr>
												<td class="dataTableContent"><?php //echo tep_draw_checkbox_field("exportformat[]","E",($format=="E")?true:false,'','onclick="javascript:checkformatSell(this)"');?>&nbsp;<?php //echo TEXT_EASY_POPULATE;?>
												</td>
											</tr>
										</table>
										</td>
									</tr>
									<tr height="20">
										<td colspan="2" class="cell_bg_report_header"></td>
									</tr>
									<?php
									if($format!="")
									{
										tep_content_title_top("Products",true,false,false,'',true);
										echo "<tr><td><table width=100% cellpadding=2>";
										switch($format)
										{
											case "F":
												tep_list_category('db_link',0,0);
												break;
											case "O":
												tep_list_category('oscomm_link',0,0);
												break;
											case "Z":
												tep_list_category('zencart_link',0,0);
												break;
										}
										echo "</table></td></tr>";
										tep_content_title_bottom();
										echo "<script>";
										echo "document.export_products.form_action.value='export'";
										echo "</script>";
									} ?>
									<tr>
										<td colspan="2" align="right"><?php echo tep_image_button('button_reset.gif', IMAGE_RESET,'onClick="javascript:location.href=\'products_export.php\';" style="cursor:pointer"');  ?>
											&nbsp;&nbsp;<?php echo tep_image_button('button_export.gif','Export',' style="cursor:pointer" onClick="javascript:check_form();"'); ?></td>
									</tr>
							  </table>
							  </form>
							</td> 
						</tr>
					</table>
					</td>
				</tr>	  
			</table>
			</td>
		</tr> 
	</table>
	</td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>