<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;

use modules\users\models\User;

/* @var $this yii\web\View */
/* @var $model backend\models\Dt143be */
/* @var $form yii\widgets\ActiveForm */
$yesno = ['no' => 'NO', 'yes' => 'YES'];
$this->registerJsFile('/js/touch_0.js');
$this->registerJsFile('/js/updatesignatures.js');
$employees = User::Employeesu();

$layout = '<div class="row">
				<div class="col-12 col-md-9">{label}</div>
				<div class="col-12 col-md-3">{input}{hint}{error}</div>
			</div>';
$model->date = is_int($model->date) ? Date('d/m/Y', $model->date) : $model->date;
?>
<script>
$(function() {
    init0();
})
</script>
<div class="dt143be-form col-sm-12">
    <div class="row">
        <div class="col-sm-3"><?= HTML::IMG('/'.Yii::$app->params['settings']['logo'], ['alt'=>'logo']) ?></div>
        <div class="col-sm-9 h3 text-center"> <?= $model->formname ?></div>
    </div>
    <?php $form = ActiveForm::begin(); ?>
    <p>For duties of a Safety Critical nature alertness and reasonable physical fitness are essential, it is therefore
        important to answer the following questions as accurately as possible. When you declare NO you are accepting a
        degree of responsibility for your own safety.</p>
    <p></p>
    <p>After reading the following questions carefully, indicate 'YES' or 'NO' and sign the declaration below to confirm
        that you have read and fully understood the questions on the form.

    </p>

    <?= $model->getAttributeLabel('question1') !== 'question1' ? $form->field($model, 'question1', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question2') !== 'question2' ? $form->field($model, 'question2', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question3') !== 'question3' ? $form->field($model, 'question3', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question4') !== 'question4' ? $form->field($model, 'question4', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question5') !== 'question5' ? $form->field($model, 'question5', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question6') !== 'question6' ? $form->field($model, 'question6', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question7') !== 'question7' ? $form->field($model, 'question7', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question8') !== 'question8' ? $form->field($model, 'question8', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question9') !== 'question9' ? $form->field($model, 'question9', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question10') !== 'question10' ? $form->field($model, 'question10', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question11') !== 'question11' ? $form->field($model, 'question11', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question12') !== 'question12' ? $form->field($model, 'question12', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question13') !== 'question13' ? $form->field($model, 'question13', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question14') !== 'question14' ? $form->field($model, 'question14', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question15') !== 'question15' ? $form->field($model, 'question15', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question16') !== 'question16' ? $form->field($model, 'question16', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question17') !== 'question17' ? $form->field($model, 'question17', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question18') !== 'question18' ? $form->field($model, 'question18', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question19') !== 'question19' ? $form->field($model, 'question19', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>
    <?= $model->getAttributeLabel('question20') !== 'question20' ? $form->field($model, 'question20', ['template' => $layout])->dropdownlist($yesno, ['prompt' => 'Please Select'])->label() :false ?>



    <div class="row">
        <div class='col-sm-6'>
			<label for='dt143-signature' class="control-label"> <?= $model->getAttributeLabel('signature') ?></label><br />
            <canvas class="canvas" id="canvas_0" height="200px" width="300px"></canvas>
            <?= $form->field($model, 'signature')->hiddenInput(['id' => 'signature0'])->label(false) ?>
        </div>
        <div class='col-sm-6'>
            <?= $form->field($model, 'date')->widget(\kartik\date\DatePicker::class, ['type' => 1,  'pluginOptions' => ['showMeridian' =>true, 'convertFormat' => true, 'format' => 'dd/mm/yyyy']])->label() ?>
            <?= $form->field($model, 'employee')->dropdownlist($employees, ['prompt' => 'Please Select'])->label() ?>
        </div>
    </div>


    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<script>
$(function() {
    $('form').on('submit', function() {
        $('#signature0').val(document.getElementById('canvas_0').toDataURL());
    })
})
</script>