<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\date\DatePicker;
use modules\users\models\User;
/* @var $this yii\web\View */
/* @var $model backend\models\Dt078be */
/* @var $form yii\widgets\ActiveForm */
$this->registerJsFile('/js/touch_0.js');
$this->registerJsFile('/js/touch_1.js');
$this->registerJsFile('/js/updatesignatures.js');
?>

<script>
$(function() {
    init0();
    init1();

});
</script>
<div class="dt078be-form">

    <?php $form = ActiveForm::begin(); ?>
    <div class="row">
        <div class="col-sm-12 Title DarkerBlueC">Medication Declaration Form</div>
    </div>

    <div class="row">
        <div class='col-sm-2 DarkerBlue'>Name</div>
        <div class='col-sm-4'>
            <?= $form->field($model, 'name')->dropdownlist(User::Employees(), ['prompt' => 'Please Select'])->label(false) ?>
        </div>
        <div class='col-sm-2 DarkerBlue'>National Ins No</div>
        <div class='col-sm-4'><?= $form->field($model, 'natindno')->textInput()->label(false) ?></div>
    </div>
    <div class="row">
        <div class='col-sm-2 DarkerBlue'>Start Date</div>
        <div class='col-sm-2'>
            <?= $form->field($model, 'startdate')->widget(DatePicker::class, ['type' => 1, 'pluginOptions' => ['showMeridian' =>true, 'convertFormat' => true, 'format' => 'dd/mm/yyyy']])->label(false) ?>
        </div>
        <div class='col-sm-2 DarkerBlue'>Finish Date</div>
        <div class='col-sm-2'>
            <?= $form->field($model, 'finishdate')->widget(DatePicker::class, ['type' => 1, 'pluginOptions' => ['showMeridian' =>true, 'convertFormat' => true, 'format' => 'dd/mm/yyyy']])->label(false) ?>
        </div>
        <div class='col-sm-2 DarkerBlue'>Duration</div>
        <div class='col-sm-2'><?= $form->field($model, 'duration')->textInput()->label(false) ?></div>
    </div>
    <div class="row">
        <div class="col-sm-10">
            I declare that I am taking the following drug/s obtained privately ‘over the counter’. I am/am not aware of
            their likely effect upon the performance of my rostered duties.
        </div>
        <div class="col-sm-2">
            <?= $form->field($model, 'selfpescribed')->checkbox(['label' => 'Self Pescribed'])->label(false) ?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-10">
            I declare that I am taking the following drug(s) prescribed to me by a Registered Medical Practitioner /
            Dentist and that I have been in formed of their likely effect upon the performance of my rostered duties
        </div>
        <div class="col-sm-2">
            <?= $form->field($model, 'pescribed')->checkbox(['label' => 'Medically Pescribed'])->label(false) ?>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            I declare that the above named employee has fully informed me of the medication he/she is taking and that
            the following action requires to be taken as a result of the effects:
        </div>
    </div>
    <div class="row">
        <div class='col-sm-12'><?= $form->field($model, 'reason')->textArea()->label() ?></div>
        <div class='col-sm-12'>
            <?= $form->field($model, 'medication')->textArea()->label('Drug or medication being used:') ?></div>
    </div>

    <?php if (Yii::$app->user->identity->inGroup('Office Admins') || Yii::$app->user->identity->inGroup('Global Admins')) { ?>
        <div class="row">
            <div class='col-sm-12'>
                <?= $form->field($model, 'advice')->textArea()->label('Advice from Medical Express [Where  applicable]') ?>
            </div>
            <div class='col-sm-6'>
                <?= $form->field($model, 'maywork')->radiolist(['no' => 'NO', 'yes' => 'YES'])->label('The Operative May Work') ?>
            </div>
            <div class='col-sm-6'>
                <?= $form->field($model, 'accompanied')->radiolist(['no' => 'NO', 'yes' => 'YES'])->label('The operative must be accompanied at all time') ?>
            </div>
            <div class='col-sm-6'>
                <?= $form->field($model, 'safety')->radiolist(['no' => 'NO', 'yes' => 'YES'])->label('The operative may not take part in work of a safety critical nature') ?>
            </div>
            <div class='col-sm-6'>
                <?= $form->field($model, 'stooddown')->radiolist(['no' => 'NO', 'yes' => 'YES'])->label('The operative has been stood down') ?>
            </div>
        </div>
    <?php } ?>
    <div class="row">
        <div class='col-sm-6'>
            <label class="control-label">Signed</label>
            <canvas class="canvas" width="400px" height="150px" id="canvas_0"></canvas>
            <?= $form->field($model, 'opsigned')->hiddenInput(['id' => 'signature0'])->label(false) ?>
        </div>
        <div class='col-sm-6'>
            <?= $form->field($model, 'signednameop')->dropdownlist(User::Employees(), ['prompt' => 'Please Select'])->label('Name (Operative)') ?>
        </div>

    </div>

    <?php if (Yii::$app->user->identity->inGroup('Office Admins') || Yii::$app->user->identity->inGroup('Global Admins')) { ?>
    <div class="row">
        <div class='col-sm-6'>
            <label class="control-label">Signed</label>
            <canvas class="canvas" width="400px" height="150px" id="canvas_1"></canvas>
            <?= $form->field($model, 'supsigned')->hiddenInput(['id' => 'signature1'])->label(false) ?>
        </div>
        <div class='col-sm-6'>
            <?= $form->field($model, 'signednamesup')->dropdownlist(User::Employees(), ['prompt' => 'Please Select'])->label('Name (Supervisor)') ?>
        </div>
    </div>
    <div class="row">
        <div class='col-sm-6'>
            <?= $form->field($model, 'date')->widget(DatePicker::class, ['type' => 1, 'pluginOptions' => ['showMeridian' =>true, 'convertFormat' => true, 'format' => 'dd/mm/yyyy']])->label() ?>
        </div>
    </div>
    <?php } ?>
    <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());
        $('#signature1').val(document.getElementById('canvas_1').toDataURL());
    })
})
</script>