<ul class="clearfix form-ul material">

    <li class="col-sm-6">
        <?php echo $form->hiddenField($modeldoc, 'id'); ?>
        <?php echo $form->hiddenField($modeldoc, 'supplier_id'); ?>
        <?php echo $form->textField($modeldoc, 'document_no', array('title' => 'Document No', 'data-label' => 'Document No ')); ?>
        <?php echo $form->error($modeldoc, 'document_no'); ?>
    </li>
    <li class="col-sm-6">
        <?php // echo CHtml::dropDownList('document_type', '', MasDocumentType::getDocumenttypes(), array('class' => 'tooltipster', 'title' => 'Document Name','data-label'=>'Document Name')); ?>
        <?php echo $form->dropDownList($modeldoc, 'document_type', MasDocumentType::getDocumenttypes(), array('title' => 'Document Name', 'data-label' => 'Document Name')); ?>
        <?php echo $form->error($modeldoc, 'document_type'); ?>
    </li>
    <?php /*  <li class="col-sm-6">
      <?php  if($modeldoc->from_date!='' && $modeldoc->from_date !='0000-00-00'){
      $modeldoc->from_date = date("d/m/Y",strtotime($modeldoc->from_date));
      }
      echo $form->textField($modeldoc, 'from_date', array('class'=>'datepicker','title' => 'From Date','data-label'=>'From Date ')); ?>
      <?php echo $form->error($modeldoc, 'from_date'); ?>
      </li><?php */ ?>

    <li class="col-sm-6">
        <?php
        if ($modeldoc->to_date != '' && $modeldoc->to_date != '0000-00-00') {
            $modeldoc->to_date = date("d/m/Y", strtotime($modeldoc->to_date));
        }
        echo $form->textField($modeldoc, 'to_date', array('class' => 'datepicker', 'title' => 'To Date', 'data-label' => 'Expiry Date '));
        ?>
<?php echo $form->error($modeldoc, 'to_date'); ?>
    </li>
    <li class="col-sm-6">
        <?php
        /* echo $form->labelEx($modeldoc, 'document');
          $allowedExtensions = array("jpg","png","doc","docx","xls","xlsx","pdf","bmp","jpeg");
          $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => rand(),
          'config' => array('action' => Yii::app()->createUrl(Yii::app()->controller->id . '/UploadCustomerDocuments',
          array('folder' => 'uploads/documents')), 'multiple' => false,
          'allowedExtensions' => $allowedExtensions, 'sizeLimit' => 1 * 1024 * 1024,
          'onStart' => "js:function(){}",
          'class' => 'pull-right',
          'onComplete' => "js:function(id, fileName, responseJSON){
          var img  = '';
          if(responseJSON.fileType == 'jpg'){

          }
          $('.icon_images').html('<div class=\"each_image\"><input type=\"text\" value=\"'+responseJSON.filename+'\" name=\"CustomerDocs[document]\"><img width=\'100\' height=\'100\' src=\"" . Yii::app()->baseUrl . "/uploads/documents/'+responseJSON.filename+'\" />');                                                                    }",))); */


        echo $form->labelEx($modeldoc, 'document');
        $allowedExtensions = array("jpg", "png", "doc", "docx", "xls", "xlsx", "pdf", "bmp", "jpeg");
        $this->widget('ext.EAjaxUpload.EAjaxUpload', array(
            'id' => rand(),
            'config' => array(
                'action' => Yii::app()->createUrl(Yii::app()->controller->id . '/UploadSupplierDocuments',
                        array('folder' => 'uploads/supplierdocuments')),
                'multiple' => false,
                'allowedExtensions' => $allowedExtensions,
                'sizeLimit' => 2 * 1024 * 1024,
                'onStart' => "js:function(){}",
                'class' => 'pull-right',
                'onComplete' => "js:function(id, fileName, responseJSON){
                                var fileType  = responseJSON.fileType;
                                if(responseJSON.success == true){
                                    $('.qq-upload-failed-text').text('Success');
                                }
                                else{
                                   $('.qq-upload-failed-text').text('Failed');
                                }

                                if(fileType == 'jpg' || fileType == 'png' || fileType == 'jpeg'){
                                    $('.icon_images').html('<div class=\"each_image\"><input type=\"hidden\" value=\"'+responseJSON.filename+'\" name=\"SupplierDocs[document]\"><img width=\'100\' height=\'100\' src=\"" . Yii::app()->baseUrl . "/uploads/supplierdocuments/'+responseJSON.filename+'\" />');
                                }
                                else{
                                    $('.icon_images').html('<div class=\"each_image\"><input type=\"hidden\" value=\"'+responseJSON.filename+'\" name=\"SupplierDocs[document]\">');
                                }

                            }",
        )));
        ?>
        <div class="icon_images">
            <?php if ($modeldoc->id): ?>

                <div class="each_image">
                    <input type="hidden" name="SupplierDocs[document]" value="<?php echo $modeldoc->document; ?>">
                    <img src="<?php echo Yii::app()->baseUrl; ?>/uploads/supplierdocuments/<?php echo $modeldoc->document; ?>" width='100' height='100' />
                </div>
            <?php endif; ?>
        </div>
    </li>

</ul>
