<?php
	include "db_connection/db_connection.php";
	include "config/config.php";
//	print_r($_SESSION);
	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	else // THIS IS FOR GETTING PARTY DET ID ROM LOAGIN DET AND PARTY DET TABLE
	{
		$admin_id = $_SESSION['admin_login_id'];

		$SLCT_log = "SELECT * FROM login_details,ac_party_det WHERE ac_party_det.party_det_id = login_details.party_det_id AND login_details.admin_id = '$admin_id'";
		//echo $SLCT_log;
		$QURY_log = mysqli_query($connect,$SLCT_log);
		$FTCH_log = mysqli_fetch_object($QURY_log);
		$party_id = '$FTCH_log->party_det_id';
	}


			$ot=1;
			if(isset($_GET['ot'])!=''){
				$ot = $_GET['ot'];
			}
	$check_acc  = check_access('23');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php echo $PROJECT_TITLE ?></title>

<script type="text/javascript" src="js/design_add_JS.js"></script>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script type="text/javascript" src="js/plugins/forms/ui.spinner.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.mousewheel.js"></script>
 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

<script type="text/javascript" src="js/plugins/charts/excanvas.min.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.orderBars.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.pie.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.flot.resize.js"></script>
<script type="text/javascript" src="js/plugins/charts/jquery.sparkline.min.js"></script>

<script type="text/javascript" src="js/plugins/tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/plugins/tables/jquery.sortable.js"></script>
<script type="text/javascript" src="js/plugins/tables/jquery.resizable.js"></script>

<script type="text/javascript" src="js/plugins/forms/autogrowtextarea.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.uniform.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.inputlimiter.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.maskedinput.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.autotab.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.chosen.min.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.dualListBox.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.cleditor.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.ibutton.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="js/plugins/forms/jquery.validationEngine.js"></script>

<script type="text/javascript" src="js/plugins/uploader/plupload.js"></script>
<script type="text/javascript" src="js/plugins/uploader/plupload.html4.js"></script>
<script type="text/javascript" src="js/plugins/uploader/plupload.html5.js"></script>
<script type="text/javascript" src="js/plugins/uploader/jquery.plupload.queue.js"></script>

<script type="text/javascript" src="js/plugins/wizards/jquery.form.wizard.js"></script>
<script type="text/javascript" src="js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript" src="js/plugins/wizards/jquery.form.js"></script>

<script type="text/javascript" src="js/plugins/ui/jquery.collapsible.min.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.breadcrumbs.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.tipsy.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.progress.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.colorpicker.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.jgrowl.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.fancybox.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.fileTree.js"></script>
<script type="text/javascript" src="js/plugins/ui/jquery.sourcerer.js"></script>

<script type="text/javascript" src="js/plugins/others/jquery.fullcalendar.js"></script>
<script type="text/javascript" src="js/plugins/others/jquery.elfinder.js"></script>

<script type="text/javascript" src="js/plugins/ui/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="js/files/bootstrap.js"></script>
<script type="text/javascript" src="js/files/functions.js"></script>

<script type="text/javascript" src="js/charts/chart.js"></script>
<script type="text/javascript" src="js/charts/hBar_side.js"></script>

<!-- Shared on MafiaShare.net  --><!-- Shared on MafiaShare.net  --></head>

<body onload="document.getElementById('addpage').focus();">

<!-- Top line begins -->
<?php include "header_footer/header.php"; ?>
<!-- Top line ends -->

<!-- Sidebar begins -->
<?php include "menus/left_menu.php"; ?>
<!-- Sidebar ends -->

<!-- Content begins -->
<div id="content">

<?php include "menus/top_menu.php"; ?>
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="#">Dashboard</a></li>
                <li><a href="javascript:">Design Reload</a></li>
            </ul>
        </div>
	<?php include "menus/top_left_menu.php"; ?>
    </div>
    <!-- Main content -->
    <div class="wrapper">
