<?php
require_once('constants.php');
class Product
{
	public function __construct()
	{
		
		?>
        <script language="javascript" src="js/sub_index.js?t=<?=time();?>" type="text/javascript"></script>
      
 		<style>
			.report tr:hover{ background-color:#FFFF99;}
		</style><style>
#result {
	height:20px;
	font-size:16px;
	font-family:Arial, Helvetica, sans-serif;
	color:#333;
	padding:5px;
	margin-bottom:0px;
	background-color:#FFFF99;
}
#country{
	padding:3px;
	border:1px #CCC solid;
	font-size:17px;
}
.suggestionsBox {
	position: absolute;
	left: 0px;
	top: 0px;
	margin: 6px 0px 0px 0px;
	width: 200px;
	padding:0px;
	background-color: #000;
	border-top: 3px solid #000;
	color: #fff;
	z-index:999!important;
	
}
.suggestionList {
	margin: 0px;
	padding: 0px;
	z-index:3000 !important;
}
.suggestionList ul li {
	list-style:none;
	margin: 0px;
	padding: 6px;
	border-bottom:1px dotted #666;
	cursor: pointer;
	z-index:3000 !important;
}
.suggestionList ul li:hover {
	background-color: #FC3;
	color:#000;
}
ul {
	font-family:Arial, Helvetica, sans-serif;
	font-size:11px;
	color:#FFF;
	padding:0;
	margin:0;
	z-index:3000 !important;
}

.load{
background-image:url(loader.gif);
background-position:right;
background-repeat:no-repeat;
}

.suggest {
	position:relative;
	z-index:20;
}

</style>
        <?php
	}
	
	function common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other='')
	{
		if($matchField=="")
		 	$qry = "SELECT ".$fields." FROM $table";
		else 
			$qry = "SELECT ".$fields." FROM ".$table." WHERE ".$matchField."='".$code."' $other";
			
		 
		$res=mysql_query($qry);
		
		$out = '<select id="'.$id.'" name="'.$id.'" class="'.$class.'" '.$function.'>';
		$out .='<option value="" >--Select--</option>';
		
		while($result=mysql_fetch_array($res))
		{	
			if(strtolower($result[$value])==strtolower($sel))
				$out .='<option value="'.$result[$value].'" selected="selected">'.$result[$displayName].'</option>';
			else
				$out .='<option value="'.$result[$value].'" >'.$result[$displayName].'</option>';
		}
		$out .= '</select>';
		return $out;	
	}
			
	/*-------------------------------------------------------------------------------------KMS list----*/
	
		public function showProductList()
		{
		?>
		<script type="text/javascript" language="javascript">
			$(function() { $("#date_1").datepicker({dateFormat: 'yy-mm-dd'}); });
			$(function() { $("#date_2").datepicker({dateFormat: 'yy-mm-dd'}); });		
			$(function() { $("#date").datepicker({dateFormat: 'yy-mm-dd'}); });		
		</script>
		<style>
		.light{ color:#FF9900; font-size:12px;}
		.numaric{ width:100px!important;}
		</style>
		<div style="clear:both;"></div>
		
				<div class="atstextfield-wrapper">	
					<div class="textfieldtab">
					  <h92>Our Product (for Sale)</h92>
					</div>
					<div class="textfieldtab">
					</div> 
					<input type="hidden" id="ref_id" value="<?=$_REQUEST['ref_id'];?>"  />
					<?php $_SESSION['customer_ref_id'] = $_REQUEST['ref_id'];?>
					<div  class="textfieldtab">Search: 
						<input type="text" id="searchtext" />
					</div>
                    <div class="textfieldtab" >Status : 
						<select id="s_status" name="s_status">
                        	<option value="">-All-</option>
                            <option value="0"> Inactive </option>
                            <option value="1"> Active </option>
                       </select>     
					</div>
                    <div class="textfieldtab" >Stock : 
						<select id="s_stock" name="s_stock">
                        	<option value="">-All-</option>
                            <option value="0"> Not in Stock </option>
                            <option value="1"> IN Stock </option>
                            <option value="2"> Sold Out</option>
                       </select>     
					</div>
                    <div  class="textfieldtab">Style : 
						<?php 
							$table = "product_style_master";	//$table = name of table
							$fields = "*";//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "";			//$class = css classs 
							$sel = $data['s_product_style_code'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "s_product_style_code";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							
							
							echo $this->common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value); ?>
                            
					</div>
                     <div class="textfieldtab">
                  All Records
                    <input name="s_all_records" id="s_all_records" type="checkbox"   value="1" />
</div>
					<div class="textfieldtab">
						<input name="" type="image" src="../../main_images/search_btt1.png" onclick="ProductDetails()" />
					</div>
				</div>    
				<div style="clear:both;"></div>
				<div id="main_result_div">
				<script language="javascript" type="text/javascript">ProductDetails(1);</script>
				</div>
		
		
		<?php
		}
	
	//Add 
		public function add_edit($data='',$error="")
		{
			
			$data['id'] = $data['product_id'];
			
			if($data['supplier_invoice_date']=='' or $data['supplier_invoice_date']=='0000-00-00')
				$data['supplier_invoice_date'] = date("d-m-Y");
			else	
				$data['supplier_invoice_date'] = date("d-m-Y",strtotime($data['supplier_invoice_date']));
			
				
		?>
            <div id="add_edit">
               <form  name="add_edit_form" id="add_edit_form" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' >
              	<div id="add_edit">
                <?php if($data['id']>0) { ?>
                	<input type="hidden" name="task2" id="task2" value="update"  />
                    <input type="hidden" name="id" id="id" value="<?=$data['id'];?>"  />
                   <?php }else{ ?>
                   <input type="hidden"  name="task2" id="task2" value="Add"  />
                   <input type="hidden" name="id" id="id" value=""  />
                   <?php } ?>
                   
                </div>
                <table id="" cellspacing="0" style="border-top:10px solid #777;">
    		    <tr>
                   	<th colspan="4"><?php if($data['id']>0) echo 'Edit Product'; else echo 'Add New Product'; ?></th>
                </tr>
                
                <tr>
                  <td >Supplier Name</td>
                  <td colspan="3"><?php $supplier = fetch_details('supplier_master','code',$data['supplier_code']); ?>
      
     <?php $name='supplier';?><input type="text" id="<?=$name;?>"  <?=$disabled;?> name="<?=$name;?>" value="<?=$supplier['name'];?>" style="width:500px;" maxlength="240" class="mandatory"  onkeyup="suggest(this.value);" onblur="fill_supplier('');"   />
                    <div id="suggest" class="suggest">
      <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
        <div class="suggestionList" id="suggestionsList"> &nbsp; </div>
      </div>
   </div>
   
					
      <?php $name='supplier_code';?><input id="<?=$name;?>"  <?=$disabled;?> name="<?=$name;?>" type="hidden" value="<?=$data[$name];?>"  /></td>
                </tr>
                
                <tr>
                   	<td >Have Supplier Invoice number :</td>
                     <td colspan="3"><?php $name='supplier_have_supplier_invoice_no';?><select onchange="supplier_have_supplier_invoice_nof()" id="<?=$name;?>" name="<?=$name;?>"   class="mandatory" />
                     <option value=""> - </option>
                     <option value="1" <?=($data[$name]==1)?'selected="selected"':'';?>> Yes </option>
                      <option value="0" <?=($data[$name]=='0')?'selected="selected"':'';?>> No </option>
                      </select>
                     </td>
                  </tr>
                  
                 <tr style="display:<?=($data['supplier_have_supplier_invoice_no']==1)?'':'none';?>;" class="invoice_sel">
                   	<td >Supplier Invoice Number :</td>
                     <td colspan="3"><?php $name='supplier_invoice_no';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="<?=($data['supplier_have_supplier_invoice_no']==1)?'mandatory':'';?>" /></td>
                  </tr>  
                  
                  <tr style="display:<?=($data['supplier_have_supplier_invoice_no']==1)?'':'none';?>;" class="invoice_sel">
                   	<td >Supplier Invoice Date :</td>
                     <td colspan="3"><?php $name='supplier_invoice_date';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"    maxlength="140" class="<?=($data['supplier_have_supplier_invoice_no']==1)?'mandatory':'';?> date_textbox" /></td>
                  </tr> 
                  
                  
                   <tr>
                   	<td >Supplier Product Code :</td>
                     <td colspan="3"><?php $name='supplier_product_code';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140"  /></td>
                  </tr> 
                  
                  <tr>
                   	<td > </td>
                     <td colspan="3"> </td>
                  </tr> 
                <tr>
                   	<td  style="border-top:2px solid #666666;">Product Code/SKU :</td>
                     <td colspan="3" style="border-top:2px solid #666666;"><?php $name='product_ccode';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="" /></td>
                  </tr>
                   <tr>
                   	<td >Certificate Number  :</td>
                     <td colspan="3"><?php $name='certificate_number';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="" /></td>
                  </tr>
                   <tr>
                   	<td >Product Style :</td>
                     <td colspan="3">
					 
					 <?php $product_style = fetch_details('product_style_master','code',$data['product_style_code']); ?>
					 <?php $name='product_style_code';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$product_style['name'];?>" style="width:200px;"  <?=$disabled;?> maxlength="240" class="mandatory"  onkeyup="suggest_v(this.value);" onblur="fill_v('');"   />
                    <div id="suggest_v" class="suggest">
      <div class="suggestionsBox" id="suggestions_v"  style="display: none;"> <img src="arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
        <div class="suggestionList" id="suggestionsList_v"> &nbsp; </div>
        
        
					 <?php 
						//	$table = "product_style_master";	//$table = name of table
//							$fields = "*";//Fields = Fields of tables
//							$matchField = "";		//$matchField = matching fields
//							$code = "";				//$code = where $code
//							$class = "mandatory";			//$class = css classs 
//							$sel = $data['product_style_code'];				//$sel = selected fields
//							$function ="";			//$function = javascript function
//							$id = "product_style_code";		//$id = id of select
//							$displayName = "name";		//displayName = display name
//							$value ="code";  			// $value = value of Select
//							
//							
//							echo $this->common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value); ?></td>
                  </tr>
                  
                  <tr>
                   	<td width="169" >Product Name :</td>
                     <td colspan="3"><?php $name='product_name';?>
                     <input type="text" id="<?=$name;?>" name="<?=$name;?>" style="width:500px" value="<?=$data[$name];?>"  maxlength="255" class="mandatory" />					  </td>
                 <!--<tr>
                   	<td >Discount(%) :</td>
                    <td width="242"><?php $name='discount_percantage';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:100px;" maxlength="2" class="numaric" /></td>
                    <td width="169" style="text-align:right;" ></td>
                    <td width="472"  ></td>
                </tr>-->
                <tr>
                   	<td style="width:120px;">Category : <strong style="color:#f00;">*</strong> </td>
                    <td colspan="3" >
                    <?php 
				
						 
						$as = array();
						  $sq = "Select * from menu_category_codes where  product_code='".$data['id']."'  ";
						  $rr = mysql_query($sq);
						  while($ron = mysql_fetch_assoc($rr))
						  {
						  		$as[$ron['category']]  = $ron['category'];
						  }
						  
						   
						  
					  $sq = "Select * from menu_category where   is_deleted=0 order by name";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
						  if($as[$ron['code']]>0)
						  	$seelced_cat = $ron['code'];
							
				?>    <?php $name='menu_category['.$ron['code'].']';
						$name='menu_category';
				?>
                        <label style="width:24%; float:left; height:23px;"><!--<input type="checkbox" <?=($as[$ron['code']]>0)?'checked="checked"':'';?> id="menu_category_<?=$ron['code'];?>" name="<?=$name;?>" class="cat_size" value="<?=$ron['code'];?>" /> -->
                         <input type="radio" <?=($as[$ron['code']]>0)?'checked="checked"':'';?>  id="menu_category" name="<?=$name;?>" class="cat_size" value="<?=$ron['code'];?>" />
                        <?=($ron['name']);?> </label>&nbsp;&nbsp;&nbsp;
                       
						 

                        <?php  } ?>                 </td>
                </tr>
                 
                 
                 
                     
                 
                     
                  <tr>
                   	<th colspan="4"  >Diamond Details</th>
                     </tr>
                     
                     
                    <tr>
                   	<td valign="top" >Colour/Clarity : </td>
                    <td colspan="3"  style="background:url(diamond-education-cover-.jpg) #FFFFFF  center no-repeat;">
					 
					<?php 
				
						 
						$as = array();
					 $sq = "Select * from diamond_type_code where  product_code='".$data['id']."'  ";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
							$as[$ron['diamond_type_code']]  = $ron['diamond_type_code'];
					  }
						?>
                        
                         <table class="report" >
                     <tr>
                    	 
                        <th>Select</th>
                        <th>Title</th>
                     </tr>   
                     
                        <?php  
						   
						 
					  $sq = "Select * from diamond_type  where   is_deleted=0 order by sort_id";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
						  
				?>    
                		<tr>
                    	 
                        <td><?php $name='diamond_type_default';?><input type="radio" <?=($data['diamond_type_default']==$ron['code'])?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="<?=$ron['code'];?>" /></td>
                        <td><?=($ron['title']);?></td>
                     </tr>   
                        
						 

                        <?php  } ?> 
                       </table>                      </td>
                  </tr> 
                     
                    <tr>
                   	<td valign="top" >Diamond Total Weight :</td>
                     <td ><?php $name='diamond_total_weight';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="10" class="mandatory numaric" /> Ct</td>
                    
                 	<td style="text-align:right;">Total No. Of Diamonds : </td>
                     <td ><?php $name='diamond_total_no';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="mandatory numaric" /></td>
                  </tr> 
                    
                    
                
                     
                     
                     <tr> 
                     <td valign="top" >Shape : </td>
                     <td  ><?php $name='shape';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="mandatory" /></td>
                     
                     <td style="text-align:right;">Setting Type : </td>
                     <td  ><?php $name='setting_type';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="mandatory" /></td>
                     </tr> 
                     <tr>
                   	<th colspan="4"  >Gem Stons Details &nbsp;&nbsp;&nbsp;
                    
                    <?php $name='gems';?>
                        <input type="checkbox" <?=($data[$name]>0)?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="1"  />                    </th>
                     </tr>
                     
                     
                    <tr  class="gems_rows">
                   	<td valign="top" >Stone Details : </td>
                    <td colspan="3"  style="background:url(gems-cover-.jpg) #FFFFFF  center right no-repeat;">
					 
					<?php 
				
						 
					  $as = array();
					  $sq = "Select * from gems_type_code where  product_code='".$data['id']."'  ";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
							$as[$ron['gems_type_code']]  = $ron['gems_type_code'];
							$as['price_'.$ron['gems_type_code']]  = $ron['price'];
					  }
						?>
                        
                    
                    
                    
                    <table class="report" >
                     <tr>
                    	 
                        <th>Default</th>
                        <th>Title</th>
                        <th>Price</th>
                     </tr>   
                     
                        <?php  
						   
						 
					  $sq = "Select * from gems_type  where   is_deleted=0 order by sort_id";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
						  
				?>    
                		<tr>
                    	 
                    	 
                     <td><?php $name='gems_type_default';?><input type="radio" <?=($data['gems_type_default']==$ron['code'])?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" <?=($pro['gems_type_default']==$ron['code'])?'checked="checked"':'';?> value="<?=$ron['code'];?>" /></td>
                      
                     <td><?=($ron['title']);?></td>
                     <td>
                    <!-- <?php $name='gems_type_code_price['.$ron['code'].']';?>
                     <input type="text" id="gems_type_code_price_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$as['price_'.$ron['code']];?>"  maxlength="10"  class="numaric ggg<?=($ron['code']);?>" title="Gems Price for <?=($ron['name']);?>" style="width:40px !important;"/> Rs.      -->               </td>
                     </tr>   
                        
						 

                        <?php  } ?> 
                       </table>                      </td>
                  </tr> 
                     
                  <tr class="gems_rows">
                   	<td valign="top" >Gems Price :</td>
                     <td ><?php $name='gem_price';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="10" class="numaric gems" /> Rs</td>
                    
                 	<td style="text-align:right;"> </td>
                     <td > </td>
                  </tr> 
                    
                  
                  <tr class="gems_rows">
                   	<td valign="top" >Gems Size :</td>
                     <td ><?php $name='gems_size';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="10" class="mandatory numaric gems" /> mm</td>
                    
                 	<td style="text-align:right;">Total No. Of Gems : </td>
                     <td ><?php $name='gems_total_no';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="mandatory numaric gems" /></td>
                  </tr> 
                    
                  <tr class="gems_rows"> 
                     <td valign="top" >Gems Shape : </td>
                     <td  ><?php $name='gems_shape';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="mandatory gems" /></td>
                     
                     <td style="text-align:right;">Gems Setting Type : </td>
                     <td  ><?php $name='gems_setting_type';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="140" class="mandatory gems" /></td>
                     </tr>
                     <tr valign="top">
                   	<th colspan="4"  >Metal Details</th>
                    </tr>
                  <tr>
                  
                  <tr>
                   	<td valign="top" >Metal : </td>
                    <td colspan="3" style="background:url(gold-bullions.jpg) #FFFFFF  center no-repeat;">
					 
					<?php 
				
						 
					  $as = array();
					  $sq = "Select * from 	metal_type_code where  product_code='".$data['id']."'  ";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
							$as[$ron['metal_type_code']]  = $ron['metal_type_code'];
							$as['weight_'.$ron['metal_type_code']]  = $ron['weight'];
					  }
						  
					?>
                    <table class="report" >
                     <tr>
                    	 
                        <th>Default</th>
                        <th>Title</th>
                        <!--<th>Weight</th>-->
                     </tr>   
                    <?php	   
						 
					  $sq = "Select * from metal_type  where is_deleted=0 order by sort_id";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
						  
				?>    
                	 <tr>
                    	 
                        
                     <td><?php $name='metal_type_default';?><input type="radio" <?=($data['metal_type_default']==$ron['code'])?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="<?=$ron['code'];?>" /></td>
                     <td><?=($ron['name']);?></td>
                     <!--<td>
                     <?php $name='metal_type_code_w['.$ron['code'].']';?>
                     <input type="text" id="metal_type_code_w_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$as['weight_'.$ron['code']];?>"  maxlength="10"  class="numaric xxx<?=($ron['code']);?>" title="Metal Weight for <?=($ron['name']);?>" style="width:40px !important;"/> gm
                     </td>-->
                     </tr>
                        
						
						
                        
                         
                       
						 

                        <?php  } ?> 
                    </table>                     </td>
                </tr>
                
                <tr>
                   	<td valign="top" >Metal Total Weight :</td>
                     <td colspan="3"><?php $name='metal_weight';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="10" class="mandatory numaric" /> gm</td>
                  </tr> 
                <HR/>
                
                       
                <tr>
                   	<td valign="top" >Making Charges :</td>
                     <td colspan="3"><?php $name='making_charges';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="10" class="mandatory numaric" /> Rs.</td>
                  </tr>      
                 
                 
                 <tr >
                   	<td valign="top" style="border:1px solid #666666;">Product Size :</td>
                     <td colspan="3" style="border:1px solid #666666;" id="size_display"><?php $name='product_size_default';?>
                     
                     <?php $this->size_display($data['product_id'],$seelced_cat)?>
					 
					  </td>
                 </tr>    
                  <tr >
                   	<td valign="top" style="border:1px solid #666666;">Total item Weight :</td>
                     <td colspan="3" style="border:1px solid #666666;"><?php $name='total_item_weight';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>"  maxlength="10" class="mandatory numaric" /> gm</td>
                 </tr> 
                  
                <tr>
                   	<td valign="top" >Product Description :</td>
                    <td colspan="3"><?php $name='description';?><textarea class="mceEditor" id="<?=$name;?>" name="<?=$name;?>"  style="width:700px; height:100px;" ><?=$data[$name];?></textarea>                    </td>
                </tr>
                
                
                <tr>
                   	<td >Metal Discount(%) :</td>
                    <td width="242"><?php $name='metal_discount_percentage';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:100px;" maxlength="2" class="numaric" /></td>
                    <td width="169" style="text-align:right;" ></td>
                    <td width="472"  ></td>
                </tr>
                
                <tr>
                   	<td >Diamond Discount(%) :</td>
                    <td width="242"><?php $name='diamond_discount_percentage';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:100px;" maxlength="2" class="numaric" /></td>
                    <td width="169" style="text-align:right;" ></td>
                    <td width="472"  ></td>
                </tr>
                
                <tr>
                   	<td >Stone Discount(%) :</td>
                    <td width="242"><?php $name='stone_discount_percentage';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:100px;" maxlength="2" class="numaric" /></td>
                    <td width="169" style="text-align:right;" ></td>
                    <td width="472"  ></td>
                </tr>
                
                <tr>
                   	<td >Making Charges Discount(%) :</td>
                    <td width="242"><?php $name='making_charges_discount_percentage';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:100px;" maxlength="2" class="numaric" /></td>
                    <td width="169" style="text-align:right;" ></td>
                    <td width="472"  ></td>
                </tr>
             
                
                <tr>
                   	<td valign="top" >Meta Description(SEO) :</td>
                    <td colspan="3"><?php $name='meta_description';?><textarea id="<?=$name;?>" name="<?=$name;?>"  style="width:700px; height:30px;" ><?=$data[$name];?></textarea></td>
                </tr>
                
                
                <tr>
                   	<td valign="top" >Keywords(SEO) :</td>
                    <td colspan="3"><?php $name='keywords';?><textarea id="<?=$name;?>" name="<?=$name;?>"  style="width:700px; height:30px;" ><?=$data[$name];?></textarea></td>
                </tr>
                
                
                
                <?php if($data['id']>0){ ?>
                   <tr>
                   	<td style="vertical-align:top;" >Pictures </td>
                     <td colspan="3" id="comparison_block">ssssssssssss</td>
                   </tr>
                 
                 <tr>
                   	<td style="vertical-align:top;" > </td>
                     <td colspan="3" ><a href="<?=SITE_PATH;?>product&id=<?=$data['product_id'];?>" style="background:#F60; padding:6px; font-size:1.3em; color:#FFF; text-decoration:none; " target="_blank"> View Preview</a></td>
                   </tr>
                 
                 
                  <?php } ?>
                  
                  
                
                  <tr>
                   	<td valign="top" ></td>
                    <td colspan="3"><?php $name='free_shipping';?>
                          <label><input type="checkbox" <?=($data[$name]==1)?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="1" /> Free Shipping?</label>&nbsp;&nbsp;&nbsp; <?php $name='is_stock';?>
                         <label><input type="checkbox" <?=($data[$name]==1)?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="1" /> In Stock?</label>&nbsp;&nbsp;&nbsp; 
						 
						 <?php $name='is_featured_product';?>
                         <label><input type="checkbox" <?=($data[$name]==1)?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="1" /> Featured Product?</label>&nbsp;&nbsp;&nbsp; <?php $name='is_new';?>
                         <label><input type="checkbox" <?=($data[$name]==1)?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="1" /> In New Product?</label></td>
                </tr>
                
                  
                <tr>
                   	<td >Show Product/Status</td>
                     <td colspan="3">
					 	<?php $name='status';?>
                     	<?php 
							
								$displayName = 'name';
								$table='select_yn';
								$fields='*';
								$id = $name;
								$sel=$data[$name];
								$function = ' style="width:100px;"';
