<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<?php 
	echo $this->render('_list_pdf_head',[ 'searchModel' =>$searchModel, 'label' => 'Napi bevételek - Közepes', 'type' =>'medium']);
?>
<h2>Közepes összesítés</h2>

<?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')  => 'medium']);
		echo Html::a("Közepes összesítő Pdf", $pdfUrl,['class' => 'btn btn-primary' ]);
	}


?>

				<h3>Bérletek típus szerint</h3>
				<table class="table table-bordered table-striped table-summary">
					<thead>
						<tr>
							<th>Bérlet típus</th>
							<th>Mennyiség</th>
							<th>Összeg</th>
						</tr>
					</thead>
					<tbody>
    		<?php
						foreach ( $searchModel->ticketStats as $ticketStat ) {
							?>
						<tr>
    						<td class="name"><?php echo $ticketStat['ticket_type_name'] ?></td>
							<td class="count"><?php echo $ticketStat['ticket_count']?> Db</td>
							<td class="money"><?php echo $ticketStat['ticket_money']?> FT</td>
					    </tr>
    		<?php } ?>
					</tbody>
				</table>
			
				<div class="row">
	    			<div class="col-md-12 text-right" style="text-decoration: underline;">
	    				Összesen: <?php	echo $searchModel->ticketMoney;	?> Ft
	    				
	    			</div>
	    		</div>
				<h3>Termékek kategória szerint</h3>
				<table class="table table-bordered table-striped table-summary">
					<thead>
						<tr>
							<th>Termék kategória</th>
							<th>Mennyiség</th>
							<th>Összeg</th>
						</tr>
					</thead>
					<tbody>
    		<?php
						foreach ( $searchModel->productMoneies as $pm ) {
							?>
						<tr>
    						<td class="name"><?php echo $pm['category_name'] ?></td>
							<td class="count"><?php echo $pm['category_count']?> Db</td>
							<td class="money"><?php echo $pm['product_money']?> FT</td>
				    	</tr>
    		<?php } ?>
					</tbody>
				</table>
				<div class="row">
	    			<div class="col-md-12 text-right" style="text-decoration: underline;">
	    				Összesen: <?php	echo $searchModel->productMoney;	?> Ft
	    				
	    			</div>
	    		</div>
				
				<h3>Termékek kategória szerint részletes</h3>
				
				<?php 
				
				
				foreach($searchModel->productsByCategory['categories'] as $categoryHolder ){
					
					$products = $categoryHolder['products'];
				?>
				<h4><?php echo $categoryHolder['category']['name']?></h4>
				
				<table class="table table-bordered table-striped table-summary table-category-product">
					<thead>
						<tr>
							<th>Termék</th>
							<th>Mennyiség</th>
							<th>Összeg</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ( $products as $p){?>
							
							<tr>
	    						<td class='name'><?php echo $p['product_name'] ?></td>
	    						<td class='count'><?php echo $p['product_count'] ?> Db</td>
								<td class='money'><?php echo $p['product_money']?> FT</td>
					    	</tr>
						
						<?php }?>
						<tr class="warning">
	    						<td><?php echo "Összesen" ?></td>
	    						<td><?php  ?></td>
								<td class='money'><?php echo $categoryHolder['total']?> FT</td>
					    	</tr>
					</tbody>
				</table>
	    		<?php
				}
				
	    		?>
	    		<div class="row">
	    			<div class="col-md-12 text-right" style="text-decoration: underline;">
	    				Összesen:
	    				<?php 
		    				echo $searchModel->productsByCategory['total'];
	    				?>
	    			</div>
	    		</div>
	    		
				<h3>Pénzmozgások típus szerint</h3>
				<table class="table table-bordered table-striped table-summary">
					<thead>
						<tr>
							<th>Pénzmozgás típus</th>
							<th>Mennyiség</th>
							<th>Összeg</th>
						</tr>
					</thead>
					<tbody>
	    		<?php
							foreach ( $searchModel->moneyMovementsByType as $mmStat ) {
								?>
						<tr>
				    		<td class="name"><?php echo $mmStat['name'] ?></td>
							<td class="count"><?php echo $mmStat['money_movement_count']?> Db</td>
							<td class="money"><?php echo $mmStat['money_movement_money']?> FT</td>
			    	</tr>
	    		<?php } ?>
					</tbody>
				</table>
			<div class="row">
	    			<div class="col-md-12 text-right" style="text-decoration: underline;">
		    				Összesen: <?php	echo $searchModel->moneyMovementMoneis;	?> Ft
		    			</div>
		    		</div>
		    		
		    		<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>
