<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\time\TimePicker;
use kartik\date\DatePicker;
use kartik\select2\Select2;
use yii\bootstrap4\Modal;
/* @var $this yii\web\View */
/* @var $model modules\forms\models\Dt130 */
/* @var $form yii\widgets\ActiveForm */
//data from other models
Use backend\models\Attributesvalues; //drop down options
use modules\custom\models\Accounts;  //client accounts

use modules\users\models\User; //user accounts

//typeahead for wear
use kartik\typeahead\TypeaheadBasic;
use kartik\typeahead\Typeahead;
//select2 user Query
$users = \frontend\models\User::EmployeesU();
$wearav = Attributesvalues::formarray('wear');
$wear = [];
foreach($wearav as $key => $value) {
    $wear[] = $value;
}
$yardschain  = Attributesvalues::formArray('yardschain');
$milemeters  = Attributesvalues::formArray('milemeters');
$profile = Attributesvalues::formArray('profile');
$yesno = Attributesvalues::formArray('yesno');
$rail = Attributesvalues::formArray('rail');
$railtype = Attributesvalues::formArray('railtype');
$location = Attributesvalues::formArray('location');
$cuttingmethod = Attributesvalues::formArray('cuttingmethod');
$process = Attributesvalues::formArray('process');
$this->registerJsFile('/js/touch.js'); //load canvas drawing 
//$this->registerJsFile('/js/touch_0.js'); //load canvas drawing 
$this->registerJsFile('/js/touch_1.js');//load canvas_1 
//$this->registerJsFile('/js/touch_2.js'); //load canvas_2 
//$this->registerJsFile('/js/touch_3.js'); //load canvas_3 
$this->registerJsFile('/js/update179.js'); 
?>
<script>
$(function() {
    init(); //Drawing
    //	init0(); //Drawing
    init1(); //canvas_1
    //	init2(); //canvas_2
    //	init3(); //canvas_3
});
</script>

