<?php
$this->widget('ext.PlNavbar', array(
    'brand'=>__('CSV_IMPORT_NAV_BAR_HEADER'),
    'helpBtnUrl' => $helpBtnUrl,
    'htmlOptions'=>array(
        'data-translation-id'=>'CSV_IMPORT_NAV_BAR_HEADER',
    ),
   'items'=>array(
        array(
            'class'=>'bootstrap.widgets.TbMenu',
            'items'=>array(
		'---',
                array(
		  'label'=>__('CDR_NAVBAR_BACK'), 'url'=>$returnUrl,
		  'icon'=>'arrow-left',
		  'linkOptions'=>array(
		      'id'=>'back_button',
		      'data-target'=>'#',
		      'data-translation-id'=>'CDR_NAVBAR_BACK'
		  ),
		),
            ),
        ),
    )
));

$form=$this->beginWidget('CActiveForm', array(
    #'id'=>'addresses-form',
    'enableAjaxValidation'=>false,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
)); 
/*
Here you have the possibility to upload a file in CSV format to adopt the entries in an addressbook.
Before the import starts you will be presented a preview.
In the preview you can choose, if the existing address book shall be extended or replaced.
*/
echo "<div class='alert alert-block alert-info' data-translation-id='CSV_IMPORT_SELECT_FILE_INFO_TEXT'>";
echo  __("CSV_IMPORT_SELECT_FILE_INFO_TEXT"); 
echo "</div>";
	// Set accepted file formats: http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#attr-input-accept
	echo "<div class='selectFileForm'>";
	echo "<div id='fileField'>"; 
	echo CHtml::FileField('file', '', array('accept'=>"text/csv"));
	echo "</div>";
	echo "<div id='submitButton'>";
        echo CHtml::Button(
          'CSV-Import',
              array(
                  'submit'=>$this->createUrl(
                      '/addressbookImportExport/default/selectColumns',
                          $params
                  ),
		  'class'=>'btn btn-primary',
		  'onclick'=>'if(!$("#file").val()){alert("'.__('CSV_SELECT_FILE_NO_FILE_SELECTED').'");return false;}'
              )
        );
        echo "</div>";
    echo "</div>"; // selectFileForm end ! 
$this->endWidget();
if (app()->user->translateMode) {
  echo "<i data-translation-id='INVALID_CSV_DATA'>INVALID_CSV_DATA = ".__('INVALID_CSV_DATA')."</i><br><br>";
  echo "<i data-translation-id='CSV_SELECT_FILE_NO_FILE_SELECTED'>CSV_SELECT_FILE_NO_FILE_SELECTED = ".__('CSV_SELECT_FILE_NO_FILE_SELECTED')."</i><br><br>";
  
  echo "<i data-translation-id='CSV_IMPORT_NO_SELECT_VALUES_FOUND'>CSV_IMPORT_NO_SELECT_VALUES_FOUND = ".__('CSV_IMPORT_NO_SELECT_VALUES_FOUND')."</i><br><br>";
  echo "<i data-translation-id='CSV_IMPORT_SUCCESS_MESSAGE'>CSV_IMPORT_SUCCESS_MESSAGE = ".__('CSV_IMPORT_SUCCESS_MESSAGE')."</i><br><br>";
  echo "<i data-translation-id='CSV_IMPORT_SUCCESS_BUTTON'>CSV_IMPORT_SUCCESS_BUTTON = ".__('CSV_IMPORT_SUCCESS_BUTTON')."</i><br><br>";
  echo "<i data-translation-id='CSV_IMPORT_ABORT_BUTTON'>CSV_IMPORT_ABORT_BUTTON = ".__('CSV_IMPORT_ABORT_BUTTON')."</i><br><br>";
  echo "<i data-translation-id='PROGRESS_BAR_HEADER_PROCESS'>PROGRESS_BAR_HEADER_PROCESS = ".__('PROGRESS_BAR_HEADER_PROCESS')."</i><br><br>";
  echo "<i data-translation-id='PROGRESS_BAR_HEADER_SUCCESS'>PROGRESS_BAR_HEADER_SUCCESS= ".__('PROGRESS_BAR_HEADER_SUCCESS')."</i><br><br>";
}
