<commit_before><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Main_control extends MY_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model("Menus_model", "m_md");
		$this->load->model("Productos_model", "pr_md");
		$this->load->model("Categorias_model", "cat_md");
	}

	public function scripts() {
		$this->load->view("structure/main");
	}

	public function showMenu(){
		$data["productos"] = $this->pr_md->getProductos();
		//$data["menu"] = $this->m_md->menuLeve1();
		//$this->load->view("Admin/welcome", $data, FALSE);
		$this->estructura("Admin/welcome", $data);
	}

	public function newProducto(){
		$data["title"]="Registrar nuevos productos";
		$this->load->view("Structure/header_modal", $data);
		$data['categorias'] = $this->cat_md->get();
		$this->load->view("Admin/new_producto", $data);
		$this->load->view("Structure/footer_modal_save");
	}

	public function updateProducto($id){
		$data["title"]="Actualizar datos del producto";
		$this->load->view("Structure/header_modal", $data);
		$data["producto"] = $this->pr_md->get(['id_producto'=>$id])[0];
		$data['categorias'] = $this->cat_md->get();
		$this->load->view("Admin/edit_producto", $data);
		$this->load->view("Structure/footer_modal_edit");
	}

	public function deleteProducto($id){
		$data["title"]="Producto a eliminar";
		$this->load->view("Structure/header_modal", $data);
		$data["producto"] = $this->pr_md->get(['id_producto'=>$id])[0];
		$this->load->view("Admin/delete_producto", $data);
		$this->load->view("Structure/footer_modal_delete");
	}

	public function accion($param){
		$producto = array(
				'nombre'		=>	strtoupper($this->input->post('nombre')),
				'precio'		=>	$this->input->post('precio'),
				'descripcion'	=>	$this->input->post('descripcion'),
			);
		switch ($param) {
			case (substr($param, 0, 1) === 'I'):
				$data ['id_producto']=$this->pr_md->insert($producto);
				$mensaje = array(
					"id" 	=> 'Éxito',
					"desc"	=> 'Producto registrado correctamente',
					"type"	=> 'success'
				);
				break;

			case (substr($param, 0, 1) === 'U'):
				$data ['id_producto'] = $this->pr_md->update($producto, $this->input->post('id_alumno'));
				$mensaje = array(
					"id" 	=> 'Éxito',
					"desc"	=> 'Producto actualizado correctamente',
					"type"	=> 'success'<commit_msg>FEAT: Columnas agregadas al array<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Main_control extends MY_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model("Menus_model", "m_md");
		$this->load->model("Productos_model", "pr_md");
		$this->load->model("Categorias_model", "cat_md");
	}

	public function scripts() {
		$this->load->view("structure/main");
	}

	public function showMenu(){
		$data["productos"] = $this->pr_md->getProductos();
		//$data["menu"] = $this->m_md->menuLeve1();
		//$this->load->view("Admin/welcome", $data, FALSE);
		$this->estructura("Admin/welcome", $data);
	}

	public function newProducto(){
		$data["title"]="Registrar nuevos productos";
		$this->load->view("Structure/header_modal", $data);
		$data['categorias'] = $this->cat_md->get();
		$this->load->view("Admin/new_producto", $data);
		$this->load->view("Structure/footer_modal_save");
	}

	public function updateProducto($id){
		$data["title"]="Actualizar datos del producto";
		$this->load->view("Structure/header_modal", $data);
		$data["producto"] = $this->pr_md->get(['id_producto'=>$id])[0];
		$data['categorias'] = $this->cat_md->get();
		$this->load->view("Admin/edit_producto", $data);
		$this->load->view("Structure/footer_modal_edit");
	}

	public function deleteProducto($id){
		$data["title"]="Producto a eliminar";
		$this->load->view("Structure/header_modal", $data);
		$data["producto"] = $this->pr_md->get(['id_producto'=>$id])[0];
		$this->load->view("Admin/delete_producto", $data);
		$this->load->view("Structure/footer_modal_delete");
	}

	public function accion($param){
		$producto = array(
				'nombre'		=>	strtoupper($this->input->post('nombre')),
				'precio'		=>	$this->input->post('precio'),
				'descripcion'	=>	$this->input->post('descripcion'),
				'longitud'		=>	$this->input->post('longitud'),
				'latitud'		=>	$this->input->post('latitud'),
				'id_categoria'	=>	($this->input->post('id_categoria') !="-1") ? $this->input->post('id_categoria') : NULL
			);
		switch ($param) {
			case (substr($param, 0, 1) === 'I'):
				$data ['id_producto']=$this->pr_md->insert($producto);
				$mensaje = array(
					"id" 	=> 'Éxito',
					"desc"	=> 'Producto registrado correctamente',
					"type"	=> 'success'
				);
				break;

			case (substr($param, 0, 1) === 'U'):
				$data ['id_producto'] = $this->pr_md->update($producto, $this->input->post('id_alumno'));
				$mensaje = array(
					"id" 	=> 'Éxito',
					"desc"	=> 'Producto actualizado correctamente',
					"type"	=> 'success'
{'fraction_non_alphanumeric': 0.2310513447432763, 'fraction_numerical': 0.003056234718826406, 'mean_word_length': 5.060493827160494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 142, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7646235', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1804, 'n_words': 270}