<?php
class Marketplace_model extends CI_Model {
	public function lista_marketplaces() {
		$this->db->select('id, nombre');
		$this->db->from('marketplaces');
		$this->db->where('deleted', 0);
		$this->db->where('activo', 1);
		$this->db->order_by('id', 'ASC');
		$marketplaces = $this->db->get()->result_array();

		$r = [];
		foreach ($marketplaces as $mp) {
			$r[$mp['id']] = $mp['nombre'];
		}
		return $r;
	}

	public function get_marketplaces() {
		$this->db->from('marketplaces');
		$this->db->where('deleted', 0);
		$this->db->where('activo', 1);
		$this->db->order_by('id', 'ASC');
		$marketplaces = $this->db->get()->result_array();

		$r = [];
		foreach ($marketplaces as $mp) {
			$r[$mp['id']] = $mp;
		}
		return $r;
	}

	public function carga_menu() {
		$marketplaces = $this->get_marketplaces();
		$_SESSION['marketplaces_activos'] = $marketplaces;
	}
}