<?php
use common\components\RoleDefinition;
use yii\helpers\Html;
use yii\helpers\Url;
?>
<?php 
	echo $this->render('_list_pdf_head',[ 'searchModel' =>$searchModel, 'label' => 'Napi bevételek - Rézsletes','type' =>'detailed']);
?>
<h2>Részletes összesítés</h2>
				<?php 
					//////////////////////////
					// Bérletek
					////////////////////////
				?>
				<h3>Bérletek</h3>
				<?php 
				
if ( !isset($searchModel->output) ){
		$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output')  => 'pdf']);
		echo Html::a("Teljes PDF letöltése", $pdfUrl,['class' => 'btn btn-primary btn-all' ]);
	
		$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output')  => 'pdf', Html::getInputName($searchModel, 'outputView')  => 'detailed']);
			echo Html::a("Egyszerű összesítő Pdf", $pdfUrl,['class' => 'btn btn-primary' ]);
	}
	?>
				<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>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['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 
						}else{?>
						
						<div class="row">
			    			<div class="col-md-12 text-right" style="text-decoration: underline;">
			    				Összesen: <?php	echo $searchModel->ticketMoney;	?> Ft
			    				
			    			</div>
			    		</div>
			    		 <pagebreak />
						<?php 
						}
						?>
						<?php 
					//////////////////////////
					// Termék eladás
					////////////////////////
				?>
				<h3>Termék eladások</h3>
				<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>Kategória</th>
							<th>Termék</th>
							<th>Egység ár</th>
							<th>Mennyiség</th>
							<th>Összeg</th>
						</tr>
					</thead>
					<tbody>
				    	<?php foreach ($searchModel->products as $p ){?>
				    	<tr>
			    						<td><?php echo $p['product_created_at']?> </td>
			    						<td><?php echo $p['product_paid_at']?> </td>
			    						<td><?php echo $p['account_name']?> </td>
			    						<td><?php echo $p['user_name']?> </td>
			    						<td><?php echo $p['product_category_name'] ?></td>
			    						<td><?php echo $p['product_name'] ?></td>
										<td class='money'><?php echo $p['product_item_price']?> Ft</td>
										<td class='count'><?php echo $p['product_count']?> Db</td>
										<td class='money'><?php echo $p['product_money']?> FT</td>
				    		
					    </tr>
				    	<?php } ?>
				</tbody>
				</table>
						<?php if ( count($searchModel->products ) == 0 ) {
						?>
						Nincs találat
						<?php 
						}else{?>
						
						<div class="row">
			    			<div class="col-md-12 text-right" style="text-decoration: underline;">
			    				Összesen: <?php	echo $searchModel->productMoney;	?> Ft
			    			</div>
			    		</div>
			    				 <pagebreak />
						<?php 
						}
						?>
				<?php 
					//////////////////////////
					// Pénzmozgások
					////////////////////////
				?>
				<h3>Pénzmozgások</h3>
				<table class="table table-bordered table-striped table-summary">
					<thead>
						<tr>
							<th>Dátum</th>
							<th>Kassza</th>
							<th>Felhasználó</th>
							<th>Név</th>
							<th>Típus</th>
							<th>Összeg</th>
						</tr>
					</thead>
					<tbody>
				    	<?php foreach ($searchModel->moneyMovements as $p ){?>
				    	<tr>
			    						<td><?php echo $p['money_movement_created_at']?> </td>
			    						<td><?php echo $p['account_name']?> </td>
			    						<td><?php echo $p['user_name']?> </td>
			    						<td><?php echo $p['money_movement_name'] ?></td>
			    						<td><?php echo $p['money_movement_type_name'] ?></td>
										<td class='money'><?php echo $p['signed_money']?> Ft</td>
				    		
					    </tr>
				    	<?php } ?>
				</tbody>
				</table>
						<?php if ( count($searchModel->moneyMovements ) == 0 ) {
						?>
						Nincs találat
							<?php 
						}else{?>
						
						<div class="row">
			    			<div class="col-md-12 text-right" style="text-decoration: underline;">
			    				Összesen: <?php	echo $searchModel->moneyMovementMoneis;	?> Ft
			    				
			    			</div>
			    		</div>
						<?php 
						}
						?>
						
						<div class="row">
			    			<div class="col-md-12 text-right" style="text-decoration: underline; font-weight: bold;">
			    				Végösszeg: <?php	echo $searchModel->total;	?> Ft
			    				
			    			</div>
			    		</div>