- $currentUrl = Yii::app()->createAbsoluteUrl($this->route,$context)

- $vehicleSources = paramdeep('plateAuthorizations','vehicleSources')
- if($vehicleSources == null || count($vehicleSources) <= 0)
  - $vehicleSources = array()
- else
  - $vehicleSources = array_merge(array('' => ''), $vehicleSources)

- $hasData = isset($vehicles) && count($vehicles->data)>0

- $paramDescription = array_get($_REQUEST,"v_description")
- $paramNationality = array_get($_REQUEST,"v_nationality")
- $paramClass = array_get($_REQUEST,"v_class")
- $paramSource = array_get($_REQUEST,"v_source",paramdeep('plateAuthorizations','default','vehicleSource'))
- $paramAction = array_get($_REQUEST,"v_action")
- $paramNote = array_get($_REQUEST,"v_note")

-if(count($vehicleSources)>0)
  - if(!array_key_exists(paramdeep('plateAuthorizations','default','vehicleSource'),$vehicleSources))
    -$vehicleSources[paramdeep('plateAuthorizations','default','vehicleSource')] = paramdeep('plateAuthorizations','default','vehicleSource')


.page-header
  %h2
    %i.icon-truck
    =t('Vehicles')

%h5
  - $navigate_url_list = Yii::app()->createAbsoluteUrl('plateAuthorization')
  %a(href="#{$navigate_url_list}")
    %i.icon-file-text-alt
    =$objList->name
  - $navigate_url_user = Yii::app()->createAbsoluteUrl($this->route,array('plateListId'=>$plateListId,'step'=>'1'))
  %i.icon-long-arrow-right 
  %a(href="#{$navigate_url_user}")
    %i.icon-user
    ="$objOwner->Nome $objOwner->Cognome"
  %i.icon-long-arrow-right
  %i.icon-truck
  =t('Select vehicle')
  %i.icon-long-arrow-right
  %font(color="gray")
    %i.icon-time
    =t('Select validity period')
  %i.icon-long-arrow-right 
  %font(color="gray")
    %i.icon-ok-circle
    =t('Select plate authorization')

- $goback_url = Yii::app()->createAbsoluteUrl($this->route,array('plateListId'=>$plateListId,'step'=>'1'))
  
.row
  .form-box 
    - $form = $this->beginWidget('bootstrap.widgets.TbActiveForm',       |
                array(                                                     |
                'id'=>'vehicle-search-form',                                  |
                'action' => Yii::app()->createUrl($this->route),           |
                'method' => 'GET',           |
              ))                                                           |

    %input(type="hidden" name="plateListId" value="#{$plateListId}")
    %input(type="hidden" name="ownerId" value="#{$ownerId}")
    %input(type="hidden" name="step" value="2")
    %input(type="hidden" name="action" value="search")

    %h3
      =t("Search vehicle")

    %input(type="text" name="what" value="#{$what}")
    %a(href="#{$currentUrl}")
      %i.icon-remove-sign
        
    - $this->endWidget()

    
    - if ($hasData)

      .tableContainer.pagination-data-container
        %table.table.table-condensed
          %thead
            %tr
              %th
              %th= Vehicle::model()->getAttributeLabel('Descrizione')
              %th= Vehicle::model()->getAttributeLabel('Targa')
              %th= Vehicle::model()->getAttributeLabel('Nationality')
              %th= Vehicle::model()->getAttributeLabel('Classe')
              %th= Vehicle::model()->getAttributeLabel('category')
              %th= Vehicle::model()->getAttributeLabel('epoch')
              %th= t('Actions')
          
          %tbody
            - foreach($vehicles->data as $vehicle)
              - $vehicle_url = Yii::app()->createAbsoluteUrl($this->route,array('plateListId'=>$plateListId,'step'=>'3','ownerId'=>$ownerId,'vehicleId'=>$vehicle->ID))
              - $delete_url = Yii::app()->createUrl('plateAuthorization/whiteListWizardDelete',array('listId'=>$plateListId, 'objType'=>'vehicle', 'objId'=>$vehicle->ID, 'returnUrl'=>$currentUrl))
              %tr
                %td
                  %a(href="#{$vehicle_url}")
                    %i.icon-eye-open
                %td
                  %a(href="#{$vehicle_url}")
                    = $vehicle->Descrizione
                %td
                  %a(href="#{$vehicle_url}")
                    = $vehicle->Targa
                %td
                  = $vehicle->Nationality
                %td
                  = t($vehicle->Classe)
                %td
                  = t($vehicle->category)
                %td
                  = $vehicle->epoch
                %td
                  -if(user()->checkAccess('vehicle_management') && user()->checkAccess('vehicle_update'))
                    %a(href="#{url('vehicle/update', array('id'=>$vehicle->ID))}")
                      %i.icon-pencil
                  -if(Yii::app()->user->checkAccess("plate_auth_delete"))
                    %a(href="#{$delete_url}" onclick="return confirm('#{t('Are you sure you want to delete this item?')}')")
                      %i.icon-trash

      - if (isset($vehicles->pagination))
        .pagination.pagination-links-container
          - $this->widget('bootstrap.widgets.TbPager', array('pages' => $vehicles->pagination))

    - else

      %h4= Yii::t("app", "No results")

- if(true)
  %br
  .row
    .form-box 
      - $form = $this->beginWidget('bootstrap.widgets.TbActiveForm',       |
                array(                                                     |
                'id'=>'vehicle-create-form',                                  |
                'action' => Yii::app()->createUrl($this->route),           |
                'method' => 'POST',           |
              ))                                                           |

      %input(type="hidden" name="plateListId" value="#{$plateListId}")
      %input(type="hidden" name="ownerId" value="#{$ownerId}")
      %input(type="hidden" name="step" value="2")
      %input(type="hidden" name="action" value="create")

      %h3=t("Create vehicle")

      %h5=Vehicle::model()->getAttributeLabel('Descrizione')
      %input(type="text" name="v_description" value="#{$paramDescription}")
      =t("(for example: 'FIAT Panda')")

      %h5
        =Vehicle::model()->getAttributeLabel('Targa')
        %font(color="red")='*'
      %input.touppercase(type="text" name="v_plate" value="#{$what}")

      %h5
        =Vehicle::model()->getAttributeLabel('Nationality')
        %font(color="red")='*'
      != CHtml::dropDownList('v_nationality', $paramNationality, array_merge(array('' => ''), CountryList::localized()), array('class'=>'span2  chzn-select', 'data-placeholder' => Yii::t('app', 'Country...')));

      %h5=Vehicle::model()->getAttributeLabel('Classe')
      != CHtml::dropDownList('v_class', $paramClass, array_merge(array('' => ''), VehicleTypes::localized()), array('class'=>'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Class...')));
      
      %h5=Vehicle::model()->getAttributeLabel('source')
      -if(count($vehicleSources)>0)
        != CHtml::dropDownList('v_source', $paramSource, $vehicleSources, array('class'=>'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Source...')));
      -else
        %input(type="text" name="v_source" value="#{$paramSource}")

      %h5=Vehicle::model()->getAttributeLabel('action')
      != CHtml::textArea('v_action', $paramAction, array('class'=>'span2', 'maxlength' => '250'));

      %h5=Vehicle::model()->getAttributeLabel('note')
      != CHtml::textArea('v_note', $paramNote, array('class'=>'span2', 'maxlength' => '250'));

      %br
      %br
      
      %input(type="submit" name="create" value="#{t('Create')}")
        
      - $this->endWidget()

%br
%a(href="#{$goback_url}")
  %h4=t('Go back')