<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php echo $javascript->link('jquery.js'); ?>
<?php echo $javascript->link('alphanumeric.js'); ?>
<?php echo $javascript->link('tooltip.js'); ?>
<script>
   function chkdigit(di){
if(di == 'Digital'){ 	
	// $('#digit').show();$('#prodwght').hide();
          $('#digit').show();
         $('#prodwght').hide();
         // $('.stock_div').hide();
        //  $('.reorder_div').hide();
}else{
	// $('#digit').hide();$('#prodwght').show();
          $('#digit').hide();
         $('#prodwght').show();
          $('.stock_div').show();
          $('.reorder_div').show();
}
return true;
}
</script>
<script>
  $(document).ready(function() 
	{
	   <?php if($productdet["Product"]["combination"]=='N' || $productdet["Product"]["combination"]=='') { ?>
	    $('.stock_div').show();$('.reorder_div').show();$('.reorder1_div').hide();$('.prodesc1_div').hide();
	   <?php } ?>
	   <?php if($productdet["Product"]["prodtype"]=='Digital') { ?>
	    chkdigit('Digital');
	   <?php } ?>	   
	   <?php if($productdet["Product"]["discount_type"]=='per') { ?>
	     setDiscountlbl('per');
	   <?php } ?>
	   <?php if($productdet["Product"]["discount_type"]=='amnt') { ?>
	    setDiscountlbl('amnt');
	   <?php } ?>
                setTimeout('chkdigit(varprdtype)', 1000);
  });
	
var index=<?php echo ($totcnt+1);?>;
var catid=<?php echo $catid;?>;
function deleteProdcombn(catid,prodid,delid)
{
	var con=confirm("Do you want to delete this product combination.");
	if(con==true)
	{
	  window.location="../../delProdcombn/"+catid+"/"+prodid+"/"+delid;
	 }
	 else
	return false;
}


function addMore()
{	  
	 
         for(i=index;i>=2;i--)
	 {var newindex = i-1;
	   $('#addmore'+newindex+'').remove();
	   $('#delrow'+newindex+'').show();
	 }
         ajaxLoadAttributes(catid);
	 return false;		
}
function addMore1()
{	  
	 
         for(i=index;i>=2;i--)
	 {var newindex = i-1;
	   $('#addmore'+newindex+'').remove();
	   $('#delrow1'+newindex+'').hide();
	 }
         ajaxLoadAttributes(catid);
	 return false;		
}

function delRow(rowid)
{		
	 
	 $('.attributes'+rowid+'').remove();
	 $('#combn_cnt'+rowid+'').remove();
	 return false;
}

function checkSubcat(id)
{ 
  if($.trim($('#ProductCategoryId').val())!= 1)
	{
		 $.ajax({
			type: "post",  // Request method: post, get
			url: "../../checksubcat/"+id, // URL to request		
			success: function(response)
			 {	
			   var res=$.trim( response);
			   if(res=='yes')
			   {		   
				 alert("Subcategory exists under this category.\nPlease select a leaf level category.\n\n"); 
				 $('#ProductCategoryId').val(0);
				 return false;
			   }	 
			},
			error:function (XMLHttpRequest, textStatus, errorThrown) {
			alert(textStatus);
			}
			});		
	}		
}

function ajaxLoadAttributes(id)
{
	   $.ajax({
		type: "post",  // Request method: post, get
		url: "../../showcustomfields/"+id+"/"+index, // URL to request		
		success: function(response)
		 {
		   if($.trim(response)!='')
		   {
		   // alert(response);
                   var newid = index-1;
		    $('.new_attributes').before(response);
		    index++;		
			}		
		 },
		error:function (XMLHttpRequest, textStatus, errorThrown) {
		alert(textStatus);
		}
		});

                 varprdtype = $('#ProductProdtype').val();
                if(varprdtype){
                    setTimeout('chkdigit(varprdtype)', 1000);

               // chkdigit(varprdtype);
                }
	return false;		
}	

