<?php $__env->startSection('content'); ?>
						<?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">
    		<h1 class="page-header">Welcome to uAdmin <i class="fa fa-refresh hidden-xs" style="float: right; cursor: pointer;" onclick="location.reload()"></i></h1>
    	</div>
    </div>

    <?php if(count($tickets)>0): ?>
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    My Active Tickets
                </div>
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-my_actives">
                            <thead>
                                <tr>
                                    <th>Title</th>
                                    <th>ID</th>
                                    <th>Type</th>
                                    <th>Queue</th>
                                    <th>Customer</th>
                                    <th>Assigned To</th>
                                    <th>Priority</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php $count = 0;  ?>
                            <?php foreach($tickets as $ticket): ?>
                            <?php $count++; ?>
                            <?php if($count % 2 == 1): ?>
                                <tr class="odd">
                            <?php else: ?>
                                <tr class="even">
                            <?php endif; ?>
                                    <td><?php echo e($ticket->title); ?></td>
                                    <td><?php echo e($ticket->getID()); ?></td>
                                    <td><?php echo e($ticket->type); ?></td>
                                    <td><?php echo e(App\Ticket_Queue::find($ticket->queue)['name']); ?></td>
                                    <td><?php echo e(App\Customer::find($ticket->customer)['company_name']); ?></td>
                                    <td>
                                        <?php if($ticket->assigned_to): ?>
                                        <?php echo e(App\User::select('name')->where('id', $ticket->assigned_to)->first()->name); ?>

                                        <?php else: ?>
                                        --
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e(ucfirst($ticket->priority)); ?></td>
                                    <td style="text-align: center;">
                                        <?php if(!$ticket->closed_at): ?>
                                            <button type="buton" class="btn btn-primary" style="float: center; margin-right: 10px;">
                                                <a  href="<?php echo e(url('uadmin/tickets/view/'.$ticket->id)); ?>" style="color:white;">Complete</a>
                                            </button>
                                        <?php endif; ?>

                                        <a href='<?php echo e(url('uadmin/tickets/edit/'.$ticket->id)); ?>'>
                                            <i class="fa fa-edit fa-fw" style="text-align: left;"></i>
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>

    <div class="row">
    	<div class="col-md-6">
    		<div class="panel panel-default">
                <div class="panel-heading">
                    My Active Projects
                </div>
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-my_actives">
                            <thead>
                                <tr>
                                    <th>Company Name</th>
                                    <th>Status</th>
                                    <th>City</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php $count = 0;  ?>
                            <?php foreach($my_actives as $project): ?>
                            <?php $count++; ?>
                            <?php if($count % 2 == 1): ?>
                                <tr class="odd">
                            <?php else: ?>
                            	<tr class="even">
                            <?php endif; ?>
                                    <td><a href="<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>" target="_blank"><?php echo e($project->company_name); ?></a></td>
                                    <td><a href="<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>" target="_blank"> <span style="display: none;"><?php echo e($project->status); ?> - </span><?php echo e($team_object->find($project->status)->name); ?></a></td>
                                    <td><?php echo e($project->service_city); ?></td>
                                </tr>
                            <?php endforeach; ?>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
    	</div>
    	<div class="col-md-6">
    		<div class="panel panel-default">
                <div class="panel-heading">
                    My Upcoming Projects
                </div>
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-my_upcomings">
                            <thead>
                                <tr>
                                    <th>Company Name</th>
                                    <th>Status</th>
                                    <th>City</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php $count = 0;  ?>
                            <?php foreach($my_upcomings as $project): ?>
                            <?php $count++; ?>
                            <?php if($count % 2 == 1): ?>
                                <tr class="odd">
                            <?php else: ?>
                            	<tr class="even">
                            <?php endif; ?>
                                    <td><a href="<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>" target="_blank"><?php echo e($project->company_name); ?></a></td>
                                    <td><a href="<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>" target="_blank"> <span style="display: none;"><?php echo e($project->status); ?> - </span><?php echo e($team_object->find($project->status)->name); ?></a></td>
                                    <td><?php echo e($project->service_city); ?></td>
                                </tr>
                            <?php endforeach; ?>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
    	</div>
    	<div class="col-md-12">
    		<div class="panel panel-default">
                        <div class="panel-heading">
                            Active Projects: Status
                        </div>
                        <div class="panel-body">
                            <div id="active_projects_status"></div>
                        </div>
            </div>
    	</div>
        <div class="col-md-4">
            <div class="panel panel-default">
                <div class="panel-heading">
                    Active Projects: Total
                </div>
                <div class="panel-body">
                    <div style="text-align: center; font-size: 4em;">
                        <strong><?php echo e($total_active); ?></strong>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    Active Projects: Age
                </div>
                <div class="panel-body">
                    <div id="active_projects_age"></div> 
                </div>
            </div>
        </div>
        <div class="col-md-8">
            <div class="panel panel-default">
                <div class="panel-heading">
                    Active Projects: Pending MRC/NRC
                </div>
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-phaseMrcNrc">
                            <thead>
                                <tr>
                                    <th style="text-align: left;">Phase</th>
                                    <th style="text-align: right;">MRC &nbsp;</th>
                                    <th style="text-align: right;">NRC &nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $total_mrc = 0.00; $total_nrc = 0.00; ?>
                                <?php foreach(\App\Team::getMrcNrcFaster() as $results): ?>
                                    <?php
                                        $phase = $results['phase'];
                                        $total_mrc += $results['mrc'];
                                        $total_nrc += $results['nrc'];
                                    ?>
                                    <tr>
                                        <td style="text-align: left;">
                                            <span style="display: none;">
                                                <?php echo e(str_pad($phase->id,2,'0',STR_PAD_LEFT)); ?>

                                            </span>
                                            <?php echo e($phase->name); ?>

                                        </td>
                                        <td style="text-align: right;">
                                            $<?php echo e(number_format($results['mrc'],2)); ?>

                                        </td>
                                        <td style="text-align: right;">
                                            $<?php echo e(number_format($results['nrc'],2)); ?>

                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td style="text-align: left;">
                                        <strong>Totals</strong>
                                    </td>
                                    <td style="text-align: right;">
                                        <strong>$<?php echo e(number_format($total_mrc,2)); ?></strong>
                                    </td>
                                    <td style="text-align: right;">
                                        <strong>$<?php echo e(number_format($total_nrc,2)); ?></strong>
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    	
    </div>
    <hr>
    <br>
    <?php if(false): ?>

    
    <?php 
    	$currentWeek = strtotime('today 3:00 am') == strtotime('Sunday 3:00 am') ? strtotime('today 3:00 am') : strtotime('last Sunday 3:00 am') ; 
    	$weekStart = $currentWeek - 7257600;
    	$monthStart = $weekStart;
    	$projectStart = $weekStart;
    	$months = array();

    	for($i=1;$i<=26;$i++)
    	{
    		if(!array_key_exists(date('M', $monthStart), $months))
    		{
    			$months[date('M', $monthStart)] = 1;
    		}
    		else 
    		{
    			$months[date('M', $monthStart)]++;
    		}
    		
    		$monthStart += 604800;
    	}
    ?>
    <br>
    <!--

    <div class="row">
    	<div class="col-md-12">
    		<div class="panel panel-default">
                        <div class="panel-heading">
                            Active Projects: Timeline
                        </div>
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-gantt" >
                                    <thead>
                                        <tr>
                                            
                                            <th colspan="4">&nbsp;</th>
											
                                            <?php foreach($months as $month => $weeks): ?>
                                            <th colspan="<?php echo e($weeks); ?>"><?php echo e($month); ?></th>	
                                            <?php endforeach; ?>
                                            

                                        </tr>
                                        <tr>
                                        	<th>Company</th>
                                            <th>City</th>
                                            <th>Sold</th>
                                            <th>Due</th>
                                            <?php for($i=1;$i<=26;$i++): ?>
                                            <?php if($weekStart == $currentWeek): ?>
                                            <th style="border-right: 1px solid gray;">
                                            <?php else: ?>
                                            <th>
                                            <?php endif; ?>
                                            
                                            	<?php echo e(date('d', $weekStart)); ?>

                                            </th>
                                            <?php $weekStart += 604800; ?>
                                            <?php endfor; ?>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php $count = 0;  ?>
                                    <?php foreach($all_active as $project): ?>
                                    <?php if($project->desired_due_date != '' && strtotime($project->desired_due_date) != 0): ?>
                                    <?php $count++; ?>
                                    <?php if($count % 2 == 1): ?>
                                        <tr class="odd" title="Status: <?php echo e($team_object->find($project->status)->name); ?>">
                                    <?php else: ?>
                                    	<tr class="even" title="Status: <?php echo e($team_object->find($project->status)->name); ?>">
                                    <?php endif; ?>
                                            <td><a href="<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>" target="_blank"><?php echo e($project->company_name); ?></a></td>
                                            <td><?php echo e($project->service_city); ?></td>
                                            <td><i style="display: none;"><?php echo e($project->date_sold); ?> </i><?php echo e($project->date_sold != '' && strtotime($project->date_sold) != 0 ? date('M d', strtotime($project->date_sold)) : ''); ?></td>
                                            <td><i style="display: none;"><?php echo e($project->desired_due_date); ?></i><?php echo e($project->desired_due_date != '' && strtotime($project->desired_due_date) != 0 ? date('M d', strtotime($project->desired_due_date)) : ''); ?></td> 
                                            
                                            <?php $projectWeeks = $projectStart; 
                                            
                                            		$soldWeek = strtotime(date('Y-m-d', strtotime($project->date_sold)).' 3:00 am') == strtotime('Sunday 3:00 am', strtotime(date('Y-m-d', strtotime($project->date_sold)).' 3:00 am')) 
                                            					? strtotime(date('Y-m-d', strtotime($project->date_sold)).' 3:00 am') : strtotime('last Sunday 3:00 am', strtotime(date('Y-m-d', strtotime($project->date_sold)).' 3:00 am')) ; 
                                            		
                                            		$dueWeek = strtotime(date('Y-m-d', strtotime($project->desired_due_date)).' 3:00 am') == strtotime('Sunday 3:00 am', strtotime(date('Y-m-d', strtotime($project->desired_due_date)).' 3:00 am')) 
                                            					? strtotime(date('Y-m-d', strtotime($project->desired_due_date)).' 3:00 am') : strtotime('last Sunday 3:00 am', strtotime(date('Y-m-d', strtotime($project->desired_due_date)).' 3:00 am')) ; 
                                            		
                                            		$lastClass = '';
                                            		$nextWeek = false;
                                            ?>
                                            
                                            <?php for($i=1;$i<=26;$i++): ?>
                                            	
                                            	<?php 
                                            		$class = '';
                                            		if($projectWeeks > $soldWeek && $projectWeeks < $dueWeek) $class = 'mid';
                                            		if(date('Y-m-d', $projectWeeks) == date('Y-m-d', $soldWeek)) $class = 'start';
                                            		if(date('Y-m-d', $projectWeeks) == date('Y-m-d', $dueWeek)) $class = 'end';
                                            		if($projectWeeks > $dueWeek && $dueWeek < $currentWeek && $projectWeeks <= $currentWeek) $class = 'overdue';
                                            		if($i == 26 && $projectWeeks > $soldWeek && $projectWeeks < $dueWeek) $class = 'leaving';
                                            		if($i == 1 && $projectWeeks > $soldWeek && $projectWeeks < $dueWeek) $class = 'entering';
                                            		
                                            	?>
                                            	<?php if($projectWeeks == $currentWeek): ?>
                                            	<td style="padding: 0; border: 0px; border-right: 1px solid gray;"><div class="<?php echo e($class); ?>">&nbsp;</div></td>
                                            	<?php else: ?>
                                            	<td style="padding: 0; border: 0px;"><div class="<?php echo e($class); ?>">&nbsp;
                                            		
                                            	</div>
                                            	<?php if($nextWeek): ?>
                                            		<div class="currentStatus" style="
                                            		<?php if($class == '' || $class == "end"): ?>
                                            			color: #317aba;
                                            		<?php endif; ?>
                                            		<?php if($class == "end"): ?>
                                            			
														margin-top: -10px; 
                                            		<?php endif; ?>
                                            		"><?php echo e($team_object->find($project->status)->name); ?></div>
                                            		<?php $nextWeek = false; ?>
                                            	<?php endif; ?>
                                            	</td>
                                            	<?php endif; ?>
                                            	<?php if($projectWeeks == $currentWeek): ?>
                                            	
                                            	<?php $nextWeek = true; ?>
                                            	<?php endif; ?>
                                            	<?php $projectWeeks += 604800; 
                                            		  $lastClass = $class;
                                            		  
                                            	?>
                                            <?php endfor; ?>
                                        </tr>
                                        <?php endif; ?>
                                    <?php endforeach; ?>

                                    </tbody>
                                </table>
                            </div>
                        </div>
            </div>
    	</div>
    </div>

    -->

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

