0
我的控制器,镶在表中invHdrData表, 行我想最大文件号码中插入文档自动编号 回调插入之前没有作品。 那么问题在哪里? 我将不胜感激,如果你请给我一些答案:)回拨前杂货CRUD嵌件不起作用
我的控制器:
public function sanads()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('invhdrdata');
$crud->set_subject('BLAH BLAH BLAH');
$crud->columns('FiscalYear','StoreNo','DocType','CreateDate','UpdateDate');
$crud->fields('FiscalYear','StoreNo','DocType','DocNo','CreateDate','UpdateDate');
$crud->callback_before_insert(array($this,'maxDocNoCon'));
$crud->field_type('DocNo','invisible');
$output = $crud->render();
$this->_example_output($output);
}
另一种功能的控制器:
public function maxDocNoCon($post_array) {
$this->load->model('inv_model');
$post_array['DocNo'] = $this->inv_model->maxDocNoMod($post_array['FiscalYear'],$post_array['StoreNo'],$post_array['DocType']);
$test['DocNo'] = (int)explode(",", $post_array['DocNo'])+1;
return $test;
}
我的模型:
function maxDocNoMod($FiscalYear,$StoreNo,$DocType){
$this->db->select_max('DocNo');
$this->db->where('FiscalYear', $FiscalYear);
$this->db->where('StoreNo', $StoreNo);
$this->db->where('DocType', $DocType);
$data = $this->db->get('invhdrdata');
if ($data->num_rows() != 1) {
// there should only be one row - anything else is an error
return false;
}
return $data->row()->DocNo;
}