<div class="dt130-form">
    <?php $form = ActiveForm::begin(); ?>


    <table class="Table">
        <tr>
            <td><img src="/images/logo.jpg" alt="inline"></td>
            <td colspan="4" class="Title">Conductor Rail Welding Installation &amp; Timesheet Form (DT130)</td>
        </tr>
        <tr class="DarkerBlue">
            <td width="25%">Installation Date</td>
            <td width="25%">Welders Name</td>
            <td width="25%">Welding Asstistants name</td>
            <td width="25%">Inline Job Number</td>
        </tr>
        <tr>
            <td valign="top">
                <?= $form->field($model, 'insdate')->widget(DatePicker::class, [
                'type' => 1,
                'pluginOptions' => [
                    'format' => 'dd/mm/yyyy',
                    'convertFormat' => true,
                    'todayHighlight' => true
                    ]
                    ])->label(false);?>
            </td>

            <td><?=$form->field($model, 'welders_name')->dropdownlist($users, ['prompt' => 'Select Operatives...'])->label(false)?>
            </td>
            <td><?=$form->field($model, 'weldersassist_name')->dropdownlist($users, ['prompt' => 'Select Operatives...'])->label(false)?>
            </td>
            <td><?= $form->field($model, 'inlinejobno')->textInput(['maxlength' => 100, 'id' => 'injobno' ]) ->label(false)?>
            </td>
        </tr>
        <tr class="DarkerBlue">
            <td>Area</td>
            <td>Work Site Location</td>
            <td>Start Time</td>
            <td>Finish Time</td>
        </tr>
        <tr>
            <td><?= $form->field($model, 'area')->textInput(['maxlength' => 100]) ->label(false)?></td>
            <td><?= $form->field($model, 'location')->textInput(['maxlength' => 100, 'id' => 'location']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'start_time')->widget(TimePicker::class, [
                'disabled' => true,
                'pluginOptions' => [
                        'showMeridian' =>false, 
                        'defaultTime' => '00:00'
                    ]
                ])->label(false);?>
            </td>
            <td><?= 
            $form->field($model, 'finish_time')->widget(TimePicker::class, [
                'disabled' => true,
                'pluginOptions' => [
                        'showMeridian' =>false, 
                        'defaultTime' => '00:00'
                    ]
                ])->label(false);?>
            </td>
        </tr>
        <tr class="DarkerBlue">
            <td class="DarkerBlue">Client Name</td>
            <td>Process used <span class="fa fa-plus btn-attributes float-right" data-value="process"></span></td>
            <td>Travel Start Time</td>
            <td>Travel Finish Time</td>
        </tr>
        <tr>
            <td><?= $form->field($model, 'client_name')->dropDownList(Accounts::getActive(), ['readonly' => 'true', 'id' => 'client', 'prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'process')->label(false)->dropDownList($process, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td>
            <?= $form->field($model, 'travel_start')->widget(TimePicker::class, [
                'disabled' => true,
                'pluginOptions' => [
                        'showMeridian' =>false, 
                        'defaultTime' => '00:00'
                    ]
                ])->label(false);?>
            </td>
            <td>
            <?= $form->field($model, 'travel_finish')->widget(TimePicker::class, [
                'disabled' => true,
                'pluginOptions' => [
                        'showMeridian' =>false, 
                        'defaultTime' => '00:00'
                    ]
                ])->label(false);?>
            </td>

        </tr>
    </table>
    <table class="Table">

        <tr>
            <td width="2%" rowspan="8" class="DarkerBlueC">
                <div class="rotate">Location</div>
            </td>
            <td width="24%" class="DarkerBlueC"></td>
            <td colspan="2" width="17%" class="DarkerBlueC">Weld1</td>
            <td colspan="2" width="17%" class="DarkerBlueC">Weld2</td>
            <td colspan="2" width="17%" class="DarkerBlueC">Weld3</td>
            <td colspan="2" width="17%" class="DarkerBlueC">Weld4</td>
        </tr>
        <tr>
            <td class="DarkerBlue"> ELR</td>
            <td colspan="2"><?= $form->field($model, 'elr1')->textInput(['id' => 'elr1']) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'elr2')->textInput(['id' => 'eld2']) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'elr3')->textInput(['id' => 'eld3']) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'elr4')->textInput(['id' => 'elr4']) ->label(false)?></td>
        </tr>
        <tr>
            <td class="DarkerBlue">Mileage</td>
            <td colspan="2">
                <Table>
                    <tr>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage1')->textInput(['id' => 'm1', 'maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage2')->dropDownList($milemeters, ['id' => 'm2','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage3')->textInput(['id' => 'm3','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage4')->dropDownList($yardschain, ['id' => 'm4','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                    </tr>
                </Table>
            </td>
            <td colspan="2">
                <Table>
                    <tr>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage5')->textInput(['id' => 'm5','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage6')->dropDownList($milemeters, ['id' => 'm6','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage7')->textInput(['id' => 'm7','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage8')->dropDownList($yardschain, ['id' => 'm8','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                    </tr>
                </Table>
            </td>
            <td colspan="2">
                <Table>
                    <tr>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage9')->textInput(['id' => 'm9','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage10')->dropDownList($milemeters, ['id' => 'm10','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage11')->textInput(['id' => 'm11','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage12')->dropDownList($yardschain, ['id' => 'm12','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                    </tr>
                </Table>
            </td>
            <td colspan="2">
                <Table>
                    <tr>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage13')->textInput(['id' => 'm13','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage14')->dropDownList($milemeters, ['id' => 'm14','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage15')->textInput(['id' => 'm15','maxlength' => 100]) ->label(false)?>
                        </td>
                        <td class="w-25">
                            <?= $form->field($model, 'mileage16')->dropDownList($yardschain, ['id' => 'm16','prompt' => 'Please Select...']) ->label(false)?>
                        </td>
                    </tr>
                </Table>
            </td>

        </tr>
        <tr>
            <td class="DarkerBlue">Chord Point</td>
            <td colspan="2"><?= $form->field($model, 'chord1')->textInput(['maxlength' => 100]) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'chord2')->textInput(['maxlength' => 100]) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'chord3')->textInput(['maxlength' => 100]) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'chord4')->textInput(['maxlength' => 100]) ->label(false)?></td>
        </tr>
        <tr>
            <td class="DarkerBlue">Track ID</td>
            <td colspan="2"><?= $form->field($model, 'trackid1')->textInput(['id' => 'trackid1']) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'trackid2')->textInput(['id' => 'trackid2']) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'trackid3')->textInput(['id' => 'trackid3']) ->label(false)?></td>
            <td colspan="2"><?= $form->field($model, 'trackid4')->textInput(['id' => 'trackid4']) ->label(false)?></td>
        </tr>
        <tr>
            <td class="DarkerBlue">Back to Low Mileage Rail <span class="fa fa-plus btn-attributes float-right" data-value="rail"></span></td>
            <td colspan="2">
                <?= $form->field($model, 'btol1')->dropDownList($rail, ['prompt'=>'Please Select', 'id' => 'rail1']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'btol2')->dropDownList($rail, ['prompt'=>'Please Select', 'id' => 'rail2']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'btol3')->dropDownList($rail, ['prompt'=>'Please Select', 'id' => 'rail3']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'btol4')->dropDownList($rail, ['prompt'=>'Please Select', 'id' => 'rail4']) ->label(false)?>
            </td>

        </tr>
        <tr>
            <td class="DarkerBlue">Rail Type<span class="fa fa-plus btn-attributes float-right" data-value="railtype"></span></td>
            <td colspan="2">
                <?= $form->field($model, 'rt1')->dropDownList($railtype, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'rt2')->dropDownList($railtype, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'rt3')->dropDownList($railtype, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'rt4')->dropDownList($railtype, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>

        <tr>
            <td class="DarkerBlue">Rail Location<span class="fa fa-plus btn-attributes float-right" data-value="location"></span></td>
            <td colspan="2">
                <?= $form->field($model, 'lt1')->dropDownList($location, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'lt2')->dropDownList($location, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'lt3')->dropDownList($location, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'lt4')->dropDownList($location, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td width="2%" rowspan="4" class="DarkerBlueC">
                <div class="rotate">Rail Details</div>
            </td>
            <td width="24%" class="DarkerBlue">Standing in 4 foot (Rail)</td>
            <td width="8.5%" class="LighterBlue">LH Rail</td>
            <td width="8.5%" class="LighterBlue">RH Rail</td>
            <td width="8.5%" class="LighterBlue">LH Rail</td>
            <td width="8.5%" class="LighterBlue">RH Rail</td>
            <td width="8.5%" class="LighterBlue">LH Rail</td>
            <td width="8.5%" class="LighterBlue">RH Rail</td>
            <td width="8.5%" class="LighterBlue">LH Rail</td>
            <td width="8.5%" class="LighterBlue">RH Rail</td>
        </tr>
        <tr>
            <td class="DarkerBlue">Profile<span class="fa fa-plus btn-attributes float-right" data-value="profile"></span></td>
            <td><?= $form->field($model, 'profile1_lh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile1_rh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile2_lh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile2_rh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile3_lh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile3_rh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile4_lh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'profile4_rh')->dropDownList($profile, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Weld Gap (A)</td>
            <td><?= $form->field($model, 'head1_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head1_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head2_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head2_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head3_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head3_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head4_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td><?= $form->field($model, 'head4_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Weld Gap (B)</td>
            <td>
                <?= $form->field($model, 'foot1_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot1_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot2_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot2_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot3_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot3_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot4_lh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td>
                <?= $form->field($model, 'foot4_rh')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
        </tr>
        <tr>
            <td rowspan="4" class="DarkerBlueC">
                <div class="rotate">
                    Rail Prep
                </div>
            </td>
            <td class="DarkerBlue">
                Rail Cutting Method<span class="fa fa-plus btn-attributes float-right" data-value="cuttingmethod"></span>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'standing4foot1')->dropDownList($cuttingmethod, ['prompt'=>'Please Select'])->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'standing4foot2')->dropDownList($cuttingmethod, ['prompt'=>'Please Select'])->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'standing4foot3')->dropDownList($cuttingmethod, ['prompt'=>'Please Select'])->label(false)?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'standing4foot4')->dropDownList($cuttingmethod, ['prompt'=>'Please Select'])->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Head Depth (C)</td>
            <td colspan="2">
                <?= $form->field($model, 'gap_head_1')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_head_2')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_head_3')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_head_4')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Welding gap Dimensions Web (D)</td>
            <td colspan="2">
                <?= $form->field($model, 'gap_web_1')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_web_2')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_web_3')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_web_4')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
        </tr>

        <tr>
            <td class="DarkerBlue">Foot Depth(E)</td>
            <td colspan="2">
                <?= $form->field($model, 'gap_foot_1')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_foot_2')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_foot_3')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
            <td colspan="2">
                <?= $form->field($model, 'gap_foot_4')->widget(Typeahead::class, ['options' => ['placeholder' => 'Filter as you type ...'],'pluginOptions' => ['highlight' => true],'dataset' => [['local' => $wear, 'limit' => 10 ]]]) ->label(false);?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlueC">
                <div class="rotate">Welding Diagram</div>
            </td>
            <td colspan="2">&nbsp;</td>
            <td colspan="4">
                <div hidden="yes">
                    <img src="/images/dt130.png" id="image" />
                </div>
                <div id="drawing">
                    <canvas id="canvas" width="666" height="190"></canvas>
                </div>


                <?= Html::button('Reset', [ 'class' => 'btn btn-primary', 'onclick' => 'ClearCanvasX(0);' ]); ?>
                <?= $form->field($model, 'drawingloc')->hiddenInput(['id' => 'drawingloc']) ->label(false)?>
            </td>
        </tr>
    </table>
    <table class="Table">
        <tr>
            <td width="32%" class="DarkerBlue">Inspection by the Welder</td>
            <td width="17%" class="DarkerBlueC">Weld 1</td>
            <td width="17%" class="DarkerBlueC">Weld 2</td>
            <td width="17%" class="DarkerBlueC">Weld 3</td>
            <td width="17%" class="DarkerBlueC">Weld 4</td>
        </tr>
        <tr>
            <td class="DarkerBlue">Weld conforms to Infrastructure Specifications</td>
            <td class="LighterBlue">
                <?= $form->field($model, 'conform_1')->label(false)->dropDownList($yesno, ['id' => 'noncon1', 'onchange' => 'noncon1j()', 'prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'conform_2')->label(false)->dropDownList($yesno, ['id' => 'noncon2', 'onchange' => 'noncon2j()', 'prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'conform_3')->label(false)->dropDownList($yesno, ['id' => 'noncon3', 'onchange' => 'noncon3j()', 'prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'conform_4')->label(false)->dropDownList($yesno, ['id' => 'noncon4', 'onchange' => 'noncon4j()', 'prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Weld Stamp Details</td>
            <td><?= $form->field($model, 'stamp_1')->textInput(['maxlength' => 100, 'id' => 'stamp1']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'stamp_2')->textInput(['maxlength' => 100, 'id' => 'stamp2']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'stamp_3')->textInput(['maxlength' => 100, 'id' => 'stamp3']) ->label(false)?>
            </td>
            <td><?= $form->field($model, 'stamp_4')->textInput(['maxlength' => 100, 'id' => 'stamp4']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Non-Conformance Completed</td>
            <td class="LighterBlue">
                <?= $form->field($model, 'non_con_1')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'non_con_2')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'non_con_3')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'non_con_4')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Weld Clamped</td>
            <td class="LighterBlue">
                <?= $form->field($model, 'weld_1')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'weld_2')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'weld_3')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'weld_4')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Non-Conformance Reported to Management </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'noncon_r_1')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'noncon_r_2')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'noncon_r_3')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
            <td class="LighterBlue">
                <?= $form->field($model, 'noncon_r_4')->label(false)->dropDownList($yesno, ['prompt'=>'Please Select']) ->label(false)?>
            </td>
        </tr>
        <tr>
            <td class="DarkerBlue">Reason for Non-conformance Report</td>
            <td colspan="4">
                <?= $form->field($model, 'noncon_1')->textArea(['rows' => 6, 'id' => 'nonconr1']) ->label(false)?></td>
        </tr>
    </table>
    <table class="Table">

        <tr>
            <td colspan="3" class="DarkerBlue">Site Representive Signature </td>
            <td colspan="3" class="DarkerBlue">Site Representive Print</td>
            <td colspan="3" class="DarkerBlue">Date</td>
        </tr>
        <tr>
            <td colspan="3">
                <div id="canvas1">
                    <canvas id="canvas_1" class="canvas1"></canvas>
                </div>

                <?= Html::button('Reset', [ 'class' => 'btn btn-primary', 'onclick' => 'ClearCanvasX(1);' ]); ?>
                <?= $form->field($model, 'signatureloc')->hiddenInput(['id' => 'signatureloc']) ->label(false)?>
            </td>
            <td colspan="3">
                <?= $form->field($model, 'rep_print')->textInput(['maxlength' => 100, 'id' => 'contact' ]) ->label(false)?>
            </td>
            <td colspan="3"><?=DatePicker::widget(['model' => $model, 'attribute' => 'rep_date', 'pluginOptions' => [
        'convertFormat' => true,
        'format' => 'dd/m/yyyy',
        'todayHighlight' => true]]);?></td>
        </tr>
    </table>
    <table class="Table">
        <tr>
            <th class="DarkerBlueC">Welds Expected</th>
            <td><?= $form->field($model, 'noofwelds')->textInput(['maxlength' => 100, 'id' => 'expectedwelds', 'readonly' => 'true']) ->label(false)?>
            </td>
            <th class="DarkerBlueC">Good Welds</th>
            <td><?= $form->field($model, 'goodwelds')->textInput(['maxlength' => 100, 'id' => 'goodwelds', 'onchange' => 'welds()' ]) ->label(false)?>
            </td>
            <th class="DarkerBlueC">Bad Welds</th>
            <td><?= $form->field($model, 'badwelds')->textInput(['maxlength' => 100, 'id' => 'badwelds', 'onchange' => 'welds()']) ->label(false)?>
            </td>
            <th class="DarkerBlueC">Welds Completed</th>
            <td><?= $form->field($model, 'weldscompleted')->textInput(['maxlength' => 100, 'id' => 'completedwelds' ]) ->label(false)?>
            </td>
        </tr>

    </table>

    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-primary', 'onclick' => 'saveImage9()']) ?>
        <?= Html::button('Add Attributes+', ['value' => Url::to(['form_attribs/createdt130']), 'id' => 'modalButton', 'class' => 'btn btn-primary' ]) ?>

        <?php
    Modal::begin(['id' => 'modal', 'size' => 'modal-lg' ]);
    echo "<div id='modalContent'></div>";
    Modal::end();
    ?>

    </div>

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

