<?php
    use yii\helpers\Url;
    use yii\helpers\Html;
    use kartik\grid\GridView;
    
    use app\base\Converter;
    use app\models\Settings;
    $SModel = Settings::find()->one();
    // print_r($SModel);
    
    $stngs_app_name = $SModel->stngs_app_name;
    $stngs_org_name = $SModel->stngs_org_name;
    $stngs_org_addrs = $SModel->stngs_org_addrs;
    $stngs_org_phone = $SModel->stngs_org_phone;
    $stngs_org_mail = $SModel->stngs_org_mail;
    $stngs_org_website = $SModel->stngs_org_website;

    $rec = $dataProvider->getModels();

    $disp_header = '
        <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; line-height: 30px;">
            <tr>
                <th align="center"><h3>Visit Schedule Report</h3></th>
            </tr>
        </table>
        <div style="border: 1px solid #000000; margin: 10px auto;">
            <table >
                
                <tr>
                    <td><h4> Client ID </h4></td>
                    <td><h4> : </h4></td>
                    <td> '.$rec[0]['participant_id'].' </td>
                </tr>
            </table>
        </div>
        <br><br>';

    $disp_table = '<table border="1" cellpadding="0" cellspacing="0" style="width: 100%; line-height: 30px;">
        <thead>';
    $disp_table .= '<tr>
            <td width="50" nowrap><strong>SL #</strong></td>
			<td width="150" nowrap><strong>Date Of Screening</strong></td>	
            <td width="150" nowrap><strong>Visit Code</strong></td>			
            <td width="150"><strong>Actual Date</strong></td>
            <td width="150"><strong>Visit Date</strong></td>
			<td width="150"><strong>Window Start</strong></td>
            <td width="150"><strong>Window End</strong></td>
			<td width="150"><strong>Status</strong></td>';
    $disp_table .= '</tr>
        </thead>
        <tbody>';
    
    // for($i=0; $i<count($rec); $i++)
    foreach ($rec as $key => $model) {       
        $disp_table .= '<tr>
                <td>'.($key+1).'</td>
                <td>'.$model->date_of_screening.'</td>
                <td>'.$model->visit->visit_name.'</td>				
				<td>'.$model->actual_date.'</td>
				<td>'.$model->visit_date.'</td>
				<td>'.$model->window_start.'</td>
				<td>'.$model->window_end.'</td>
                <td>'.$model->status.'</td>';
        $disp_table .= '</tr>';
    }
    $disp_table .= '</tbody></table>';

?>
<table border="0" cellpadding="0" cellspacing="0" width="90%" align="center" class="table">
    <tr>
        <td>
            <img src="../images/iccplus.jpg" style="height: 75px; padding-top: 5px;" />
        </td>
        <td>
            <?php
                echo "<font size=\"3\">".$stngs_org_name."<br/>".$stngs_org_addrs."<br/><b>T : </b>".$stngs_org_phone."<br/><b>E : </b>".$stngs_org_mail."  <b>  Web : </b>".$stngs_org_website."</font>";
            ?>
        </td>
        <td align="right">
            <?php
                $dt_fmt = str_replace("mm", "m", strtolower(Yii::$app->formatter->dateFormat));
                $dt_fmt = str_replace("dd", "d", $dt_fmt);
                $dt_fmt = str_replace("yyyy", "Y", $dt_fmt);
                $dt = date($dt_fmt);
                echo $title_rght = "<br/><font size=\"3\"><b>Printed from :</b> ".$stngs_app_name."<br/>
                <b>Printed by : </b>".Yii::$app->user->identity->users_name."<br/>
                <b>Report Printed on : </b>".$dt."</font>";
            ?>
        </td>
    </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="90%" align="center" class="table">
    <tr>
        <td><?= $disp_header; ?></td>
    </tr>
    <tr>
        <td><?= $disp_table; ?></td>
    </tr>
    
</table>