<?php $this->load->view('checkout/style'); ?>


<div class="content-wrapper">
	<div class="content">
		<div class="row section-title text-center">
			<div class="col">
				<h1>Project Checkout</h1>
				<p>Total cost of your project</p>
			</div>
		</div>
		<div class="row">
			<?php foreach($projects as $project){ ?>
				<div class="col-sm-12">
					<div class="panel panel-default">
						<div class="panel-body">
							<div class="col-sm-8 col-sm-offset-2">
								<div class="item-name p-1-b">
									<h2>Your Project Overview</h2>
								</div>
								<div class="item-overview table-responsive">
									<table class="table table-striped table-bordered table-hover">
										<tr>
											<th>Name</th>
											<td><?php echo $project['title']; ?></td>
										</tr>
										<tr>
											<th>Date</th>
											<td><?php echo $project['startDT'].' - '.$project['endDT']; ?></td>
										</tr>
										<tr>
											<th>Venue</th>
											<td><?php echo $project['venue']; ?></td>
										</tr>
										<tr>
											<th>Status</th>
											<td><?php echo $project['status']; ?></td>
										</tr>
										<tr>
											<th>Total Voters</th>
											<td><?php echo count($project['voters']); ?></td>
										</tr>
										<tr>
											<th>Cost (RM)</th>
											<td>
												<table class="table table-striped table-bordered table-hover calc">
													<tr class="">
														<th>Base Price (First 200 voters)</th>
														<td class="text-right"><?php echo number_format($project['cost']['basePrice'], 2) ?></td>
													</tr>
													<?php if(isset($project['cost']['tier1'])){ ?>
														<tr class="">
															<th>Low Tier (<?php echo $project['cost']['tier1']['voters'].' voters x RM'.number_format($project['cost']['tier1']['rate'], 2); ?>)</th>
															<td class="text-right"><?php echo number_format($project['cost']['tier1']['cost'], 2); ?></td>
														</tr>
													<?php } ?>
													<?php if(isset($project['cost']['tier2'])){ ?>
														<tr>
															<th>Mid Tier (<?php echo $project['cost']['tier2']['voters'].' voters x RM'.number_format($project['cost']['tier2']['rate'], 2); ?>)</th>
															<td class="text-right"><?php echo number_format($project['cost']['tier2']['cost'], 2); ?></td>
														</tr>
													<?php } ?>
													<?php if(isset($project['cost']['tier3'])){ ?>
														<tr>
															<th>Top Tier (<?php echo $project['cost']['tier3']['voters'].' voters x RM'.number_format($project['cost']['tier3']['rate'], 2); ?>)</th>
															<td class="text-right"><?php echo number_format($project['cost']['tier3']['cost'], 2); ?></td>
														</tr>
													<?php } ?>
												</table>
											</td>
										</tr>
										<tr class="total">
											<th>Total Cost (RM)</th>
											<td id="" class="text-right"><?php echo $project['cost']['totalCost']; ?></td>
										</tr>
									</table>
								</div>
							</div>
							<div class="col-sm-8 col-sm-offset-2">
								<div class="item-name p-1-b">
									<h3>Please check the following information to make sure everything is true.</h3>
								</div>
								<div class="item-overview table-responsive">
									<table class="table table-striped table-bordered table-hover">
										<tr>
											<th>Name</th>
											<td>
												<input type="text" class="form-control" id="userName" placeholder="Name" value="<?php echo $user['username']; ?>" disabled />
											</td>
										</tr>
										<tr>
											<th>E-Mail</th>
											<td>
												<input type="email" class="form-control" id="userNum" placeholder="Phone Number" value="<?php echo $user['phone_mobile']; ?>" disabled />
											</td>
										</tr>
										<tr>
											<th>Phone Number</th>
											<td>
												<input type="email" class="form-control" id="userEmail" placeholder="E-Mail" value="<?php echo $user['email']; ?>" disabled />
											</td>
										</tr>
									</table>
								</div>
								<div class="item-checkout">
									<div class="checkbox pull-left">
										<label><input id="userVerification" type="checkbox">I hereby confirm the provided information are true unless stated otherwise.</label>
									</div>
									<div class="pull-right">
										<button id="checkoutBtn" class="btn btn-primary" onclick="return checkout()" <?php if($project['paid'] === '1') echo "disabled data-toggle='tooltip' title='This project is fully paid.'"; ?>>Checkout</button>
									</div>
								</div>
								
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</div>
</div>


<?php $this->load->view('checkout/script', $projects); ?>