</div>
<script type="text/javascript">
var9 = "<?= $model->actid ?>";

function welds() {
    var expected = document.getElementById('expectedwelds').value;
    var good = document.getElementById('goodwelds').value;
    var bad = document.getElementById('badwelds').value;
    var completed = document.getElementById('completedwelds').value;
    //var1 = document.getElementById('nonconr1').value;
    var2 = document.getElementById('contact').value;
    var3 = document.getElementById('injobno').value;
    var4 = document.getElementById('location').value;
    var5 = document.getElementById('dt130-insdate').value; //Date
    var6 = document.getElementById('client').value;
    var7 = document.getElementById('dt130-start_time').value; //startdate
    var8 = document.getElementById('dt130-finish_time').value; //finishdate
    var10 = document.getElementById('dt130-welders_name').value;


    //MATHS
    var total = +good + +bad;
    var miscalc = total - +expected;

    //Set Values	
    document.getElementById('completedwelds').value = total;
    url = "?contact=" + var2 + "&injobno=" + var3 + "&site=" + var4 + "&date=" + var5 + "&company=" + var6 +
        "&starttime=" + var7 + "&finishtime=" + var8 + "&actid=" + var9 + "&welders=" + var10;

    //Logic
    //alert(misc
    if (bad >= 1) {
        var x
        if (confirm(
                'Bad welds detected have you completed a non-conformance press Ok to continue or Cancel to create a non-conformance'
            ) == true) {
            x = "done";
        } else {
            x = "noncon";


            // Open new window to site report
            var params = ['height=' + 1920, 'width=' + 1080, 'fullscreen=no'].join(',');
            var myWindow = window.open("/dt128/create" + url, "", params);
        }
        // only works in IE, but here for completeness

    }
}

