fix notification chat error cuando cliente no tiene facturas asociadas

This commit is contained in:
amazuecos
2024-10-23 05:48:06 +00:00
parent c79bc4343f
commit 3dd9f8f7e3

View File

@ -199,7 +199,7 @@ class ChatModel extends Model
}
public function getClienteChatPedidos(array $pedidos) : array
{
$results = $this->db->table("chats")
$q = $this->db->table("chats")
->select([
"chats.id as chatId",
"chats.pedido_id as pedidoId",
@ -208,10 +208,13 @@ class ChatModel extends Model
"pedidos.id as title"
])
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
->join("pedidos","pedidos.id = chats.pedido_id","left")
->whereIn("pedidos.id",$pedidos)
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
->get()->getResultObject();
->join("pedidos","pedidos.id = chats.pedido_id","left");
if(count($pedidos)>0){
$q->whereIn("pedidos.id",$pedidos);
}else{
return [];
}
$results = $q->get()->getResultObject();
$chatMessageModel = model(ChatMessageModel::class);
$count = 0;
foreach ($results as $row) {
@ -227,7 +230,7 @@ class ChatModel extends Model
}
public function getClienteChatFacturas(array $facturas) : array
{
$results = $this->db->table("chats")
$q = $this->db->table("chats")
->select([
"chats.id as chatId",
"chats.factura_id as facturaId",
@ -236,10 +239,13 @@ class ChatModel extends Model
"facturas.numero as title"
])
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
->join("facturas","facturas.id = chats.factura_id","left")
->whereIn("facturas.id",$facturas)
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
->get()->getResultObject();
->join("facturas","facturas.id = chats.factura_id","left");
if(count($facturas)>0){
$q->whereIn("facturas.id",$facturas);
}else{
return [];
}
$results = $q->get()->getResultObject();
$chatMessageModel = model(ChatMessageModel::class);
$count = 0;
foreach ($results as $row) {
@ -255,7 +261,7 @@ class ChatModel extends Model
}
public function getClienteChatPresupuestos(array $presupuestos) : array
{
$results = $this->db->table("chats")
$q = $this->db->table("chats")
->select([
"chats.id as chatId",
"chats.presupuesto_id as presupuestoId",
@ -264,10 +270,13 @@ class ChatModel extends Model
"presupuestos.titulo as title"
])
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
->whereIn("presupuestos.id",$presupuestos)
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
->get()->getResultObject();
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left");
if(count($presupuestos)>0){
$q->whereIn("presupuestos.id",$presupuestos);
}else{
return [];
}
$results = $q->get()->getResultObject();
$chatMessageModel = model(ChatMessageModel::class);
$count = 0;
foreach ($results as $row) {