<?php $__env->startSection('content'); ?>
<?php $date = $timecard->date; 
		$url_date = date('Y-m-d', strtotime($timecard->date));
		$thisWeek = strtotime('last Sunday');
		$startWeek = strtotime('2017-02-26');
?>
	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Timecard</h1> 
    		<select class="notes" onchange="window.location = '<?php echo e(url("uadmin/timecard/accountant")); ?>' + '/' + this.value;">
    			<option>Select Week</option>
    			<?php while($thisWeek != $startWeek): ?>
    				<option value="<?php echo e(date('Y-m-d', $thisWeek)); ?>"><?php echo e(strtoupper(date('d-M-Y', $thisWeek)).' through '.strtoupper(date('d-M-Y', strtotime('+6 days', $thisWeek)))); ?></option>
    				<?php $thisWeek = strtotime('-1 week', $thisWeek);?>
    			<?php endwhile; ?>
    		</select>
    	</div>
    </div>
    <?php if(session('status')): ?>
							<div class="alert alert-success">
								<?php echo e(session('status')); ?>

							</div>
						<?php endif; ?>
			
						<?php if(count($errors) > 0): ?>
							<div class="alert alert-danger">
								<strong>Whoops!</strong> There were some problems with your input.<br><br>
								<ul>
									<?php foreach($errors->all() as $error): ?>
										<li><?php echo e($error); ?></li>
									<?php endforeach; ?>
								</ul>
							</div>
						<?php endif; ?>
    
        <div class="row">
                <div class="col-lg-12">
	                <h4>All Employees: <?php echo e(strtoupper(date('d-M-Y', strtotime($date)))); ?> through <?php echo e(strtoupper(date('d-M-Y', strtotime('+6 days', strtotime($date))))); ?></h4>
	                <i id="status_wheel" class="fa fa-spinner fa-pulse" style="float: right;"></i>
	                <div class="row">
						<div class="panel-group col-md-12">
						<?php $tcs = \App\Timecard::where('date','=',$date)->orderBy('created_by', 'asc')->get();?>
						<?php if($tcs): ?>
						<?php foreach($tcs as $tc): ?>
							
							
							<div class="panel panel-default">
							    <div class="panel-heading" 
							    <?php if($tc): ?>
							    onclick="window.location = '<?php echo e(url("uadmin/timecard/accountant/".$url_date."/".$tc->employee)); ?>'" style="cursor: pointer;"
							    <?php else: ?>
							    onclick="alert('Timecard not available.');"
							    <?php endif; ?>
							    >
							    	<span><?php echo e(\App\Employee::find($tc->employee)->getName()); ?></span>
							    	
							    	<span style="float: right;">
							    		<i>Employee:</i>
							    			<?php if(!$tc || !$tc->approve_self): ?>
							    			 <i class="fa fa-times" style="color: red;"></i>
							    			<?php else: ?>
							    			 <i class="fa fa-check" style="color: green;"></i>	
							    			<?php endif; ?>
							    		<i>Manager:</i> 
							    			<?php if(!$tc || !$tc->approve_manager): ?>
							    			 <i class="fa fa-times" style="color: red;"></i>
							    			<?php else: ?>
							    			 <i class="fa fa-check" style="color: green;"></i>	
							    			<?php endif; ?>
							    	</span>
							    	
							    	
							    </div>
							    
							    <?php if($tc && $tc->id == $timecard->id): ?>
						<div class="panel-body">
                			<div class="row hidden-sm hidden-xs col_head">
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Account</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Company</span>
								</div>
								<div class="col-md-2 excel">
									<span class="col-md-12 excel">Description</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Sun</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Mon</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Tue</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Wed</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Thur</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Fri</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Sat</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-md-12 excel">Total</span>
								</div>
								
							</div> <!-- /pannel-body -->
						<?php $i = 0;?>
                        <?php foreach($accounts as $account): ?>
                        	<?php $access = !$account->global ?  \App\Access::where('employee','=',$employee->id)->where('type','=','account')->where('account','=',$account->id)->first() : false; ?>
							<div
							id="<?php echo e($access ? 'access' . $access->id : 'global'.$account->id); ?>"
							<?php if($access && $access->default): ?>
							class="row" 
							<?php else: ?>
							class="row rhidden"
							<?php endif; ?>
							<?php if(++$i%2 != 0): ?>
							style="background-color: #ecf2f5; border-top: 1px dotted #aaa;"
							<?php else: ?> if 
							style="border-top: 1px dotted #888;"
							<?php endif; ?>
							>
								<div class="col-md-1 excel sb">
									<!-- <button class="btn btn-primary btn-xs"><i class="fa fa-minus"></i></button> -->
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Account:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style"><?php echo e($account->number); ?></span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Company:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style"><?php echo e($account->company); ?></span>
								</div>
								<div class="col-md-2 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Description:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style"><?php echo e($account->description); ?></span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg weekend">Sunday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel weekend">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_1" name="entry_<?php echo e($account->id); ?>[1]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="1" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Monday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_2" name="entry_<?php echo e($account->id); ?>[2]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="2" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Tuesday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_3" name="entry_<?php echo e($account->id); ?>[3]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="3" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Wednesday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_4" name="entry_<?php echo e($account->id); ?>[4]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="4" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Thursday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_5" name="entry_<?php echo e($account->id); ?>[5]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="5" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Friday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_6" name="entry_<?php echo e($account->id); ?>[6]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="6" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg weekend">Saturday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel weekend">
										<input class="time_input" id="entry_<?php echo e($account->id); ?>_7" name="entry_<?php echo e($account->id); ?>[7]" type="number" step=".25" value="0.00" account="<?php echo e($account->id); ?>" day="7" accounttype="account" disabled>
									</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Total:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										<strong id="<?php echo e($account->global ? 'total_global'.$account->id : 'total_access'.$access->id); ?>"  class="account_totals">0.00</strong>
									</span>
								</div>
							</div>
						<?php endforeach; ?>
						<?php foreach($allocations as $allocation): ?>
							<?php $access = \App\Access::where('employee','=',$employee->id)->where('type','=','allocation')->where('account','=',$allocation->id)->first(); ?>
							<div
							id="<?php echo e('access' . $access->id); ?>"
							<?php if($access->default): ?>
							class="row" 
							<?php else: ?>
							class="row rhidden"
							<?php endif; ?>
							<?php if(++$i%2 != 0): ?>
							style="background-color: #ecf2f5; border-top: 1px dotted #aaa;"
							<?php else: ?> if 
							style="border-top: 1px dotted #888;"
							<?php endif; ?>
							>
								<div class="col-md-1 excel sb">
									<!-- <button class="btn btn-primary btn-xs"><i class="fa fa-minus"></i></button> -->
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Account:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style">-</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Company:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style">-</span>
								</div>
								<div class="col-md-2 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Description:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style"><?php echo e($allocation->description); ?></span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg weekend">Sunday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel weekend">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_1" name="allo_entry_<?php echo e($allocation->id); ?>[1]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="1" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Monday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_2" name="allo_entry_<?php echo e($allocation->id); ?>[2]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="2" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Tuesday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_3" name="allo_entry_<?php echo e($allocation->id); ?>[3]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="3" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Wednesday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_4" name="allo_entry_<?php echo e($allocation->id); ?>[4]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="4" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Thursday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_5" name="allo_entry_<?php echo e($allocation->id); ?>[5]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="5" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Friday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_6" name="allo_entry_<?php echo e($allocation->id); ?>[6]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="6" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg weekend">Saturday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel weekend">
										<input class="time_input" id="allo_entry_<?php echo e($allocation->id); ?>_7" name="allo_entry_<?php echo e($allocation->id); ?>[7]" type="number" step=".25" value="0.00" account="<?php echo e($allocation->id); ?>" day="7" accounttype="allocation" disabled>
									</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Total:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										<strong id="total_access<?php echo e($access->id); ?>" class="account_totals">0.00</strong>
									</span>
								</div>
							</div>
						<?php endforeach; ?>
						<?php for($k=1;$k<=18;$k++): ?>
                        	<div
							id="wo<?php echo e($k); ?>"

							class="row rhidden" 

							<?php if(++$i%2 != 0): ?>
							style="background-color: #ecf2f5; border-top: 1px dotted #aaa;"
							<?php else: ?> if 
							style="border-top: 1px dotted #888;"
							<?php endif; ?>
							>
								<i style="display: none;" id="wo_id<?php echo e($k); ?>"></i>
								<i style="display: none;" id="awo_id<?php echo e($k); ?>"></i>
								<div class="col-md-1 excel sb">
									<!-- <button class="btn btn-primary btn-xs"><i class="fa fa-minus"></i></button> -->
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Work Order:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style" id="wo_number<?php echo e($k); ?>"></span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Company:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style">-</span>
								</div>
								<div class="col-md-2 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg col_label">Description:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style" id="wo_description<?php echo e($k); ?>" title=""></span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg weekend">Sunday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel weekend">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_1" name="wo_entry_<?php echo e($k); ?>[1]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="1" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Monday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_2" name="wo_entry_<?php echo e($k); ?>[2]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="2" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Tuesday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_3" name="wo_entry_<?php echo e($k); ?>[3]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="3" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Wednesday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_4" name="wo_entry_<?php echo e($k); ?>[4]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="4" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Thursday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_5" name="wo_entry_<?php echo e($k); ?>[5]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="5" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Friday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_6" name="wo_entry_<?php echo e($k); ?>[6]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="6" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg weekend">Saturday:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel weekend">
										<input class="time_input" id="wo_entry_<?php echo e($k); ?>_7" name="wo_entry_<?php echo e($k); ?>[7]" type="number" step=".25" value="0.00" account="<?php echo e($k); ?>" day="7" accounttype="work_order" disabled>
									</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Total:&nbsp;</span>
									<span class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										<strong id="total_wo<?php echo e($k); ?>"  class="account_totals">0.00</strong>
									</span>
								</div>
							</div>
							<?php endfor; ?>
							<div class="row" style="border-top: 1px solid black; ">
								<div class="col-md-4 excel hb">
									Total
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Sunday:&nbsp;</span>
									<span id="day_d1" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Monday:&nbsp;</span>
									<span id="day_d2" class="col-xs-6 col-sm-6 col-md-12 exce account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Tuesday:&nbsp;</span>
									<span id="day_d3" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Wednesday:&nbsp;</span>
									<span id="day_d4" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Thursday:&nbsp;</span>
									<span id="day_d5" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel sb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Friday:&nbsp;</span>
									<span id="day_d6" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel hb">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Saturday:&nbsp;</span>
									<span id="day_d7" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										0.00
									</span>
								</div>
								<div class="col-md-1 excel">
									<span class="col-xs-6 col-sm-6 hidden-md hidden-lg">Total:&nbsp;</span>
									<span id="day_all" class="col-xs-6 col-sm-6 col-md-12 excel account_style">
										<strong>0.00</strong>
									</span>
								</div>
							</div>
							<div class="row">
				             	<div class="col-md-12" style="padding: 0; margin: 0;">
				             		<textarea id="notes" name="notes" class="notes" rows="3" placeholder="Notes" disabled style="margin-top: 15px; margin-bottom: 0; border-radius: 0px;"><?php echo e($timecard->notes); ?></textarea>
				             	</div>
				             </div>
				             <?php if(count($allocations) > 0): ?>
				             <div class="row">
				             	<div class="col-md-12">
				             		<div class="panel panel-default">
				             			<div class="panel-heading">
				             				Allocations Summary
				             			</div>
				             			<div class="panel-body">
				             				<?php $none_used = false;?>
				             				<?php foreach($allocations as $allocation): ?>
				             					
				             					<?php if(\App\Entry::where('timecard','=',$timecard->id)->where('type','=','allocation')->where('account','=',$allocation->id)->exists()): ?>
				             						<?php $a_total = 0;?>
				             						<?php $a_cal = array(); ?>
							             			<?php $a_time = \App\Allocation_link::where('allocation','=',$allocation->id)->where('time','!=',0.00)->exists() ? true : false;?>
				             						<?php foreach(\App\Entry::where('timecard','=',$timecard->id)->where('type','=','allocation')->where('account','=',$allocation->id)->get() as $a_entry): ?>
				             							<?php $a_total += $a_entry->value;?>
				             							<?php if($a_time): ?>
				             							<?php $a_temp = $allocation->calculate($a_entry->value); ?>
				             							<?php foreach($a_temp as $kk => $vv): ?>
				             								<?php if(array_key_exists($kk, $a_cal)): ?>
				             									<?php $a_cal[$kk] += $vv;	?>
				             								<?php else: ?>
				             									<?php $a_cal[$kk] = $vv; ?>
				             								<?php endif; ?>
				             							<?php endforeach; ?>
				             							<?php endif; ?>		
				             						<?php endforeach; ?>
				             						<?php if(!$a_time): ?>
				             							<?php $a_cal = $allocation->calculate($a_total); ?>
				             						<?php endif; ?>
				             						<strong><?php echo e($allocation->description); ?></strong>
				             						<?php foreach($a_cal as $k => $v): ?>
				             							<?php $ind_acc = \App\Account::find($k);?>
				             							<?php echo "<br>" . $ind_acc->number . " | " . $ind_acc->company . " | " . $ind_acc->description . ': ' . $v; ?>

				             						<?php endforeach; ?>
				             						<br>
				             						<?php $none_used = true;?>
				             					<?php else: ?>
				             						<?php if(!$none_used): ?>
				             							No allocations were used this week.
				             							<?php $none_used = true;?>
				             						<?php endif; ?>
				             					<?php endif; ?>
				             				<?php endforeach; ?>
				             			</div>
				             		</div>
				             	</div>
				             </div>
				             <?php endif; ?>
				              
				             <div class="row">
					             <div class="col-md-12">
									<?php if(Auth::user()->isAccountant() && $timecard->approve_self != ''): ?>
										<form method="POST" action="<?php echo e(url('admin/timecard/unapprove_accountant')); ?>">
											<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
											<input type="hidden" name="timecardID" value="<?php echo e($timecard->id); ?>">
											<button type="submit" class="btn btn-primary" style="float: right; margin-left: 5px; margin-top: 5px;">Remove Approval</button>
										</form>
										
									<?php endif; ?>
								</div>
							</div>
							
                         </div>
							    <?php endif; ?>
							</div>
						<?php endforeach; ?>
						<?php endif; ?>
							    	
						</div>
					</div>
                </div>
        </div>

    
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/t/bs/pdfmake-0.1.18,dt-1.10.11,b-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2/datatables.min.css"/>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css" />
    <style>
	    @import  url('https://fonts.googleapis.com/css?family=Ubuntu');
		.time_input {
			width: 100%;
			background-color: transparent;
			outline: none;
			border: none;
			padding-left: 10px;
			opacity: 0.2;
		}

		input:focus {
			background-color: #333;
/* 			border: 1px solid gray; */
			color: white;
		}
		.col_label {
/*
			border-right: none;
			border-left: none;
			border-top: none;
			border-bottom: 1px solid #b3b3b3;
*/
			background-color: #555;
			color: white;
			text-align: right;
			font-family: 'Ubuntu', sans-serif;
			text-transform:uppercase;
			font-size: .75em;
			padding: 0.2em 0 0.2em 0;
			letter-spacing: 1px;
			}
		.col_head {
			background-color: #555;
			color: white;
			text-align: center;
			font-family: 'Ubuntu', sans-serif;
			text-transform:uppercase;
			font-size: .75em;
			padding: 0.25em 0 0.25em 0;
			letter-spacing: 1px;
		}
		.col_head .excel {
			border-right: 1px solid #b3b3b3;
			border-left: none;
		}
		.col_head .excel:last-child {
			border-right: none;
		}
		.excel {
			margin: 0;
			padding: 0;
			padding-left: 0px;
			font-family: 'Ubuntu', sans-serif;
		}
		.weekend {
			background-color: rgba(0, 0, 0, 0.25);
			color: #555;
			height: 20px;
		}
		.account_style {
			padding-left: 10px;
		}
		.default-checkbox {
			float: right;
			display: none;
		}
		.excel:hover .default-checkbox {
			display: block;
		}
		.rhidden {
			display: none;
		}
		.wo_select {
			
			width: 100% !important;
		}
		.wo_select button {
			width: 100%;
			background-color: transparent;
			outline: none;
			border: none;
			padding: 0;
		}
		.dropdown-menu .open {
			max-width: 100px !important;
			min-width: 100px !important;
		}
		a:hover{
    		text-decoration: none;
    	}
    	.odd .subBack {
    		background-color: #f0fcff;
    	}
    	.even .subBack {
    		background-color: #ecf7fa;
    	}
    	.floatLeft
    	{
    		float: left;
    	}
    	.notes {
    		opacity: 1;
    		background-color: #f6f6f6;
    		border-radius: 4px;
    		padding-top: 5px;
    		padding-right: 5px;
    		padding-bottom: 5px;
    		margin-bottom: 15px;
    		border: 1px solid #e1e1e1;
    		width: 100%;
			outline: none;
			padding-left: 10px;
    	}
    	@media  print {
  @page  {
    size: 427mm 330mm;
    margin: 14mm;
  }
  .container {
    width: 1170px;
  }
}
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('bottom'); ?>
   <script type="text/javascript" src="https://cdn.datatables.net/t/bs/pdfmake-0.1.18,dt-1.10.11,b-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2/datatables.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
   <script>
	
   		var status_wheel = document.getElementById('status_wheel');
   		var account_options = <?php echo e($accounts->count()); ?>;
   		var accounts_table, workorders_table;
   		var visible_wo = 0;
   		
   		function statusWheel(state)
   		{
			if(state)
			{
				status_wheel.style.display = "block";
			}
			else
			{
				status_wheel.style.display = "none";
			}
   		}
   		function addAccount()
   		{
   	   		statusWheel(true);
			var accounts = document.getElementById('accounts');
			if(accounts.value > 0)
			{
				var option = document.getElementById('option'+accounts.value);
				var row = document.getElementById('access'+accounts.value);
				row.style.display = 'block';
				option.style.display = 'none';
				accounts.selectedIndex = 0;
				account_options--;
				if(account_options < 1)
				{
					accounts.style.display = 'none';
				}
				
			}
			statusWheel(false);
   		}
   		function addAccount2(access)
   		{
   	   		statusWheel(true);
			
			if(access > 0)
			{
				
				var row = document.getElementById('access'+access);
				row.style.display = 'block';
				
				account_options--;
				
				
			}
			statusWheel(false);
   		}
		function addWO(wo)
		{
			statusWheel(true);
			if(document.getElementById('awo_id'+wo) == null)
			{
				visible_wo++;
				if(visible_wo > 18)
				{
					alert('Cannot add additional work orders.');
					statusWheel(false);
					return;
					
				}
				var wo_num = document.getElementById('wo_number'+visible_wo);
				var wo_desc = document.getElementById('wo_description'+visible_wo);
				var wo_id = document.getElementById('wo_id'+visible_wo);
				var awo_id = document.getElementById('awo_id'+visible_wo);

				wo_num.innerHTML = wos[wo].number;
				
				var description = wos[wo].description;
				if(description.length > 18)
				{
					wo_desc.innerHTML = description.substring(0,17)+'...';
				}
				else
				{
					wo_desc.innerHTML = description;
				}
				wo_desc.title = description;

				wo_id.innerHTML = wo;
				awo_id.id = 'awo_id'+wo;
				awo_id.innerHTML = visible_wo;
				
				var row = document.getElementById('wo'+visible_wo);
				row.style.display = 'block';

				removeRowWO(document.getElementById('wo_row'+wo));
			}
			

			statusWheel(false);
		}
   		function updateDefault(box)
   		{
   	   		statusWheel(true);
			$.post("/uadmin/ajaxTimecardDefault.php",
			{
				access: box.getAttribute('access'),
				value: box.checked ? 1 : 0

			},
			function(data,status)
			{
				console.log(data);
				console.log(status);
				statusWheel(false);
			}
			);
   		}
   		function PREupdateEntry(entry)
   		{
   			entry.value = Number(entry.value);

			if(entry.value < 0)
			{
				entry.value = 0.00;
			}
   			if(entry.value > 24)
   			{
				entry.value = 24.00;
   			}
   			
   			entry.value = (Math.round(entry.value * 4)/4).toFixed(2);
   			
   			updateEntry(entry);

   		}
   		function updateEntry(entry)
   		{
   	   		
   	   		statusWheel(true);
			var account;
			if(entry.getAttribute('accounttype') == 'work_order')
			{
				var k = entry.getAttribute('account');
				var wo_id = document.getElementById('wo_id'+k).innerHTML;
				account = wo_id;

			}
			else
			{
				account = entry.getAttribute('account');
			}
   	   		if(entry.value > 0)
   	   		{
				entry.style.opacity = '1';
   	   		}
   	   		else
   	   		{
				entry.style.opacity = '0.3';
   	   		}
   	   		
			$.post("/uadmin/ajaxTimecardEntry.php",
			{
				timecard: <?php echo e($timecard->id); ?>,
				value: entry.value,
				account: account,
				type: entry.getAttribute('accounttype'),
				day: entry.getAttribute('day')
			},
			function(data,status)
			{
				getTotals();
				statusWheel(false);
			}
			);
   		}
   		function getEntries()
   		{
   	   		statusWheel(true);
   			$.get("/uadmin/ajaxEntries.php",
   			{
				timecard: <?php echo e($timecard->id); ?>

   			},
   		   	function(data, status)
   		   	{
   		        //console.log("Data: " + data.entries[0].value + "\nStatus: " + status);
   		        for(j=0;j<data.access.length;j++)
   		       	{
   	   		       	var access = data.access[j];
					var row = document.getElementById('access'+access);
					row.style.display = 'block';
					removeRowAccount(document.getElementById('a_row'+access));
   		       	}
   		    	for(k=0;k<data.global.length;k++)
		       	{
	   		       	var account3 = data.global[k];
					var row = document.getElementById('global'+account3);
					row.style.display = 'block';
					var table_row = document.getElementById('ag_row'+account3);
					if(table_row != null)
					{
						removeRowAccount(table_row);
						
					}
					
		       	}
   		     	if(account_options < 1)
				{
   		     	var accounts = document.getElementById('accounts');
					accounts.style.display = 'none';
				}
   		        for(i=0;i<data.entries.length;i++)
   		       	{
   	   		       	var entry = data.entries[i];
   	   		       	if(entry.type == 'account')
   	   		       	{
   	   		      		var input = document.getElementById('entry_'+entry.account+'_'+entry.day);
   	   		       	}
   	   		       	else if(entry.type == 'work_order')
   	   		       	{
   	   	   		       	addWO(entry.account);
   	   	   		        var k_num = document.getElementById('awo_id'+entry.account).innerHTML;
   	   		      		var input = document.getElementById('wo_entry_'+k_num+'_'+entry.day);
   	   		       	}
   	   		       	else
   	   		       	{
   	   		      		var input = document.getElementById('allo_entry_'+entry.account+'_'+entry.day);
   	   		       	}
					
					input.value = entry.value;
					if(input.value > 0)
					{
						input.style.opacity = '1';
					}
   		       	}
   		       	getTotals();
   		       	statusWheel(false);
   		    }
   		    );
   		}
   		function getTotals()
   		{
   			statusWheel(true);
   			$.get("/uadmin/ajaxTimecardTotals.php",
   			{
				timecard: <?php echo e($timecard->id); ?>

   			},
   		   	function(data, status)
   		   	{
   				//console.log(data);
   		   		var total_hours = 0.00;
   		   		for(i=1;i<=7;i++)
   		   		{
   		   			var Ptotal = document.getElementById('day_d'+i);
					Ptotal.innerHTML = Number(0.00).toFixed(2);
   		   		}
   		        for(var day in data.days)
   		       	{
   	   		       	
					var total = document.getElementById('day_'+day);
					total.innerHTML = Number(data.days[day]).toFixed(2);
					total_hours += +data.days[day];
   		       	}
   		       	var sheet_total = document.getElementById('day_all');
   		       	sheet_total.innerHTML = Number(total_hours).toFixed(2);

   		       	

				var account_totals = document.getElementsByClassName('account_totals');
   		       	for(var one in account_totals)
   		       	{
   	   		       	var ind = account_totals[one];
					ind.innerHTML = Number(0.00).toFixed(2);
					
   		       	}
   		     	for(var key in data.accounts)
		       	{
   		     		var k_num = document.getElementById('awo_id'+key);
   		     		if(k_num == null)
   		     		{
   		     			var total = document.getElementById('total_'+key);
   		     			total.innerHTML = Number(data.accounts[key]).toFixed(2);
   		     		}
   		     		else
   		     		{
   	   		     		
   		     			var total = document.getElementById('total_wo'+k_num.innerHTML);
   		     			
   		     			total.innerHTML = Number(data.accounts[key]).toFixed(2);
   		     		}
					
					
					
		       	}
   		       	statusWheel(false);
   		    }
   		    );
   		}


   		function removeRowAccount(element)
		{
   			var table = $('#dataTables-accounts').DataTable();
			table.row(element).remove().draw();
		}

   		function removeRowWO(element)
		{
   			var table = $('#dataTables-workorders').DataTable();
			table.row(element).remove().draw();
		}
   		
   	    $(document).ready(function() {
   	     accounts_table = $('#dataTables-accounts').dataTable( {
   	 					"pageLength": 10,
   	 					"order": [ 0, 'asc' ],
   	 					"stateSave" : false,
   	 					"scrollX" : window.innerWidth < 800 ? true : false,
   	 					"columnDefs": [
   	 					               {
   	 					                   "targets": [ 3 ],
   	 					                   "visible": false,
   	 					                   "searchable": true
   	 					               },
   	 					           ],
   	 					"pagingType": 'simple',
   	 					"language": {
   	 			            "lengthMenu": "Show _MENU_",
   	 			            "zeroRecords": "No available accounts",
   	 			            "info": "Showing _START_ to _END_ of _TOTAL_ accounts",
   	 			            "infoEmpty": "No available accounts",
   	 			            "infoFiltered": "(filtered from _MAX_ accounts)",
   	 			        	"paginate": {
		   	 			        "first":      "First",
		   	 			        "last":       "Last",
		   	 			        "next":       "<i class='fa fa-arrow-right'></i>",
		   	 			        "previous":   "<i class='fa fa-arrow-left'></i>"
		   	 			    	}
   	 			        }
   	 					
   	         } ); 
   	  	workorders_table = $('#dataTables-workorders').dataTable( {
						"pageLength": 10,
						"order": [ 0, 'asc' ],
						"stateSave" : false,
						"scrollX" : window.innerWidth < 800 ? true : false,
						"columnDefs": [
						               {
						                   "targets": [ 2 ],
						                   "visible": false,
						                   "searchable": true
						               },
						           ],
						"pagingType": 'simple',
   	 					"language": {
   	 			            "lengthMenu": "Show _MENU_",
   	 			            "zeroRecords": "No available work orders",
   	 			            "info": "Showing _START_ to _END_ of _TOTAL_ work orders",
   	 			            "infoEmpty": "No available work orders",
   	 			            "infoFiltered": "(filtered from _MAX_ work orders)",
   	 			        	"paginate": {
		   	 			        "first":      "First",
		   	 			        "last":       "Last",
		   	 			        "next":       "<i class='fa fa-arrow-right'></i>",
		   	 			        "previous":   "<i class='fa fa-arrow-left'></i>"
		   	 			    	}
   	 			        }
						
		  		} );   

   			
   	     });
   	 if ( typeof $.fn.dataTable == "function" && typeof $.fn.dataTableExt.fnVersionCheck == "function" && $.fn.dataTableExt.fnVersionCheck('1.9.2')/*older versions should work too*/ )
     {
         $.fn.dataTableExt.oApi.clearSearch = function ( oSettings )
         {
      
             var table = this;
              
             //any browser, must include your own file
             //var clearSearch = $('<img src="/images/delete.png" style="vertical-align:text-bottom;cursor:pointer;" alt="Delete" title="Delete"/>');
              
             //no image file needed, css embedding must be supported by browser
             var clearSearch = $('<i class="fa fa-times-circle-o fa-fw" style="vertical-align:text-bottom;cursor:pointer;color: gray;"></i>');
             $(clearSearch).click( function ()
                     {
                           table.fnFilter('');
                     });
             $(oSettings.nTableWrapper).find('div.dataTables_filter').append(clearSearch);
             $(oSettings.nTableWrapper).find('div.dataTables_filter label').css('margin-right', '-16px');//16px the image width
             $(oSettings.nTableWrapper).find('div.dataTables_filter input').css('padding-right', '16px');
         }
      
         //auto-execute, no code needs to be added
         $.fn.dataTable.models.oSettings['aoInitComplete'].push( {
             "fn": $.fn.dataTableExt.oApi.clearSearch,
             "sName": 'whatever'
         } );
     }

			var wos = [];
			<?php foreach($work_orders as $wo): ?>
				wos[<?php echo e($wo->Id); ?>] = {
					"number": "<?php echo e($wo->WONumber); ?>",
					"description": "<?php echo e($wo->Client_WO_Name); ?>",
					"company": "<?php echo e($wo->Client_Company); ?>"
				};
			<?php endforeach; ?>


   		
   		window.onload = getEntries();
    </script> 

<?php $__env->stopSection(); ?>

<?php echo $__env->make('residential.templates.uadmin', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>