@@ -305,13 +305,8 @@ public function sellsReport($idEmpresa = 0
$searchValue = $this->request->getVar('search')['value'] ?? '';
$order = $this->request->getVar('order');
$columns = $this->request->getVar('columns');
-
-
// Parámetros personalizados para filtrar
-
-
-
// Obtener query base sin paginar
$queryBuilder = $this->sells->mdlVentasPorProductos(
$idEmpresa, $idSucursal, $idProducto,
@@ -513,7 +508,7 @@ public function getXMLEnlazados($uuidVenta) {
// === WHERE principal ===
$builder->where('a.idDocumento', $datosVenta["id"]);
- $builder->where('a.idDocumento', "ven");
+ $builder->where('a.tipo', "ven");
// === Total sin filtro ===
$total = $builder->countAllResults(false); // no reset
@@ -526,7 +521,7 @@ public function getXMLEnlazados($uuidVenta) {
}
$builder->groupEnd();
}
-
+ //log_message('debug', $builder->getCompiledSelect());
// === Total filtrado ===
$filtered = $builder->countAllResults(false);
@@ -544,6 +539,8 @@ public function getXMLEnlazados($uuidVenta) {
// === Ejecutar y devolver ===
$query = $builder->get();
$data = $query->getResultArray();
+
+
return $this->response->setJSON([
'draw' => intval($request->getPost('draw')),
@@ -655,6 +652,26 @@ public function editSell($uuid) {
$sell = $this->sells->mdlGetSellUUID($uuid, $empresasID);
+
+
+ /**
+ * Verificamos que no tenga enlazado XML
+ */
+ if ($this->xmlEnlace->select("*")->where("idDocumento", $sell["id"])->countAllResults() > 0) {
+
+ $this->sells->db->transRollback();
+ return $this->failNotFound('La Venta no se puede eliminar por que ya tiene timbre enlazado');
+ }
+
+ /**
+ * Verificamos que no tenga Pagos Enlazados
+ */
+ if ($this->payments->select("*")->where("idSell", $sell["id"])->countAllResults() > 0) {
Comentarios
Publicar un comentario