function noncon1j() {
    var noncon1 = document.getElementById('noncon1').value
    var1 = document.getElementById('nonconr1').value;
    var2 = document.getElementById('contact').value;
    var3 = document.getElementById('injobno').value;
    var5 = document.getElementById('location').value;
    var6 = document.getElementById('client').value;
    var10 = document.getElementById('m1').value;
    var11 = document.getElementById('m2').value;
    var12 = document.getElementById('m3').value;
    var13 = document.getElementById('m4').value;
    var14 = document.getElementById('dt130-welders_name').value;
    var trackid = document.getElementById('trackid1').value;
    var rail = document.getElementById('rail1').value;
    var stamp = document.getElementById('stamp1').value;
    var date = document.getElementById('dt130-insdate').value;



    URL = "?nonconr1=" + var1 + "&contact=" + var2 + "&injobno=" + var3 + "&location=" + var5 + "&company=" + var6 +
        "&weld=1" + "&actid=" + var9 + "&m1=" + var10 + "&m2=" + var11 + "&m3=" + var12 + "&m4=" + var13 + "&welders=" +
        var14 + "&stamp=" + stamp + "&date=" + date + "&trackid=" + trackid + "&rail=" + rail;
    if (noncon1 == 'No') {
        var params = [
            'height=' + screen.height, 'width=' + screen.width,
            'fullscreen=yes' // only works in IE, but here for completeness
        ].join(',');
        var myWindow = window.open("/forms/dt128/create" + URL, "", params);
    } else {
        alert("Are you sure?")
    }
}

