<?php
use yii\helpers\Html;
$types = ['Facing' => 'Facing','Trailing' => 'Trailing','Single' => 'Single'];
$construction = ['Cast Monobloc' => 'Cast Monobloc', 'Cast Centre Block' => 'Cast Centre Block', 'Cast Vee' => 'Cast Vee', 'Machined nose block' => 'Machined nose block', 'Electro-slag welded Vee' => 'Electro-slag welded Vee', 'Fabricated' => 'Fabricated'];
$design = ['Common' => 'Common', 'Obtuse' => 'Obtuse', 'Swing nose' => 'Swing nose'];
$installationtype = ['Plated' => 'Plated', 'Welded' => 'Welded', 'Part Welded' => 'Part Welded'];
$steeltype = ['AMS' => 'AMS', 'Bainitic' => 'Bainitic', 'Normal' => 'Normal', 'Grade' => 'Grade', 'Low alloy(i.e. machined nose block)' => 'Low alloy(i.e. machined nose block)'];

?>

<div class="dt203-pdf">

<?= $this->render('//common/_pdfheader.php', ['title' => 'Crossing Inspection Report (DT203)']) ?>

    
	<table class="Table notbb nolb norb">
		<tr>
			<th class="DarkerBlue">Location</th>
			<td colspan="4"><?= $model->location ?></td>
			<th class="DarkerBlue">Date Inspected</th>
			
    		<td>
    			<?= $model->date  ?>
    		</td>
		</tr>
		<tr>
			<th class="DarkerBlue">ELR</th>
			<td><?= $model->elr ?></td>
			<th class="DarkerBlue">Track ID</th>
			<td colspan="2"><?= $model->trackid ?></td>
			<th class="DarkerBlue">Mileage</th>
			<td>
			<table class="Table notbb nolb norb">
				<tr>
					<td class="notbb nolb norb"><div class="col-xs-9"><?= $model->mileagem ?></div><div class="col-xs-2">m</div></td>
					<td class="notbb nolb norb"><div class="col-xs-9"><?= $model->mileagey ?></div><div class="col-xs-3">yrds</div></td>
				</tr>
			</table>
			 </td>
    
		</tr>
		<tr>
			<th class="DarkerBlue">Point Number</th>
				<td><?= $model->pointsno ?></td>
			<th class="DarkerBlue">Type</th>
			<td colspan="2" >
			<?php  foreach ($types as $a => $dep) { ?>
					<?php if (is_array($model->type) == true) { ?>
						<?php if (in_array($dep, $model->type) == true) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
						<?php }else{ ?>
							<span class='check'> <?= strtoupper($dep) ?></span>
						<?php } ?>
					<?php } elseif($dep == $model->type) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
					<?php } else { ?>
						<span class='check'> <?= strtoupper($dep) ?></span>
					<?php } ?>
				<?php } ?>
			
			<th class="DarkerBlue">Crossing Angle</th>
				<td><?= $model->crossingangle ?></td>
		</tr>
		<tr>
			<th class="DarkerBlue">Construction</th>
			<td colspan="6" >
				<?php  foreach ($construction as $a => $dep) { ?>
					<?php if (is_array($model->construction) == true) { ?>
						<?php if (in_array($dep, $model->construction) == true) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
						<?php }else{ ?>
							<span class='check'> <?= strtoupper($dep) ?></span>
						<?php } ?>
					<?php } elseif($dep == $model->construction) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
					<?php } else { ?>
						<span class='check'> <?= strtoupper($dep) ?></span>
					<?php } ?>
				<?php } ?>
			</td>
		</tr>
		<tr>
			<th class="DarkerBlue">Design</th>
			<td colspan="4">
			<?php  foreach ($design as $a => $dep) { ?>
					<?php if (is_array($model->design) == true) { ?>
						<?php if (in_array($dep, $model->design) == true) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
						<?php }else{ ?>
							<span class='check'> <?= strtoupper($dep) ?></span>
						<?php } ?>
					<?php } elseif($dep == $model->design) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
					<?php } else { ?>
						<span class='check'> <?= strtoupper($dep) ?></span>
					<?php } ?>
				<?php } ?>
				
			</td>
			<th class="DarkerBlue">Installation Type</th>
			<td colspan="">
			<?php  foreach ($installationtype as $a => $dep) { ?>
					<?php if (is_array($model->installationtype) == true) { ?>
						<?php if (in_array($dep, $model->installationtype) == true) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
						<?php }else{ ?>
							<span class='check'> <?= strtoupper($dep) ?></span>
						<?php } ?>
					<?php } elseif($dep == $model->installationtype) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
					<?php } else { ?>
						<span class='check'> <?= strtoupper($dep) ?></span>
					<?php } ?>
				<?php } ?>
			</td>
		

		</tr>
		<tr>
			<th class="DarkerBlue">Steel Type</th>
			<td colspan="2">
			<?php  foreach ($steeltype as $a => $dep) { ?>
					<?php if (is_array($model->steeltype) == true) { ?>
						<?php if (in_array($dep, $model->steeltype) == true) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
						<?php }else{ ?>
							<span class='check'> <?= strtoupper($dep) ?></span>
						<?php } ?>
					<?php } elseif($dep == $model->steeltype) { ?>
							<span class='check font-weight-bolder' >&#10003; <?= strtoupper($dep) ?></span>
					<?php } else { ?>
						<span class='check'> <?= strtoupper($dep) ?></span>
					<?php } ?>
				<?php } ?>			
			</td>
			<td><?= $model->datemanufactured ? $model->datemanufactured : '' ?></td>
			<th class="DarkerBlue">Date Installed</th>
			<td><?= $model->dateinstalled ? $model->dateinstalled : '' ?></td>
		</tr>
		<tr>
			<th class="DarkerBlue">Manufacturer</th>
			<td colspan="2"><?= $model->manufacturer ?></td>
			<th class="DarkerBlue">Cast No</th>
			<td colspan="3"><?= $model->castno ?></td>
		</tr>
		
		
	</table>
	<br />
	<table class="Table notbb nolb norb">
		<thead>
			<tr>
				<th class="DarkerBlue" rowspan="2">Defect Description</th>
				<th class="DarkerBlue" colspan="2">Defect Present</th>
				<th class="DarkerBlue" rowspan="2" >if yes, UIC</th>
				<th class="DarkerBlue" rowspan="2">Comments; include length, depth &amp; width as appropiate</th>
			</tr>
			<tr>
				<th class="DarkerBlue">Yes</th>
				<th class="DarkerBlue">No</th>
			</tr>
		</thead>
		<tbody>
				<?php $x = 1; ?>
					<?php while($x <= 47 ){ ?>
						<?= $x == 1 ? '<tr class="DarkerBlue"><td colspan="4">Cast Monobloc, Cast Centre or Cast Vee Within fishplate limits</td></tr>' : null ?>
						<?php if($model->getAttributelabel("response$x".'a') !== "response$x".'a'){ ?>
							<tr>
								<th>
									<?= $model->getAttributelabel("response$x".'a') ?>
								</th>
									<?php $fielda = "response$x".'a'; ?>
									<?php if ($model->$fielda == 'YES') { 
										$defecttrue = "<span class='check'>&#10003;</span>";
										$defectfalse = null;
									} elseif ($model->$fielda == 'NO' && !is_null($model->$fielda)) { 
										$defecttrue = null;
										$defectfalse = "<span class='check'>&#10003;</span>";
									} else { 
										$defecttrue = "";
										$defectfalse = "";
									} ?>
								<td><?= $defecttrue ?></td>
								<td><?= $defectfalse ?></td>
					
								<th>
									<?php $fieldb = "response$x".'b'; ?>
									<?= $model->$fieldb  ?>
								</th>
								<td>
									<?php $fieldc = "response$x".'c'; ?>
									<?= $model->$fieldc  ?>
								</td>
							</tr>
						<?php } ?>
						<?= $x == 9 ? '<tr class="DarkerBlue"><td colspan="5">Leg ends</td></tr>' : null ?>
						<?= $x == 14 ? '<tr class="DarkerBlue"><td colspan="5">Anywhere within casting</td></tr>' : null ?>
						<?= $x == 24 ? '<tr class="DarkerBlue"><td colspan="5">Change of section</td></tr>' : null ?>
						<?= $x == 29 ? '<tr class="DarkerBlue"><td colspan="5">Monobloc</td></tr>' : null ?>
						<?= $x == 40 ? '<tr class="DarkerBlue"><td colspan="5">Rolled Steel Crossing Components Wheel transfer area</td></tr>' : null ?>
						<?php  $x++ ?>
					<?php  } ?>
		</tbody>
	</table>

