<!doctype html>
<html class="no-js" lang="">

<head>
    <!-- meta -->
    <meta charset="utf-8">
    <meta name="description" content="Flat, Clean, Responsive, application admin template built with bootstrap 3">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <!-- /meta -->

    <title>Orion</title>

    <!-- page level plugin styles -->
    <link rel="stylesheet" href="plugins/responsive-tables/theme.css">
    <!-- /page level plugin styles -->

    <!-- core styles -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/font-awesome.css">
    <link rel="stylesheet" href="css/themify-icons.css">
    <link rel="stylesheet" href="css/animate.min.css">
    <!-- /core styles -->

    <!-- template styles -->
    <link rel="stylesheet" href="css/skins/palette.css">
    <link rel="stylesheet" href="css/fonts/font.css">
    <link rel="stylesheet" href="css/main.css">
	
	<link rel="stylesheet" type="text/css" media="all" href="date/jsDatePick_ltr.min.css" />
<!-- 
	OR if you want to use the calendar in a right-to-left website
	just use the other CSS file instead and don't forget to switch g_jsDatePickDirectionality variable to "rtl"!
	
	<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.css" />
-->

 


	<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
	
	<link rel="stylesheet" type="text/css" media="all" href="date/jsDatePick_ltr.min.css" /> 
	
	<link rel="stylesheet" href="awesomplete-gh-pages/awesomplete.css" />
<script src="awesomplete-gh-pages/awesomplete.js" async></script>

<script type="text/javascript" src="date/jsDatePick.min.1.3.js"></script>
    <!-- template styles -->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- load modernizer -->
    <script src="plugins/modernizr.js"></script>
	
	
	<script>
	function checkChangesSideBar(link,code)
	{
		window.location = link + "?x=" + code;
		
	}
	</script>
</head>

<!-- body -->