$value='code';
								echo common_select($table,$fields,$matchField,$code,$class='mandatory',$sel,$function,$id,$displayName,$value,$other=''); ?>                         </td>
                </tr>
                <?php if($data['id']<=0) { ?>
                <?php } ?>
                  
                <tr style="padding: 10px;">
                	<td></td>
                    <td colspan="3"><span id="res" class="sucess_2"><?=$error;?></span></td>
                </tr>
                <tr style="padding: 10px;">
                	<td style="width:120px;">&nbsp;</td>
                    <td colspan="3">Please Make sure you clicked on uplaod Picture before save it....<br />
                    	<?php if($data['product_sold_out']==0){ ?>
                        
                        <button type="button" id="btnInsertPro" name="btnInsertPro" onClick="addNew_Key()"><?php if($data['id']>0) echo 'Update Record'; else echo 'Submit'; ?></button>&nbsp;&nbsp;&nbsp;&nbsp;<?php }?><button type="button" id="as" name="as" onclick="ProductDetails(<?=$_SESSION['page'];?>)" >Go Back</button>                          </td>
                </tr>
            </table>
		</form>
        </div>
        
        </div>
        <?php
	}
		public function size_display($id,$cat='')
		{
			 			$sql = "select * from product where product_id = '".$id."'";
						$rr = mysql_query($sql);
						$pro = mysql_fetch_assoc($rr);
						
						 
						 
					  $as = array();
					  $sq = "Select * from 	product_size_master_code where  product_code='".$id."'  ";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
							$as[$ron['product_size_master_code']]  = $ron['product_size_master_code'];
							$as['weight_'.$ron['product_size_master_code']]  = $ron['weight'];
							$as['height_'.$ron['product_size_master_code']]  = $ron['height'];
							$as['width_'.$ron['product_size_master_code']]  = $ron['width'];
							
							$as['making_charges_'.$ron['product_size_master_code']]  = $ron['making_charges'];
							
					  }
						  
					?>
                    <table class="report" >
                     <tr>
                    	<th style="visibility:hidden;"></th>
                        <th>Default</th>
                        <th>Title(Internal)</th>
                        <th>Title</th>
                        <!--<th>Height</th>
                        <th>Width</th>                        
                        <th>Weight</th>
                        <th>Making Charges</th>-->
                        
                     </tr>   
                    <?php	   
						 
					  $sq = "Select m.* from product_size_master m where code IN (select size_code from menu_category_size_codes c where   c.category IN (".$cat.") )  order by sort_id";
					  $rr = mysql_query($sq);
					  while($ron = mysql_fetch_assoc($rr))
					  {
						  
				?>    
                	 <tr>
                    	<td style="visibility:hidden;"><?php $name='product_size_code['.$ron['code'].']';?>
                        <input readonly="readonly" type="checkbox" <?=($as[$ron['code']]>0)?'checked="checked"':'';?> id="product_size_code_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$ron['code'];?>" class="product_size_code ccc<?=$ron['code']?>" /></td>
                        
                     <td><?php $name='product_size_default';?><input type="radio" <?=($data['product_size_default']==$ron['code'])?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" <?=($pro['product_size_default']==$ron['code'])?'checked="checked"':'';?> value="<?=$ron['code'];?>" /></td>
                     <td><?=($ron['title_internal']);?></td>
                     <td><?=($ron['title']);?></td>
                    <!-- <td>
                     <?php $name='product_size_code_height['.$ron['code'].']';?>
                     <input type="text" id="product_size_code_height_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$as['height_'.$ron['code']];?>"  maxlength="10"  class="numaric yyy<?=($ron['code']);?>" title="Metal Height for <?=($ron['name']);?>" style="width:40px !important;"/> mm
                     </td>
                     
                     <td>
                     <?php $name='product_size_code_width['.$ron['code'].']';?>
                     <input type="text" id="product_size_code_width_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$as['width_'.$ron['code']];?>"  maxlength="10"  class="numaric yyy<?=($ron['code']);?>" title="Metal Width for <?=($ron['name']);?>" style="width:40px !important;"/> mm
                     </td>
                     
                     <td>
                     <?php $name='product_size_code_weight['.$ron['code'].']';?>
                     <input type="text" id="metal_type_code_w_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$as['weight_'.$ron['code']];?>"  maxlength="10"  class="numaric yyy<?=($ron['code']);?>" title="Metal Weight for <?=($ron['name']);?>" style="width:40px !important;"/> gm
                     </td>
                     
                     <td>
                     <?php $name='product_size_code_making_charges['.$ron['code'].']';?>
                     <input type="text" id="metal_type_code_w_<?=$ron['code'];?>" name="<?=$name;?>" value="<?=$as['making_charges_'.$ron['code']];?>"  maxlength="10"  class="numaric yyy<?=($ron['code']);?>" title="Metal Making Charges for <?=($ron['name']);?>" style="width:40px !important;"/> Rs
                     </td>-->
                     
                     
                     
                     
                     
                     </tr>
                        
						
						
                        
                         
                       
						 

                        <?php  } ?> 
                        
                        
                    </table>   
                    <?php 
		}
		public function add_edit2($data='',$error="")
		{
			 
			$data['id'] = $data['code'];
			
			
				
		?>
            <div id="add_edit" class="convert_tables">
                   <form  name="add_edit_form2" id="add_edit_form2" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' >

              	 
                <?php if($data['id']>0) { ?>
                	<input type="hidden" name="task22" id="task22" value="update"  />
                    <input type="hidden" name="id22" id="id22" value="<?=$data['id'];?>"  />
                   <?php }else{ ?>
                   <input type="hidden"  name="task22" id="task22" value="Add"  />
                   <input type="hidden" name="id22" id="id22" value=""  />
                   <?php } ?>
                    
                
              	<table width="565" cellspacing="0" id="table2" style="border:3px solid #00F;">
              	    <tr>
              	      <th colspan="2"><?php if($data['id']>0) echo 'Edit Picture'; else echo 'Add Picture'; ?></th>
           	        </tr>
              	    <tr>
              	      <td >Title :</td>
              	      <td colspan="3"><?php $name='title_picture';?>
              	        <textarea id="<?=$name;?>" name="<?=$name;?>" class="mandatory"   style="width:500px; height:20px;" ><?=$data[$name];?></textarea></td>
           	        </tr>
              	    <tr>
              	      <td >Alternate Text :</td>
              	      <td colspan="3"><?php $name='alternate_text';?>
              	        <textarea id="<?=$name;?>" name="<?=$name;?>" class="mandatory"   style="width:500px; height:20px;" ><?=$data[$name];?></textarea></td>
           	        </tr>
              	    <tr>
              	      <td valign="top" >Picture :</td>
              	      <td><input type="hidden" id="file_format_accept" name="file_format_accept" value='jpg,png,gif,bmp'  />
              	        <input type="file" name="photoimg" id="photoimg" />
              	        <input type="button" id="upload_pic2" value="Upload"  />
              	        <br />
              	        &nbsp;&nbsp;Recommended Size = 800px X 800px
              	        <div id='preview2' >
              	          <?php if($data['pic_name']<>"")

{
				?>
                <a href="../../../product_images/<?=$data['pic_name'];?>" target="_blank"><?php
				echo "<img src='../../../product_images/sub_".$data['pic_name']."' width='160px' >";
                ?></a><?php

}

?>
           	            </div></td>
           	        </tr>
              	    <tr>
              	      <td >Website </td>
              	      <td width="371"><?php $name='is_main';?>
              	        <label>
              	          <input type="checkbox" <?=($data[$name]==1)?'checked="checked"':'';?> id="<?=$name;?>" name="<?=$name;?>" value="1" />
              	          Is Main image?</label>
              	         
              	        &nbsp;&nbsp;|&nbsp;&nbsp;
              	        Sort id
              	        <?php $name='sort_website';?>
              	        <input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:30px;" maxlength="10" class="numaric" /></td>
           	        </tr>
              	    <tr></tr>
              	    <tr style="padding: 10px;">
              	      <td></td>
              	      <td><span id="res2" class="sucess_2">
              	        <?=$error;?>
            	        </span></td>
           	        </tr>
              	    <tr style="padding: 10px;">
              	      <td style="width:120px;">&nbsp;</td>
              	      <td>Please Make sure you clicked on uplaod Picture before save it....<br />
              	        <button type="button" id="btnInsertPro2" name="btnInsertPro" onclick="addNew_Key2()">
              	          <?php if($data['id']>0) echo 'Update Record'; else echo 'Submit'; ?>
           	            </button>
              	        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              	        <button type="button" id="as2" name="as" onclick="close_fancy()" >Go Back</button></td>
           	        </tr>
           	      </table>
              </form>
        </div>
        
        </div>
        <?php
	}
		
		public function add_edit3($data='',$error="")
		{
			 
			$data['id'] = $data['code'];
			
			
				
		?>
            <div id="add_edit">
                   <form  name="add_edit_form" id="add_edit_form" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' >

              	<div id="add_edit">
                <?php if($data['id']>0) { ?>
                	<input type="hidden" name="task2" id="task2" value="update"  />
                    <input type="hidden" name="id" id="id" value="<?=$data['id'];?>"  />
                   <?php }else{ ?>
                   <input type="hidden"  name="task2" id="task2" value="Add"  />
                   <input type="hidden" name="id" id="id" value=""  />
                   <?php } ?>
                   <input type="hidden" name="pcode" id="pcode" value="<?=$_SESSION['pcode'] ;?>"  />
                </div>
                <table width="100%" cellspacing="0" id="" style="border-top:10px solid #777;">
    		    <tr>
                   	<th colspan="2"><?php if($data['id']>0) echo 'Edit Product Extra Values'; else echo 'Add Product Extra Values'; ?></th>
                </tr>
                
                
                <tr>
                   	<td >Extra Title :</td>
                     <td colspan="3"><?php $name='title';?><textarea id="<?=$name;?>" name="<?=$name;?>" class="mandatory"   style="width:500px; height:20px;" ><?=$data[$name];?></textarea></td>                
                </tr>  
                
                 
                <tr>
                   	<td >Extra Description :</td>
                     <td colspan="3"><?php $name='description';?><textarea id="<?=$name;?>" name="<?=$name;?>" class="mandatory"   style="width:500px; height:20px;" ><?=$data[$name];?></textarea></td>                
                </tr>
                   
                 
                <tr style="padding: 10px;">
                	<td></td>
                    <td><span id="res" class="sucess_2"><?=$error;?></span></td>
                </tr>
                <tr style="padding: 10px;">
                	<td style="width:120px;">&nbsp;</td>
                    <td> 
                    	<button type="button" id="btnInsertPro" name="btnInsertPro" onClick="addNew_Key3()"><?php if($data['id']>0) echo 'Update Record'; else echo 'Submit'; ?></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" id="as" name="as" onclick="Product_extraDetails(<?=$_SESSION['pcode'];?>)" >Go Back</button></td>
                </tr>
            </table>
		</form>
        </div>
        
        </div>
        <?php
	}
		 public function add_edit4($data='',$error="")
		{
			 
			$data['id'] = $data['code'];
			
			
				
		?>
            <div id="add_edit">
                   <form  name="add_edit_form" id="add_edit_form" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' >

              	<div id="add_edit">
                <?php if($data['id']>0) { ?>
                	<input type="hidden" name="task2" id="task2" value="update"  />
                    <input type="hidden" name="id" id="id" value="<?=$data['id'];?>"  />
                   <?php }else{ ?>
                   <input type="hidden"  name="task2" id="task2" value="Add"  />
                   <input type="hidden" name="id" id="id" value=""  />
                   <?php } ?>
                   <input type="hidden" name="pcode" id="pcode" value="<?=$_SESSION['pcode'] ;?>"  />
                </div>
                <table width="100%" cellspacing="0" id="" style="border-top:10px solid #777;">
    		    <tr>
                   	<th colspan="2"><?php if($data['id']>0) echo 'Edit Product Specification'; else echo 'Add Product Specification'; ?></th>
                </tr>
                 <tr>
                   	<td>Category : <strong style="color:#f00;">*</strong> </td>
                    <td colspan="3"><?=create_select('specification_category_id','category_name','specification_category','',$data['specification_category_id'],'',$code="specification_category_id","--All--","","","");?>
                 </td>
                
                <tr>
                   	<td >Specification :</td>
                     <td colspan="3" id="spc_list"><?php $name='title';?>
					 <?=create_select('specification','specification_title','specification','',$data['specification'],'mandatory',$code="code","--Select Specification --","","","",""," and is_deleted=0");?></td>                
                </tr>  
                
                 
                <tr>
                   	<td >Specification Value :</td>
                     <td colspan="3"><?php $name='specification_value';?><textarea id="<?=$name;?>" name="<?=$name;?>" class="mandatory"   style="width:500px; height:20px;" ><?=$data[$name];?></textarea></td>                
                </tr>  
                 
                <tr style="padding: 10px;">
                	<td></td>
                    <td><span id="res" class="sucess_2"><?=$error;?></span></td>
                </tr>
                <tr style="padding: 10px;">
                	<td style="width:120px;">&nbsp;</td>
                    <td> 
                    	<button type="button" id="btnInsertPro" name="btnInsertPro" onClick="addNew_Key4()"><?php if($data['id']>0) echo 'Update Record'; else echo 'Submit'; ?></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" id="as" name="as" onclick="Product_specificationDetails(<?=$_SESSION['pcode'];?>)" >Go Back</button></td>
                </tr>
            </table>
		</form>
        </div>
        
        </div>
        <?php
	}
	
	
	public function add_edit5($data='',$error="")
		{
			 
			$data['id'] = $data['code'];
			
			
				
		?>
            <div id="add_edit">
                   <form  name="add_edit_form" id="add_edit_form" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' >

              	<div id="add_edit">
                <?php if($data['id']>0) { ?>
                	<input type="hidden" name="task2" id="task2" value="update"  />
                    <input type="hidden" name="id" id="id" value="<?=$data['id'];?>"  />
                   <?php }else{ ?>
                   <input type="hidden"  name="task2" id="task2" value="Add"  />
                   <input type="hidden" name="id" id="id" value=""  />
                   <?php } ?>
                   <input type="hidden" name="pcode" id="pcode" value="<?=$_SESSION['pcode'] ;?>"  />
                </div>
                <table width="100%" cellspacing="0" id="" style="border-top:10px solid #777;">
    		    <tr>
                   	<th colspan="2"><?php if($data['id']>0) echo 'Edit Product Features'; else echo 'Add Product Features'; ?></th>
                </tr>
                
                
                <tr>
                   	<td >Specification :</td>
                     <td colspan="3"><?php $name='title';?>
					 <?=create_select('product_features','product_features_title','product_features','',$data['product_features'],'mandatory',$code="code","--Select Product Features --","","","",""," and is_deleted=0");?></td>                
                </tr>  
                
                 
                
                 
                <tr style="padding: 10px;">
                	<td></td>
                    <td><span id="res" class="sucess_2"><?=$error;?></span></td>
                </tr>
                <tr style="padding: 10px;">
                	<td style="width:120px;">&nbsp;</td>
                    <td> 
                    	<button type="button" id="btnInsertPro" name="btnInsertPro" onClick="addNew_Key5()"><?php if($data['id']>0) echo 'Update Record'; else echo 'Submit'; ?></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" id="as" name="as" onclick="Product_product_featuresDetails(<?=$_SESSION['pcode'];?>)" >Go Back</button></td>
                </tr>
            </table>
		</form>
        </div>
        
        </div>
        <?php
	}
}

?>
</div>
