 
<?php $__env->startSection('content'); ?>
	<div class="row">
    	<div class="col-lg-12">
    		<h1 class="page-header">Projects</h1>
    	</div>
    </div>
    <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
	                    <?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="panel-heading">
                            Active Projects <a href="<?php echo e(url('uadmin/projects/add')); ?>" target="_blank"> <i class="fa fa-plus fa-fw" style="float: right;"></i> </a>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>Company</th>
                                            <th>Status</th>
                                            <th>Address</th>
                                            <th>City</th>
                                            <th>Sold Date</th>
                                            <th>Due Date</th>
                                            <th>Project Created</th>
                                            <th>Action</th>
                                            <th>Keywords</th>
                                            <th>MRC</th>
                                            <th>NRC</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php $count = 0;  ?>
                                    <?php foreach($active_projects as $project): ?>
                                    <?php $count++; ?>
                                    <?php if($count % 2 == 1): ?>
                                        <tr class="odd">
                                    <?php else: ?>
                                    	<tr class="even">
                                    <?php endif; ?>
                                            <td><?php echo e($project->company_name); ?><span style="color: gray; font-size: .9em;"><?php echo e($project->title != '' ? ' - '.$project->title : ''); ?></span></td>
                                            <td
                                            <?php if($project->assignee): ?>
                                                title="Tech: <?php echo e($project->assignee); ?>"
                                            <?php endif; ?>
                                            ><a href='<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>'> <span style="display: none;"><?php echo e($project->status == 12 ? 'Z' : ($project->status == 11 ? 'Y' : ($project->status == 10 ? 'X' : $project->status))); ?> - </span><?php echo e($team_object->find($project->status)->name); ?></a></td>
                                            <td><?php echo e($project->service_address); ?></td>
											<td><?php echo e($project->service_city); ?></td>
                                            <td><?php echo e($project->date_sold != '' && strtotime($project->date_sold) != 0 ? date('Y-m-d', strtotime($project->date_sold)) : ''); ?></td>
                                            <td><?php echo e($project->desired_due_date != '' && strtotime($project->desired_due_date) != 0 ? date('Y-m-d', strtotime($project->desired_due_date)) : ''); ?></td>
                                            <td><?php echo e(date('Y-m-d', strtotime($project->created_at))); ?></td>
                                            <td style="text-align: center;">
                                            	<a href='<?php echo e(url('uadmin/projects/edit/'.$project->id.'/'.$project->status)); ?>'>
                                            		<i class="fa fa-edit fa-fw" style="text-align: left;"></i>
                                            	</a>
                                            	&nbsp &nbsp
                                            	<a href="<?php echo e(url('uadmin/projects/report/'.$project->id)); ?>" target="_blank"><i class="fa fa-file-pdf-o"></i></a>
                                            	<!--  &nbsp &nbsp
                                            	<a href='#'>
                                            		<i class="fa fa-trash-o fa-fw" style="text-align: left;"></i>
                                            	</a>  -->
                                            </td>
                                            <td>
                                            	<?php echo e($project->order_type); ?> &nbsp;
                                            	<?php echo e($project->customer_type); ?> &nbsp;
                                            	<?php echo e($project->sales_exec); ?> &nbsp;
                                            	<?php echo e($project->client_primary_contact); ?> &nbsp;
                                            	<?php echo e($project->billing_attention); ?> &nbsp;
                                            	<?php echo e($project->technical_contact); ?> &nbsp;

                                            	<?php echo e($project->service_zip); ?> &nbsp;
                                            	<?php echo e($project->account_num); ?> &nbsp;
                                            	<?php echo e($project->contact_primary_email); ?> &nbsp;
                                            	<?php echo e($project->technical_email); ?> &nbsp;
                                                <?php echo e($project->circuit_num); ?> &nbsp;
                                            	
                                            </td>
                                            <?php 
                                                $mrc = 'Disabled';
                                                $nrc = 'Disabled';

                                                $mrc = 0;
                                                $nrc = 0;
                                                $products = \App\Product::whereProject($project->id)->get();
                                                foreach($products as $product)
                                                {
                                                    $mrc += $product->mrc;
                                                    $nrc += $product->nrc;
                                                }


                                            ?>
                                            <td>
                                                <?php echo e($mrc); ?>

                                            </td>
                                            <td>
                                                <?php echo e($nrc); ?>

                                            </td>
                                        </tr>
                                  	<?php endforeach; ?>
                                       </tbody>
                                	</table>
                                </div>
                             </div>
                         </div>
                     </div>

                        <div class="col-lg-12" style="text-align: center; margin-bottom: 20px;">
                            <a href="<?php echo e(url('uadmin/projects/archive')); ?>" target="_blank" class="btn btn-primary">
                                Archived Projects
                            </a>

                        </div>
                   <div class="col-lg-12">
                    <div class="panel panel-default">
                      <div class="panel-heading">
                            Last 10 Archived Projects
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example2">
                                    <thead>
                                        <tr>
                                            <th>Company</th>
                                            <th>City</th>
                                            <th>Date Sold</th>
                                            <th>Project Created</th>
                                            <th>Completed</th>
                                            <th>Action</th>
                                            
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php $count = 0; ?>
                                    <?php foreach($archive_projects as $archive): ?>
                                    <?php $count++; ?>
                                    <?php if($count % 2 == 1): ?>
                                        <tr class="odd">
                                    <?php else: ?>
                                    	<tr class="even">
                                    <?php endif; ?>
                                            <td><?php echo e($archive->company_name); ?><span style="color: gray; font-size: .9em;"><?php echo e($archive->title != '' ? ' - '.$archive->title : ''); ?></span></td>
                                            <td><?php echo e($archive->service_city); ?></td>
                                            <td><?php echo e($archive->date_sold != '' && strtotime($archive->date_sold) != 0 ? date('Y-m-d', strtotime($archive->date_sold)) : ''); ?></td>
                                            <td><?php echo e($archive->created_at); ?></td>
                                            <td><?php echo e($archive->done); ?></td>
                                            <td style="text-align: center;">
                                            <!--
                                            <a href="<?php echo e(url('uadmin/projects/view/'.$archive->id)); ?>" target="_blank">
                                             
                                            		<i class="fa fa-file-text-o fa-fw" style="text-align: left;"></i>
                                            	</a>
                                            	 
                                            	&nbsp &nbsp   -->
                                            	<a href="<?php echo e(url('uadmin/projects/report/'.$archive->id)); ?>" target="_blank"><i class="fa fa-file-pdf-o"></i></a>
                                            	&nbsp; &nbsp;
                                            	<a href="<?php echo e(url('uadmin/projects/ross_report/'.$archive->id)); ?>" target="_blank"><i class="fa fa-list-alt"></i></a>
                                            	
                                            	
                                            </td>
                                            

                                        </tr>
                                  	<?php endforeach; ?>
                                       </tbody>
                                	</table>
                                </div>
                             </div>
                         </div>
                     </div>
                 </div>