<body>
    <div class="app">
        <!-- top header -->
        <?php //include 'hd.php';?>
 <header class="header header-fixed navbar" style="background-color:#15acdc;">

            <div class="brand" style="background-color:white;"><center>
                <!-- toggle offscreen menu -->
          
                <a href="home.php?x=31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz" class="navbar-brand">
                    <img src="img/logo.png" style="height:70%;" alt="">
                     
                </a> </center>
            </div>

            <ul class="nav navbar-nav">
                <li class="hidden-xs"> 
                     
                </li> 
            </ul> 
            <ul class="nav navbar-nav navbar-right"> 
                <li class="off-right">
                    <a href="javascript:;" data-toggle="dropdown">
                        
                        <span class="hidden-xs ml10">IBILLINGS</span>
                        <i class="ti-angle-down ti-caret hidden-xs"></i>
                    </a>
                    <ul class="dropdown-menu animated fadeInRight">
                     
                        <li>
                            
							 <a href="javascript:void()" onclick="checkChangesSideBar('exit.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">Logout</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </header>
		<section class='layout'>
		<aside class="sidebar offscreen-left" style="border-right:solid 1px #ccc;">
                <!-- main navigation -->
                <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 588px;"><nav class="main-navigation" data-height="auto" data-size="6px" data-distance="0" data-rail-visible="true" data-wheel-step="10" style="overflow: hidden; width: auto; height: 588px;">
                    <br>
                    <ul class="nav">
                        <!-- dashboard -->
                        <li style="background-color:gray;  color:white; border-bottom:solid 1px white;">
                            <a href="javascript:void()" onclick="checkChangesSideBar('home.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
                              
                                <span style="color:white;">Home</span>
                            </a>
                        </li>  
						   <li style="background-color:gray;  color:white; border-bottom:solid 1px white;">
                             <a href="javascript:void()" onclick="checkChangesSideBar('organisations.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
                              
                                <span style="color:white;">Organisations</span>
                            </a>
                        </li> 
						 <li style="background-color:gray;   color:white; border-bottom:solid 1px white;">
                          
                              
                                <span style="color:white;padding-top:2px;">&nbsp;&nbsp; &nbsp;Admin</span>
                           
							<ul class="sub-menu" style="display: block;">
							 
                               <li style="background-color:gray">
                                    <a href="javascript:void()" onclick="checkChangesSideBar('contractors.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
                                        <span style="color:white;">Contractors</span>
                                    </a>
                                </li>
								 <li style="background-color:gray">
                                   <a href="javascript:void()" onclick="checkChangesSideBar('internal-team.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
                                        <span style="color:white;">Internal Contacts</span>
                                    </a>
                                </li>
								 <li style="background-color:gray">
                                    <a href="javascript:void()" onclick="checkChangesSideBar('external-people.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
                                        <span style="color:white;">Wholesalers</span>

                                    </a>
                                </li>
								 
								
								 <li style="display:;background-color:gray">
                                
                                     <a href="javascript:void()" onclick="checkChangesSideBar('manage.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
									<span style="color:white;">Manage Attributes</span>
                                    </a>
                                </li>
								
								
                            </ul>
                        </li>
						 <li style="background-color:gray;   color:white; border-bottom:solid 1px white;">
                           <a href="javascript:void()" onclick="checkChangesSideBar('reports.php','31eOq1pG5arkyIJBdgInsAMnU2tjE1iI2xxtzW9E7BYFkHhxYZVqzHOuJiNoj67mDEPdAZRIAQnUyEswEnXe4LIO4wdnCkKgYztz')">
                              
                                <span style="color:white;">Reports</span>
                            </a>
                        </li>
                        <!-- /dashboard -->
     
                    </ul> 
                </nav><div class="slimScrollBar" style="background: rgb(0, 0, 0); width: 6px; position: absolute; top: 0px; opacity: 0.4; display: none; border-radius: 7px; z-index: 99; right: 0px; height: 588px;"></div><div class="slimScrollRail" style="width: 6px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; background: rgb(51, 51, 51); opacity: 0.2; z-index: 90; right: 0px;"></div></div>
            </aside>
		
            <!-- main content -->
            <section class="main-content">

                <!-- content wrapper -->
                <div class="content-wrap">

				
				<script>
				function fillDetails()
				{
					 
					
					var typeOf = document.getElementById('rFor').value;
					
					if (typeOf == "CL")
					{
						document.getElementById('rORGID').style.display = '';
						document.getElementById('lbl_cl').style.display = '';
						document.getElementById('rCONID').style.display = 'none';
						document.getElementById('lbl_con').style.display = 'none';
						
						var xmlhttp = new XMLHttpRequest();
													xmlhttp.onreadystatechange = function() {
														if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
															var ret = xmlhttp.responseText;
															document.getElementById('rORGID').innerHTML = ret;
														 }
													};
											xmlhttp.open("GET", "getDetails.php?type=" + "CL", true);
											 
											xmlhttp.send();
					}
					
					if (typeOf == "CON")
					{
						document.getElementById('rORGID').style.display = 'none';
						document.getElementById('lbl_cl').style.display = 'none';
						document.getElementById('rCONID').style.display = '';
						document.getElementById('lbl_con').style.display = '';
						
						var xmlhttp = new XMLHttpRequest();
													xmlhttp.onreadystatechange = function() {
														if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
															var ret = xmlhttp.responseText;
															document.getElementById('rCONID').innerHTML = ret;
														 }
													};
											xmlhttp.open("GET", "getDetails.php?type=" + "CON", true);
											 
											xmlhttp.send();
					}
					
				}
				
				</script>
				
				
				
				
				<?php
				
				$req_id_IN = $_GET['req_id'];
				$type_id_IN = $_GET['type'];
				
				
				
				
				
				//error_reporting(0);
		 
				$con = mysql_connect('localhost', 'root', 'Boom95z') or die(mysql_error());
				mysql_select_db('orion9', $con);
				
				$org_id_IN  = '';  
				$description_IN  = '';  
				$task_type_IN   = ''; 
				$to_uid_IN   = ''; 
				 
				 
				
				if ($req_id_IN != '')
				{
					if ($type_id_IN == 'CL')
					{
						$result1c = mysql_query("select * from client_requests where req_id = " . $req_id_IN);
						
						while($row = mysql_fetch_array($result1c))
						{	 											 
							$org_id_IN = $row['org_id']; 
							$description_IN = $row['description']; 
							$task_type_IN = $row['task_type']; 
						}
						
					}
					
					if ($type_id_IN == 'CON')
					{
						$result1v = mysql_query("select * from requests where req_id = " . $req_id_IN);
						
						while($row = mysql_fetch_array($result1v))
						{	 											 
							$to_uid_IN = $row['to_uid']; 
							$description_IN = $row['description']; 
							$task_type_IN = $row['task_type']; 
						}
						
					}
					
				
					
				}
				
				
				
				
				
				
				
				
				
				
				
				
				$pid = $_GET['pid'];
				//$result1 = mysql_query("SELECT a.*,b.PID from records a, process b where a.status='COMPLETE' and  a.RID = b.RID and b.stage='LEAD'");								//doc_id | pid  | doclink      | date_created        | status    | date_signed | created_by | signed_by | sig                 | random | date_submitted 
				$result1 = '';
				
				$org_id_in = ''; $org_id_in = $_GET['org_id_in'];
				$con_id_in = ''; $con_id_in = $_GET['con_id_in'];
				
				$strCl = ' 1=1 ';
				$strCon = ' 1=1 ';
				
				if ($org_id_in != '')
					$strCl = " a.org_id=" . $org_id_in;
				
				if ($con_id_in != '')
					$strCl = " a.con_id=" . $con_id_in;
				
				
				if (($_GET['typin'] == 'CL') || ($_GET['typin'] == ''))
					$result1 = mysql_query("select a.*, DATE_FORMAT(a.date_uploaded,'%d-%m-%Y') as 'date-u',b.company_name from client_documents a, organisations b where " . $strCl . " and  a.org_id = b.org_id order by company_name asc, a.date_uploaded desc");
					
				if ($_GET['typin'] == 'CON')
					$result1 = mysql_query("select a.*, DATE_FORMAT(a.date_uploaded,'%d-%m-%Y') as 'date-u', b.representative from contractor_documents a, contractors b where " . $strCon . " and a.con_id = b.con_id  order by representative asc, a.date_uploaded desc");
					
					
				//$result1 = mysql_query("select a.*, b.TEXT, c.stage, c.PID from content a, content_val b, process c where a.fid=b.fid and b.pid=c.pid and c.stage='LEAD' and a.stage='LEAD'");
				 ?>
				
                    <!-- inner content wrapper -->
                    <div class="wrapper">
					
					<!-- $org_id_IN  = '';  
				$description_IN  = '';  
				$task_type_IN   = ''; 
				$to_uid_IN   = ''; 
				$type_id_IN -->
					
						<a style='padding:5px;' href='process-flow.php?st=PROJECT&pid=<?php echo $pid; ?>&x=<?php echo $x; ?>'>< Back to Project</a>
                        <section class="panel">
						<header class="panel-heading" style="background-color:#15acdc; color:white;">Documents Uploaded By Parties <b></b></header>
                            
							<div class="panel-body" id='newTask' style='display:<?php if ($req_id_IN != '') echo ""; else echo "none";?>;'>
								 <form method="POST" action="create-task.php" style="font-size:12px;">

									<div class='row'>
										<div class='col-md-6'>
										Create Task For<br/>
										
										<input type='hidden' id='req_id' name='req_id' value="<?php echo $req_id_IN; ?>">
										
										
										<select id='rFor' <?php if ($req_id_IN != '') echo "readonly"?> name='rFor' ONCHANGE='fillDetails()'   class='form-control' REQUIRED='REQUIRED'> 
											<option value=''>- Select -</option> 
											<option  <?php if ($type_id_IN == 'CL') echo " selected ";?> value='CL'>Client</option>
											<option  <?php if ($type_id_IN == 'CON') echo " selected ";?> value='CON'>Contractor</option>
										</select> 
										 
										 <script>fillDetails();</script>
										 <div style='height:10px;'></div>
										<div style='display:<?php if ($type_id_IN == 'CL') echo "none"; ?>;' id='lbl_con'>Select Contractor<br/></div>
										<select style='display:<?php if ($type_id_IN == 'CL') echo "none"; ?>;' id='rCONID' name='rCONID'   class='form-control'  REQUIRED='REQUIRED'> 
											<option value='0'>- Select -</option>
											<?php
											
											$resultbb = mysql_query("SELECT con_id, representative FROM contractors where retired is null and representative != '' order by representative asc");
	
	 while($row = mysql_fetch_array($resultbb))
        {
            $con_id = $row['con_id'];
			$representative = $row['representative'];
				 
			$selected = "";

			if ($to_uid_IN == $con_id) $selected = " selected ";
				 
			echo  "<option " .  $selected . " value='" . $con_id . "'>" . $representative . "</option>";
        }

											?>
											
										</select>
										
										 <div style='height:10px;'></div>
										<div style='display:<?php if ($type_id_IN == 'CON') echo "none"; ?>;'  id='lbl_cl'>Select Client<br/></div >
										<select style='display:<?php if ($type_id_IN == 'CON') echo "none"; ?>;' id='rORGID' name='rORGID'  class='form-control'  REQUIRED='REQUIRED'> 
											<option value='0'>- Select -</option>
