<?php
	include "db_connection/db_connection.php";
	include "config/config.php";

	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='index.php';</script>";
	}
	$check_acc  = check_access('26');
?>
<!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>

        <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/waiting_for_appr_JS.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>

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

       <body onload="document.getElementById('listpage').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">
            <!--<div class="contentTop">
                <span class="pageTitle"><span class="icon-key-2"></span>Form validation engines</span>
                <ul class="quickStats">
                    <li>
                        <a href="" class="blueImg"><img src="images/icons/quickstats/plus.png" alt="" /></a>
                        <div class="floatR"><strong class="blue">5489</strong><span>visits</span></div>
                    </li>
                    <li>
                        <a href="" class="redImg"><img src="images/icons/quickstats/user.png" alt="" /></a>
                        <div class="floatR"><strong class="blue">4658</strong><span>users</span></div>
                    </li>
                    <li>
                        <a href="" class="greenImg"><img src="images/icons/quickstats/money.png" alt="" /></a>
                        <div class="floatR"><strong class="blue">1289</strong><span>orders</span></div>
                    </li>
                </ul>
                <div class="clear"></div>
            </div>-->
            <?php include "menus/top_menu.php"; ?> 
            <!-- Breadcrumbs line -->
            <div class="breadLine">
                <div class="bc">
                    <ul id="breadcrumbs" class="breadcrumbs">
                        <li><a href="home.php">Dashboard</a></li>
                        <li><a href="javascritp:">Waiting for Approval</a></li>
                    </ul>
                </div>
                <?php include "menus/top_left_menu.php"; ?>  
            </div>
            <!-- Main content -->
            <div class="wrapper"> 
			<?php if($check_acc==1){?>
            	<ul class="middleNavR">
                    <li><a href="waiting_for_appr.php" id="listpage" title=" Waiting for Approval" class="tipN"><img src="images/icons/middlenav/stats.png" alt="" /></a></li>
                </ul>
                <?php
					$des_sts = base64_decode(base64_decode(base64_decode(base64_decode($_GET['des_sts']))));
				?>
            	<div class="widget">
                	<div class="whead"><h6>Waiting for Approval 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="5%" align="center">S.No</th>
                                    <th width="10%" align="left">Design No</th>
                                    <th width="10%" align="left">Designer Name</th>
                                    <th width="7%" align="center">Point</th>
                                    <th width="7%" align="center">No. of Pieces</th>
                                    <th width="10%" align="center">Image</th>
                                    <th width="10%" align="center">W. App Date </th>
                                    <th width="12%" align="center">Total Design Time</th>
                                    <th width="7%" align="center">Status</th>
                                    <?php if($admin_flagg==1){ if($des_sts!='process'){ ?><th width="10%">View</th> <?php } } ?>
                               	</tr>
                			</thead>
                			<tbody>
                            <?php
								$loop=1;

								$page_id	=	base64_encode(base64_encode(base64_encode(base64_encode(1))));
								$SLCT_CAD = "SELECT *, emp_current_design.emp_det_id AS emp_id FROM emp_current_design,design_det WHERE design_det.design_det_id = emp_current_design.design_det_id AND emp_current_design.curr_status='$des_sts' AND emp_current_design.emp_det_id!=0 ORDER BY emp_current_design.emp_current_design_id ASC";
								$QURY_CAD = mysqli_query($connect,$SLCT_CAD);
			if(mysqli_num_rows($QURY_CAD)>0)
						{
							while($FTCH_CAD = mysqli_fetch_object($QURY_CAD))
							{
								$design_id	=	base64_encode(base64_encode(base64_encode(base64_encode($FTCH_CAD->design_det_id))));
				$emp_id	=	base64_encode(base64_encode(base64_encode(base64_encode($FTCH_CAD->emp_id))));
				
			$SLCT_CURR = "SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( `time_taken` ) ) ) AS tot_time FROM emp_current_design_det WHERE emp_current_design_id = '$FTCH_CAD->emp_current_design_id'";
			$QURY_CURR = mysqli_query($connect,$SLCT_CURR);
			$FTCH_CURR = mysqli_fetch_object($QURY_CURR);

		$SLCT_t = "SELECT * FROM master_cad_cat WHERE master_cad_cat_id = '$FTCH_CAD->master_cad_cat_id'";
		$QURY_t = mysqli_query($connect,$SLCT_t);
		if(mysqli_num_rows($QURY_t )>0)
	{
		$FTCH_t = mysqli_fetch_object($QURY_t);
		$cad_cat_name = $FTCH_t->cad_cat_name;
		$cad_pnts = $FTCH_t->cad_points;
	}
	else
	{ 
		$cad_cat_name = "------"; 
		$cad_pnts="----"; 
	}
				$SLCT_re = "SELECT * FROM emp_current_design_rework WHERE emp_det_id = '$FTCH_CAD->emp_id' AND design_det_id='$FTCH_CAD->design_det_id'";
				//echo $SLCT_re;
				$QURY_re = mysqli_query($connect,$SLCT_re);
				if(mysqli_num_rows($QURY_re)>0)
				{
					$FTCH_t = mysqli_fetch_object($QURY_re);
					$re_pnts = $FTCH_t->rework_pnts;
				}
				else
				{
					$re_pnts = $cad_pnts;
				}

				$SLCT_e = "SELECT * FROM emp_det WHERE emp_det_id = '$FTCH_CAD->emp_id'";
				$QURY_e = mysqli_query($connect,$SLCT_e);
				$FTCH_e = mysqli_fetch_object($QURY_e);

				$SLCT_d = "SELECT * FROM master_cat WHERE master_cat_id = '$FTCH_CAD->master_cat_id'";
				//echo $SLCT_d;
				$QURY_d = mysqli_query($connect,$SLCT_d);
				$FTCH_d = mysqli_fetch_object($QURY_d);

				if($loop%2 != "0")
					$bg = "gradeX";
				else
					$bg = "class='gradeC'";
				if($FTCH_CAD->curr_status=='finished')
				{
					$imag = "../cad_fin_images/S.".$FTCH_CAD->img_ext; 
					$imag1 = "../cad_fin_images/L.".$FTCH_CAD->img_ext;
				}
				else
				{

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

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

				else if($FTCH_CAD->imag_ext!=''){ $imag = "../design_images/S.".$FTCH_CAD->imag_ext; $imag1 = "../design_images/L.".$FTCH_CAD->imag_ext; }
			}

					//echo $FTCH_CAD->curr_status;
					if($FTCH_CAD->curr_status=='approved')
					{
						$flagg = 1;
						$row_class = 'style="display:table-cell; vertical-align:middle; color:#00FF00; font-weight:bold;"';
						$labl = "Approved";
					}
					else if($FTCH_CAD->curr_status=='waiting')
					{	
						$flagg = 2;
						$row_class = 'style="display:table-cell; vertical-align:middle; color:#FF0000; font-weight:bold;"';
						$labl = "W.app";
					}
					else if($FTCH_CAD->curr_status=='process')
					{
						$flagg = 3;
						$row_class = 'style="display:table-cell; vertical-align:middle; color:#000000; font-weight:bold;"';
						$labl = "Wip";
					}
					else if($FTCH_CAD->curr_status=='finished')
					{
						$flagg = 4;
						$row_class = 'style="display:table-cell; vertical-align:middle; color:#4a91c0; font-weight:bold;"';
						$labl = "Finished";
					}
									?>
					<tr>
						<td align="center" style="display:table-cell; vertical-align:middle;"><?php echo $loop; ?></td>
						<td align="left" style="display:table-cell; vertical-align:middle;"><?php echo $FTCH_d->master_cat_name." ".$FTCH_CAD->design_no; ?><?php if($FTCH_CAD->up_status=="yes"){ echo " ( Old ".$FTCH_CAD->no_of_tm_alt." )"; } ?></td>
						<td align="emp_current_design_det" style="display:table-cell; vertical-align:middle;"><?php echo $FTCH_e->name; ?></td>
						<td align="center" style="display:table-cell; vertical-align:middle;"><?php echo $re_pnts; ?></td>
						<td align="center" style="display:table-cell; vertical-align:middle;"><?php echo $FTCH_CAD->no_of_pice; ?></td>
						<td align="center" style="display:table-cell; vertical-align:middle;">
					   <div class="body" align="center">
							<a href="<?php echo $imag1; ?>" title="<?php echo $FTCH_d->master_cat_name." ".$FTCH_CAD->design_no; ?>" class="lightbox" rel="group"><img src="<?php echo $imag; ?>" width="60" height="60"/></a>
						</div>
					</td>
					<td align="center" style="display:table-cell; vertical-align:middle;"><?php echo $FTCH_CAD->waiting_app_dt; ?></td>
					<td align="center" style="display:table-cell; vertical-align:middle;"><?php echo $FTCH_CURR->tot_time; ?></td>
                   <td align="center" style="display:table-cell; vertical-align:middle;"><?php echo $labl; ?></td>
                   <?php if($admin_flagg==1){ if($des_sts!='process'){ ?>
                   <td align="center" <?php echo $row_class; ?> style="vertical-align:center;">
				<?php 
					if($flagg == 2)	{ ?>
                    <a href="waiting_for_appr_add.php?des_no=<?php echo $design_id; ?>&emp_ad_id=<?php echo $emp_id; ?>&des_sts=<?php echo $_GET['des_sts']; ?>" style="text-decoration:none; cursor:pointer;"><input type="button" name="sendMessage" class="buttonS bRed" value="View"></a>
                    <?php } else if($flagg == 4){ ?>
                    <a href="waiting_for_appr_add.php?des_no=<?php echo $design_id; ?>&emp_ad_id=<?php echo $emp_id; ?>&des_sts=<?php echo $_GET['des_sts']; ?>" style="text-decoration:none; cursor:pointer;"><input type="button" name="sendMessage" class="buttonS bLightBlue " style="cursor:pointer;" value="View"></a>
                    <?php } ?>
                                            	</td> 
											<?php } }?>                               
                                        </tr>
                    		<?php
										$loop++;
									}
								}
							?>                                
                			</tbody>
                		</table> 
                	</div>
                </div>
<?php } else {  echo ACCESS_MSG;} ?>
            </div>
            <!-- Main content ends -->
        </div>
        <!-- Content ends -->
    </body>
</html>
