<?php
use yii\helpers\Html;
use common\models\Account;
use common\models\User;
use common\models\ProductCategory;
use common\models\Product;
use common\models\Transfer;
use common\models\TicketType;
?>
<style>
td,th{
	padding: 3px;
}
 .table-summary td.count {
	text-align: right;
}

.table-summary td.money {
	text-align: right;
}

.table-filter th{
	text-align: left;
}
</style>
<div class="container">
		<?php
		// ////////////////////////
		// Termék eladás
		// //////////////////////
		?>
		<h3>Termék eladások</h3>
		
		<table class="table-filter">
			<tr>
		  <th><?php echo Html::encode($searchModel->getAttributeLabel('start')) ?></th>
		  <td><?php echo Html::getAttributeValue($searchModel, "start")?></td>
		  <th><?php echo Html::encode($searchModel->getAttributeLabel('end')) ?></th>
		  <td><?php echo Html::getAttributeValue($searchModel, "end")?></td>
		  </tr>
		  <tr>
		  <th><?php echo Html::encode($searchModel->getAttributeLabel('id_account')) ?></th>
		  <td><?php  if (   empty($searchModel->id_account)  ){
		  			 echo"Mind" ;
		  			}else{ 
		  			$account = Account::findOne($searchModel->id_account) ; 
		  				if ( $account != null ){
		  					echo $account->name;
		  				}
		 			 }?></td>
		 <th><?php echo Html::encode($searchModel->getAttributeLabel('id_user')) ?></th>
		  <td><?php  if (   empty($searchModel->id_user)  ){
		  			 echo"Mind" ;
		  			}else{ 
		  			$user = User::findOne($searchModel->id_user) ; 
		  				if ( $user != null ){
		  					echo $user->username;
		  				}
		 			 }?></td>
		 </tr>
		 <tr>
			 <th><?php echo Html::encode($searchModel->getAttributeLabel('id_ticket_type')) ?></th>
			 <td><?php  if (   empty($searchModel->id_ticket_type)  ){
		  			 	echo"Mind" ;
		  			}else{ 
		  			$ticketType = TicketType::findOne($searchModel->id_ticket_type) ; 
		  				if ( $ticketType != null ){
		  					echo $ticketType->name;
		  				}
		 			 }?></td>
		 		 
		 <th><?php echo Html::encode($searchModel->getAttributeLabel('customer')) ?></th>
		  <td><?php  if (   empty($searchModel->customer)  ){
		  			 	echo"" ;
		  			}else{ 
		  					echo Html::encode($searchModel->customer) ;
		 			 }?></td>
			</tr>
		 	<tr>
		 <th><?php echo Html::encode($searchModel->getAttributeLabel('status')) ?></th>
		  <td><?php  if (   empty($searchModel->status)  ){
		  			 	echo"Mind" ;
		  			}else{ 
		  			$statuses = Transfer::statuses();
		  			$status = "";
		  				if (array_key_exists($searchModel->status, $statuses) ){
		  					echo $statuses[$searchModel->status];
		  				} 
		 			 }?></td>
		 	</tr>
		</table>
		<div class="row">
			<div class="col-md-12 text-right" style="text-decoration: underline;  ">
			    				Összesen: <?php	echo $searchModel->ticketMoney;	?> Ft
			</div>
		</div>
		<table class="table table-bordered table-striped table-summary">
			<thead>
				<tr>
					<th>Kiadva</th>
					<th>Fizetve</th>
					<th>Kassza</th>
					<th>Felhasználó</th>
					<th>Vendég</th>
					<th>Bérlet típus</th>
					<th>Egység ár</th>
					<th>Mennyiség</th>
					<th>Összeg</th>
				</tr>
			</thead>
			<tbody>
		    	<?php foreach ($searchModel->tickets as $t ){?>
			    	<tr>
						<td><?php echo $t['ticket_created_at']?> </td>
	    						<td><?php echo $t['ticket_paid_at']?> </td>
	    						<td><?php echo $t['account_name']?> </td>
	    						<td><?php echo $t['user_name']?> </td>
	    						<td><?php echo $t['customer_name']?> </td>
	    						<td><?php echo $t['ticket_type_name'] ?></td>
								<td class='money'><?php echo $t['ticket_item_price']?> Ft</td>
								<td class='count'><?php echo $t['ticket_count']?> Db</td>
								<td class='money'><?php echo $t['ticket_money']?> FT</td>
	
					</tr>
		    	<?php } ?>
			</tbody>
		</table>
						<?php
						
				if (count ( $searchModel->tickets ) == 0) {
											?>
										Nincs találat
										<?php
										} 
							?>
					</div>