<?php
$resultbb = mysql_query("SELECT org_id, company_name FROM organisations where retired is null  and company_name != '' order by company_name asc");
	
	 while($row = mysql_fetch_array($resultbb))
        {
            $org_id = $row['org_id'];
			$company_name = $row['company_name'];
				 
			$selected = "";	 
				 
			if ($to_org_IN == $org_id) $selected = " selected ";	 
				 
			echo "<option  " .  $selected . " value='" . $org_id . "'>" . $company_name . "</option>";
        }									
?>													
										</select>
										
											 <div style='height:10px;'></div>
										Task Title<br/>
										<input id='rTaskTitle' name='rTaskTitle'  class='form-control' value='<?php echo $task_type_IN;?>'  REQUIRED='REQUIRED' />  
										
										<div style='height:10px;'></div>
										Task Description<br/>
										<textarea id='rDesc' name='rDesc'  REQUIRED='REQUIRED'  class='form-control'><?php echo $description_IN;?></textarea> 
										
										
										<input type='hidden' id='userIn' name='userIn' value='<?php echo $xUSERID;?>'/>
										
										<div style='height:10px;'></div>
										<button type='submit' class='btn btn-info'>SAVE</button>
										<a href="#" onclick='document.getElementById("newTask").style.display="none";document.getElementById("res").style.display="";'  class='btn btn-default'>Cancel</a>									
										
										</div>
									</div>
									</form>
							</div>
							
							<div class="panel-body">
                                 
								 
								  <br/> 	
								  
								  <script>
								  
								  function gothis()
								  {
									  if (document.getElementById("typein").value == "CL")
										  window.location = "supplied-documents.php?typin=CL";
									  else
										  window.location = "supplied-documents.php?typin=CON";
								  }
								  
								  function goCON()
								  {
									   var con_id = document.getElementById("goCON").value;
									   window.location = "supplied-documents.php?typin=CON&con_id_in=" + con_id;
								  }
								  
								   function goCL()
								  {
									   var org_id = document.getElementById("goCL").value;
									   window.location = "supplied-documents.php?typin=CL&org_id_in=" + org_id;
								  }
								  
								  
								  </script>
								  
								  <div id='res' style='display:<?php if ($req_id_IN != '') echo "none"; else echo "";?>'> 
									  <div align='left'>	
									  <div class='row'>
										<div class='col-md-2'>
										Filter Documents By:<br/>
											<select id='typein' onchange='gothis()' class='form-control'> 
											  <option <?php if ($_GET['typin'] == 'CL') echo " selected ";?> value='CL'>Client Uploads</option>
											   <option <?php if ($_GET['typin'] == 'CON') echo " selected ";?>  value='CON'>Contractor Uploads</option>
											</select>
										</div>
										<div class='col-md-2'>
										<?php echo $typin;?>
										<div id='consearch' style='display:<?php  if ($_GET['typin'] == 'CON') echo ""; else echo "none";?>;'>
										Contractor:<br/>
										<select id='goCON' onchange='goCON()' class='form-control'> 
											  <option>- Select</option> 
											  
											  <?php
												$result2x = mysql_query("select con_id,representative from contractors where retired is null and representative != '' order by representative asc" );
												while($row2 = mysql_fetch_array($result2x))
												{
													$cdx = $row2['con_id']; 
													$repx = $row2['representative']; 
													
													$sel = "";
													
													if ($_GET['con_id_in'] == $cdx)
														$sel = " selected ";
													
													echo "<option " . $sel . "  value='" . $cdx . "'>" . $repx . "</option>";
												} 
											  
											  ?>
											  </select>
											</div>  
											  <div id='clsearch' style='display:<?php  if ($_GET['typin'] == 'CL') echo ""; else echo "none";?>;'>
										Client:<br/>
										<select id='goCL' onchange='goCL()' class='form-control'> 
											  <option>- Select</option>
											  
											  <?php
												$result2x = mysql_query("select org_id,company_name from organisations where retired is null and company_name != '' order by company_name asc" );
												while($row2 = mysql_fetch_array($result2x))
												{
													$cdx = $row2['org_id']; 
													$repx = $row2['company_name']; 
													
													$sel = "";
													
													if ($_GET['org_id_in'] == $cdx)
														$sel = " selected ";
													
													echo "<option " . $sel . "  value='" . $cdx . "'>" . $repx . "</option>";
												}
											  
											  ?>
											 
											</select>
											</div>
										</div>
										<div class='col-md-2'>
										
										</div>
										 <div class='col-md-6' align='right'><br/>
										<!--<a href='#' onclick='document.getElementById("newTask").style.display="";document.getElementById("res").style.display="none";' class='btn btn-info'>Add New Task</a>
										-->
										</div>
									  </div>
																	
									  </div>								  
							   
							   
								   <div class="table-responsive">								
									 <br/>
										<table class="table table-bordered table-striped" style="font-size:12px;">
											<thead>
												<tr>
													<th>Document From</th>
													<th>Date Provided</th>
													<th>Title</th> 
											</thead> 
											<tbody>
												 
												 <?php
												 
												 
												 
												 
												 
												 
												 
												 while($row = mysql_fetch_array($result1))
												{	 											 
													$docu_id = $row['docu_id']; 
													$repD = $row['representative']; 
													$doc_title = $row['doc_title'];
													$dateu  = $row['date-u'];  	
													$company_name = $row['company_name']; 
												
													$rep = "";
													
														//if ($_GET['typin'] == 'CON')
														//{
														//	$result2 = mysql_query("select representative from contractors where con_id=" . $to_uid );
														//	while($row2 = mysql_fetch_array($result2))
														//	{
														//		$rep = $row2['representative']; 
														//	}
														//}
													//if ($_GET['typin'] == 'CL')
													//	{
														//	$result2 = mysql_query("select representative from organisations where org_id=" . $org_idV );
														//	while($row2 = mysql_fetch_array($result2))
														//	{
														//		$rep = $row2['representative']; 
														//	}
														//}
												
													$typeOf = $_GET['typin'];
												
													echo "<tr>";
													echo "<td>"; if ($_GET['typin'] == 'CON') echo $repD; else echo $company_name; echo "</a></td>";
													echo "<td>";
													echo $dateu;
													echo "</td>";
													echo "<td>";
													echo "<a target='blank' href='";
													
													if ($_GET['typin'] == 'CON') echo "contractor_docs/" . $doc_title;
													
													if ($_GET['typin'] == 'CL') echo "client_docs/" . $doc_title;
													
													 
													echo "'>" . $doc_title . "</a></td>"; 
													echo "</tr>";
												}	 
												 ?>
												 
											</tbody>
										</table>
									</div>
								</div>	
								</div>																			
							</section>
 
                    </div>
                    <!-- /inner content wrapper -->

                </div>
                <!-- /content wrapper -->
                <a class="exit-offscreen"></a>
            </section>
            <!-- /main content -->
        </section>

    </div>
<?php mysql_close($con); ?>
    <!-- core scripts -->
    <script src="plugins/jquery-1.11.1.min.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <script src="plugins/jquery.slimscroll.min.js"></script>
    <script src="plugins/jquery.easing.min.js"></script>
    <script src="plugins/appear/jquery.appear.js"></script>
    <script src="plugins/jquery.placeholder.js"></script>
    <!-- /core scripts -->

    <!-- page level scripts -->
    <script src="plugins/responsive-tables/responsive-tables.js"></script>
    <!-- /page level scripts -->

    <!-- template scripts -->
    <script src="js/offscreen.js"></script>
    <script src="js/main.js"></script>
    <!-- /template scripts -->

    <!-- page script -->
    <!-- /page script -->

</body>
<!-- /body -->

</html>