<?php $__env->startSection('extras'); ?>
	<style>
		.pagination {
			float: right;
			margin-top: 0;
			margin-bottom: 0;
		}
		th {
			text-align: center;
		}
		
		.mid {
			width:100%; text-align:center; border-bottom: 14px solid #000; line-height:.75em; margin:0 0 0; border-color: #317aba; overflow: visible;
		}
		.start { 
			width:100%; text-align:center; border-bottom: 10px solid transparent; line-height:1em; margin:0 0 0; border-top: 10px solid transparent; border-right: 20px solid #31b953; height: 100%; border-top-right-radius: 20%; border-bottom-right-radius: 20%; overflow: visible;
		}
		.end {
			width:100%; text-align:center; border-bottom: 10px solid transparent; line-height:1em; margin:0 0 0; border-top: 10px solid transparent; border-left: 20px solid #b93131; height: 100%; border-top-left-radius: 20%; border-bottom-left-radius: 20%;overflow: visible; 
		}
		.overdue {
			width:100%; text-align:center; border-bottom: 14px ridge #000; line-height:.75em; margin:0 0 0; border-color: red; overflow: visible;
		}
		.entering {
			width:100%; text-align:center; border-bottom: 14px solid #000; line-height:.75em; margin:0 0 0; border-color: #317aba; border-bottom-left-radius: 100%; overflow: visible;
		}
		.leaving {
			width:100%; text-align:center; border-bottom: 14px solid #000; line-height:.75em; margin:0 0 0; border-color: rgba(48, 122, 190, .5); overflow: visible;
		}
		.currentStatus {
			max-width: 10px; overflow: visible; color: white; position: relative; bottom: 15px; font-size: 10px; white-space: nowrap; padding-left: 2.5em;
		}
	</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('bottom'); ?>
	<script src="<?php echo e(asset('uad/js/plugins/morris/morris.js')); ?>"></script>
	<script src="<?php echo e(asset('uad/js/plugins/morris/raphael.min.js')); ?>"></script>
	<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>
	Morris.Donut({
  		element: 'active_projects_age',
	    data: [
	    {label: "<30 Days", value: <?php echo e($active_ages[29]); ?> },
	    {label: "30+ Days", value: <?php echo e($active_ages[30]); ?> },
	    {label: "60+ Days", value: <?php echo e($active_ages[60]); ?> },
	    {label: "90+ Days", value: <?php echo e($active_ages[90]); ?> }
	 	 ],
	 	resize: true,
	 	colors: ['#ffd966', '#ffb366', '#ff8c66', '#ff6666']
	});

	Morris.Bar({
		  element: 'active_projects_status',
		  data: [
		    { y: 'Entry', a: <?php echo e($statuses[1]); ?> },
		    { y: 'NNI', a: <?php echo e($statuses[2]); ?> },
		    { y: 'Mapping', a: <?php echo e($statuses[3]); ?> },
		    { y: 'Permits', a: <?php echo e($statuses[4]); ?> },
		    { y: 'Constr.', a: <?php echo e($statuses[5]); ?> },
		    { y: 'Splicing', a: <?php echo e($statuses[6]); ?> },
		    { y: 'DC', a: <?php echo e($statuses[7]); ?> },
		    { y: 'CPE', a: <?php echo e($statuses[8]); ?> },
		    { y: 'SP/NA', a: <?php echo e($statuses[9]); ?> },
		    { y: 'HV/CT', a: <?php echo e($statuses[10]); ?> },
            { y: 'NP', a: <?php echo e($statuses[11]); ?> },
		    { y: 'Billing', a: <?php echo e($statuses[12]); ?> },
		  ],
		  xkey: 'y',
		  ykeys: ['a'],
		  labels: ['Projects'],
		  resize: true,
		});

    $(document).ready(function() {
        var table1 =    $('#dataTables-my_actives').dataTable( {
    					"pageLength": 25,
    					"stateSave" : true,
    					"searching" : false,
    					"lengthChange" : true,
    					"order" : [0, "asc"],
    					"pagingType" : "simple"
    					
            } );  



        var table2 =    $('#dataTables-my_upcomings').dataTable( {
    					"pageLength": 25,
    					"stateSave" : true,
    					"searching" : false,
    					"lengthChange" : true,
    					"order" : [1, "desc"],
    					"pagingType" : "simple"
    					
            } );  



        var table4 =    $('#dataTables-phaseMrcNrc').dataTable( {
                        "paging" : false,
                        "stateSave" : false,
                        "searching" : false,
                        "info" : false,
                        "order" : [0, "asc"],                     
            } );  


        });
    /*
    $(document).ready(function() {
        var table3 =    $('#dataTables-gantt').dataTable( {
    					"stateSave" : false,
    					"searching" : false,
    					"lengthChange" : false,
    					"order" : [3, "asc"],
    					"paging" : false,
    					"scrollX" : window.innerWidth < 1500 ? true : false,
    					"columnDefs": [
    			    				   <?php for($i=4;$i<30;$i++): ?>
    					               { "orderable": false, "targets": <?php echo e($i); ?> },
    					               <?php endfor; ?>
    					             ]
    					
    					
            } );  


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