function noncon2j() {
    var noncon1 = document.getElementById('noncon2').value
    var1 = document.getElementById('nonconr1').value;
    var2 = document.getElementById('contact').value;
    var3 = document.getElementById('injobno').value;
    var4 = document.getElementById('dt130-insdate').value;
    var5 = document.getElementById('location').value;
    var6 = document.getElementById('client').value;
    var10 = document.getElementById('m5').value;
    var11 = document.getElementById('m6').value;
    var12 = document.getElementById('m7').value;
    var13 = document.getElementById('m8').value;
    var14 = document.getElementById('dt130-welders_name').value;
    var trackid = document.getElementById('trackid2').value;
    var rail = document.getElementById('rail2').value;
    var stamp = document.getElementById('stamp2').value;
    var date = document.getElementById('dt130-insdate').value;

    URL = "?nonconr1=" + var1 + "&contact=" + var2 + "&injobno=" + var3 + "&location=" + var5 + "&company=" + var6 +
        "&weld=3" + "&actid=" + var9 + "&m1=" + var10 + "&m2=" + var11 + "&m3=" + var12 + "&m4=" + var13 + "&welders=" +
        var14 + "&stamp=" + stamp + "&date=" + date + "&trackid=" + trackid + "&rail=" + rail;
    if (noncon1 == 'No') {
        var params = [
            'height=' + screen.height, 'width=' + screen.width,
            'fullscreen=yes' // only works in IE, but here for completeness
        ].join(',');
        var myWindow = window.open("/forms/dt128/create" + URL, "", params);
    } else {
        alert("Are you sure?")
    }
}

