<?php 
use yii\helpers\Html;

?>
<div class="card mb-0">
    <div class="card-header d-print-none">
        Service Labels
        <div class="float-right">
            <?= Html::Button('PRINT', ['onClick' => 'window.print()', 'class' => "btn btn-primary"]) ?>
            <?= Html::Button('BACK', ['onClick' => 'window.history.back();', 'class' => "btn btn-danger"]) ?>
        </div>
    </div>
    <div class="card-body p-0">
        <div class="d-print-block">
            <?php if($actitems = $model->activitiesitems){ ?>
                <?php foreach ($actitems as $b  => $modela) { ?>
                    <?php if ($modela->servicesheet) { ?>
                        <div class="row">
                            <div class="col-12">
                                <table class="table mb-0">
                                    <tr>
                                        <td style="border: solid 1px #000;" class="col1">
                                            <b>Job No: </b><?= $model->jobno; ?><br />
                                            <?php
                                                                switch($modela->type) {
                                                                    case 'bike' : $out = 'Bike';
                                                                    break;
                                                                    case 'lifejacket' : $out = 'Life Jacket';
                                                                    break;
                                                                    case 'liferaft' : $out = 'Life Raft';
                                                                    break;
                                                                    case 'lifeboat' : $out = 'Life Boat';
                                                                    break;
                                                                    default :$out = null;
                                                                    
                                                                } 
                                                                echo '<b>Product Type: </b>' .$out .'<br />'; 
                                                            ?>
                                            <?php 
                                                                $out ='';
                                                                if ($model->imported == true) {
                                                                    $out .= 'End User: <span class="font-weight-bold">'.$model->imp_clientname.'</span><br>'.
                                                                            'Agent: <span class="font-weight-bold">'.$model->imp_agentname.'</span><br>';
                                                                } else {
                                                                    if($model->clients){
                                                                        foreach ($model->clients as $key => $client) {
                                                                            $out .= $client ? 'End User: <span class="font-weight-bold">'.$client->fullname.'</span> <br>': null;
                                                                        }
                                                                    } else {
                                                                        $out .= $model->clientname ? 'End User: <span class="font-weight-bold">'.$model->clientname.'</span><br>' : null;
                                                                    }
                                                                    if($model->agentl) {
                                                                        $out .= $model->agentl ? 'Agent: <span class="font-weight-bold">'.$model->agentl->fullname.'</span><br>' : null;
                                                                    }
                                                                        
                                                                }
                                                                echo $out;
                                                            
                                                            ?>

                                            <b>Bay:</b> <?= $modela->locationl ? $modela->locationl->name : '&nbsp;' ?><br />
                                            <b>Service Type: </b><?= $model->type == 'Fasttrack Service' ? 'FastTrack' : null ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border: solid 1px #000;" class="qrimg p-0 text-center">
                                            <?= Html::img($modela->qrimage); ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border: solid 1px #000;" class="serial">
                                            
                                            <b>Product: </b>
                                            <?php $product = $modela->productl?->product_name;
                                            $out = empty($product) == false ? $product :  $model->productname;
                                            $out .=  empty($product) == false && $product == 'Seago Other' ? '<br /> - '.$modela->typea : '';
                                            echo $out; ?><br />
                                            <b>Serial: </b><?= $modela->serial ?> <br />
                                            <b>Email: </b><?= $model->client?->email ?> <br />
                                            <b>Phone: </b><?= $model->client?->address?->telephone ?> <br />
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="pagebreak"></div>
                    <?php } ?>
                <?php } ?>
            <?php } ?>
        </div>
    </div>
</div>



<style>
@media print {
    @page {
        size: portrait;
        margin: 2mm;
        padding: 0;
    }

    .table {
        max-width: 100vw;
    }


}

.pagebreak {
    page-break-after: always;

}

@media screen {
    .qrimg {
        height: 50mm;
        width: 50mm;
    }

    .card-body table.rotate {
        left: 0px;
        top: 0px;
        position: relative;
    }

    .collectionlabel {
        width: 60mm;
        height: 60mm;
    }

    .el1 {
        height: 150mm;
        width: 60mm;
    }

    .el2 {
        height: 60mm;
        width: 60mm;
    }

    .el3 {
        height: 120mm;
        width: 60mm;
    }

}

.table th,
.table td {
    border-top: none;
}
</style>