<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\widgets\Pjax;
use mdm\admin\components\Helper;
use common\widgets\Alert;
use yii\widgets\LinkPager;
use yii\helpers\Url;
use barcode\barcode\BarcodeGenerator as BarcodeGenerator;

use Da\QrCode\QrCode;

/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var frontend\models\StockOpnameSearch $searchModel
 */

$this->title = 'Print Surat Pesanan No.'.$model->vNoFaktur;
$this->params['breadcrumbs'][] = $this->title;

$tanggal = date("d-m-Y");
$day = date('D', strtotime($tanggal));
$dayList = array(
    'Sun' => 'Minggu',
    'Mon' => 'Senin',
    'Tue' => 'Selasa',
    'Wed' => 'Rabu',
    'Thu' => 'Kamis',
    'Fri' => 'Jumat',
    'Sat' => 'Sabtu'
);

$month = date('m', strtotime($tanggal));
$monthList = array(
    '01' => 'Januari',
    '02' => 'Februari',
    '03' => 'Maret',
    '04' => 'April',
    '05' => 'Mei',
    '06' => 'Juni',
    '07' => 'Juli',
    '08' => 'Agustus',
    '09' => 'September',
    '10' => 'Oktober',
    '11' => 'November',
    '12' => 'Desember'
);
?>

<style>
@media print{
#printableArea{
font-family:Arial;
}
img.logo {
width:83px;
display: block;
margin-left: 40px;
margin-top: 10px;
}
.kop, p{
font-size:12px;
}
.kop h4, .kop p{
margin-left:20px;
}
.table{
width:100%;
}
.table-bordered th,
.table-bordered td {
border: 1px solid #777 !important;
padding:5px;
}
.text-right{
text-align:right;
}
.margin-nol{
margin-bottom:0;
}
.sp {
    text-align:center;
}
.row {
}
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
position: relative;
min-height: 1px;
}
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
float: left;
}
.col-xs-12 {
width: 100%;
}
.col-xs-11 {
width: 91.66666667%;
}
.col-xs-10 {
width: 83.33333333%;
}
.col-xs-9 {
width: 75%;
}
.col-xs-8 {
width: 66.66666667%;
}
.col-xs-7 {
width: 58.33333333%;
}
.col-xs-6 {
width: 50%;
}
.col-xs-5 {
width: 41.66666667%;
}
.col-xs-4 {
width: 33.33333333%;
}
.col-xs-3 {
width: 25%;
}
.col-xs-2 {
width: 16.66666667%;
}
.col-xs-1 {
width: 8.33333333%;
}
.tulisan{
    font-size:12px;
}
}
</style>

<div id="printableArea">
    <div class="row header">
        <!-- <div class="col-xs-3">
            <?= html::img('@web/frontend/web/img/logo.png',['class'=>'logo'])?> 
        </div>
        <div class="col-xs-6">
            <div class="kop">
                <p><b>PT.CLINISINDO PUTRA PERKASA</b>
                <br>(APOTEK MEDICASTORE)
                <br> Jl. Pos Pengumben Lama No.24 Rt.009/003<br>Kembangan Jakarta Barat 11630
                <br> Telp. 29323456, Fax. 29324050
                </p>
            </div>
        </div> -->
    </div>
    <?php $no = 1; ?>
    <?php
    // $tbl = '<p class="margin-nol sp">No. SP/MED/</p><br>';
    $tbl = '<table class="tulisan">';
    $tbl .= '<tr>';
    $tbl .= '<td width="400px"></td>';
    $tbl .= '<td width="300px" align="right">'.$model->pelanggan->vNama.'</td>';
    $tbl .= '</tr><br>';

    $tbl .= '<tr>';
    $tbl .= '<td width="400px"></td>';
    $tbl .= '<td width="300px" align="right">'.$model->vAddress.'</td>';
    $tbl .= '</tr><br><br>';

    $tbl .= '<tr>';
    $tbl .= '<td width="400px"></td>';
    $tbl .= '<td width="300px" align="right">Jakarta, '.date("d-m-Y", strtotime($model->tCreated)).'</td>';
    $tbl .= '</tr>';
    $tbl .= '<tr>';
    // $tbl .= '<td>Apotek Medicastore</td>';
    $tbl .= '</tr>';
    $tbl .= '</table><br>';
    $tbl .= '<h4 style="text-align:center; margin-top:-15px;"><u>SURAT PESANAN</u></h4>';
    $tbl .= '<table border="0" cellpadding="0" cellspacing="0" class="table table-bordered">';
    $tbl .= '<thead><tr>';
    // $tbl .= '<th>Kode </th>';
    $tbl .= '<th>Nama Barang </th>';
    $tbl .= '<th>Kemasan </th>';
    $tbl .= '<th>Qty </th>';
    // $tbl .= '<th>Bonus </th>';
    // $tbl .= '<th>DISC </th>';
    $tbl .= '</tr></thead><tbody>';
    foreach ($model->detail as $v) {
        $bonus = 0;
        $disc = 0;
        $tbl .= '<tr>';
        // $tbl .= '<td>'.$v->barang->iId.'</td>';
        $tbl .= '<td>'.$v->barang->vNama.'</td>';
        $tbl .= '<td>'.$v->kemasan->vNama.'</td>';
        $tbl .= '<td>'.$v->iQty.'</td>';
        // $tbl .= '<td>'.$bonus.'</td>';
        // $tbl .= '<td>'.$disc.'</td>';
        $tbl .= '</tr>';
    }
    $tbl .= '</tbody></table>';

    echo $tbl;

    ?>
    <br><br>
    <div class="clearfix"></div>
    <div class="row">
        <div class="col-xs-8">
            <div class="dibuat"><p></p></div>
        </div>
        <div class="col-xs-5" style="margin-left:28em">
                <!-- <p>Pemesan</p> -->
                <!-- <img src="<?php echo Yii::$app->request->BaseUrl;?>/frontend/web/img/ttd.png" style="width: 75px;" />
                <p style="font-size:11px">(Desi, S.Farm, Apt) <br>12/B.19/31.73.08.1004.07.003.C.1/3/-1.779.3/e/2020</p> -->
        </div>
    </div>
</div>