</div>
<br><br>
 
               
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<!-- DataTables CSS -->
    <!-- <link href="<?php echo e(asset('uad/css/plugins/dataTables.bootstrap.css')); ?>" rel="stylesheet">  -->
    <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"/>
    
    
    <style>
    	a:hover{
    		text-decoration: none;
    	}
    	.odd .subBack {
    		background-color: #f0fcff;
    	}
    	.even .subBack {
    		background-color: #ecf7fa;
    	}
    	.floatLeft
    	{
    		float: left;
    	}

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

<?php $__env->startSection('bottom'); ?>

    <!-- DataTables JavaScript 
    <script src="<?php echo e(asset('uad/js/plugins/dataTables/jquery.dataTables.js')); ?>"></script>
    <script src="<?php echo e(asset('uad/js/plugins/dataTables/dataTables.bootstrap.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>

	
    
    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
    var table1 =    $('#dataTables-example').dataTable( {
        			"dom":"<'floatLeft'B>fti<'floatLeft'l>p",
					"pageLength": 100,
					"order": [[ 1, 'asc' ],[ 5, 'asc' ]],
					"stateSave" : false,
					"scrollX" : window.innerWidth < 800 ? true : false,
					"columnDefs": [
					               {
					                   "targets": [ 2,4,8,9,10 ],
					                   "visible": false,
					                   "searchable": true
					               },
					           ],
				    "buttons": [
								{
								    extend: 'csv',
								    text: '<i class="fa fa-file-excel-o"></i>',
								    title: 'uAdmin Active Projects',
								    filename: 'uAdmin_Active_Projects_'+ (Math.floor(new Date().getTime()/1000)),
								    exportOptions: {
								        columns: [0,1,2,3,4,5,6,9,10]
								    }
								},
				              {
				                  extend: 'pdf',
				                  text: '<i class="fa fa-file-pdf-o"></i>',
				                  title: 'uAdmin Active Projects',
				                  filename: 'uAdmin_Active_Projects_'+ (Math.floor(new Date().getTime()/1000)),
				                  exportOptions: {
				                      columns: [0,1,2,3,4]
				                  }
				              },
				              {
				                  extend: 'print',
				                  text: '<i class="fa fa-print"></i>',
				                  title: 'uAdmin Active Projects',
				                  exportOptions: {
				                      columns: [0,1,2,3,4]
				                  }
				              }
				              
				          ]
					
        } );  


    });

    
    
    $(document).ready(function() {
    var table2 =    $('#dataTables-example2').dataTable( {
			"paging": false,
            "ordering": false,
			"order": [ 4, 'desc' ],
            "searching": false,
			"scrollX" : window.innerWidth < 800 ? true : false,
        } );  
    });

    
    
    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'
        } );
    }

    </script> 

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




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