Files
rank24.pl/templates/client/reports-pdf.php
2024-12-12 15:33:18 +01:00

134 lines
8.0 KiB
PHP

<?
global $user;
$datetime1 = date( 'Y-m-', strtotime( $this -> _date_from ) ) . '01';
$datetime2 = date( 'Y-m-', strtotime( $this -> _date_to ) ) . date( 't', strtotime( $this -> _date_to ) );
$x = floor( ( strtotime( $datetime2 ) - strtotime( $datetime1 ) ) / 2628000 );
$months = \S::getMonthNames();
?>
<div style="text-align: right; font-size: 14px; margin-bottom: 30px; font-family: Verdana;">Raport pozycji od <?= $this -> _date_from;?> do <?= $this -> _date_to;?></div>
<?
if ( is_array( $this -> _pages ) ):
foreach ( $this -> _pages as $page ):?>
<div style="background: #618FB0; color: #FFF; padding: 10px; font-family: Verdana; margin: 20px auto 10px; text-align: center; font-size: 13px;">Raport dla strony <b><?= $page['url'];?></b></div>
<? for ( $i = 0; $i <= $x; $i++ ):?>
<div style="margin: 15px 0 5px 0; font-size: 12px;"><?= $months[ date( 'n', strtotime( '+' . $i . ' months', strtotime( $this -> _date_from ) ) )];?> <?= date( 'Y', strtotime( '+' . $i . ' months', strtotime( $this -> _date_from ) ) );?></div>
<? if ( is_array( $page['phrases'] ) ):?>
<table style="border-collapse: collapse; border: 1px solid #6F6F6F; width: 100%; font-size: 10px; font-family: verdana; margin-bottom: 10px;">
<tr>
<td style="background: #618FB0; color: #FFF; border: 1px solid #000; padding-left: 5px; height: 25px; width: 250px; font-family: Verdana; font-size: 10px;">Fraza</td>
<? for ( $z = 1; $z <= date( 't', strtotime( '+' . $i . ' months', strtotime( $this -> _date_from ) ) ); $z++ ):?>
<td style="background: #618FB0; color: #FFF; border: 1px solid #000; text-align: center; width: 25px; font-family: Verdana; font-size: 10px;"><?= $z;?></td>
<? endfor;?>
</tr>
<? foreach( $page['phrases'] as $phrase ):?>
<tr>
<td style="border: 1px solid #000; padding: 2px 5px; height: 25px; font-family: Verdana; font-size: 10px;"><?= $phrase['phrase'];?></td>
</tr>
<?
for ( $z = 1; $z <= date( 't', strtotime( '+' . $i . ' months', strtotime( $this -> _date_from ) ) ); $z++ )
{
$date = date( 'Y-m-', strtotime( '+' . $i . ' months', strtotime( $this -> _date_from ) ) );
$z < 10 ? $date .= '0' . $z : $date .= $z;
$phrase['positions'][ $date ] ? $pos = $phrase['positions'][ $date ] : $pos = '-';
if ( $pos == 1 )
$style = 'background: #6a8da7 !important; color: #fff !important;';
if ( $pos == 2 || $pos == 3 )
$style = 'background: #56bc76 !important; color: #fff !important;';
if ( $pos >= 4 && $pos <= 6 )
$style = 'background: #cb60b3 !important; color: #fff !important;';
if ( $pos >= 7 && $pos <= 10 )
$style = 'background: #e5603b !important; color: #fff !important;';
if ( $pos >= 11 && $pos <= 20 )
$style = 'background: #666666 !important; color: #fff !important;';
if ( $pos == 0 || $pos >= 21 )
$style = '';
?>
<td style="color: #000; border: 1px solid #000; text-align: center; font-family: Verdana; font-size: 10px; <?= $style;?>"><?= $pos;?></td>
<?
};?>
<? endforeach;?>
</table>
<? endif;?>
<? endfor;?>
<? if ( $this -> _report_form == 2 ):?>
<? $page['subscription'] ? $suma_all = $page['subscription'] : $suma_all = 0;?>
<? if ( is_array( $page['phrases'] ) ): foreach( $page['phrases'] as $phrase ):?>
<?
$discount = '';
if ( $page['discount'] and !$user['reseller_id'] )
$discount = $page['discount'];
if ( $phrase['discount'] )
$discount = $phrase['discount'];
$suma = 0;
$price_tmp = 0;
?>
<table style="margin: 0 0 10px 0; border-collapse: collapse;">
<? if ( is_array( $phrase['prices'] ) ): foreach ( $phrase['prices'] as $price ):?>
<?
if ( $discount > 0 )
$price_tmp += number_format( number_format( $price['price'] - ( $price['price'] * $discount / 100 ), 2 ) * $price['count'], 2, '.', ' ' );
else
$price_tmp += number_format( $price['price'] * $price['count'], 2, '.', ' ' );
?>
<? endforeach; endif;?>
<? if ( $price_tmp > 0 ):?>
<tr>
<td style="border-bottom: 1px solid #e0e4e8; padding: 2px 5px 2px 0; height: 25px; color: #000; font-family: Verdana; font-size: 11px; font-weight: bold;" colspan="4"><?= $phrase['phrase'];?> <? if ( $discount > 0 and !$user['reseller_id'] ):?><span class="discount">rabat <?= $discount;?>%</span><? endif;?></td>
</tr>
<? if ( is_array( $phrase['prices'] ) ): foreach ( $phrase['prices'] as $price ):?>
<tr>
<td style="width: 100px; border-bottom: 1px solid #e0e4e8; font-family: Verdana; font-size: 10px; height: 25px;">Pozycja <?= $price['start'];?> - <?= $price['end'];?>:</td>
<td style="text-align: right; border-bottom: 1px solid #e0e4e8; font-family: Verdana; font-size: 10px; width: 80px;">
<?
if ( $discount > 0 )
echo number_format( number_format( $price['price'] - ( $price['price'] * $discount / 100 ), 2 ), 2, '.', ' ' );
else
echo number_format( $price['price'], 2, '.', ' ' ) . ' PLN';
?>
</td>
<td style="text-align: right; border-bottom: 1px solid #e0e4e8; font-family: Verdana; font-size: 10px; width: 80px;"><?= (int)$price['count'];?></td>
<td style="text-align: right; border-bottom: 1px solid #e0e4e8; font-family: Verdana; font-size: 10px; width: 80px;">
<?
if ( $discount > 0 )
echo number_format( number_format( $price['price'] - ( $price['price'] * $discount / 100 ), 2 ) * $price['count'], 2, '.', ' ' );
else
echo number_format( $price['price'] * $price['count'], 2, '.', ' ' ) . ' PLN';
?>
</td>
</tr>
<?
$suma += number_format( number_format( $price['price'] - ( $price['price'] * $discount / 100 ), 2 ) * $price['count'], 2 );
$suma_all += number_format( number_format( $price['price'] - ( $price['price'] * $discount / 100 ), 2 ) * $price['count'], 2 );
?>
<? endforeach; endif;?>
<? endif;?>
<? if ( $suma > 0 ):?>
<tr>
<td colspan="2" style="height: 20px; width: 300px;"></td>
<td style="font-family: Verdana; font-size: 10px; text-align: right;">Razem netto:</td>
<td style="font-family: Verdana; font-size: 10px; font-weight: bold; text-align: right;"><?= number_format( $suma, 2, '.', ' ' );?> PLN</td>
</tr>
<tr>
<td colspan="2" style="height: 20px;"></td>
<td style="font-family: Verdana; font-size: 10px; text-align: right;">Razem brutto:</td>
<td style="font-family: Verdana; font-size: 10px; font-weight: bold; text-align: right;"><?= number_format( $suma * 1.23, 2, '.', ' ' );?> PLN</td>
</tr>
<? endif;?>
</table>
<? endforeach; endif;?>
<? if ( $page['subscription'] ):?>
<div style="margin: 15px 0 5px 0; font-size: 12px;">Abonament: <b><?= number_format( $page['subscription'], 2, '.', ' ' );?> PLN</b></div>
<? endif;?>
<? if ( $suma_all > 0 ):?>
<div style="margin: 15px 0 5px 0; font-size: 12px;">Razem netto: <b><?= number_format( $suma_all, 2, '.', ' ' );?> PLN</b></div>
<div style="margin: 15px 0 5px 0; font-size: 12px;">Razem brutto: <b><?= number_format( $suma_all * 1.23, 2, '.', ' ' );?> PLN</b></div>
<? endif;?>
<? endif;?>
<? endforeach;?>
<? endif;?>