<?php if($check_acc==1){?>
    	   <?php
				if(isset($_GET['master_cat_id']))
				{
					$master_cat_id = $_GET['master_cat_id'];	
				}
				else
				{
					$master_cat_id = '';
				}
			/*	if(isset($_GET['dat']))
				{
					$dat = $_GET['dat'];
				}
				else
				{
					$dat = '';
				}*/
			$page_id= base64_encode(base64_encode(base64_encode(1)));
			?>

        <ul class="middleNavR">
           <!-- <li><a href="#" title="Add an article" class="tipN"><img src="images/icons/middlenav/create.png" alt="" /></a></li>
           <li><a href="design_add.php" title="Add Design" id="addpage" class="tipN"><img src="images/icons/middlenav/add.png" alt="" /></a></li>-->
		   <?php 
			$des_view3s = check_rights('23','add');
			if($des_view3s==1){ ?>
           <li><a id="addpage" href="design_cat_add.php?id=<?php echo base64_encode(base64_encode(base64_encode(2)));?>&ot=<?php echo $ot;?>" title="Cad Finish Image" class="tipN"><img src="images/cad_fins.png" height="65" width="65" alt="" style="padding-top:0px" /></a></li>
           <li><a href="design_cat_add.php?id=<?php echo base64_encode(base64_encode(base64_encode(1)));?>" title="Render Image" class="tipN"><img src="images/rend_img.png" height="60" width="60" alt="" style="padding-top:3px" /></a></li>
		   <?php } ?>

           <!--<li><a href="#" title="Check statistics" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>-->
    	</ul>
    		<form>
            <fieldset>
    		<div class="widget">
			<div class="formRow" >
			<table width="100%">
				<tr>
					<td width="25%" style="display:table-cell; vertical-align:top;">Select Category:</td>
					<td width="75%">
					<div class="searchDrop">
					<input type="hidden" id="ot" name="ot" value="<?php echo $ot;?>">
					 <select  data-placeholder="" class="select" name="cat_name" id="cat_name" style="width:350px;" onchange="reload_page()" onfocus="foc(this.id)" onblur="stnon(this.id)">
						 <option selected="selected" value="">Choose a Category...</option>
							 <?php
								$SLCT = "SELECT  * FROM master_cat ORDER BY master_cat_id ASC";
								//echo $SLCT;
								$QURY = mysqli_query($connect,$SLCT);
								while($FTCH = mysqli_fetch_object($QURY))
								{
								$cad_name= base64_encode(base64_encode(base64_encode($FTCH->master_cat_id)));
							?>
							<option <?php if($cad_name == $master_cat_id){ ?> selected="selected" <?php }?> value="<?php echo $cad_name ?>"><?php echo $FTCH->master_cat_name." - ".$FTCH->cat_expantion; ?></option>
							<?php
								}
							?>
                                </select>
                            </div>
							</td>
							</tr>
							</table>
							</div>
                        <div class="clear"></div>
            </div>
		  <?php 
				if(isset($_GET['master_cat_id']))
				{
					$cat_id = base64_decode(base64_decode(base64_decode($_GET['master_cat_id'])));
					//THIS IS PAGE ID
					$tot_dis ="block";
				}
				else
				{
					$cat_id = '';
					$tot_dis = "none";
				} 
		 ?>
                         <?php /*?> <input type="hidden" name="pagg_id" id="pagg_id" value="<?php echo $pg_id; ?>" />
                            <?php
							if($pg_id ==1)
							{
							?><?php */?>

    	<!-- Chart --><!-- 6 + 6 -->
		<input type="hidden" name="fin_type" id="fin_type_0" value="mul_fin" />
    	<div class="widget" style="display: <?php echo $tot_dis ?>"> <!--style="width:600px; margin-left:150px;"-->
        <div class="whead"><h6>Design List</h6><div class="clear"></div></div>
        <div id="dyn" class="hiddenpars">
        	<a href="javascript:0" id="searchlink" onfocus="foc(this.id)" onblur="stnon(this.id)" class="tOptions" title="Options">
			<img src="images/icons/options.png" alt="" /></a>
            <table cellpadding="0" cellspacing="0" border="0" class="dTable" id="dynamic">
            <thead>
            <tr>
            <th width="26" align="center">S.No<span class="sorting" style="display: block;"></span></th>
            <!--<th width="92">Category</th>-->
            <th width="100" align="left">Design No</th>
            <th width="40" align="left">Points</th>
            <th width="120" align="center">No of Pcs / Master</th>
            <th width="100" align="center">Design Date</th>
            <th width="130" align="left">Design Status</th>
            <th width="70" align="center">Image</th>
            <th width="80" align="center">Action</th>
            <th width="80" align="center">SubCat</th>
            </tr>
            </thead>
            <tbody>
            <?php
			$page_id= base64_encode(base64_encode(base64_encode(2))); //THIS IS FOR PAGE IDENTIFICATION IN BL FILE for active inactive

			$SLCT = "SELECT * FROM design_det WHERE master_cat_id='$cat_id' and operation_type='".$ot."' ORDER BY design_det.design_det_id ASC";
			//$SLCT="SELECT * FROM mas_finishing,design_det,master_cat WHERE master_cat.master_cat_id = $cat_id AND master_cat.master_cat_id = design_det.master_cat_id AND design_det.design_det_id = mas_finishing.design_det_id AND design_det.statu_s='active' ORDER BY design_det.design_det_id ASC";
			//echo $SLCT;
			$QURY = mysqli_query($connect,$SLCT);
			$loop=1;
			if(mysqli_num_rows($QURY)>0)
			{
			while($FTCH = mysqli_fetch_object($QURY))
			{
				//echo $FTCH->design_det_id;
				$design_id	=	base64_encode(base64_encode(base64_encode($FTCH->design_det_id)));
				$SLCT_d = "SELECT  * FROM master_cat WHERE master_cat_id = '$FTCH->master_cat_id'";
				$QURY_d = mysqli_query($connect,$SLCT_d);
				$FTCH_d = mysqli_fetch_object($QURY_d);

				$SLCT_c = "SELECT  * FROM master_country WHERE master_country_id = '$FTCH->master_country_id'";
				$QURY_c = mysqli_query($connect,$SLCT_c);
				if(mysqli_num_rows($QURY_c)>0)
				{
					$FTCH_c = mysqli_fetch_object($QURY_c);
					$country_name=$FTCH_c->country_name;
				}else{
					$country_name='Nil';
				}

				$SLCT_dc = "SELECT  * FROM master_cad_cat WHERE master_cad_cat_id = '$FTCH->master_cad_cat_id'";
				$QURY_dc = mysqli_query($connect,$SLCT_dc);
				if(mysqli_num_rows($QURY_dc)>0)
				{
					$FTCH_dc = mysqli_fetch_object($QURY_dc);
					$cad_cat = $FTCH_dc->cad_cat_name;
				}
				else
				{
					$cad_cat = "----";
				}

				if($FTCH->statu_s == 'active'){ $sts_s = 1; }else{ $sts_s = 2; }

				if($loop%2 != "0")
					$bg = "gradeX";
				else
					$bg = "class='gradeC'";

				if($FTCH->mas_fin_ext!=''){ $imag = "../mas_fin_images/S.".$FTCH->mas_fin_ext; $imag1 = "../mas_fin_images/L.".$FTCH->mas_fin_ext; }

				else if($FTCH->cad_fin_ext!=''){ $imag = "../cad_fin_images/S.".$FTCH->cad_fin_ext; $imag1 = "../cad_fin_images/L.".$FTCH->cad_fin_ext; }

				else if($FTCH->imag_ext!=''){ $imag = "../design_images/S.".$FTCH->imag_ext; $imag1 = "../design_images/L.".$FTCH->imag_ext; }
			?>
            <tr <?php echo $bg ?>>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $loop ?></td>
            <?php /*?><td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_d->master_cat_name; ?></td><?php */?>
            <td align="left" style="display:table-cell;vertical-align:middle"><?php echo $FTCH_d->master_cat_name." ".$FTCH->design_no; ?><?php if($FTCH->up_status=="yes"){ echo " ( Old ".$FTCH->no_of_tm_alt." )"; } ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $cad_cat; ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo $FTCH->no_of_pieces." / ".$FTCH->master_pieces; ?></td>
            <td align="center" style="display:table-cell;vertical-align:middle"><?php echo str_replace("-","/",$FTCH->design_date); ?></td>
            <td align="left" style="display:table-cell;vertical-align:middle"><?php echo $FTCH->design_status; ?></td>
            <td class="center">
                <div class="body" align="center">
                <a href="<?php echo $imag1; ?>" title="<h2><?php echo $FTCH_d->master_cat_name." ".$FTCH->design_no; ?></h2>" class="lightbox" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a>
               </div>
            </td>
            <td class="center" style="display:table-cell;vertical-align:middle">
            <a href="design_view.php?design_id=<?php echo $design_id ?>&ot=<?php echo $ot;?>" id="viewlink<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)"><?php if($FTCH->up_status=="yes"){ echo "View"; }else{ echo "Update"; } ?> | <div id="ajaxres_<?php echo $loop ?>">
			<a href="javascript:0" onfocus="foc(this.id)" onblur="stnon(this.id)" onclick="des_act_ina(<?php echo $FTCH->design_det_id ?>,<?php echo $sts_s; ?>,<?php echo $loop; ?>);"><?php echo $FTCH->statu_s; ?></a></div></a>
            </td>
			<td style="display:table-cell;vertical-align:middle">
				<div class="grid4 searchDrop">
                    <select  data-placeholder="" class="select" name="sub_cat_name<?php echo $loop ?>" id="sub_cat_name<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" onchange="des_sub_cat(this.value,'<?php echo $design_id; ?>')" style="text-align: left;">
                        <option value="">Choose a Sub Category...</option>
			<?php
			$SLCT_con = "SELECT master_sub_category_id,sub_category_name FROM master_sub_category WHERE statu_s='active' ORDER BY sub_category_name ASC";
			$QURY_con = mysqli_query($connect,$SLCT_con);
			while($FTCH_con = mysqli_fetch_object($QURY_con))
			{
			?>
			<option <?php if($FTCH_con->master_sub_category_id==$FTCH->master_sub_category_id){ ?> selected="" <?php } ?> value="<?php echo base64_encode(base64_encode(base64_encode(base64_encode($FTCH_con->master_sub_category_id)))); ?>"><?php echo $FTCH_con->sub_category_name ?></option>
			<?php
			}
			?>
			</select>
			</div>
			</td>
            </tr>
            <?php
			$loop ++;
			 }
			 }
			 ?>
            </tbody>
            </table>
        </div>
        </div>
        </fieldset>
     </form>
        <div class="fluid"><!-- Media table --></div>
		<?php } else {  echo ACCESS_MSG;} ?>
</div>
    <!-- Main content ends -->
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
</body>
</html>
