mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
fix notification chat error cuando cliente no tiene facturas asociadas
This commit is contained in:
@ -199,7 +199,7 @@ class ChatModel extends Model
|
|||||||
}
|
}
|
||||||
public function getClienteChatPedidos(array $pedidos) : array
|
public function getClienteChatPedidos(array $pedidos) : array
|
||||||
{
|
{
|
||||||
$results = $this->db->table("chats")
|
$q = $this->db->table("chats")
|
||||||
->select([
|
->select([
|
||||||
"chats.id as chatId",
|
"chats.id as chatId",
|
||||||
"chats.pedido_id as pedidoId",
|
"chats.pedido_id as pedidoId",
|
||||||
@ -208,10 +208,13 @@ class ChatModel extends Model
|
|||||||
"pedidos.id as title"
|
"pedidos.id as title"
|
||||||
])
|
])
|
||||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||||
->join("pedidos","pedidos.id = chats.pedido_id","left")
|
->join("pedidos","pedidos.id = chats.pedido_id","left");
|
||||||
->whereIn("pedidos.id",$pedidos)
|
if(count($pedidos)>0){
|
||||||
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
|
$q->whereIn("pedidos.id",$pedidos);
|
||||||
->get()->getResultObject();
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$results = $q->get()->getResultObject();
|
||||||
$chatMessageModel = model(ChatMessageModel::class);
|
$chatMessageModel = model(ChatMessageModel::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($results as $row) {
|
foreach ($results as $row) {
|
||||||
@ -227,7 +230,7 @@ class ChatModel extends Model
|
|||||||
}
|
}
|
||||||
public function getClienteChatFacturas(array $facturas) : array
|
public function getClienteChatFacturas(array $facturas) : array
|
||||||
{
|
{
|
||||||
$results = $this->db->table("chats")
|
$q = $this->db->table("chats")
|
||||||
->select([
|
->select([
|
||||||
"chats.id as chatId",
|
"chats.id as chatId",
|
||||||
"chats.factura_id as facturaId",
|
"chats.factura_id as facturaId",
|
||||||
@ -236,10 +239,13 @@ class ChatModel extends Model
|
|||||||
"facturas.numero as title"
|
"facturas.numero as title"
|
||||||
])
|
])
|
||||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||||
->join("facturas","facturas.id = chats.factura_id","left")
|
->join("facturas","facturas.id = chats.factura_id","left");
|
||||||
->whereIn("facturas.id",$facturas)
|
if(count($facturas)>0){
|
||||||
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
|
$q->whereIn("facturas.id",$facturas);
|
||||||
->get()->getResultObject();
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$results = $q->get()->getResultObject();
|
||||||
$chatMessageModel = model(ChatMessageModel::class);
|
$chatMessageModel = model(ChatMessageModel::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($results as $row) {
|
foreach ($results as $row) {
|
||||||
@ -255,7 +261,7 @@ class ChatModel extends Model
|
|||||||
}
|
}
|
||||||
public function getClienteChatPresupuestos(array $presupuestos) : array
|
public function getClienteChatPresupuestos(array $presupuestos) : array
|
||||||
{
|
{
|
||||||
$results = $this->db->table("chats")
|
$q = $this->db->table("chats")
|
||||||
->select([
|
->select([
|
||||||
"chats.id as chatId",
|
"chats.id as chatId",
|
||||||
"chats.presupuesto_id as presupuestoId",
|
"chats.presupuesto_id as presupuestoId",
|
||||||
@ -264,10 +270,13 @@ class ChatModel extends Model
|
|||||||
"presupuestos.titulo as title"
|
"presupuestos.titulo as title"
|
||||||
])
|
])
|
||||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||||
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
|
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left");
|
||||||
->whereIn("presupuestos.id",$presupuestos)
|
if(count($presupuestos)>0){
|
||||||
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
|
$q->whereIn("presupuestos.id",$presupuestos);
|
||||||
->get()->getResultObject();
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$results = $q->get()->getResultObject();
|
||||||
$chatMessageModel = model(ChatMessageModel::class);
|
$chatMessageModel = model(ChatMessageModel::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($results as $row) {
|
foreach ($results as $row) {
|
||||||
|
|||||||
Reference in New Issue
Block a user