Controller
public function actionForward()
{
$params = Yii::$app->request->queryParams;
$searchModel = new EquipmentSearch();
$options = [];
$options['store_id'] = 1;
$dataProvider = $searchModel->searchAssigned(Yii::$app->request->queryParams, $options);
if (!isset($params['EquipmentSearch']['store_id']) || $params['EquipmentSearch']['store_id'] == '') {
$dataProvider->query->andWhere('0=1');
}
$searchModelWithdrawal = new EquipmentRequestSearch();
$dataProviderWithdrawal = $searchModelWithdrawal->searchWithdrawal(Yii::$app->request->queryParams);
return $this->render('forward', [
'searchModel' => $searchModel,
'searchModelWithdrawal' => $searchModelWithdrawal,
'dataProvider' => $dataProvider,
'dataProviderWithdrawal' => $dataProviderWithdrawal,
]);
}
View
<?php
use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use backend\models\Option;
use backend\models\EquipmentType;
use backend\models\Store;
use backend\models\UserStores;
$this->params['breadcrumbs'][] ='Inventory Movement';
$userStores = UserStores::getUserStores(Yii::$app->user->id);
$equiCondData = ArrayHelper::map(Option::find()->where(['option_type_id' => EQUIPMENT_CONDITION_TYPE_ID])->all(),'id', 'option_title');
if(Yii::$app->user->can(ROLE_HEAD_OFFICE_STORE_INCHARGE)){
$storesData = ArrayHelper::map(Store::find()->all(),'id', 'store_name');
}else{
$storesData = ArrayHelper::map(Store::find()->Where(['IN', 'id', $userStores])->all(),'id', 'store_name');
}
$equiTypeData = ArrayHelper::map(EquipmentType::find()->all(),'id', 'equipment_type_name');
//$docTypeData = ArrayHelper::map(DocumentTypes::find()->all(),'id', 'document_type_symbol');
$equiStatusData = ArrayHelper::map(Option::find()->where(['option_type_id' => EQUIPMENT_STATUS_TYPE_ID])->all(),'id', 'option_title');
unset($equiStatusData[EQUIPMENT_STATUS_APPROVAL_REJECTED]);
$equiConditionData = ArrayHelper::map(Option::find()->where(['option_type_id' => EQUIPMENT_CONDITION_TYPE_ID])->all(),'id', 'option_title');
$toolbarContents = Html::button('Forward Request', ['type'=>'button', 'title'=> 'Forward Request', 'class'=>'btn btn-primary', 'onclick'=>'forwardRequest($("#equipmentsearch-store_id").val())', 'id'=>'equi-withdraw-btn']) . ' ';
?>
<div>
<h1><?= Html::encode($this->title) ?></h1>
<div class='row'>
<div class='col-sm-2' id="w0-filters">
<?php
echo "<b> Source Store </b> <br /> ";
echo Html::activeDropDownList($searchModel, 'store_id', $storesData,['class'=>'left curBox','class' => 'btn btn-primary', 'style' => 'margin-right:10px', 'prompt' => 'Select']
).'<br/><br/>';
?>
</div>
<div class='col-sm-2' id="w1-filters">
<?php
echo "<b> Destination Store </b> <br /> ";
echo Html::activeDropDownList($searchModel, 'store_id', $storesData, ['class'=>'left curBox','class' => 'btn btn-primary', 'style' => 'margin-right:10px', 'prompt' => 'Select']
// ['options' => ['style' => 'color: #FA4575; font-size: 48px;'],]
).'<br/><br/>'; ?>
</div>
</div>
<script type = "text/javascript">
function GetSelectedRow()
{
var keys = $('#w0').yiiGridView('getSelectedRows');
}
<?php echo GridView::widget([
'dataProvider' => $dataProvider,
//'filterModel'=>$searchInstance,
'containerOptions'=>['class'=>'instance-pjax-container'],
'id'=>'w0',
'filterModel' => $searchModel,
'pjax'=>true,
'pjaxSettings' => [
'options' => [
'enablePushState' => false,
],
],
'pager' => [
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
],
'toolbar' => [
['content'=> $toolbarContents],
'{export}',
'{toggleData}',
],
'columns' => [
['class'=>'yii\grid\CheckboxColumn','header'=>'Select'],
'equipmentType.equipment_type_name',
'equipmentCondition.option_title',
'equipmentType.manufacturer',
'equipmentType.model_number',
],
'toolbar' => [
// ['content'=> Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['forward'], ['data-pjax'=>1, 'class' => 'btn btn-default resetGrid', 'title'=>'Reset Grid', 'id'=>'forward-reset'])],
//'{export}',
//'{toggleData}',
],
'panel' => [
'type' => kartik\grid\GridView::TYPE_DEFAULT,
//['from'=>GridView::ICON_INACTIVE()],
'heading' => "<i class='fa fa-gear'></i> Available Inventory",
],
]); ?>
<?= Html::SubmitButton( 'Mark to forward', [ 'class' => 'btn btn-success' , 'id' =>'x']) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'formatter' => ['class' => 'yii\i18n\Formatter','nullDisplay' => ''],
'headerRowOptions'=>['class'=>'skip-export-csv kartik-sheet-style'],
'filterRowOptions'=>['class'=>'kartik-sheet-style'],
'floatHeader' => 'true',
'floatHeaderOptions' => ['scrollingTop' => 0],
'pjax'=>true,
'pjaxSettings' => [
'options' => [
'enablePushState' => false,
],
],
/* 'pager' => [
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
],
' panel' => [
'type' => kartik\grid\GridView::TYPE_DEFAULT,
'heading' => "<i class='fa fa-gear'></i> To be Forwarded",
],
'columns' => [
['class' => 'yii\grid\CheckBoxColumn','header'=>'Select'],
],]); ?>*/
'toolbar' => [
// ['content'=> Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['forward'], ['data-pjax'=>1, 'class' => 'btn btn-default resetGrid', 'title'=>'Reset Grid', 'id'=>'forward-reset'])],
//'{export}',
//'{toggleData}',
],
'panel' => [
'type' => kartik\grid\GridView::TYPE_DEFAULT,
'heading' => "<i class='fa fa-gear'></i> To be Forwarded",
],
'columns' => [
['class' => 'yii\grid\CheckBoxColumn','header'=>'Select'],
],]); ?>