<?php
/* @var $this TicketController */
/* @var $model Ticket */

$this->breadcrumbs = array(
    yii::t('default', 'Requests') => array('/dashboard/requests'),
    Yii::t('default', 'Tickets') => array('index'),
    $model->id,
);
$this->widget('bootstrap.widgets.TbAlert');


//echo CHtml::link(yii::t('default', 'Show As PDF'), array('ConvertToPDF', 'ticket_id' => $model->id));
//echo CHtml::link('HTML preview', array('ConvertToPDF', 'preview' => 1, 'ticket_id' => $model->id));
if ($model->issued_at_server == 1)
    echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/css/flags/pdf.png'), array('ConvertToPDF', 'download' => 1, 'ticket_id' => $model->id), array('id' => 'PDF', 'style' => 'background-image:url(css/flags/pdf.png)'));


$this->widget('ext.bootstrap.widgets.TbDetailView', array(
    'type' => 'striped',
    'cssFile' => Yii::app()->request->baseUrl . '/css/general/CDetailView/' . Yii::app()->language . '/styles.css',
    'data' => $model,
    'attributes' => array(
        'id',
        array(
            'type' => 'raw',
            'label' => yii::t('deafult', 'Lcation'),
            'value' => $model->department->location->code,
        ),
        array(
            'type' => 'raw',
            'name' => 'department_id',
            'value' => $model->department->name,
        ),
        array(
            'type' => 'raw',
            'name' => 'pos_id',
            'value' => $model->pos->name,
        ),
        array(
            'type' => 'raw',
            'name' => 'schedule_id',
            'value' => $model->schedule->name
        ),
        'date_time',
        'quantity',
        array(
            'type' => 'raw',
            'name' => 'issuing_reason_id',
            'value' => $model->issuingReason ? $model->issuingReason->reason : "",
            'visible' => $model->issuingReason != null,
        ),
    ),
));
?>
<!--<script>
$(document).ready(function(){
$("#a").click(function(event){
alert("Thanks for visiting!");
});
});
</script>-->


<?php
if ($new_ticket == 1)
{
    ignore_user_abort(TRUE);
?>
    <script type="text/javascript">
        $(document).ready(function(){<?php
    echo CHtml::ajax(array(
        'type' => 'POST',
        'data' => 'ajax:true}',
        'url' => CController::createUrl('ticket/sendTicketEmail', array('ticket_id' => $model->id)),
            )
    );
?>
                                });
    </script>
<?php } ?>
