<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Transfer;
use common\components\Helper;

/* @var $this yii\web\View */
/* @var $model frontend\models\ProductSaleForm */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $currencies common\models\Currency[] */


function mkOptions($options){
	// 	$o = $options;

	$all = ['' => '-' ];

	$o =  $all + $options;

	return $o;
}

$currencyOptions = mkOptions( ArrayHelper::map($currencies, 'id_currency', 'name') );
$accountOptions = mkOptions( ArrayHelper::map($accounts, 'id_account', 'name') );
$discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name') );
?>
<?php ?>

<div class="row">
	<div class="col-md-12">
		<?php echo  $this->render('_view')?>
	</div>
</div>

<div class="row">
	<?php   $form =  ActiveForm::begin([
	'id' => 'filter_text_form',
	'class' =>'form-inline',
		'layout' => 'horizontal',
			 'fieldConfig' => [
		        'horizontalCssClasses' => [
		            'label' => 'col-sm-5',
		            'offset' => 'col-sm-offset-6',
		            'wrapper' => 'col-sm-7',
		            'error' => '',
		            'hint' => '',
		        ],
		    ],
		]	)?>
	<div class='col-md-12'>
<!-- 		<input type='text' name='product_search' id="product_search" > -->
		<?php  echo $form->field($lookupModel,'product_search')->textInput(['id'=>'product_search']); ?>
		<?php  echo $form->field($lookupModel,'filter_text')->textInput(['id'=>'filter_text']); ?>
	</div>
	<?php    ActiveForm::end()?>
</div>

<?php $form = ActiveForm::begin(
		[
			'id' => 'product_form',
			'class' =>'form-inline',
			'layout' => 'horizontal',
				 'fieldConfig' => [
			        'horizontalCssClasses' => [
			            'label' => 'col-sm-5',
			            'offset' => 'col-sm-offset-6',
			            'wrapper' => 'col-sm-7',
			            'error' => '',
			            'hint' => '',
			        ],
			    ],
		]	
	); ?>
	<?php echo Html::activeHiddenInput($model, 'id_product') ?>
	<?php echo Html::activeHiddenInput($model, 'cart') ?>
	

	<div class="row">
		<div class='col-md-12'>
			<?php echo $form->field($model, 'count')->input("number")  ?>
		</div>
	</div>
	<div class="row">
		<div class='col-md-12'>
			<?php //echo $form->field($model,'id_currency')->dropDownList($currencyOptions)  ?>
		</div>
	</div>
	<div class="row">
		<div class='col-md-12'>
			<?php echo $form->field($model,'id_account')->dropDownList($accountOptions)  ?>
		</div>
	</div>
	<div class="row">
		<div class='col-md-12'>
			<?php echo $form->field($model,'id_discount')->dropDownList($discountOptions)  ?>
		</div>
	</div>
	<div class="row">
		<div class='col-md-12'>
			<?php echo $form->field($model,'payment_method')->dropDownList(Transfer::paymentMethodsForProduct())  ?>
		</div>
	</div>
	<div class="row">
		<div class='col-md-12'>
			<?php  echo $form->field( $model,'comment' )->textarea() ?>
		</div>
	</div>
	<div class="row">
		<div class='col-md-4'>
			<?php echo Html::a(Yii::t("frontend/product","Sell"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
		</div>
		<div class='col-md-4'>
			<?php  if ( Helper::isUserCartOn()){ ?>
			<?php echo Html::a(Yii::t("frontend/product","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_sell_append'] );?>
			<?php }?>
		</div>
		<div class='col-md-4'>
			<?php 
				if ( $receptionForm->isCardWithCustomer() ){
					echo Html::a(Yii::t("frontend/product","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] );
				}			
			?>
		</div>
	</div>
<?php ActiveForm::end(); ?>