| Current Path : /var/www/html/crm/views/stockout/ |
| Current File : /var/www/html/crm/views/stockout/_form.php |
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\ParamList;
use app\models\Company;
use app\models\Product;
use app\models\Vendor;
/* @var $this yii\web\View */
/* @var $model app\models\StockOut */
/* @var $form yii\widgets\ActiveForm */
$ParamList = new ParamList();
$optionstatus = false;
if (Yii::$app->controller->action->id == 'update')
$optionstatus = true;
?>
<div class="stock-out-form">
<div class="kt-container kt-container--fluid kt-grid__item kt-grid__item--fluid">
<div class="kt-portlet kt-portlet--mobile">
<div class="kt-portlet__body kt-portlet__body--fit">
<div class="kt-portlet__head">
<div class="kt-portlet__head-label">
<span class="kt-font-info"><i class="fas fa-info-circle"></i> Field with <span class="required">*</span> is required</span>
</div>
</div>
<div class="kt-portlet__body">
<?php $form = ActiveForm::begin(['options' => ['class' => 'kt-form kt-form--label-right', 'enctype' => 'multipart/form-data']]); ?>
<?php $form->errorSummary($model); ?>
<div class="row">
<div class="col-4">
<div class='form-group-custom'>
<?php
$productArr = ArrayHelper::map(Product::find()
->orderBy(['name' => SORT_ASC])->all(), 'id', 'name');
echo $form->field($model, 'product_id', [
'template' => "{label}<span class='required'>*</span>{input}<span class='kt-font-danger font-weight-bold'>{error}</span>"])
->dropDownList($productArr, [
'class' => 'form-control kt-selectpicker',
'data-live-search' => 'true',
'disabled' => $optionstatus]);
?>
</div>
</div>
<div class="col-4">
<div class='form-group-custom'>
<?=
$form->field($model, 'type', [
'template' => "{label}<span class='required'>*</span>{input}<span class='kt-font-danger font-weight-bold'>{error}</span>"])
->dropDownList($ParamList->getparamlist(14), ['class' => 'form-control kt-selectpicker']);
?>
</div>
</div>
<div class="col-4">
<div class='form-group-custom'>
<?=
$form->field($model, 'quantity', [
'template' => "{label}<span class='required'>*</span>{input}<span class='kt-font-danger font-weight-bold'>{error}</span>"
])->textInput(['maxlength' => true]);
?>
</div>
</div>
<div class="col-12">
<div class='form-group-custom'>
<?= $form->field($model, 'remarks', ['template' => "{label}{input}{error}"])->textarea(['rows' => 6]); ?>
</div>
</div>
</div>
</div>
<div class="kt-portlet__foot">
<div class="kt-form__actions">
<?= Html::a('<i class="fas fa-arrow-left"></i> Back', ['index'], ['class' => 'btn btn-outline-brand']) ?>
<?=
Html::a('<i class="fas fa-sync"></i> Reset', [Yii::$app->controller->action->id,
'uuid' => Yii::$app->getRequest()->getQueryParam('uuid')], ['class' => 'btn btn-outline-success']);
?>
<?= Html::submitButton('<i class="fas fa-paper-plane"></i> Submit', ['class' => 'btn btn-info']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Search product</h5>
</div>
<div class="modal-body">
<form autocomplete="off">
<input class="form-control" type="text" id="search-product" autocomplete="off">
</form>
<div id="search-result"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" onclick="gofind()">Search</button>
</div>
</div>
</div>
</div>
<script>
function updateproductlist() {
var com_id = $('#stockout-company_id').val();
if (com_id !== '') {
$.ajax({
url: "index.php?r=stockout/listproduct",
method: "POST",
data: {"com_id": com_id},
success: function (response) {
$('#stockout-product_id').find('option').not(':first').remove();
$("#stockout-product_id").append(response);
$('#stockout-product_id').selectpicker('refresh');
},
});
}
}
function findproduct() {
$('#myModal').modal('show');
}
function gofind() {
var search_product = $('#search-product').val();
if (search_product !== '') {
$.ajax({
url: "index.php?r=stockout/searchproduct",
method: "POST",
data: {"search_product": search_product},
success: function (response) {
$("#search-result").html(response);
},
});
}
}
function selectproduct(val) {
var data = val.split("<--->");
$('#stockout-product_id').val(data[0]);
$('#stockout-product_name').val(data[1]);
$('#myModal').modal('hide');
changeownerid();
}
function changeownerid() {
var product_id = $('#stockout-product_id').val();
var owner_type = $('#stockout-owner_type').val();
if (product_id !== '') {
$.ajax({
url: "index.php?r=stockout/getownerid",
method: "POST",
data: {"product_id": product_id, "owner_type": owner_type},
success: function (response) {
$('#stockout-owner_id').find('option').remove();
$("#stockout-owner_id").append(response);
$('#stockout-owner_id').selectpicker('refresh');
},
});
}
}
</script>