<section class="container">
	<div class="row">
		<div class="col-xs-12">
			Further to your enquire for the above, we are pleased to submit our quotation for your kind consideration and approval.
		</div>
	</div>
	<?php if (isset($table)) { ?>
	<div class="row">
		<div class="col-xs-12 table-responsive">
			<table width="100%">
				<?php if (isset($table['header'])) { ?>
				<thead>
					<tr>
						<th class="tac">#</th>
						<?php
						$index = 0;
						foreach ($table['header'] as $header) {
						?>
						<th class="<?php echo (isset($table['right-column']) && in_array(++$index, $table['right-column'])) ? 'tar' : ''; ?>"><?php echo $header; ?></th>
						<?php
						}
						?>
					</tr>
				</thead>
				<?php } ?>
				<?php if (isset($table['body'])) { ?>
				<tbody>
					<?php
					$row = 0;
					$sum = array();
					if (isset($table['total-column'])) {
						foreach ($table['total-column'] as $total) {
							$sum[$total] = 0;
						}
					}
					foreach ($table['body'] as $data) {
						if (is_object($data)) {
							$data = get_object_vars($data);
						}
					?>
					<tr>
						<td class="tac"><?php echo ++$row; ?></td>
						<?php
						$index = 0;
						foreach ($data as $key => $value) {
						?>
						<td class="<?php echo (isset($table['right-column']) && in_array(++$index, $table['right-column'])) ? 'tar' : ''; ?>">
							<?php
							if (isset($table['right-column']) && in_array($index, $table['right-column'])) {
								echo number_format(floatval($value), 2);
							} else {
								echo nl2br($value);
							}
							?>
						</td>
						<?php
							if (count($sum) > 0 && array_key_exists($index, $sum)) {
								$sum[$index] += floatval($value);
							}
						}
						?>
					</tr>
					<?php
					}
					?>
				</tbody>
				<?php } ?>
			</table>
		</div>
	</div>
	<?php } ?>
	<?php if (isset($table['total-title'])) { ?>
	<div class="row">
		<div class="col-xs-12">
			<div class="col-xs-6 col-sm-5 col-md-4 pull-right grand-total form-horizontal">
				<?php
				if (isset($table['total-title']) && count($table['total-title'] == count($sum))) {
					foreach ($table['total-title'] as $title) {
				?>
				<div class="form-group">
					<label class="col-xs-7 total-title"><?php echo $title; ?>:</label>
					<div class="col-xs-5">
						<span class="total-value"><?php echo number_format(array_shift($sum), 2); ?></span>
					</div>
				</div>
				<?php
					}
				}
				?>
			</div>
		</div>
	</div>
	<?php } ?>
</section>
