<style>

    #Tid_value {
        width: 170px !important;
    }

    #table-container {
        margin-left: 175px !important;
    }

    #buttons-container {
        margin-left: 175px !important;
    }

    .bootstrap-widget-header {
        text-align: center !important;
    }
</style>
<script language="javascript" type="text/javascript">
    var view_url = "<?php echo Yii::app()->createAbsoluteUrl("/tid/view"); ?>";
    var create_url = "<?php echo Yii::app()->createAbsoluteUrl("/invoice/create"); ?>";
    

</script>
<?php
/* @var $this TidController */
/* @var $model Tid */
/* @var $form CActiveForm */

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'segment-form',
    'enableAjaxValidation' => false,
        ));

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


<div id="flash-msg">
    <br>
    <?php $this->widget('bootstrap.widgets.TbAlert'); ?>
</div>

<table style="width: 100%; margin-bottom: 15px;" id="table-container">
    <tr>
        <td>
            <?php
            $this->beginWidget('yiiwheels.widgets.box.WhBox', array(
                'title' => Yii::t('default', 'TID'),
                'headerIcon' => 'icon-th-list',
                'htmlOptions' => array(
                    'style' => 'width: 400px !important;margin-bottom: 6px !important;',
                ),
                'htmlContentOptions' => array(
                    'style' => 'height: 680px !important; ',
                ),
            ));

            echo $form->textFieldControlGroup($model, 'tid_no', array('size' => 20, 'maxlength' => 20));

            echo $form->labelEx($model, 'initial_issue_date');

            $this->widget('yiiwheels.widgets.datepicker.WhDatePicker', array(
                'model' => $model,
                'id' => 'initial_issue_date',
                'attribute' => 'initial_issue_date',
                'pluginOptions' => array(
                    'format' => 'yyyy-mm-dd'
                )
            ));


            echo $form->textFieldControlGroup($model, 'customs_letter_no', array('size' => 15, 'maxlength' => 15));

            echo $form->labelEx($model, 'customs_letter_date');

            $this->widget('yiiwheels.widgets.datepicker.WhDatePicker', array(
                'model' => $model,
                'id' => 'customs_letter_date',
                'attribute' => 'customs_letter_date',
                'pluginOptions' => array(
                    'format' => 'yyyy-mm-dd'
                )
            ));




            echo $form->textFieldControlGroup($model, 'shipment_ref', array('size' => 20, 'maxlength' => 20));

            echo $form->dropDownListControlGroup($model, 'point_of_entry_id', PointOfEntry::getNamesForDropDown(), array('empty' => Yii::t('default', 'Select Point of Entry')));

            echo $form->labelEx($model, 'original_documnets_delivery_date');

            $this->widget('yiiwheels.widgets.datepicker.WhDatePicker', array(
                'model' => $model,
                'id' => 'original_documnets_delivery_date',
                'attribute' => 'original_documnets_delivery_date',
                'pluginOptions' => array(
                    'format' => 'yyyy-mm-dd'
                )
            ));            



            echo $form->textFieldControlGroup($model, 'value', array('size' => 15, 'maxlength' => 15,'append' => 'USD'));
            ?>

            <?php
            $this->endWidget();
            ?>
        </td>
        <td>
            <?php
            $this->beginWidget('yiiwheels.widgets.box.WhBox', array(
                'title' => Yii::t('default', 'TID Status'),
                'headerIcon' => 'icon-th-list',
                'htmlOptions' => array(
                    'style' => 'width: 400px !important;margin-bottom: 6px !important;',
                ),
                'htmlContentOptions' => array(
                    'style' => 'height: 680px !important;',
                ),
            ));

            Yii::app()->controller->renderPartial('/tidStatus/_form', array('model' => $model, 'form' => $form, 'from' => ''));

            $this->endWidget();
            ?>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <?php
            $this->beginWidget('yiiwheels.widgets.box.WhBox', array(
                'title' => Yii::t('default', 'TID Documents'),
                'headerIcon' => 'icon-th-list',
                'htmlOptions' => array(
                    'style' => 'width: 815px !important;margin-bottom: 6px !important;',
                ),
                'htmlContentOptions' => array(
                    'style' => 'min-height: 250px !important;',
                ),
            ));

            Yii::app()->controller->renderPartial('/document/index', array('model' => $model, 'form' => $form, 'from_view' => null));

            $this->endWidget();
            ?>
        </td>
    </tr>
</table>

<div class="row buttons view-button" id="buttons-container">
    <?php
    echo CHtml::ajaxSubmitButton(
            Yii::t('default', 'Save'), ($model->isNewRecord) ? array('create') : array('update', 'id' => $model->id), array(
        'type' => "post",
        'success' => 'js:function(data) {                            
			   if(data.indexOf("</div>") != -1){
                                $("#flash-msg").html(data);
				$("html, body").animate({ scrollTop: 0 }, "slow");
				}
                           else
                                window.location.href=addParam(view_url,"id",data);


		    }',
            ), array('type' => 'submit', 'class' => 'btn', 'name' => 'submit', 'id' => 'submit')
    );
    ?>
    &ensp;

    <?php
    echo CHtml::ajaxSubmitButton(
            Yii::t('default', 'Save and Add Invoice'), ($model->isNewRecord) ? array('create') : array('update', 'id' => $model->id), array(
        'type' => "post",
        'success' => 'js:function(data) {
			   if(data.indexOf("</div>") != -1){
                                $("#flash-msg").html(data);
				$("html, body").animate({ scrollTop: 0 }, "slow");
				}
                           else
                                window.location.href=addParam(create_url,"tid_id",data);


		    }',
            ), array('type' => 'submit', 'class' => 'btn', 'name' => 'submit', 'id' => 'submitNew')
    );
    ?>
    &ensp;
    <?php echo CHtml::link(Yii::t('default', 'Cancel'), array('index'), array('class' => 'btn')); ?>
</div>

<?php $this->endWidget(); ?>
	    

