点击 "Release"后触发前端的investigation_button_release()方法ajax的url为http://test.com/evo/_panels_c/voucher/search_form/investigate
change_status"6-2"
status_id"6-1"
voucher_no"05-2"
investigate方法为:
function investigate()
{
if(IS_AJAX)
{
$d_time = date('Y-m-d H:i:s');
$voucher_no = $this->input->post('voucher_no'); // voucher No. with prefix
$voucher_id = $this->input->post('voucher_id');
$remarks = $this->input->post('remarks');
$action = $this->input->post('action');
$status_id = $this->input->post('status_id');
$new_status = $this->input->post('change_status');
$voucher_update_data = array();
if($new_status != $status_id && ($status = $this->voucher_lkup->show_available_status_to_change()) && isset($status[$new_status]))
{
$new_description = $status[$new_status];
$old_description = $status[$status_id];
$new_channel = FALSE;
if(strpos($new_status, '-') !== FALSE)
{
$tmp = explode('-', $new_status);
$new_status = $tmp[0];
$new_channel = $tmp[1];
$voucher_update_data['status_id'] = $new_status;
$voucher_update_data['transfer_channel'] = $new_channel == 'NIL' ? '' : $new_channel;
}
else
{
$voucher_update_data['status_id'] = $new_status;
}
$action_data = array();
$action_data['action_id'] = $this->voucher_lkup->get_action_id('change_status');
$action_data['voucher_id'] = $voucher_id;
$action_data['user_id'] = $this->voucher_lkup->_user_id;
$action_data['action_time'] = $d_time;
$action_data['comment'] = "From $old_description to $new_description";
$this->voucher_batch->insert_voucher_action($action_data);
// if status = tenant_submit and voucher existed in tenant_submit_error table, delete it from error table.
if($status_id == $this->voucher_lkup->get_status_id('tenant_submitted'))
{
$this->voucher_batch->delete_tenant_submission_error($voucher_id);
}
}
// do investigation on $voucher_id.
$b_investigate = true;
if($action == 'release')
{
$action_data = array();
$action_data['action_id'] = $this->voucher_lkup->get_action_id('release_investigation');
$action_data['voucher_id'] = $voucher_id;
$action_data['user_id'] = $this->voucher_lkup->_user_id;
$action_data['action_time'] = $d_time;
$action_data['comment'] = $remarks;
$this->voucher_batch->insert_voucher_action($action_data);
if($status_id == $this->voucher_lkup->get_status_id('tenant_submitted'))
{
$errors = $this->voucher_batch->get_tenant_submission_error($voucher_id);
if(!empty($errors))
{
$voucher_update_data['submission_id'] = $errors['submission_id'];
$this->voucher_batch->delete_tenant_submission_error($voucher_id);
//check if tenant_submit action recorded in voucher_action, if not, record it.
$log = $this->voucher_batch->get_voucher_action($voucher_id, $this->voucher_lkup->get_action_id('tenant_submit'));
if(empty($log))
{
$action_data = array();
$action_data['action_id'] = $this->voucher_lkup->get_action_id('tenant_submit');
$action_data['voucher_id'] = $voucher_id;
$action_data['user_id'] = $this->voucher_lkup->_user_id;
$action_data['action_time'] = $errors['submission_time'];
$this->voucher_batch->insert_voucher_action($action_data);
}
}
}
$voucher_update_data['under_investigation'] = 'N';
$this->voucher_batch->update_vouchers_data_by_voucher_id($voucher_id, $voucher_update_data);
}
else
{
$voucher_update_data['under_investigation'] = 'Y';
$this->voucher_batch->update_vouchers_data_by_voucher_id($voucher_id, $voucher_update_data);
$action_data = array();
$action_data['action_id'] = $this->voucher_lkup->get_action_id('investigate');
$action_data['voucher_id'] = $voucher_id;
$action_data['user_id'] = $this->voucher_lkup->_user_id;
$action_data['action_time'] = $d_time;
$action_data['comment'] = $remarks;
$this->voucher_batch->insert_voucher_action($action_data);
}
$result = array();
$result['result'] = ($b_investigate !== FALSE) ? '1' : '2';
$result['voucher'] = $this->_search_individual($voucher_no);
echo json_encode($result);
}
}
在investigate里做了2个操作,一个是$this->voucher_batch->insert_voucher_action($action_data);
一个是 $this->voucher_batch->update_vouchers_data_by_voucher_id($voucher_id, $voucher_update_data);