⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


tinchorton

Member Since 01 Apr 2017
Offline Last Active Apr 01 2017 04:14 AM
-----

Posts I've Made

In Topic: Form Validation Callbacks not working with HMVC modular extention

01 April 2017 - 03:36 AM

Hello mit,




Did you see the official wiredesizn's post on this ?
 

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
Its a working fix. Kindly give some time and go through it and suggest.

thanks

 

well...... this is working for me.......

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home

it is broken !!!!!! lcdm!      

This repository does not have wiki enabled.

In Topic: set_rules callback

01 April 2017 - 12:51 AM

even if I call to an anonymous function

		$crud->set_rules('qty', 'qty',
        array(
                'requireda',
                function($value)
                {
                        // Check $value
                	$this->form_validation->set_message('requireda',"Salt value must be less then FIVE2");
                	return false;
                }
        )
);

I got: "Unable to access an error message corresponding to your field name qty.(Anonymous function)

 Guardar

 

"


In Topic: set_rules callback

01 April 2017 - 12:39 AM

guys... I got a problem.... set_rules() appears to be well stated.. but still not working

I got MY_Form_validation lib

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

class MY_Form_validation extends CI_Form_validation
{
	public $CI;

	/*public function __construct()
	{
        $this->CI =& get_instance();
	}*/
	/*function run($module = '', $group = ''){
		(is_object($module)) AND $this->CI =& $module;
		return parent::run($group);
	}*/
	

}

/* End of file MY_Form_validation.php */
/* Location: ./application/libraries/MY_Form_validation.php */

and then in the controller call to  $this->form_validation->CI =& $this;

 

but not working.

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

