<?php
include("../include/config.php");
include("../include/functions.php"); 

if($_REQUEST['product_id']!=''){
	 $featArr=$obj->query("select * from  tbl_features where product_id='".$_REQUEST['product_id']."' ");
	 $fArray='';
	 while($resultFeature=$obj->fetchNextObject($featArr)){
		$fArray[$resultFeature->attribute_id]= stripslashes($resultFeature->feature_value);
	 }
}
if($_REQUEST['cat_id']!=''){
	
	$cat_id=getMainParent($_REQUEST['cat_id']);
	$groupArr=$obj->query("select attribute_ids from $tbl_maincategory join $tbl_attributegroup on $tbl_attributegroup.id=$tbl_maincategory.group_id  where $tbl_maincategory.id='".$cat_id."' ");
	if($obj->numRows($groupArr)>0){
	$rsGroup=$obj->fetchNextObject($groupArr);
	if($rsGroup->attribute_ids!=''){
$AttrbueArr=$obj->query("select * from $tbl_attribute where id in($rsGroup->attribute_ids) ");	
}
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
                               <?php while($resultAttribute=$obj->fetchNextObject($AttrbueArr)){ ?>
                            <tr>
                         <td width="25%" align="right" class="paddBot11 paddRt14"><strong> <?php echo stripslashes($resultAttribute->attribute); ?>:</strong></td>
				         <td width="75%" align="left" class="paddBot11">
                          <?php if($resultAttribute->attribute_type=='Dropdown'){?>
                          <select name="att[<?php echo stripslashes($resultAttribute->id); ?>]" style="width:240px;">
                          <option value="">-Select-</option>
                          <?php $AttrbuteValueArr=$obj->query("select * from $tbl_attributevalue where attribute_id='".$resultAttribute->id."' ");
						  while($resultVal=$obj->fetchNextObject($AttrbuteValueArr)){?>
                           <option value="<?php  echo stripslashes($resultVal->attributevalue);?>" <?php if($fArray[$resultAttribute->id]==$resultVal->attributevalue){ ?>selected<?php } ?>><?php  echo stripslashes($resultVal->display_value);?></option>
                          <?php } ?>
                          </select>
                         <?php } ?>
                         
                         <?php if($resultAttribute->attribute_type=='MultipleSelect'){
							  $mutiArr='';
					         $mutiArr=explode(",",$fArray[$resultAttribute->id]);
							 ?>
                          <select name="att[<?php echo stripslashes($resultAttribute->id); ?>][]"   multiple style="width:240px;">
                          <option value="">-Select-</option>
                          <?php $AttrbuteValueArr=$obj->query("select * from $tbl_attributevalue where attribute_id='".$resultAttribute->id."' ");
						  while($resultVal=$obj->fetchNextObject($AttrbuteValueArr)){?>
                           <option value="<?php  echo stripslashes($resultVal->attributevalue);?>" <?php if($mutiArr!='' && in_array($resultVal->attributevalue,$mutiArr)){ ?>selected<?php } ?> ><?php  echo stripslashes($resultVal->display_value);?></option>
                          <?php } ?>
                          </select>
                         <?php } ?>
                         
                         <?php if($resultAttribute->attribute_type=='Yes/No'){?>
                         <input type="radio" name="att[<?php echo stripslashes($resultAttribute->id); ?>]" <?php if($fArray[$resultAttribute->id]=='Yes'){ ?>checked<?php } ?>  value="Yes" />
                         <input type="radio" name="att[<?php echo stripslashes($resultAttribute->id); ?>]" <?php if($fArray[$resultAttribute->id]=='No'){ ?>checked<?php } ?>  value="No" />
                         <?php } ?>
                         
                          <?php if($resultAttribute->attribute_type=='Textbox'){?>
                         <input type="text" name="att[<?php echo stripslashes($resultAttribute->id); ?>]"   value="<?php echo $fArray[$resultAttribute->id]; ?>" />
                         <?php } ?>
                         
                         <?php if($resultAttribute->attribute_type=='Date'){?>
                         <link rel="stylesheet" href="calender/css/jquery-ui.css">
	<script src="calender/js/jquery-1.9.1.js"></script>
	<script src="calender/js/jquery-ui.js"></script>
	<script>
	$(function() {
		$( "#feature_date" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange:'2013:<?php echo date('Y') ?>'
		});
	});
	</script>
                         <input type="text" name="att[<?php echo stripslashes($resultAttribute->id); ?>]" id="feature_date"   value="<?php echo $fArray[$resultAttribute->id]; ?>" />
                         <?php } ?>
                         
                         <?php if($resultAttribute->attribute_type=='TextArea'){?>
                         <textarea name="att[<?php echo stripslashes($resultAttribute->id); ?>]"   rows="5" cols="40"><?php echo $fArray[$resultAttribute->id]; ?></textarea>
                         <?php } ?>
                         </td>
							  </tr>
                              <?php } ?>
</table>

<?php } } ?>