<?php
namespace frontend\components;

use Yii;
use common\models\Order;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use common\models\AccountState;

class HtmlHelper{
	

	/**
	 * Mehtod used in reception widgets to render card dependent buttons
	 * 
	 * @see ReceptionCardNumberTicketsWidget
	 * @see ReceptionCardNumberWidget
	 * @see ReceptionMenuWidget
	 * */
	public static function mkReceptionCardBtn($recptionForm, $label,$route = null ){
	
		$url = null;
		$card = $recptionForm->card;
		$classes =  'btn btn-primary btn-reception';
		if ( $card == null ){
			$classes .= ' disabled';
		}
		if ( isset($route)){
			$url = [$route, 'number' => ( isset( $card ) ?   $card->number : '' )];
		}
		return  Html::a(  $label   , $url,  ['class' =>   $classes ] );
	}
	public static function mkReceptionCustomerBtn($recptionForm, $label,$route = null ){
	
		$url = null;
		$card = $recptionForm->card;
		$customer = $recptionForm->customer;
		$classes =  'btn btn-primary btn-reception';
		if ( $card == null || $customer == null){
			$classes .= ' disabled';
		}
		if ( isset($route)){
			$url = [$route, 'number' => ( isset( $card ) ?   $card->number : '' )];
		}
		return  Html::a(  $label   , $url,  ['class' =>   $classes ] );
	}
	
	public static function mkReceptionBtn($recptionForm, $label,$route = null ){
	
		$url = null;
		$card = $recptionForm->card;
		$classes =  'btn btn-primary btn-reception';
	
		if ( isset($route)){
			$url = [$route, 'number' => ( isset( $card ) ?   $card->number : '' )];
		}
	
		return  Html::a(  $label   , $url,  ['class' =>   $classes ] );
	}
	
	
	public static function mkOptions( $models, $key, $value = 'name'   ){
		$result = [];
		$result = ArrayHelper::map( $models, $key, $value );
		return $result;
		
	}
	
	/**
	 * @var $models common\models\Account[]
	 * @return 
	 * */
	public static function mkAccountOptions( $models  ){
		$result = HtmlHelper::mkOptions( $models, 'id_account' );
		return $result;
	}
	/**
	 * @var $models common\models\Discount[]
	 * @return 
	 * */
	public static function mkDiscountOptions( $models  ){
		$result = HtmlHelper::mkOptions( $models, 'id_discount' );
		return $result;
	}
	
	/**
	 * @var $models common\models\TicketType[]
	 * @return 
	 * */
	public static function mkTicketTypeOptions( $models  ){
		$result = HtmlHelper::mkOptions( $models, 'id_ticket_type');
		return $result;
	}
	
	public static function formatMoney($money){
		$s = $money;
		return $s;
	}
	
	
	
	
	
}