class Stock_log extends MY_Controller {
	function __construct()
    {
        parent::__construct();  
        $this->load->library('template');
        //$this->template->add_js('bootstrap/js/bootstrap.min.js');
        //$this->load->library('form_validation');
        $this->load->library('form_validation');
        $this->form_validation->CI =& $this;
    }
	public function index()
	{
		$crud = new grocery_CRUD();
		
		$crud->set_table('warehouse_stock_log');
		$crud->set_subject('Movimiento de Stock');
		if (!$this->ion_auth->is_admin()) {
			$crud->unset_edit();
			$crud->unset_delete();
			$crud->unset_add_fields('date');
		}
		else{
			$crud->unset_add_fields('date');
		}		
		$crud->set_relation('item','products_catalog','nombre');

		$crud->set_relation('fromm','warehouse_manager','name');
		$crud->set_relation('too','warehouse_manager','name');

/*		$crud->set_rules('qty', 'qtyy',
        array(
                'requireda',
                function($value)
                {
                        // Check $value
                	$this->form_validation->set_message('requireda',"Salt value must be less then FIVE2");
                	return false;
                }
        )
);*/
		$crud->set_rules('qty', 'qty','callback_check_qty');

		$state = $crud->getState();
		$state_info = $crud->getStateInfo();
		switch ($state) {
			case 'list':
				$crud->set_relation('user','auth_users','{first_name} {last_name}');
				break;
			case 'add':
				$crud->field_type('user', 'hidden',$this->ion_auth->user()->row()->id);		
				break;
			
			default:
				$crud->set_relation('user','auth_users','{first_name} {last_name}');
				break;
		}		
		$crud->callback_before_insert(array($this,'check2moove_stock'));
		$crud->callback_after_insert(array($this,'moove_stock'));
		$output = $crud->render();
		//$this->template->set_messages('un mensagesfdgdsf gfdsgfds fdsgdfsgdfsgdfs fddsdsg ds gdfs ds ddsgds dg fds dsd ');
		//$this->template->set_messages('otro mensage');
		//$this->session->set_flashdata('error','Put your error message here');

		//$this->session->set_flashdata('error','Put your error message here');

		$this->template->template_name('AdminLTE-2.3.7');
        $this->template->set_title('Movimiento de Stock');            
        $this->template->load_view('stock_log',$output);	
	}
	public function check_qty(){
		//$this->load->library('form_validation');
		/*$qty = $_POST['qty'];
		$qty = $str;
		$this->form_validation->set_message('qty',"Salt value must be less then FIVE");
      	return false;*/
      	$this->form_validation()->set_message('check_qty',"Salt value must be less then FIVE1");
      	$this->form_validation->set_message('check_qty',"Salt value must be less then FIVE2");
      	//"whatever i write here..... it seems that this function is not found"
      	return FALSE;
      	//die(var_dump($str));
	}
	function stock_log_insert($post_array, $primary_key){
		$data['item']=$primary_key;
		$data['qty']=$post_array['qty'];
		//$data['date']=$post_array['algo'];
		$data['user']=$this->ion_auth->user()->row()->id;
		$data['fromm']=$post_array['from'];
		$data['too']=$post_array['to'];
		return $this->db->insert('warehouse_stock_log', $data);
	}
	function check2moove_stock($post_array){
		$return=false;		$
		$item_too=$this->db->get_where('warehouse_'.$post_array['too'],array('item'=>$post_array['item']))->result();
		$item_fromm=$this->db->get_where('warehouse_'.$post_array['fromm'],array('item'=>$post_array['item']))->result();
		if ($item_too!=false and $item_fromm!=false) {
			if ($item_fromm->real_qty>$post_array['qty'] and ($item_fromm->real_qty-$item_fromm->real_qty)<=$post_array['qty'] ) {
				return $post_array;
			} else {
				// mensaje: la cantidad supera a la cantidad real (o diferencia de virtual) disponible
						$this->session->set_flashdata('error',"la cantidad supera a la cantidad real (o diferencia de virtual) disponible");
				return false;
			}
			
		} else {
			// mensaje: el producto {postarray['item']} no existe en alguno de los depositos seleccionados.
			$this->session->set_flashdata('error',"el producto no existe en alguno de los depositos seleccionados.");
			return false;
		}
		
		if ($return) {
			return true;
		} else {
			return false;
		}
		
		
	}
	function moove_stock ($post_array, $primary_key){

		/*$this->db->set('real_qty', 'real_qty+'.$post_array['qty'], FALSE);
		$this->db->set('virtual_qty', 'virtual_qty+'.$post_array['qty'], FALSE);
		$this->db->where('item', $post_array['item']);
		if ($this->db->update('warehouse_'.$post_array['too'])) {
			# code...
		} else {
			$this->db->set('real_qty', 'real_qty+'.$post_array['qty'], FALSE);
			$this->db->set('virtual_qty', 'virtual_qty+'.$post_array['qty'], FALSE);
			$this->db->set('item', $post_array['item']);
			$this->db->insert('warehouse_'.$post_array['too']);
		}
		
		 

		$this->db->set('real_qty', 'real_qty-'.$post_array['qty'], FALSE);
		$this->db->set('virtual_qty', 'virtual_qty-'.$post_array['qty'], FALSE);
		$this->db->where('item', $post_array['item']);
		if ($this->db->update('warehouse_'.$post_array['fromm'])) {
			# code...
		} else {
			$this->db->set('real_qty', 'real_qty-'.$post_array['qty'], FALSE);
			$this->db->set('virtual_qty', 'virtual_qty-'.$post_array['qty'], FALSE);
			$this->db->set('item', $post_array['item']);
			$this->db->insert('warehouse_'.$post_array['fromm']);
		}*/
		
		
		
		return $post_array;
	}
	

}



/* End of file Stock_log.php */
/* Location: ./application/modules/deposito/controllers/Stock_log.php */

always the result is : "Unable to access an error message corresponding to your field name qty.(check_qty)

 

what is wrong? 

 

GC version  1.5.8

 * @package     grocery CRUD

 * @copyright   Copyright © 2010 through 2014, John Skoumbourdis
 * @version     1.5.8
 * @author     John Skoumbourdis <scoumbourdisj@gmail.com>