/home/dvjjulio/softtrash/resources/views/welcome.blade.php
@extends('layout')

@section('content')
<style type="text/css">
    .filterable {
        margin-top: 15px;
    }
    .filterable .panel-heading .pull-right {
        margin-top: -20px;
    }
    .filterable .filters input[disabled] {
        background-color: transparent;
        border: none;
        cursor: auto;
        box-shadow: none;
        padding: 0;
        height: auto;
    }
    .filterable .filters input[disabled]::-webkit-input-placeholder {
        color: #333;
    }
    .filterable .filters input[disabled]::-moz-placeholder {
        color: #333;
    }
    .filterable .filters input[disabled]:-ms-input-placeholder {
        color: #333;
    }

</style>
<div id="page-content">
   <div class="content-header">
		<div class="header-section">
			<h1>
			<i class="fa fa-recycle"></i>Bienvenido<br><small>Sistema de Monitoreo a Recolectora <br> {!! ($fecha == null)? Helper::mostrar_fecha_completa(date('Y-m-d')) : Helper::mostrar_fecha_completa($fecha) !!}</small>
			</h1>
		</div>
	</div>

	<div class="block">
		<div class="row">
			<div class="col-md-12 block">
				<div class="block-title">
					<h2><strong>Salida</strong> Trabajadores</h2>
				</div>
				<div class="table-responsive">
					<table id="general-table" class="table table-striped table-vcenter">
						<thead>
						<tr>
							<th>Usuario</th>
							<th>Vehiculo</th>
							<th>Obs Inicio</th>
							<th>Obs Fin</th>
							<th>Hora Inicio</th>
							<th>Km Inicio</th>
							<th>Hora Fin</th>
							<th>Km Fin</th>
							<th>Total Km</th>
							<th>Reset Inicio</th>
							<th>Reset Termino</th>
						</tr>
						</thead>
						<tbody>
							@if( $history->getData()->status != false )
								@foreach($history->getData()->data as $key => $histo)
									<tr>
										<td>{!! $histo->username." ".$histo->ape_pat !!} </td>
										<td>{!! $histo->placas !!}</td>
										<td>{!! $histo->observaciones_inicio !!}</td>
										<td>{!! $histo->observaciones_termino !!}</td>
										<td><a target="blank" href="{{ 'http://maps.google.com/maps?q='.$histo->latitude_inicio.','.$histo->longitude_inicio }}" class="label label-success">{!! date('h:i:s a', strtotime($histo->hora_inicio)) !!}</a></td>
										<td>{!! $histo->kilometraje_inicio !!}</td>
										<td><a target="blank" href="{{ 'http://maps.google.com/maps?q='.$histo->latitude_termino.','.$histo->longitude_termino }}" class="label label-success">{!! ($histo->hora_termino == '00:00:00' | $histo->hora_termino == NULL) ? '' : date('h:i:s a', strtotime($histo->hora_termino)); !!}</a></td>
										<td>{!! $histo->kilometraje_termino !!}</td>
										<td>{!! ($histo->kilometraje_termino != '')? $histo->kilometraje_termino - $histo->kilometraje_inicio : '' !!} </td>
										<td><button class="btn btn-sm btn-warning" data-reset="inicio" data-id='{!! $histo->id !!}' onclick="Main.reset(this)">Reset Inicio</button></td>
										<td><button class="btn btn-sm btn-warning" data-reset="termino" data-id='{!! $histo->id !!}' onclick="Main.reset(this)">Reset Termino</button></td>
									</tr>
								@endforeach
							@endif
						</tbody>
					</table>
				</div>
			</div>
		</div>
	 </div>	
      <div class="col-md-12 block">
				<div class="block-title">
					<h2><strong>Check List</strong> Fuera de Tiempo</h2>
				</div>
				<div class="table-responsive">
					<table id="check-table" class="table table-striped table-vcenter">
						<thead>
						<tr>
							<th class="text-center">Cliente</th>
							<th class="text-center">Conductor</th>
							<th class="text-center">Dia</th>
							<th class="text-center">Hora</th>
						</tr>
						</thead>
						<tbody>
              @if($checklist->getData()->status == true)
              @foreach( $checklist->getData()->data as $ordenc )
             
                @if(Helper::to_late($ordenc) == true )
                  <tr >
                         <td class="text-center text-danger">{!! $ordenc->nombre_comercial !!}</td>
                         <td class="text-center text-danger">{!! $ordenc->username !!}</td>
                         <td class="text-center text-danger">{!! $ordenc->dia !!}</td>
                         <td class="text-center text-danger">{!! date('h:i:s a', strtotime($ordenc->hora)) !!}</td>
                  </tr>
                  @endif
                 @endforeach
               @endif
						</tbody>
					</table>
				</div>
			</div>
			<!--<div class="col-md-5 block">
				<div class="block-title">
					<h2><strong>Metas</strong> Clientes</h2>
				</div>
				<div class="table-responsive">
					<table id="general-table" class="table table-striped table-vcenter">
						<thead>
						<tr>
							<th>Cliente</th>
							<th>Usuario</th>
							<th>Hora</th>
							<th>Comentario</th>
						</tr>
						</thead>
						<tbody>
							<tr>
								<td>HOSPITAL SAN JAVIER</td>
								<td>Arturo</td>
								<td>8:50</td>
								<td>Todo Bien</td>
							</tr>
							<tr>
								<td>VISTA SUR RESIDENCIAL</td>
								<td>-</td>
								<td>-</td>
								<td>-</td>
							</tr>
							<tr>
								<td>EL MERCADITO</td>
								<td>-</td>
								<td>-</td>
								<td>-</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>!-->

	<div class="block">
		<div class="block-title">
			<h2><strong>Cargas</strong> Recolectora</h2>
			<div class="block-options pull-right">
				<a href="javascript:void(0)" class="btn btn-alt btn-sm btn-default toggle-bordered enable-tooltip" data-toggle="button" title="" data-original-title="Fecha"><i class="fa fa-calendar"></i>
				<input type="text" id="fecha-welcome-datepicker" name="example-datepicker" class="form-control input-datepicker" onchange="Main.fecha(this)" data-date-format="yyyy-mm-dd" placeholder="yyyy-mm-dd">
				</a>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="panel filterable block full" >
					<div class="pull-right">
						<button onclick="Main.tableFilter(this)" id="filter" class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button>
					</div>
					<table id="general-table" class="table table-hover table-responsive" width='100%'>
						<thead>
							<tr class="filters">
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="No. Orden" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Usuario" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Vehiculo" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Cliente" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Reciclable" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Peso R" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Material" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Cantidad" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Observaciones" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Inicio" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Fin" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Tiempo" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Traslado" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Km" disabled/>
								</th>
								<th class="text-center">
									<input type="text" class="form-control text-center" placeholder="Km Recorridos" disabled/>
								</th>
								<th>Acciones</th>
							</tr>
						</thead>
						<tbody>
						@if( $orden->getData()->status != false )
							@foreach($orden->getData()->data as $key => $ordenes)
								<tr>
									<td style="padding:0px;fontSize:10px;"><span style="font-size:10px;color:{!! ($ordenes->cancel == 1)? 'red' : 'black' !!}" title="Orden {!! ($ordenes->cancel == 1)? 'Cancelada' : 'Activa' !!}">{!! $ordenes->orden_no !!}</span></td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->username !!}</td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->placas !!}</td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->nombre_comercial !!}</td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->reciclable !!}</td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->peso_reciclable !!}</td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->unidad !!}</td>
									<td style="padding:0px;font-size:10px">{!! number_format($ordenes->cantidad,2) !!}</td>
									<td style="padding:0px;font-size:10px">{!! $ordenes->observaciones !!}</td>
									<td style="padding:0px;font-size:10px"><a href="{{ 'http://maps.google.com/maps?q='.$ordenes->lat_ini.','.$ordenes->lng_ini }}" class="label label-{!! Helper::distanciaGeodesica($ordenes->cliente_lat,$ordenes->cliente_lng,$ordenes->lat_ini,$ordenes->lng_ini) !!}" target="blank">{!! date('h:i:s a', strtotime($ordenes->hora_inicio)) !!}</a>
									</td>
									<td style="padding:0px;font-size:10px"><a href="{{ 'http://maps.google.com/maps?q='.$ordenes->lat_ter.','.$ordenes->lng_ter }}" class="label label-{!! Helper::distanciaGeodesica($ordenes->cliente_lat,$ordenes->cliente_lng,$ordenes->lat_ter,$ordenes->lng_ter) !!} " target="blank">{!! ($ordenes->hora_termino == '00:00:00' | $ordenes->hora_termino == Null)? '' : date('h:i:s a', strtotime($ordenes->hora_termino)) !!}</a>
									</td>
									<td style="padding:0px;font-size:10px">
										{!! ($ordenes->hora_termino == '00:00:00' )? '' : Helper::getDif($ordenes->hora_inicio,$ordenes->hora_termino) !!}
									</td>
					  				<td style="padding:0px;font-size:10px">
										{!! ($ordenes->tiempo_traslado == '00:00:00' )? '' : $ordenes->tiempo_traslado !!}
									</td>
					  				<td style="padding:0px;font-size:10px">{!! $ordenes->km !!}</td>
									<td style="padding:0px;font-size:10px" title="{!! $ordenes->km !!}">{!! $ordenes->km_dif !!}{{-- ($ordenes->hora_termino == '00:00:00')? '' : (($key == 0)? Helper::km_rest($ordenes->km, $ordenes->kilometraje_inicio): Helper::km_rest($ordenes->km, $orden->getData()->data[$key-1]->km))  --}}</td>
									<td style="padding:0px;font-size:10px">
										<a href="javascript:void(0)" data-id="{!! $ordenes->id !!}" data-fecha="{!! $fecha !!}" data-toggle="tooltip" title="" class="btn btn-default btn-xs" data-original-title="Edit" onclick="Main.edit(this)"><i class="fa fa-pencil"></i></a>
									</td>
								</tr>
								@endforeach
							@endif
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>

