<?php

	//die("test");

//ini_set("display_errors", 1);
//error_reporting( E_ALL);
if(stripos($_SERVER['SCRIPT_FILENAME'],"/admin/")>0){
	include("../connect.php");
	include("../session.php");
	$isAdmin = $_SESSION['isAdmin'];
}else{
	include("./connect.php");
	$isAdmin= false;
	include("./functions.php");
}

//die();

$assignment = new Assignment($_REQUEST['id']);
if (!$isAdmin) {
	if(isset($_REQUEST['key'])){
		if($assignment->getTokenKey() != $_REQUEST['key']){
			header("Location: index.php");
		}
	}else{
		header("Location: index.php");
	}

}




$title = "Assignment - A" . $assignment->AssignmentID;


 ?>
 <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title> <?=$title . " - " . $config['CompanyName'] ?></title>

      <!-- Bootstrap -->
      <link href="<?= $root ?>css/bootstrap.min.css" rel="stylesheet">
      <link rel="stylesheet" href="<?= $root ?>css/bootstrap-combobox.css" />

      <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src="<?= $root ?>js/bootstrap.min.js"></script>
        	 <script src="<?= $root ?>js/bootstrap-combobox.js"></script>
            <script type="text/javascript">
              $(document).ready(function(){
                //$('.combobox').bscombobox();
				<?php
				if(isset($_REQUEST['print']) && $_REQUEST['print'] == "true"){
				?>

				window.print();
				setTimeout(function(){
					if(confirm('Close?')){
						window.close();
					}else{

					}

				}, 1000);

				<?php
				}
				?>

              });
            </script>

      <![endif]-->
 	<link rel="stylesheet" href="<?= $root ?>css/styles.css"/>
	<style>
		#invoiceItemsTable , #invoiceItemsTable tr, #invoiceItemsTable tr th, #invoiceItemsTable tr td {
			border: solid;
			border-width: thin;
			border-color: black;
		}
		.invoiceItemsTable , .invoiceItemsTable tr, .invoiceItemsTable tr th, .invoiceItemsTable tr td {
			border: solid;
			border-width: thin;
			border-color: black;
		}
		.invoiceItemsTable{
			width: 100%;

		}
		.description_cell{
			max-width: 100px;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
		@media print {
  a[href]:after {
    content: none
  }
}
	</style>
    </head>
    <body>
    <style>
		.table-bordered > tbody > tr > td, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > td, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > thead > tr > th {
    border: thin solid black !important;
}

	</style>
    <!-- Stack the columns on mobile by making one full-width and the other half-width -->
 <div class="container-fluid" style="margin-top: -50px;">

	<!---INSERT HEADER 12345-->
	<?= insertHeader() ?>


 	</div>

 <style>
	.borderless {
		border: hidden;
		border-top: hidden;
		border-left-style: none;
		border-right-style: none;
		border-bottom-style: none;
		line-height: 1;
	}
	.borderless>td {
		line-height: 1;
	}

	.borderless td span {
		line-height: 1;
	}
 </style>
 <style type="text/css" media="print">
	body { margin: 0;  font-size: 1em }


 </style>
 </div>
	<div>
    <div class="panel-body">


    </div>
  </div>

		<div style="" class="row">

			<div class="col-xs-6">

				<b>Received By:</b>________________________________________________________
			</div>
			<div class="col-xs-3">

				<b>Date:</b>______________________________
			</div>

        </div>

		<div class="row">

				<style>
					.shipcontainer {
						position: relative;
						text-align: center;
						color: red;
					}
					.shipcrate_number{

						font-size: 22px;

					}
				</style>

			</div>
			<div class="row">
				<center>
					<span><big><b><?= $config["CompanySlogan"] ?></b></big></span>
				</center>
			</div>
    </body>

  </html>

  <?php


  function insertHeader($page = 1){
		global $assignment;
	?>
	<h2><a href="./"><img src="/img/Logo_250.png"></a></h2>
	<div style="margin-left: 10px; margin-top: -10px; margin-bottom: 10px">
	<?= $config["PostalAddess1"] ?> &#x25cf; <?= ($config["PostalAddess2"]!=""?($config["PostalAddess2"] . "&#x25cf;"):"") ?> <?= $config["PostalCity"] ?>,<?= $config["PostalState"] . " " . $config["PostalZip"] ?><br>
		<?= $config["OrderEmail"] ?><br>
		<?= $config["CompanyPhone"] ?><br>

	</div>
 	<div class="row">
  	<div class="col-xs-5">
			<p style="">
				<div style="font-size: 15px;"><b>Address: </b><br></div>
 	  		<div style="height: 100px; border: none; border-width: thin; font-size: 12px;  padding-left: 5px;">
					<b><?= $assignment->ShipToName; ?></b><br>
					<?= $assignment->ShipToAddress1?$assignment->ShipToAddress1 . "<br>":"" ?>
					<?= $assignment->ShipToAddress2?$assignment->ShipToAddress2 . "<br>":"" ?>
					<?= $assignment->ShipToCity . "," . $assignment->ShipToState . " " . $assignment->ShipToZip ?>
				</div>
			</p>
	  </div>
		<div class="col-xs-5">
			<p style="">
				<div style="font-size: 15px;"><b>Contact: </b><br></div>
 	  		<div style="height: 100px; border: none; border-width: thin; font-size: 12px;  padding-left: 5px;">
					<b><?= $assignment->ContactName; ?></b><br>
					<?= $assignment->ContactPhone ?>
				</div>
			</p>
	  </div>

 	  <div class="col-xs-2" style="text-align: center; float: right; position:  absolute; margin-top: -110px;width: 200px; right: 20px; ">
 		  <h2>
			  Assignment
			  <br>
			  <b>A<?= $assignment->AssignmentID ?></b>
		  </h2>
 		  <p>
	 		  <b>Date: </b><?= date("m/d/Y g:i a",strtotime($assignment->AssignmentDate)) ?><br>
				<b>Delivery Date: </b><?= ($assignment->DeliveryDate)?date("m/d/Y",strtotime($assignment->DeliveryDate)):"TBD" ?><br>
				<img src="/assets/barcode.php?text=A<?= $assignment->AssignmentID ?>" alt="A<?= $assignment->AssignmentID ?>" />
 		  </p>
 	  </div>
	</div>
	<div class="row">
		<div class="col-xs-12">
			<h4><b><?= $assignment->AssignmentTitle ?></b></h4>
			<h5><?= $assignment->AssignmentText ?></h5>
		</div>
	</div>
</div>


	<?php
  }

  ?>
