	<script type="text/javascript" src="<?php echo $thisPage; ?>js/messages.js"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo $thisPage; ?>css/messages.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo $thisPage; ?>css/captcha.css" />
	
    <?php
	$idEvent = "ConfirmProduct";
	echo "<script>";
		echo "function validate(form) {";	
		$sql = "select designName from form_label, form_design where labelType='".$idEvent."' and labelID=labelParentID and validasi='YES' order by designORDER asc";
		//echo "<br> sql : ".$sql; 
		if ($hasil = mysqli_query($conn, $sql)) {
			while ($rec = mysqli_fetch_array($hasil)) {
				if ($rec["designName"] != "website") {
					echo "var ".$rec["designName"]." = form.".$rec["designName"].".value;";
					echo '
						if('.$rec["designName"].' == "") {
							inlineMsg("'.$rec["designName"].'","Field can not be empty.",2);
							return false;
					  	} else {
							var targetdiv = document.getElementById("'.$rec["designName"].'"); 
					  		targetdiv.style.backgroundColor = "white";
					  	}
					';	
				}
			}
		}	
		echo "
				return true;
			}
		";
	echo "</script>";
	
	?>
    <h3>Edit Product Category</h3>
    <form name="form" id="form" class="form" action="<?php echo $thisPage.'adm1n/'.$curPage1;?>" onsubmit="return validate(this)" method="post">
        <p>
            <?php
            //echo "<breditProduct : ".$editProduct;
            if ($editProduct == "editProduct"){
                $productName=(isset($_POST["productName"]) ? $_POST["productName"] : null);
                $sql = 
				" UPDATE form_element_sub ".
				" SET elementSubDescription = '".$productName."' ".
                " WHERE elementSubID = '".$elementSubID."' ";				
			    //echo $sql;
				if ($hasil = mysqli_query($conn, $sql)) {
                    echo '
                    <script type="text/javascript">';
                        echo '
                        window.location = "'.$thisPage.'adm1n/'.$curPage1.'?elementSubID='.$elementSubID.'"';
                        echo '
                    </script>';
                } else 
                    echo "Failed to Update Data ";
            } else {
                $sql = 
				" SELECT * ".
				" FROM form_element_sub, form_element_link ".
				" WHERE linkElementSubID = elementSubID ".
				" AND linkDesignID = '41' ".
                " AND elementSubID = '".$elementSubID."' ";				
				//echo "<br>sql: ".$sql;
				if ($hasil = mysqli_query($conn, $sql)) {
					$productName = "";
					while ($data = mysqli_fetch_array($hasil)) {
					    $productName = $data["elementSubDescription"];
					}
				}
                $sql = 
                " select * from form_label ".
                " where labelType='$idEvent'";
                //echo "<br> sql".$sql; 
                if ($hasil = mysqli_query($conn, $sql)) {		
                    while ($rec = mysqli_fetch_array($hasil)) {
                        echo "<h2 class='h2-teasers'>".$rec["labelNameTitle"]."</h2>";
                        $sql2 = 
                        " SELECT * FROM form_design, form_element ".
                        " WHERE elementID = element AND labelParentID = ".$rec["labelID"].
                        " ORDER BY designORDER asc";
                        // echo $sql2;
                        if ($hasil2 = mysqli_query($conn, $sql2)) {
                            echo '<table width="100%" cellpadding="10" cellspacing="1" border="0" bgcolor="#999999">';
                            while ($rec2 = mysqli_fetch_array($hasil2)) {
                                // Link ke Element
                                //echo $elementSubStat;
                                if ($rec2["labelName"] == "Product Name") {
                                    if ($rec2["elementName"] != "hidden") {
                                        //echo "$designName : ".$$designName;
                                        echo '<tr valign="middle" bgcolor="#e4e4e4">';
                                        echo '	<td width=25% style="background-color:#e4e4e4;">
                                                    <strong>
                                                        '.$rec2["labelName"];
                                                        if ($rec2["labelNameEng"]) {
                                                            echo '
                                                            (<i>'.$rec2["labelNameEng"].'</i>)';
                                                        }
                                                    echo '	
                                                    </strong>													
                                                </td>';
                                        echo '	<td style="background-color:#e4e4e4;">';
                                                    echo '<input style="width:96%; height:30px; padding: 8px; font-size:18px" ';
                                                    echo 'type="'.$rec2["elementName"].'" 
                                                          name="'.$rec2["designName"].'" 
                                                          id="'.$rec2["designName"].'" 
                                                          value="'.(isset(${$rec2["designName"]}) ? ${$rec2["designName"]} : null).'">';
                                        echo '	</td>';
                                        echo '</tr>';
                                    }
                                }
                            }
                            echo '</table>';
                        }
                    }
                    ?>
                    <table width="100%" cellpadding="15" cellspacing="1" border="0">
                        <tr>
                            <td align="center">
                                <input type="hidden" name="action" id="action" value="Edit Product" />
                                <input type="hidden" name="elementSubID" id="elementSubID" value="<?php echo $elementSubID; ?>" />
                                <input type="hidden" name="editProduct"  id="editProduct"  value="editProduct" />
                                <input type="submit" name="submit" id="submit" class="button" value="Update Data">
                            </td>
                        </tr>
                    </table>
                    <?php
                }
            }													
            ?>
        </p>
    </form>