<?php

session_name("SIGNADMAUTH");
session_start();

include "common/config/config.php";
include "common/config/dbconfig.php";
include "common/functions/funcconnect.php";
openDB();

include "common/functions/funcauthen.php";
include "common/functions/funcselectdb.php";

if (!authen())
{ 
	header("location: login.php");
}
else if (!fullaccess($_GET['menuid'], $_SESSION['SES_GROUPID']))
{ 
	header("location: index.php");
}
else
{
    $idmerek=$_GET['id'];
    $qm="SELECT * FROM $db_merek WHERE idmerek='".mysqli_real_escape_string($dbConnection, $idmerek)."' ";
    $rm=mysqli_query($dbConnection, $qm);
    $dm=mysqli_fetch_array($rm);

    $form="<form method='POST' action='merek_edit_process.php?id=".$idmerek." &menuid=".$_GET['menuid']."' style='padding:0; margin:0;'>
                <table border='0' cellpadding='10px' cellspacing='0'>
                    <tr>
                        <td align='left' valign='middle' nowrap>
                            Kode Merek
                        </td>
                        <td align='left' valign='middle'>
                            <input type='text' name='kodemerek_edit' size='50' value='".$dm['kodemerek']."' autocomplete='off' required>
                        </td>
                    </tr>

                    <tr>
                        <td align='left' valign='middle' nowrap>
                            Nama Merek
                        </td>
                        <td align='left' valign='middle'>
                            <input type='text' name='namamerek_edit' size='50' value='".$dm['namamerek']."' autocomplete='off' required>
                        </td>
                    </tr>

                    <tr>
                        <td align='left' valign='middle' nowrap>
                            Status Tersedia
                        </td>
                        <td align='left' valign='middle' nowrap>
                            <input type='radio' name='status_edit' value='".$dm['status_tersedia_merek']."' checked> Tersedia &nbsp;
                            <input type='radio' name='status_edit' value='".$dm['status_tersedia_merek']."'>Tidak Tersedia
                        </td>
                    </tr>

                    <tr>
                        <td align='left' valign='middle' nowrap></td>
                        <td align='left' valign='middle' nowrap>
                            <input type='submit' value=' Edit '> &nbsp;
                            <input type='button' value=' Batal ' onclick='history.back(-1)'>
                        </td>
                    </tr>
                </table>
            </form>";

        
        //-----------------------------------------------------------------------------------------------------

        //QUERY APP MENU
        $qq="SELECT a.appmenuname, b.parentmenuname FROM $db_appmenu a, $db_parent_menu b ";
		$qq.="WHERE a.appmenuid='".mysqli_real_escape_string($dbConnection, $_GET['menuid'])."' AND b.parentmenuid=a.parentid";
		$rr=mysqli_query($dbConnection, $qq);
		$dd=mysqli_fetch_array($rr);


        $content=$jscript.
        "<table border='0' cellpadding='6px' cellspacing='0' width='100%'>
            <tr>
                <td align='left' valign='top' width='100%'>
                    <b class='title'>".$dd['parentmenuname']." &gt; ".$dd['appmenuname']."</b>
                    <br><hr size='1' color='#000000'><br>

                    <table border='0' cellpadding='0' cellspacing='0' width='100%'>
                        <tr>
                            <td align='left' valign='top'>
                                $form
                            </td>
                        </tr>
                    </table>

                </td>
            </tr>
        </table>";


}

//--------------------------------------------------------------------------------------------------------------------------------


//TEMPLATE
include "webmenu.php";
include "common/include/template.php";
$temp=new template;
$temp->define_theme("themes/theme1.html");
$temp->define_tag("{PAGETITLE}", $namaaplikasi);
$temp->define_tag("{NAMAUSER}", strtoupper($_SESSION['SES_FULLNAME']));
$temp->define_tag("{APPMENU}", $webmenu);
$temp->define_tag("{APPCONTENT}", $content);
$temp->parse();
$temp->printproses();

closeDB();

?>






















?>