function noncon3j() {
    var noncon1 = document.getElementById('noncon3').value
    var1 = document.getElementById('nonconr1').value;
    var2 = document.getElementById('contact').value;
    var3 = document.getElementById('injobno').value;
    var4 = document.getElementById('dt130-insdate').value;
    var5 = document.getElementById('location').value;
    var6 = document.getElementById('client').value;
    var10 = document.getElementById('m9').value;
    var11 = document.getElementById('m10').value;
    var12 = document.getElementById('m11').value;
    var13 = document.getElementById('m12').value;
    var14 = document.getElementById('dt130-welders_name').value;
    var trackid = document.getElementById('trackid3').value;
    var rail = document.getElementById('rail3').value;
    var stamp = document.getElementById('stamp3').value;
    var date = document.getElementById('dt130-insdate').value;

    URL = "?nonconr1=" + var1 + "&contact=" + var2 + "&injobno=" + var3 + "&location=" + var5 + "&company=" + var6 +
        "&weld=3" + "&actid=" + var9 + "&m1=" + var10 + "&m2=" + var11 + "&m3=" + var12 + "&m4=" + var13 + "&welders=" +
        var14 + "&stamp=" + stamp + "&date=" + date + "&trackid=" + trackid + "&rail=" + rail;
    if (noncon1 == 'No') {
        var params = [
            'height=' + screen.height, 'width=' + screen.width,
            'fullscreen=yes' // only works in IE, but here for completeness
        ].join(',');
        var myWindow = window.open("/forms/dt128/create" + URL, "", params);
    } else {
        alert("Are you sure?")
    }
}

