<style>
    table td, table th {
	word-wrap: break-word !important;
    }
</style>
<?php
$id;
if (isset($id) && ($id != '')) {
    $model = ItemRequestHeader::model()->findByPk($id);
?>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <div style="height: 380px;margin-right: 100px">
        <font size="6">
    	<table  border="0" style="border-collapse:collapse;" cellspacing="0" cellpadding="7" width="100%" border="1" align="center">
    	    <tr height="70">
    		<th scope="row" align="left" colspan="4">Request For Items:</th>

    	    </tr>
    	    <tr height="70">
		<th scope="row" align="right" style="width: 155px">Ticket ID:</th>
    		<td style="width: 250px"><?php echo $model->id; ?></td>
    		<th scope="row" align="right" style="width: 100px">Geo-market:</th>
    		<td style="width: 250px"><?php echo $model->location->geomarket->name; ?></td>
    	    </tr>
    	    <tr height="70">
    		<th scope="row" align="right">Request Date:</th>
    		<td><?php echo date('Y-m-d  H:i:s'); ?></td>
    		<th scope="row" align="right">Location:</th>
    		<td><?php echo $model->location->code; ?></td>
    	    </tr>
    	    <tr height="70">
    		<th scope="row" align="right">Serving Date:</th>
    		<td><?php echo $model->date_time; ?></td>
    		<th scope="row" align="right">Department:</th>
    		<td><?php echo $model->department->name; ?></td>
    	    </tr>
    	</table>
        </font>
    </div>
  

    <div style="height:900px">
        <p>
    	<font size="+3" >
                                                                    	    To Whom It May Concern. Please deliver to the department (<?php echo $model->department->name; ?>) <br/> on (<?php echo date('Y-m-d', strtotime($model->date_time)); ?>) the following items:
	</font>
    </p>
    <br/>
    <br/>
    <br/>
    <font size="6">
	<?php
	    $index = 0;
	    if (count($model->itemRequestDetails) <= 10) {
	?>
		<table  border="1" style="border-collapse:collapse;margin-left: 80px" cellspacing="0" cellpadding="7" width="1000" border="1"  >
		    <tr>
			<th scope="row" align="center">Item</th>
			<th width="30%" scope="row" align="center">Quantity</th>
		    </tr>
	    <?php
		foreach ($model->itemRequestDetails as $item_detail) {
	    ?>
		    <tr>
			<td align="center"><?php echo $item_detail->item->name ?></td>
			<td align="center"><?php echo $item_detail->quantity ?></td>
		    </tr>

	    <?php } ?>
    	</table>
	<?php } else {
	?>
		<table  border="0" style="border-collapse:collapse;margin-right: 100px" cellspacing="0" cellpadding="0" width="1200">
		    <tr>
			<td style="vertical-align: top;padding: 0;margin: 0;width: 600px">
			    <table  border="1" style="border-collapse:collapse;" cellspacing="0" cellpadding="7" width="590" border="1"  >
				<tr>
				    <th scope="row" align="center">Item</th>
				    <th width="30%" scope="row" align="center">Quantity</th>
				</tr>
			<?php
			for (; $index < 10; $index++) {
			    $item_detail = $model->itemRequestDetails[$index];
			?>
    			<tr>
    			    <td align="center"><?php echo $item_detail->item->name ?></td>
    			    <td align="center"><?php echo $item_detail->quantity ?></td>
    			</tr>

			<?php } ?>
		    </table>
		</td>
		<td style="vertical-align: top;padding: 0;margin: 0;width: 600px">
		    <table  border="1" style="border-collapse:collapse;" cellspacing="0" cellpadding="7" width="590" border="1" align="right" >
			<tr>
			    <th scope="row" align="center">Item</th>
			    <th width="30%" scope="row" align="center">Quantity</th>
			</tr>
			<?php
			for (; $index < count($model->itemRequestDetails); $index++) {
			    $item_detail = $model->itemRequestDetails[$index];
			?>
    			<tr>
    			    <td align="center"><?php echo $item_detail->item->name ?></td>
    			    <td align="center"><?php echo $item_detail->quantity ?></td>
    			</tr>

			<?php } ?>
		    </table>
		</td>
	    </tr>
	</table>

	<?php } ?>


	        </font>
	    </div>

	    <div style="height:150px">
	        <p>
	    	<b>
	    	    <font size="+3">Requested By:<br/><br/> &ensp;&ensp;&ensp;&ensp;&ensp;</font>
	    	</b>
	    	<font size="6">
	    <?php
		    $user_model = User::model()->findByPk($model->user_id);
		    if ($user_model->role == 'Food Manager') {
			$person_model = Person::model()->findByAttributes(array('alias' => $user_model->username));
			echo $person_model->name;
		    } else {
			echo $user_model->identifier;
		    }
	    ?>
		</font>
	    </p>
	</div>
	<br/><br/>
	<div style="height:150px">
	    <p>
		<b>
		    <font size="+3">Signature:</font>
		</b>
	    </p>
	</div>

<?php
		}
?>
