<?php
namespace Trash;
use Illuminate\Database\Eloquent\Model;
class OrdenC extends Model
{
//
protected $table = 'orden_ruta';
public function getCheckList(){
$sql = "SELECT o.id, c.nombre_comercial, u.username, o.dia, o.hora
FROM orden_ruta o
JOIN cliente c ON c.id = o.cliente_id
JOIN user u ON u.id = o.user_id
Order by dia,nombre_comercial";
$data = \DB::select( \DB::raw( $sql ) );
if(count($data)!=null){
return response()->json(array('status'=>true, 'data'=>$data));
}else{
return response()->json(array('status'=>false));
}
}
public function clientes_faltantes($fecha){
$sql = "SELECT c.nombre_comercial, u.username, o.dia, o.hora,
CASE (dia)
WHEN 'domingo' THEN 'Sunday'
WHEN 'lunes' THEN 'Monday'
WHEN 'martes' THEN 'Tuesday'
WHEN 'miercoles' THEN 'Wednesday'
WHEN 'jueves' THEN 'Thursday'
WHEN 'viernes' THEN 'Friday'
WHEN 'sabado' THEN 'Saturday' END dia_en, od.orden_no
FROM orden_ruta o
JOIN cliente c ON c.id = o.cliente_id
JOIN user u ON u.id = o.user_id
LEFT JOIN orden od ON od.cliente_id = o.cliente_id
-- AND od.user_id = o.user_id
AND date(od.fecha_inicio) = '$fecha'
WHERE CASE (dia)
WHEN 'domingo' THEN 'Sunday'
WHEN 'lunes' THEN 'Monday'
WHEN 'martes' THEN 'Tuesday'
WHEN 'miercoles' THEN 'Wednesday'
WHEN 'jueves' THEN 'Thursday'
WHEN 'viernes' THEN 'Friday'
WHEN 'sabado' THEN 'Saturday' END = DAYNAME('$fecha')
Order by hora";
$data = \DB::select( \DB::raw( $sql ) );
if(count($data)>0){
return response()->json(array('status'=>true, 'data'=>$data));
}else{
return response()->json(array('status'=>false, 'data'=>''));
}
}
}