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

	if($_SESSION['admin_login_id'] == '')
	{
		echo "<script>window.location='../index.php';</script>";
	}

?>
<!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="js/po_entry_add_JS.js"></script>
<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(); load_data();">

<!-- 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:">Clint Request</a></li>
            </ul>
        </div>
	<?php include "menus/top_left_menu.php"; ?>

    </div>

    <!-- Main content -->
    <div class="wrapper">
    	<div class="widget">
        <div class="whead"><h6>Client Request List</h6><div class="clear"></div></div>
		<div id="get-list-view"></div>
		<div id="load-msg"></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="table" id="dynamic">
            <thead>
            <tr>
            <th width="26" align="center">S.No</th>
            <th width="70" align="left">Party Code</th>
            <?php if($admin_flagg==1){ ?>
			<th width="200" align="left">Comp Name</th>
            <?php } ?>
            <th width="79" align="center">Request Date</th>
            <th width="80" align="center">No of Req Designs</th>
            <th width="80" align="center">No of Req Dies</th>
            <th width="78" align="center">No of Ord Designs</th>
            <th width="78" align="center">No of Ord Dies</th>
            <th width="79" align="center">Cancel</th>
            <th width="79" align="center">View</th>
			 <!--<th width="61">Status</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
			$bck_flg = base64_encode(base64_encode(base64_encode(1)));
			$flg1 = base64_encode(base64_encode(base64_encode(1)));

			$SLCT = "SELECT party_det_id,sel_date FROM design_sel_det GROUP BY party_det_id,sel_date ORDER BY design_sel_det_id DESC limit 0,5";
			$QURY = mysqli_query($connect,$SLCT);
			$loop=1;
			if(mysqli_num_rows($QURY)>0)
			{
			while($FTCH = mysqli_fetch_object($QURY))
			{
				$pa_id	=	base64_encode(base64_encode(base64_encode($FTCH->party_det_id)));
				$sel_date = base64_encode(base64_encode(base64_encode($FTCH->sel_date)));

				$SLCT_dd = "SELECT COUNT(design_sel_det_id) AS sel_cnt,IFNULL(SUM(master_pieces),0) AS mas_pic FROM design_sel_det,design_det WHERE  party_det_id = '$FTCH->party_det_id' and `sel_date` ='$FTCH->sel_date' AND design_det.design_det_id = design_sel_det.design_det_id GROUP BY sel_date";
				$QURY_dd = mysqli_query($connect,$SLCT_dd);
				$FTCH_dd = mysqli_fetch_object($QURY_dd);

				$SLCT_E = "SELECT cmp_name,party_code FROM party_det WHERE party_det_id = '$FTCH->party_det_id'"; 
				$QURY_E = mysqli_query($connect,$SLCT_E);
				$FTCH_E = mysqli_fetch_object($QURY_E);

				$SLCT_Ec = "SELECT COUNT(design_sel_det_id) AS des_cnt,IFNULL(SUM(master_pieces),0) AS mas_pic FROM design_sel_det,design_det WHERE party_det_id = '$FTCH->party_det_id' AND design_det.design_det_id = design_sel_det.design_det_id AND ord_status = 'yes' and `sel_date` ='$FTCH->sel_date'";

				$QURY_Ec = mysqli_query($connect,$SLCT_Ec);
				$FTCH_Ec = mysqli_fetch_object($QURY_Ec);

				$SLCTre = "SELECT party_det_id,sel_date FROM design_sel_det WHERE party_det_id = '$FTCH->party_det_id' GROUP BY STR_TO_DATE(sel_date,'%d-%m-%Y') ORDER BY design_sel_det_id DESC";

				$QURYre = mysqli_query($connect,$SLCTre);
				$nu_rows = 0;
				$rowsre = mysqli_num_rows($QURYre);
				if($rowsre>0){
				while($FTCHre = mysqli_fetch_object($QURYre))
				{
					$SLCTre_sub = "SELECT * FROM design_sel_det WHERE party_det_id = '$FTCHre->party_det_id' and sel_date = '$FTCHre->sel_date' and ord_status='no'";
					//echo $SLCTre;
					$QURYre_sub = mysqli_query($connect,$SLCTre_sub);
					if(mysqli_num_rows($QURYre_sub)>0)
					{
						$nu_rows++;
					}
				}
				}
				$SLCT_DES = "SELECT COUNT(des_sel_cancel_id) AS canc_cnt FROM des_sel_cancel WHERE party_det_id = '$FTCH->party_det_id' AND sel_date = '$FTCH->sel_date'";
				$QURY_DES = mysqli_query($connect,$SLCT_DES);
				$FTCH_DES = mysqli_fetch_object($QURY_DES);

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

			?>
            <tr <?php echo $bg ?>>
            <td align="center" style="vertical-align:middle;"><?php echo $loop ?></td>
            <td align="left" style="vertical-align:middle;"><?php echo $FTCH_E->party_code; ?></td>
             <?php if($admin_flagg==1){ ?>
			<td align="left" style="vertical-align:middle;">
			<?php //echo $FTCH_E->cmp_name; ?>
			<?php  
				$name_count = strlen($FTCH_E->cmp_name);
				$name='';
				if($name_count>25){
					$name = substr($FTCH_E->cmp_name,0,25)."...";
				} else {
					$name = $FTCH_E->cmp_name;
				} ?>
			<?php if($name_count>25){?>
			<div class="tooltip1">
			<?php echo $name;?>
				<span class="tooltiptext1"><?php echo $FTCH_E->cmp_name;?></span>
			</div>
			<?php } else { ?>
			<?php echo $name;?>
			<?php } ?>
			</td>
            <?php } ?>
            <td align="center" style="vertical-align:middle;"><?php echo str_replace("-","/",$FTCH->sel_date); ?></td>
            <td align="center" style="vertical-align:middle;">
				<?php echo $FTCH_dd->sel_cnt; ?>
				<?php 
					if($FTCH_DES->canc_cnt > 0)
					{ 
				?> 
						<a id="viewlink1<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="clien_cancel_view.php?po_id=<?php echo $pa_id ?>&sel_date=<?php echo $sel_date ?>" class="an_own"><?php echo " ( ".$FTCH_DES->canc_cnt." ) "; ?></a>
				<?php 
					}
				?>
			</td>
			<td class="center" style="vertical-align:middle;"><?php echo $FTCH_dd->mas_pic; ?></td>
            <td class="center" style="vertical-align:middle;"><?php if($FTCH_Ec->des_cnt > 0){ ?> <a id="viewlink2<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="cli_ord_req_po_view.php?pa_id=<?php echo $pa_id ?>&sel_date=<?php echo $sel_date ?>" style="text-decoration:underline"><?php echo $FTCH_Ec->des_cnt; ?></a><?php }else{ echo $FTCH_Ec->des_cnt; } ?></td>
			<td class="center" style="vertical-align:middle;"><?php echo $FTCH_Ec->mas_pic; ?></td>
			<td class="center" style="vertical-align:middle;">
			<?php if($FTCH_Ec->des_cnt != $FTCH_dd->sel_cnt){ ?>
			<a href="cli_ord_req_cancel.php?pa_id=<?php echo $pa_id ?>&sel_date=<?php echo $sel_date ?>&bck_flg=<?php echo $bck_flg; ?>&flg=<?php echo $flg1; ?>" class="an_own" id="viewlink3<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)">Cancel</a>
			 <?php }else{ ?>
			-----
			<?php } ?>
			</td>
            <td class="center" align="center" style="vertical-align:middle;">
			<?php if($FTCH_Ec->des_cnt != $FTCH_dd->sel_cnt){ ?>
			<?php if($nu_rows > 1){ ?>
			<a id="viewlink4<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="cli_ord_req_sub_view.php?pa_id=<?php echo $pa_id ?>" class="an_own">View/Approve</a>
			<?php }else{ ?>

			<a id="viewlink5<?php echo $loop ?>" onfocus="foc(this.id)" onblur="stnon(this.id)" href="cli_ord_req_view.php?pa_id=<?php echo $pa_id ?>&sel_date=<?php echo $sel_date ?>&bck_flg=<?php echo $bck_flg; ?>&flg=<?php echo $flg1; ?>" class="an_own">View/Approve</a>

			<?php }}else{ ?>
			Approved
			<?php } ?>
			</td>
			</tr>

            <?php
			$loop ++;
			 }
			 }
			 ?>
            </tbody>
            </table>
        </div>
        </div>
        <div class="fluid"><!-- Media table --></div>

    </div>
    <!-- Main content ends -->
</div>
<!-- Content ends -->
<?php /*?><?php include "header_footer/footer.php"; ?><?php */?>
<script src="js/js.scrollPagination.js"></script>

<script>
function load_data(){
	$(document).loadScrollData(0,{
		limit		:	8,
		listingId	:	"#get-list-view",
		loadMsgId	:	'#load-msg',
		catid		:	$('#cat_id').val(),
		sub_name	:	$('#sub_name').val(),
		wrange		:   $('#wrange').val(),
		srange		:   $('#srange').val(),
		ajaxUrl		:	'/../lOADdmoreContentACT',
		loadingMsg	:	'<div class="text-center"><img src="/../img/green_style.gif" width="30" height="30"></div>',
		loadingSpeed:100
	});
}
</script>
</body>
</html>