function noncon4j() {
    var noncon1 = document.getElementById('noncon4').value
    var1 = document.getElementById('nonconr1').value;
    var2 = document.getElementById('contact').value;
    var3 = document.getElementById('injobno').value;
    var4 = document.getElementById('dt130-insdate').value;
    var5 = document.getElementById('location').value;
    var6 = document.getElementById('client').value;
    var10 = document.getElementById('m13').value;
    var11 = document.getElementById('m14').value;
    var12 = document.getElementById('m15').value;
    var13 = document.getElementById('m16').value;
    var14 = document.getElementById('dt130-welders_name').value;
    var trackid = document.getElementById('trackid4').value;
    var rail = document.getElementById('rail4').value;
    var stamp = document.getElementById('stamp4').value;
    var date = document.getElementById('dt130-insdate').value;

    URL = "?nonconr1=" + var1 + "&contact=" + var2 + "&injobno=" + var3 + "&location=" + var5 + "&company=" + var6 +
        "&weld=4" + "&actid=" + var9 + "&m1=" + var10 + "&m2=" + var11 + "&m3=" + var12 + "&m4=" + var13 + "&welders=" +
        var14 + "&stamp=" + stamp + "&date=" + date + "&trackid=" + trackid + "&rail=" + rail;
    if (noncon1 == 'No') {
        var params = [
            'height=' + screen.height, 'width=' + screen.width,
            'fullscreen=yes' // only works in IE, but here for completeness
        ].join(',');
        var myWindow = window.open("/forms/dt128/create" + URL, "", params);
    } else {
        alert("Are you sure?")
    }
}

function saveImage9() {
    $("#drawingloc").val(document.getElementById('canvas').toDataURL());
    $("#signatureloc").val(document.getElementById('canvas_1').toDataURL());

}

function stampno() {
    var stamp = '<?= Yii::$app->user->identity->stampno; ?>';

    var elr1 = document.getElementById('elr1').value;
    if (elr1 !== '') {
        document.getElementById('stamp1').value = stamp;
    };
    var elr2 = document.getElementById('elr2').value;
    if (elr2 !== '') {
        document.getElementById('stamp2').value = stamp;
    };
    var elr3 = document.getElementById('elr3').value;
    if (elr3 !== '') {
        document.getElementById('stamp3').value = stamp;
    };
    var elr4 = document.getElementById('elr4').value;
    if (elr4 !== '') {
        document.getElementById('stamp4').value = stamp;
    };
}
</script>