var imgcnt='<?php echo (count($imgarr)-1);?>';
var totimgcnt='<?php echo $cnfg["product_images"];?>';
function addMoreImage()
{
  imgcnt++;
  if(imgcnt<totimgcnt)
  {
  $('#prod_img').append('<div><input type=\'file\' name=\'data[Product][pdctimg'+imgcnt+']\' id=\'pimage'+imgcnt+'\' size=\'10\'>'+
                        '&nbsp;&nbsp;Set as Default Image<input type=\'radio\' name=\'dfltimg\' value=\''+imgcnt+'\' onclick="javascript:$(\'#ProductDefaultimg\').val(this.value)"'+'/></div>');
	$('#ProductTotalimg').val();
        //... Append the newly added values to the total image count
        var totImageCount = parseInt($('#ProductTotalimg').val())+1;
        $('#ProductTotalimg').val(totImageCount);
        
    }
  else
  alert("Sorry,You can upload only "+totimgcnt+" images");
  return false;
}

</script>

<script>
function validateFields(thisform)
{ 
       
     var i=0;
	 var j=0;
	 var fcs_fld=new Array();
	 var errorstr = '';
	 var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	// if($.trim($('#ProductCategoryId').val())==0) { errorstr += "- Please Select a Category.\n";  fcs_fld[i]='ProductCategoryId'; i++; }
	if($.trim($('#ProductCategoryId').val())==1)
	{
	   alert("Please select a leaf level category.");
	   return false;
	}  
        
	 if($.trim($('#ProductPname').val())=='') { errorstr += "- Please enter Product Name.\n"; fcs_fld[i]='ProductPname'; i++; }	 		
		 
		<?php if($productdet["Product"]["combination"]=='N') { ?>		
		//  if($.trim($('#ProductStock').val())=='') { errorstr += "- Please enter the Stock value.\n"; fcs_fld[i]='ProductStock'; i++; }		 
		 //  if($.trim($('#ProductReorderlevel').val())=='') { errorstr += "- Please enter the Reorder level.\n"; fcs_fld[i]='ProductReorderlevel'; i++; }		       		
		<?php } ?> 
		
		  /*Code for Image type Validation starts here */
                               
				for(j=0;j<(imgcnt+1);j++)
				  {
                                      
				   
					  if($('#pimage'+j+'').val()!='')
					  {
                                               if(!isNaN($('#pimage'+j+'').val())){
                                                    var img_src=$('#pimage'+j+'').val();		

                                                    var imgformats = ['.png','.gif','.jpg','.jpeg'];

                                                          if(img_src.length>0)
                                                             {

                                                                    var fileType1 = checkImageType(img_src);
                                                                           if(fileType1)
                                                                                    {
                                                                                          if(!inArray(imgformats,fileType1.toLowerCase()))
                                                                                                  {
                                                                                                            errorstr += "- Please upload a valid File format.('png','gif','jpg','jpeg') for Product Image "+ (j+1) +".\n";
                                                                                                            img_src='';
                                                                                                   }
                                                                                     }
                                                             }
                                                  
						}
                                            }
					} 
                                        
		/*Code for Image type Validation starts here */					
	 
	    //if($.trim($('#ProductDescr').val())=='') { errorstr += "- Please enter Product Description.\n"; fcs_fld[i]='ProductDescr'; i++;}
		//if($.trim($('#ProductPrice').val())=='') { errorstr += "- Please enter Product Price.\n"; fcs_fld[i]='ProductPrice'; i++; }
		//if($.trim($('#ProductWholesalePrice').val())=='') { errorstr += "- Please enter Product Wholesale Price.\n"; fcs_fld[i]='ProductWholesalePrice'; i++; }		
		if($.trim($('#ProductPrice').val())=='') { errorstr += "- Please enter Product Retail Price.\n"; fcs_fld[i]='ProductPrice'; i++; }
		
		if($.trim($('#ProductWholesalePrice').val())!='') {
		var wprice=$.trim($('#ProductWholesalePrice').val());
		var rprice=$.trim($('#ProductPrice').val());
		if(parseFloat(wprice) > parseFloat(rprice))
		{ errorstr += "- Wholesale Price should be less than or equal to Retail price.\n"; fcs_fld[i]='ProductPrice'; i++; }
		}
		
		//if($.trim($('#ProductProdtype').val())=='') { errorstr += "- Please Select Product Type.\n"; fcs_fld[i]='ProductProdtype'; i++; }

         if($.trim($('#ProductProdtype').val())=='Non-Digital') {
		if($.trim($('#ProductWeight').val())=='') { errorstr += "- Please enter Product Weight.\n"; fcs_fld[i]='ProductWeight'; i++; }		
		}
		 
	if($.trim($('#ProductDiscountType').val())=='amnt')   
        {
			var ret_price=$.trim($('#ProductPrice').val());
		    	var discnt=$.trim($('#ProductDiscount').val());   		
		        if(parseFloat(discnt) >= parseFloat(ret_price)) 
				{ errorstr += "- Discount amount should be smaller than retail price.\n"; fcs_fld[i]='ProductDiscount'; i++; }
        }        
        else if($.trim($('#ProductDiscountType').val())=='per')   
        {
			   	var discnt=$.trim($('#ProductDiscount').val());   		
		        if(parseFloat(discnt) >= 100) 
				{ errorstr += "- Discount percentage should be smaller 100.\n"; fcs_fld[i]='ProductDiscount'; i++; }
        }
		
		if (errorstr != '')
		{
		  msgstr = msgstr + errorstr;
		  alert(msgstr);		
		  $('#'+fcs_fld[0]+'').focus();$('#'+fcs_fld[0]+'').select();
		  return false;
		}
	    else
	    {		  
		  $('#ProductTotalimg').val(imgcnt);
		  thisform.submit();
		  return true;
	    }	
}
</script>
<script>
/*for checking image extension*/
function getFileType(formobj,field) {
 var formElement = field;
 var filePath = field.value;
 var pathLength = filePath.length;
 var lastDot = filePath.lastIndexOf(".");
 var fileType = filePath.substring(lastDot,pathLength);
 return fileType;
 }
 
