
<?php

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use kartik\date\DatePicker;
use backend\models\Attributesvalues;
use backend\models\SysShippingSetting;
use yii\widgets\ActiveForm;
$extended = $model->data->netsuite;
?>

<div class="linkform">
<?php $form = ActiveForm::begin([
    'enableClientValidation' => true,
    'enableAjaxValidation' => true,
    'options' => [
        'id' => "linktons",
        'class' => '',
    ]
]); ?>
<p>
    To get these values, open netsuite and search for <strong><?= $model->orderref ?></strong>.<br />
    this should give you a result, if not, use the send to NetSuite button.<br />
    with the result, open the order. in the address at the top of the screen you will see the Following <br/>
    https://4465021.app.netsuite.com/app/accounting/transactions/salesord.nl?id=<strong>XXXXXX</strong>&whence=
    enter this number in the field below. 
    <br/>
    <i>Note 1 NGauge order could have 2 Orders in NetSuite, if it has two please complete both fields</i>
</p>
    <?= $form->field($extended, 'deliveryid')->textInput(['type' => 'Number'])->label('Netsuite Delivery ID'); ?>
    <?= $form->field($extended, 'collectionid')->textInput(['type' => 'Number'])->label('Netsuite Collection ID'); ?>
    <?= Html::SubmitButton('Save', ['class' => 'btn btn-success']); ?>
    <?php ActiveForm::end(); ?>
</div>
    
<script>
    $('#linktons').on('beforeSubmit', function(ev) {
        ev.preventDefault();
        form = $(this);
        data = form.serialize();
        $.ajax({
            url: form.attr('action'),
            type: form.attr('method'),
            data: data,
            success: function(result, b, c) {
                if (result.status == '200') {
                    window.location.reload();
                } else {
                    console.log('Error');
                }
            }
        })
    return false;
    })
</script>