<pagebreak>
<table class="Table notbb nolb norb">
<tr>
	<td rowspan="2" valign="top">
		<img width="auto" height="200px" src="<?= $model->image0 ?>" alt="no image" />
	</td>
	<td colspan="2">
		<img width="auto" height="200px" src="<?= $model->image1 ?>" alt="no image" />
	</td>
		
		</tr>
		<tr>
			<td colspan="2">Indicate Areas requiring repair (diagram my not accurately refect the crossing construction)</td>		
		</tr>
		<tr>
			<th class="DarkerBlue">Rail Defects</th>
			<th class="DarkerBlue">Actions in Accordance with NR/L2/TRK/1054</th>
			<th class="DarkerBlue">RDMS No</th>
		</tr>
		<tr>
			<td><?= $model->railfefect1 ? $model->railfefect1 : '&nbsp;' ?></td>
			<td><?= $model->actions1 ?></td>
			<td><?= $model->rdmsno1 ?></td>
		</tr>
		<tr>
			<td><?= $model->railfefect2 ? $model->railfefect2 : '&nbsp;'  ?></td>
			<td><?= $model->actions2 ?></td>
			<td><?= $model->rdmsno2 ?></td>
		</tr>
		<tr>
			<td><?= $model->railfefect3 ? $model->railfefect3 : '&nbsp;'  ?></td>
			<td><?= $model->actions3 ?></td>
			<td><?= $model->rdmsno3 ?></td>
		</tr>
		
		<tr>
			<th class="DarkerBlue">Track Condition</th>
			<th class="DarkerBlue">Actions in Accordance with NR/L2/TRK/001 &amp; <br /> NR/L2/TRK/1054</th>
			<th class="DarkerBlue">ELLIPSE</th>
		</tr>
		
		<tr>
			<td><?= $model->trackconditions1 ? $model->trackconditions1 : '&nbsp;'  ?></td>
			<td><?= $model->actions4 ?></td>
			<td>
				<table class="Table notbb nolb norb">
					<tr><td>Std Job</td><td></td></tr>	
					<tr><td>W/O</td><td></td></tr>	
					<tr><td>Pty</td><td></td></tr>	
					<tr><td>Qty</td><td></td></tr>	
				</table>
			</td>
		</tr>
		<tr>
			<td><?= $model->trackconditions2 ? $model->trackconditions2 : '&nbsp;'  ?></td>
			<td><?= $model->actions5 ?></td>
			<td>
				<table class="Table notbb nolb norb">
					<tr><td>Std Job</td><td></td></tr>	
					<tr><td>W/O</td><td></td></tr>	
					<tr><td>Pty</td><td></td></tr>	
					<tr><td>Qty</td><td></td></tr>	
				</table>
			</td>
		</tr>
		<tr>
			<td><?= $model->trackconditions3 ? $model->trackconditions3 : '&nbsp;'  ?></td>
			<td><?= $model->actions6 ?></td>
			<td>
				<table class="Table notbb nolb norb">
					<tr><td>Std Job</td><td></td></tr>	
					<tr><td>W/O</td><td></td></tr>	
					<tr><td>Pty</td><td></td></tr>	
					<tr><td>Qty</td><td></td></tr>	
				</table>
			</td>
		</tr>

