<?php
define('Admin_USER',true);
session_start();
if(!isset($_SESSION['adm1n']) || $_SESSION['adm1n']['Nbr'] == ''){
  
       header("Location: ../misc/default.php");
       exit;
       
}
require_once("../../includes/php/defines.php");
require_once("../../includes/php/classes/mainClass.php");
require_once("../../includes/php/classes/resourceClass.php");

$res = new resourceClass;

$docs = $res->getPDF_Docs();
?>
<section>
<div class="container-fluid">
    <div class="container">
        <div class="col-md-4">
            <div class="col-md-12 result-heading">
                <div class="rh-form">
                    <div class="col-md-10"> 
                        <h1>&nbsp;</h1>
                        <form id="Admin_Form">                            
                            <div class="form-group gallery-btn-group" id="Add_PDF">
                                <input type="button" value="Upload New PDF" onclick="initiatePopup('upload-pdf');" class="gallery-btn">
                            </div> 
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-8">
            <div class="col-md-12 result-heading">
                <h1 id="ResultsTitle" name="ResultsTitle">Uploaded PDF Documents</h1>&nbsp;
              <div id="Animation">
                  <div class="blockG" id="rotateG_01"></div>
                  <div class="blockG" id="rotateG_02"></div>
                  <div class="blockG" id="rotateG_03"></div>
                  <div class="blockG" id="rotateG_04"></div>
                  <div class="blockG" id="rotateG_05"></div>
                  <div class="blockG" id="rotateG_06"></div>
                  <div class="blockG" id="rotateG_07"></div>
                  <div class="blockG" id="rotateG_08"></div>                                            
              </div>
              <div id="Result" style="margin-bottom:25px;"></div>               
            </div>
              <div id="RowContainer">
              <?php             
                    if($docs[0]['Nbr'] != ''){

                           for($i=0;$i<count($docs);$i++){

                                  echo '<div class="col-md-12';
                                  if($i == 0 || $i%2 == 0) { echo ' light-white'; }
                                  echo '" id="Row_'.$docs[$i]['Nbr'].'" name="Row_'.$docs[$i]['Nbr'].'">';
                                  echo '<div class="result-form">';
                                  echo '<h2>'.$docs[$i]['Name'].' &nbsp;&nbsp; <em style="font-size:12px; font-weight:normal;">Uploaded: '.date("M-D-Y",$docs[$i]['Upload_Date']).'</em></h2>';
                                  echo '<p>';
                                  echo '<button onclick="copyToClipBoard(\''.$docs[$i]['Nbr'].'\')" class="clipboard_btn">COPY URL TO CLIPBOARD</button>';
                                  echo '<input type="text" id="URL_'.$docs[$i]['Nbr'].'" name="URL_'.$docs[$i]['Nbr'].'" value="'.$docs[$i]['Url'].'" style="display:block; clear:both; margin-bottom:10px;">';                                  
                                  echo '</p>';
                                  echo '<p>[ <span class="delete" title="Delete '.$docs[$i]['Name'].'" onclick="deleteRow(\'Delete-PDF\',\''.$docs[$i]['Nbr'].'\')">DELETE</span> ]</p>';
                                  echo '</div>';
                                  echo '</div>';

                           }

                    }else{
                           
                           echo '<div class="col-md-12 light-white><div class="result-form"><h2>There are no PDF documents uploaded</h2></div></div>';
                           
                    }  
               ?>
              </div>            
        </div>
    </div>
</div>
</section>