<?php
$cs = Yii::app()->clientScript;
$cssCoreUrl = $cs->getCoreScriptUrl();
$cs->registerCssFile($cssCoreUrl . '/jui/css/base/jquery-ui.css');
$cs->registerCoreScript('jquery.ui');
$cs->registerScriptFile($cssCoreUrl . '/jui/js/jquery-ui.min.js', Yii::app()->clientScript->coreScriptPosition);
?>

<?php
/* @var $this InvoiceController */
/* @var $model Invoice */

$this->breadcrumbs = array(
    yii::t('default', 'TIDs Management') => array('dashboardLayout/tids'),
    yii::t('default', 'Invoices') => array('index'),
    $model->number,
);


$this->widget('bootstrap.widgets.TbAlert');
?>


<?php
$this->widget('bootstrap.widgets.TbDetailView', array(
    'data' => $model,
    'type' => 'striped',
    'cssFile' => Yii::app()->request->baseUrl . '/css/general/CDetailView/' . Yii::app()->language . '/styles.css',
    'attributes' => array(
	array(
	    'type' => 'raw',
	    'name' => 'tid_id',
	    'value' => CHtml::link($model->tid->tid_no, array('tid/view', 'id' => $model->tid_id))
	),
	'number',
	array(
	    'type' => 'raw',
	    'name' => 'value',
	    'value' => ($model->value != '') ? $model->value . ' USD' : ''
	),
	'description',
	'comments',
	array(
	    'type' => 'raw',
	    'name' => 'last_edited_by',
	    'value' => ($model->last_edited_by == '') ? '' : User::getUsernameById($model->last_edited_by)
	),
    ),
));
echo "<br/>";
echo "<br/>";

$this->beginWidget('yiiwheels.widgets.box.WhBox', array(
    'title' => Yii::t('default', 'Assets'),
    'headerIcon' => 'icon-th-list',
    'htmlOptions' => array(
	'style' => 'min-width: 1180px !important;',
    ),
));
Yii::app()->controller->renderPartial('/asset/viewAssetInInvoice', array('model' => new VAsset('search'), 'invoice_id' => $model->id, 'page_name' => 'view_invoice'));
$this->endWidget();
?>


<br />

<?php echo CHtml::link(Yii::t('default', 'View TID'), array('/tid/view', 'id' => $model->tid_id), array('class' => 'btn primary')); ?>
&nbsp;
<?php
if (!Yii::app()->user->isGuest) {
    echo CHtml::link(Yii::t('default', 'Add New Invoice'), array('create'), array('class' => 'btn primary'));
    echo "&nbsp;";
}
?>

<?php
if (!Yii::app()->user->isGuest) {
    echo CHtml::link(Yii::t('default', 'Add Asset'), array('/asset/create', 'invoice_id' => $model->id, 'tid_id' => $model->tid_id), array('class' => 'btn primary'));
    echo "&nbsp;";
}
?>

<?php
if (!Yii::app()->user->isGuest) {
    echo CHtml::link(Yii::t('default', 'Manage Assets'), array('/asset/index', 'invoice_id' => $model->id), array('class' => 'btn primary'));
    echo "&nbsp;";
}
?>

<?php
if (!Yii::app()->user->isGuest) {
    echo CHtml::link(Yii::t('default', 'Edit'), array('update', 'id' => $model->id), array('class' => 'btn primary'));
    echo "&nbsp;";
}
?>

<?php
if (!Yii::app()->user->isGuest) {
    echo CHtml::link(Yii::t('default', 'Delete'), array('/invoice/delete', 'id' => $model->id), array(
	'class' => 'btn primary', 'id' => 'delete_btn',
	'onclick' => 'return confirm("' . yii::t("zii", 'Are you sure you want to delete this item?') . '");'));
    echo "&nbsp;";
}
?>

<?php echo CHtml::link(Yii::t('default', 'Back'), array('index'), array('class' => 'btn primary')); ?>
