I have a question about calculated fields on before or after insert. I have a calculated field that is called "difference" in "alokim" table. Also I have a file alokim-dv.js which contains java script code for checking the field(difference) before insertions if it meets a condition:
Code: Select all
function show_error(field, msg){
modal_window({
message: '<div class="alert alert-danger">' + msg + '</div>',
title: 'Error in ' + field,
close: function(){
$j('#' + field).focus();
$j('#' + field).parents('.form-group').addClass('has-error');
}
});
return false;
}
$j(function(){
$j('#insert').click(function(){
var difference= $j('#difference').val();
if(difference< 1){
return show_error('Alokim', 'Nuk ka gjendje per kategorine e caktuar' );
}
});
})
Code: Select all
function alokim_before_insert(&$data, $memberInfo, &$args) {
$id_alokim = makeSafe($data['selectedID']);
$formulas = calculated_fields();
update_calc_fields('alokimi', $id_alokim, $formulas['alokimi']);
return TRUE;
}
Please any suggestion?
Ervis