
<?php
$ticket_id;
if (isset($ticket_id) && ($ticket_id != ''))
{
    $ticket_model = Ticket::model()->findByPk($ticket_id);
?>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <div>
        <font size="+3">
            <b>Request For Meals:</b>
        </font>
        <font size="6">
            <table  border="0" style="border-collapse:collapse;" cellspacing="0" cellpadding="7" width="678" border="1" align="center">
                <tr height="100">
                    <th width="213" scope="row" align="right">Ticket ID:</th>
                    <td width="262"><?php echo $ticket_model->id; ?></td>
                </tr>
                <tr height="100">
                    <th scope="row" align="right">Geo-market:</th>
                    <td><?php echo $ticket_model->department->location->geomarket->name; ?></td>
                </tr>
                <tr height="100">
                    <th scope="row" align="right">Location:</th>
                    <td><?php echo $ticket_model->department->location->code; ?></td>
                </tr>
                <tr height="100">
                    <th scope="row" align="right">Department:</th>
                    <td><?php echo $ticket_model->department->name; ?></td>
                </tr>
                <tr height="100">
                    <th scope="row" align="right">Request Date:</th>
                    <td><?php echo date('Y-m-d  H:i:s'); ?></td>
                </tr>
                <tr height="100">
                    <th scope="row" align="right">Serving Date:</th>
                    <td><?php echo $ticket_model->date_time; ?></td>
                </tr>
                <tr height="100">
                    <th scope="row" align="right">POS Name:</th>
                    <td><?php echo $ticket_model->pos->name; ?></td>
                </tr>		
                <tr height="100">
                    <th scope="row" align="right">Meal Name:</th>
                    <td><?php echo $ticket_model->schedule->name; ?></td>
                <tr height="100">
                    <th scope="row" align="right">Meals Number:</th>
                    <td><?php echo $ticket_model->quantity; ?></td>
                </tr>
		<tr height="100">
                    <th scope="row" align="right">Reason:</th>
                    <td><?php echo ($ticket_model->issuingReason != null) ? $ticket_model->issuingReason->reason : "" ?></td>
                </tr>
            </table>
        </font>
    </div>
    <br/>
    <br/>
    <br/>

    <div style="height:200px">
        <p >
            <font size="+3">
                To Whom It May Concern. Please issue (<?php echo $ticket_model->quantity; ?>) <?php echo $ticket_model->quantity > 1 ? "meals" : "meal" ?> for the department (<?php echo $ticket_model->department->name; ?>) <br/> on (<?php echo date('Y-m-d', strtotime($ticket_model->date_time)); ?>).
            </font>
        </p>
    </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($ticket_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
        }
?>