function inArray(array,val){
 for(var i = 0; i < array.length; i++)
 { 
  if(array[i] === val) return true; 
  } 
 return false; 
 } 
 
 
function checkImageType(path) 
{
 var filePath = path;
 var pathLength = filePath.length;
 var lastDot = filePath.lastIndexOf(".");
 var fileType = filePath.substring(lastDot,pathLength);
 return fileType;
 }		
 /*for checking image extension*/ 
 function setDiscountlbl(arg)	   
{
  var curncy='<?php echo $curlogo;?>';
  if(arg != '')
   {
	   $('#disc_div').show(); 	  
	   if(arg=='per')
	   $('#discount_lbl').html('Discount (%)');
	   else if(arg=='amnt')
	   $('#discount_lbl').html('Discount ('+curncy+')');
    }
   else
   $('#disc_div').hide(); 	   
}	
</script>

<div align="center" class="subheading">
              <div align="left">Products</div>
            </div>
            <br />
			<?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>
			
            <div align="left" id="item_details_admin">
              <!--items display area start -->
              <div align="center" id="items_display_area_admin">
                <div align="left" class="inner_content_area_admin">
				
				
                  <!--form area start -->
			<?php echo $form->create('Product', array('name' =>'Product','type' => 'file')); ?>
                  <div id="admin_heading">Edit Product</div>
				  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Category  <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php 
									echo $form->input('category_id', array('type'=>'select', 'options'=>$tree->indentTree($categoriesList),'label' => '','class' => 'box2_admin',"OnChange"=>"javascript:checkSubcat(this.value)"));
									?>	
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Name  <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('pname', array('label' => '','class' => 'box2_admin')); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="grid_admin" class="stock_div" style="display:none;">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Stock  <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('stock', array('label' => '','class' => 'box2_admin')); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="grid_admin" class="reorder_div" style="display:none;">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Reorder Level  <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('reorderlevel', array('label' => '','class' => 'box2_admin')); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  <!--
						      <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">SKU No<span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('skuno', array('label' => '','class' => 'box2_admin')); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  -->
						  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Image </p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									   <div id="prod_img" class="maintext_inner">
										   <?php if($primcnt < $cnfg["product_images"]) { ?>
											<label>Add More<a href="#" onClick="javascript:return addMoreImage();">
											<?php echo $html->image("/img/add.gif", array("border" => "0", "valign" => "top"));?>
											</a></label><br>
											<?php } ?>
											<?php
                                                                                        if(!empty($imgarr)){
											 for($i=0;$i<count($imgarr);$i++)
											{
											  ?>
											     <input type="file" name="data[Product][pdctimg<?php echo $i;?>]"  id="pimage<?php echo $i;?>" size="5">
											     &nbsp; &nbsp;Set as Default Image
											      <input type="radio" name="dfltimg"  value="<?php echo $i;?>" <?php if($imgarr[$i]["Productimages"]["default_img"]=='Y') print "checked=checked"; ?> onclick="javascript:$('#ProductDefaultimg').val(this.value);">
												



												  
												  <?php											 								 
											      $img = explode(".",$imgarr[$i]['Productimages']["imagename"]);
											      $ext='.'.end(explode(".",$imgarr[$i]['Productimages']["imagename"]));
											     ?>
												 <?php if($img[0] <> '') { ?>
												   &nbsp; &nbsp;/&nbsp; &nbsp;
										         <u><a href='<?php echo $cnfg["sitebasefolder"];?>/img/products/<?php echo $img[0].'_thumb'.$ext;?>' class="preview" onclick="return false;">View</a></u>												 
											    <?php } ?>												  
												 &nbsp; &nbsp; 
												  <?php if($img[0] <> '') { ?>/&nbsp; &nbsp;
												  <u><?php echo $html->link('Delete',"/products/deleteimage/".$productdet["Product"]["id"]."/".$productdet["Product"]["category_id"]."/".$imgarr[$i]['Productimages']["id"]."/pdct",null,'Are you sure to delete this Image.'); ?></u>
												  <?php } ?>
											      <br>
											      <input type="hidden" name="data[Product][imageid][]" value="<?php echo $imgarr[$i]['Productimages']["id"] ;?>">
											<?php }
                                                                                        }
                                                                                        ?>
											</div>
											<div class="maintext_inner"><font color="#FF0000">Note: Upload Images of size greater than 200 x 200 pixels.</font></div>
											<div class="maintext_inner">&nbsp;</div>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
				<?php if($productdet["Product"]["combination"]  == 'Y') { ?>
						  
						<?php
                                                //echo 'Hello'.$totcnt;
						if($totcnt>0)
							{
							for($cnt=0;$cnt<$totcnt;$cnt++)
							{?>  						   
						  <div id="grid_admin" class="reorder1_div" >
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner"></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									
									
										
											<div class="maintext_inner">
													<?php
													$i=0;
                                                                                                        
                                                                                                       //print '<pre />';print_r($selected_cfieldvalues);
													foreach($selected_cfieldvalues as $key => $val)
													{
                                                                                                            
													?>
													<div id="row<?php echo $key;?>" style="width:70px;float:left"><?php echo ucwords($selected_cfieldnames[$i]);?></div>
													<div>
													<select name="<?php echo "data[Product][attributes$cnt][]"?>" class="box2_admin">
													<option value="">--------------- Select --------------</option>
													<?php
													  foreach($val as $key1 => $val2)	 
													{ 
													?>
													<option  value="<?php echo $key1;?>" <?php if(in_array($key1,$edit_combn["Combndetail$cnt"])) print "selected"; ?>>
													<?php echo $val2;?>
													</option>			   
													<?php 
													}  ?>
													</select>
													</div><br />
													<?php $i++; } ?>
													
													<div class="stock_div">	<div style="width:70px;float:left">Stock</div>
                                                                                                            <div><input type="text" name="data[Product][stock<?php echo $cnt;?>]" value="<?php echo $edit_stock[$cnt];?>" class="box2_admin"></div><br />	</div>
														
														 <div class="reorder_div"><div style="width:70px;float:left">Reorder Level</div>
                                                                                                                     <div><input type="text" name="data[Product][reorderlevel<?php echo $cnt;?>]" value="<?php echo $edit_reorderlevel[$cnt];?>" class="box2_admin"></div><br /></div>
													
													   <div style="width:70px;float:left">Skuno</div>
														<div><input type="text" name="data[Product][skuno<?php echo $cnt;?>]" value="<?php echo $edit_skuno[$cnt];?>" class="box2_admin"></div><br />
													  
													    <div style="width:70px;float:left">Extra Price</div>
													   <div><input type="text" name="data[Product][extraprice<?php echo $cnt;?>]" value="<?php echo $edit_extraprice[$cnt];?>" class="box2_admin"></div><br />								
													  													
														<div style="width:70px;float:left">Image</div>
														<div><input type="file" name="data[Product][pdctfile<?php echo $cnt;?>]" size="5">
                                                                                                                 <br />
														 <?php	
                                                                                                                // print '<pre />';print_r($edit_pdctfile);
														 $editimage=explode('=',$edit_pdctfile[$cnt]);
                                                                                                                  
														 $img	= explode(".",$editimage[1]);
														 $ext	= '.'.end(explode(".",$edit_pdctfile[$cnt]));
														 if(isset($img[0]) && !empty($img[0])) { ?>														
													<u><a href='<?php echo $cnfg["sitebasefolder"];?>/img/products/<?php echo $img[0]."_thumb".$ext;?>' class="preview" onclick="return false;">View</a></u>
											        &nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;<u><?php echo $html->link('Delete',"/products/deleteimage/".$productdet["Product"]["id"]."/".$productdet["Product"]["category_id"]."/".$editimage[0]."/cmbn",null,'Are you sure to delete this Image.'); ?></u>
													<?php } ?>
														</div><br />
														
										
										</div>
										   <input type="button" onclick="return deleteProdcombn('<?php echo $catid;?>','<?php echo $prodid;?>','<?php echo $edit_id[$cnt];?>');" id="addmore>" value="Delete Combination" />
										<input type="hidden" name="data[Product][combn_cnt][]" id="combn_cnt<?php echo $cnt;?>" value="<?php echo $cnt;?>-><?php echo $edit_id[$cnt];?>"/>
										<div>&nbsp;</div>

								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  <?php } } ?>
						  
						  
						  <!-- Displaying An Extra Add Box here --> 
						  
						  <div id="grid_admin" class="attributes<?php echo ($totcnt);?>">
							<div align="left" id="inner_leftcontent" >
							  <p class="maintext_inner"></p>
							</div>
                                                      <?php if(count($selected_cfieldvalues[1])!=$cnt) { ?>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">																			
																					
											<?php
											if(!isset($cnt)) $cnt=0;
											 if(isset($selected_cfieldvalues) && !empty($selected_cfieldvalues))
											{?>
												<!--<div class="maintext_inner">
														<?php
														$i=0;
														foreach($selected_cfieldvalues as $key => $val)
														{
														?>
														<div id="row<?php echo $key;?>" style="width:70px;float:left"><?php echo ucwords($selected_cfieldnames[$i]);?></div>
														<div>
														<select name="<?php echo  "data[Product][attributes$cnt][]"?>" class="box2_admin">
														<option value="">--------------- Select --------------</option>
														<?php  foreach($val as $key1 => $val2)
														{ 
														?>
														<option  value="<?php echo $key1;?>">
														<?php echo $val2;?>
														</option>			   
														<?php
														}  ?>
														</select>
														</div><br /> 
														<?php $i++; } ?>
															 <div class="stock_div"><div style="width:70px;float:left">Stocks</div>
                                                                                                                             <div><input type="text" name="data[Product][stock<?php echo $cnt;?>]" class="box2_admin"></div><br /></div>
															<div class="reorder_div"><div style="width:70px;float:left">Reorder Level</div>
                                                                                                                            <div><input type="text" name="data[Product][reorderlevel<?php echo $cnt;?>]"  class="box2_admin"></div><br /></div>
															<div style="width:70px;float:left">Skuno</div>
															<div><input type="text" name="data[Product][skuno<?php echo $cnt;?>]"  class="box2_admin"></div><br />
															<div style="width:70px;float:left">Extra Price</div>
															<div><input type="text" name="data[Product][extraprice<?php echo $cnt;?>]"  class="box2_admin"></div><br />
														   <div style="width:70px;float:left">Image</div>
															<div><input type="file" name="data[Product][pdctfile<?php echo $cnt;?>]" size="20" ></div><br />
														 
											</div>-->
											   <input type="hidden" name="data[Product][combn_cnt][]" id="combn_cnt<?php echo $cnt;?>" value="<?php echo $cnt;?>"/>
											   <input type="button"  onclick="return delRow('<?php echo $cnt;?>');" id="delrow1<?php echo $cnt;?>" style="display:none;" value="Remove Combination"> 
											   <input type="button" onclick="return addMore1();" id="addmore<?php echo $cnt;?>" value="Add More Combination"> 
											<?php } ?>
										<div>&nbsp;</div>										
								</span>							
							</div>
                                                      <?php } ?>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						
						<!-- Displaying An Extra Add Box Ends here -->  
						  
						  
						<?php } ?>  <!-- End of if for checking combination==y -->  
						  
						  
						  
						  <div id="grid_admin" class="new_attributes">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Description</p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('descr', array('rows' => '3','label' => '', 'class' => 'box2_admin', 'value' => $productdet["Product"]["descr"])); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  <!--
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product price  <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('price', array('label' => '', 'class' => 'box2_admin', 'value' => $productdet["Product"]["price"])); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div> -->
						  
						   <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Wholesale price (<?php echo $curlogo; ?>)</p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('wholesale_price', array('label' => '','class' => 'box2_admin')); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Retail price (<?php echo $curlogo; ?>)  <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('price', array('label' => '','class' => 'box2_admin')); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  
						   <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Discount Type</p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input("discount_type", array("options" => array(""=>"-------------- Select ----------------","amnt"=>"Dollar","per"=>"Percentage"),"label" => "",'class' => 'box2_admin',"OnChange"=>"return setDiscountlbl(this.value);", 
	"selected" => $productdet['Product']['discount_type'])); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						   
						   <div style="display:none;" id="disc_div"> 
						  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner" id="discount_lbl">Discount (<?php echo $curlogo;?>)<span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('discount', array('label' => '','class' => 'box2_admin', 'value' => $productdet["Product"]["discount"])); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  </div>
						  
						  
						  
				  <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Type</p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input("prodtype", 
									array("options" => array("Non-Digital"=>"Physical","Digital"=>"Digital"),
									"label" => "",'class' => 'box2_admin',"OnChange"=>"javascript:chkdigit(this.value);"));?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  
						  
						  <div id="digit" style="display:none;">
						   <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product File <span class="required_field">*</span></p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('pdctfile', array('type' => 'file','label' => "",'class' => 'box2_admin')); ?>
								</span>
                                                                <?php if($productdet["Product"]["pdctfile"]!='') { ?>
                                                                  <br />
                                                                <b ><?php echo $productdet["Product"]["pdctfile"]; ?></b>
                                                                <br />
                                                                 <br />
                                                              
                                                                <?php } ?>
								we support files with the following extentions only. <font color="#FF0000">jpg,pjpeg,jpeg,png,gif,zip,pdf,rar,psd<br>opf,azw,lit,pdb,pkg,mp3,mpeg,mp4,and avi</font>					
								<p>
                                                                    <b>Max. File Upload Size : <?php echo $max_upload; ?> Mb</b>
                                                                </p>
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
						  </div>
						  
					
						  <div id="prodwght">
						   <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">Product Weight(lbs)</p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="toplinks">
									<?php echo $form->input('weight', array('label' => '','class' => 'box2_admin')); ?>
								</span>		
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
							 </div>
						  </div>
							</div>  
				  
				        <div id="grid_admin">
							<div align="left" id="inner_leftcontent">
							  <p class="maintext_inner">&nbsp;</p>
							</div>
							<div align="right" id="inner_rightcontent">
								<span class="maintext_inner">								
									 <?php echo $form->radio('Set as Featured Item', array('No', 'Yes'), array('default' => $productdet["Product"]["featured"])); ?>
								</span>							
							</div>
							<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						  </div>
				  								
								
								<div id="admin_bottom">
								<div align="left" id="inner_leftcontent">
								  <p class="maintext_inner">&nbsp;</p>
								</div>
								<div align="right" id="inner_rightcontent">
									<span class="toplinks">		
									<input type="submit" value="Update" class="buttn_admin" onclick="return validateFields(document.Product);">
									<input type="button" value="Cancel" class="buttn_admin" onClick="javascript:history.go(-1);">
									</span>
								</div>
								<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
								</div>
								
								<?php echo $form->input('hidcatid', array('type' => 'hidden','value' => $productdet["Product"]["category_id"])); ?>
								<?php echo $form->input('totalimg', array('type' => 'hidden','value' =>0)); ?>
								<?php echo $form->input('defaultimg', array('type' => 'hidden','value' =>0)); ?>

								
				 <?php echo $form->end(); ?> 
                  <!--form area end -->			  
				  
                </div>
                <!--form area end -->
              </div>
              <div align="left" class="float_clear1"></div>
            </div>
            <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
            <br /> <br /> 
			
	<script>
	$('#ProductStock').numeric({allow:"."});
	$('#ProductReorderlevel').numeric({allow:"."});
	$('#ProductWholesalePrice').numeric({allow:"."});
	$('#ProductPrice').numeric({allow:"."});
	$('#ProductDiscount').numeric({allow:"."});
	$('#ProductWeight').numeric({allow:"."});
	</script>