</div>
<div id="modalOrden" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Actualizar Orden</h4>
      </div>
      <div class="modal-body">
        <form id="form-actor" method="post" enctype="multipart/form-data" class="form-horizontal form-bordered" onsubmit="return false;">
            <input type="hidden" name="_token" id="csrf-token" value="{{ csrf_token() }}" />
             <div class="form-group">
                <label class="col-md-3 control-label">Usuario <span class="text-danger">*</span></label>
                <div class="col-md-6" >
                    <select id="user-select" class="form-control" required="required">
                        <option value="0">Selecciona</option>
                        @if(isset($users))
	                        @foreach($users as $key => $user)
	                            <option value="{!! $user->id !!}">{!! $user->username !!}</option>
	                        @endforeach
                        @endif
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">No Orden<span class="text-danger">*</span></label>
                  <div class="col-md-6">
                    <input id="orden-input" class="form-control" type="text" required="required" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">Cliente <span class="text-danger">*</span></label>
                <div class="col-md-6" >
                    <select id="cliente-select" class="form-control" required="required">
                        <option value="0">Selecciona</option>
                        @if(isset($clientes))
	                        @foreach($clientes as $key => $cliente)
	                            <option value="{!! $cliente->id !!}">{!! $cliente->nombre_comercial !!}</option>
	                        @endforeach
                        @endif
                    </select>
                </div>
            </div>
            <div class="form-group reciclable">
                <label class="col-md-3 control-label">Cantidad<span class="text-danger">*</span></label>
                  <div class="col-md-6">
                    <input id="cantidad-input" class="form-control" type="number" required="required" placeholder="3.5" step="0.01" required="required"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">Camión <span class="text-danger">*</span></label>
                <div class="col-md-6" >
                    <select id="camion-select" class="form-control" required="required">
                        <option value="0">Selecciona</option>
                        @if(isset($camiones))
	                        @foreach($camiones as $key => $camion)
	                            <option value="{!! $camion->id !!}">{!! $camion->placas !!}</option>
	                        @endforeach
                        @endif
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">Kilometraje<span class="text-danger">*</span></label>
                  <div class="col-md-6">
                    <input id="km-input" class="form-control" type="text" required="required" />
                </div>
            </div>
			<div class="form-group reciclable">
                <label class="col-md-3 control-label">Reciclable </label>
                <div class="col-md-6" >
                    <select id="reciclable-select" class="form-control">
                        <option value="0">Selecciona</option>
                        @if(isset($reciclables))
	                        @foreach($reciclables as $key => $reciclable)
	                            <option value="{!! $reciclable->id !!}">{!! $reciclable->reciclable !!}</option>
	                        @endforeach
                        @endif
                    </select>
                </div>
            </div>
            <div class="form-group reciclable">
                <label class="col-md-3 control-label">Peso Reciclable</label>
                  <div class="col-md-6">
                    <input id="peso-reciclable-input" class="form-control" type="text"  />
                </div>
            </div>
			<div class="form-group vertedero combustible">
				<label class="col-md-3 control-label" for="example-hf-orden">Nota:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<input type="number" id="nota-input"  class="form-control" placeholder="3412">
				</div>
			</div>
			<div class="form-group vertedero combustible">
				<label class="col-md-3 control-label" for="example-hf-orden">Hora:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<input type="text" id="hora-input"  class="form-control" placeholder="5:30 PM">
				</div>
			</div>
			<div class="form-group combustible">
				<label class="col-md-3 control-label" for="example-hf-orden">Litros:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<input type="number" id="litros-input"  class="form-control" placeholder="20" step="0.01" >
				</div>
			</div>
			<div class="form-group combustible">
				<label class="col-md-3 control-label" for="example-hf-orden">Tipo de Combustible:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<select id="tipo-select" class="form-control">
						<option value="Magna">Magna</option>
						<option value="Premium">Premium</option>
						<option value="Diesel">Diesel</option>
						<option value="LP">Gas LP</option>
					</select>
				</div>
			</div>
			<div class="form-group combustible">
				<label class="col-md-3 control-label" for="example-hf-orden">Precio Litro:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<input type="number" id="precio-input"  class="form-control" placeholder="20.20" step="0.01">
				</div>
			</div>
			<div class="form-group vertedero">
				<label class="col-md-3 control-label" for="example-hf-orden">Peso Neto:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<input type="number" id="peso-input"  class="form-control" placeholder="30" step="0.01">
				</div>
			</div>
			<div class="form-group vertedero">
				<label class="col-md-3 control-label" for="example-hf-orden">Precio:<span class="text-danger">*</span></label>
				<div class="col-md-6">
					<input type="number" id="precio-vertedero-input"  class="form-control" placeholder="5.20" step="0.01">
				</div>
			</div>

            <div class="form-group">
                <label class="col-md-3 control-label">Observaciones</label>
                  <div class="col-md-6">
                    <input id="obs-input" class="form-control" type="text"  />
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">Cancelar Orden</label>
                  <div class="col-md-6">
                    <input id="cancel-checkbox" class="form-control" type="checkbox"  />
                </div>
            </div>
            <div class="form-group form-actions">
                <div class="col-md-9 col-md-offset-3">
                    <button id="send-button" type="submit" data-id="" data-km-dif="" data-km-inicio="" data-km-first="" class="btn btn-sm btn-success" onclick="Main.getOrden(this);"><i class="fa fa-angle-right"></i> Guardar</button>
                </div>
            </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>
{!! Html::script("/js/main.js") !!}
<script type="text/javascript">
    $('.filterable .filters input').keyup(function(e){
        /* Ignore tab key */
            var code = e.keyCode || e.which;
            if (code == '9') return;
            /* Useful DOM data and selectors */
            var $input = $(this),
            inputContent = $input.val().toLowerCase(),
            $panel = $input.parents('.filterable'),
            column = $panel.find('.filters th').index($input.parents('th')),
            $table = $panel.find('.table'),
            $rows = $table.find('tbody tr');
            /* Dirtiest filter function ever ;) */
            var $filteredRows = $rows.filter(function(){
                var value = $(this).find('td').eq(column).text().toLowerCase();
                return value.indexOf(inputContent) === -1;
            });
            /* Clean previous no-result if exist */
            $table.find('tbody .no-result').remove();
            /* Show all rows, hide filtered ones (never do that outside of a demo ! xD) */
            $rows.show();
            $filteredRows.hide();
            /* Prepend no-result row if all rows are filtered */
            if ($filteredRows.length === $rows.length) {
                $table.find('tbody').prepend($('<tr class="no-result text-center"><td colspan="'+ $table.find('.filters th').length +'">No result found</td></tr>'));
            }
        });
</script>
@stop