</table>

    <table class="Table notbb nolb norb">
    	<tr>
    		<th class="DarkerBlue" width="16.7%">Inspected by Name</th>
    
    		<td width="16.7%"><?= $model->inspectedbyname ?></td>
    		<th width="16.7%" class="DarkerBlue">Signature</th>
    		<td width="16.7%">
    			<img height="50px" src="<?= $model->inspectedbysignature ?>" />
    		</td>
    		<th width="16.7%" class="DarkerBlue">Date</th>
    		<td width="16.7%"><?= $model->inspectedbydate ? $model->inspectedbydate : '' ?></td>
    	</tr>
    	<tr>
    		<th class="DarkerBlue">SM[T] Name</th>
    		<td><?= $model->smtname ?></td>
    		<th class="DarkerBlue">Signature</th>
    		<td>
    			<img height="50px" src="<?=  $model->smtsignature ?>" />
    			
    		</td>
    		<th class="DarkerBlue">Date</th>
    		<td><?= $model->smtdate ? $model->smtdate : '' ?></td>
    	</tr>
    	<tr>
    		<th class="DarkerBlue">Imputer Name</th>
    		<td><?= $model->inputername ?></td>
    		<th class="DarkerBlue">Signature</th>
    		<td>
    			<img height="50px" src="<?= $model->inputersignature ?>" />
    				
    			</td>
    		<th class="DarkerBlue">Date Entered RDMS</th>
    		<td><?= $model->inputerdate ? $model->inputerdate : '' ?></td>
    	</tr>
    	<tr>
    		<th class="DarkerBlue">Section Planner Name</th>
    		<td><?= $model->sectionplannername ?></td>
    		<th class="DarkerBlue">Signature</th>
    		<td>
    			<img height="50px" src="<?=  $model->sectionplannersignature ?>" />
    				
    		</td>
    		<th class="DarkerBlue">Date Entered ELLIPSE</th>
    		<td><?= $model->sectionplannerdate ? $model->sectionplannerdate : '' ?></td>
    	</tr>
    </table>
    <br />
    <table class="Table notbb nolb norb">
    	<tr>
    		<th colspan="4" class="">Section Manager or Representive (W&G) Assessment (Including 7-point check) </th>
    	</tr>
    	<tr>
    		<td>&nbsp;</td>
    		<th class="DarkerBlue">Please "x" recommended action</th>
    		<th class="DarkerBlue">Estimate of time required for repair</th>
    		<th class="DarkerBlue">can repair be staged over successive possessions?</th>
    	</tr>
		<tr>
    		<th class="DarkerBlue">Temporary Weld Repair - <br /> Pending Replacement</th>
    		<td><?= $model->twrrecommendation ?></td>
    		<td><?= $model->twrrepairtime ?></td>
    		<td><?= $model->twrstaged ?></td>
    	</tr>
    	<tr>
    		<th class="DarkerBlue">Permanent Repair</th>
    		<td><?= $model->prrecommendation ?></td>
    		<td><?= $model->prrepairtime ?></td>
    		<td><?= $model->prstaged ?></td>
    	</tr>
    	<tr>
    		<th class="DarkerBlue">Replace</th>
    		<td><?= $model->rrecommendation ?></td>
    		<td><?= $model->rrepairtime ?></td>
    		<td><?= $model->rstaged ?></td>
    	</tr>
    	<tr>
    		<td colspan="4" height="50px">
    			Ultrasonics Findings(if Applicable)<br />
    			<?= $model->ultrasonics ? $model->ultrasonics : '&nbsp;'  ?>
    		
    		</td>
    	</tr>
    	<tr>
    		<td colspan="4" height="50px">
    			Additional Comments (This may include addinitional required work prior to welding e.g fetting)<br />
    			<?= $model->addcomments  ? $model->addcomments : '&nbsp;' ?>
    		</td>
    	</tr>
    	<tr>
    		<th class="DarkerBlue" colspan="3">Was a site visit performed by welding expertise to inspect the defect and complete the above assessment?</th>
    		<td><?= $model->sitevisitperformed ?></td>
    	</tr>
    </table>
    

    <table class="Table notbb nolb norb">
    	<tr> 
	    	<th class="DarkerBlue" width="150px">Section Manager (W&amp;G)</th>
	    	<th class="DarkerBlue">Name</th>
	    	<td><?= $model->sectionmanname ?></td>
	    	<th class="DarkerBlue">Signature</th>
	    	<td>
    			<img height="50px" src="<?=  $model->sectionmansignature ?>" />
		    </td>
	    	<th class="DarkerBlue">Date</th>
	    	<td><?= $model->sectionmandate ? $model->sectionmandate : '' ?></td>
    	</tr> 
    	<tr> 
	    	<th class="DarkerBlue">Track Maintenance Engineer</th>
	    	<th class="DarkerBlue">Name</th>
	    	<td><?= $model->trackmanname ?></td>
	    	<th class="DarkerBlue">Signature</th>
	    	<td>
    			<img height="50px" src="<?= $model->trackmansignature ?>" />
	    	</td>
	    	<th class="DarkerBlue">Date</th>
	    	<td><?= $model->trackmandate ? $model->trackmandate : '' ?></td>
    	</tr>
    	
    </table>
</div>
    
    
	