Hello, here what I have done for now, but still have some error
sorties.php
function sorties_after_insert($data, $memberInfo, &$args){
$id = makeSafe($data['matricule']);
$tots = sqlValue("SELECT SUM(total_sortie) FROM sorties WHERE matricule='$id' ");
sql("UPDATE sorties SET total_tous_sortie = '$tots' WHERE matricule='$id'", $eo);
return TRUE;
}
sorties-dv.js
$j(function(){
/* set montant total entree field to read only*/
$j('#total_sortie').prop('readonly', true);
/* calcul du champs total entree */
$j('#qts_sortie, #montant_sortie, #total_tous_sortie, #total_sortie').change(function(){
var quantity = parseFloat($j('#qts_sortie').val()) || 0;
var unitPrice = parseFloat($j('#montant_sortie').val()) || 0;
var totalPrice = quantity * unitPrice;
$j('#total_sortie').val(totalPrice);
});
/* calculate total price on opening the detail view form*/
$j('#montant_sortie').change();
})
entrees.php
function entrees_after_insert($data, $memberInfo, &$args){
$id = makeSafe($data['matricule']);
$tote = sqlValue("SELECT SUM(total_entree) FROM entrees WHERE matricule='$id' ");
sql("UPDATE entrees SET total_tous_entree = '$tote' WHERE matricule='$id'", $eo);
return TRUE;
}
entrees-dv.js
$j(function(){
/* set montant total entree field to read only*/
$j('#total_entree').prop('readonly', true);
/* calcul du champs total entree */
$j('#qts_entree, #montant_entree, #total_tous_entree, #total_entree').change(function(){
var quantity = parseFloat($j('#qts_entree').val()) || 0;
var unitPrice = parseFloat($j('#montant_entree').val()) || 0;
var totalPrice = quantity * unitPrice;
$j('#total_entree').val(totalPrice);
});
/* calculate total price on opening the detail view form*/
$j('#montant_entree').change();
})
clients.php
function clients_after_insert($data, $memberInfo, &$args){
$id = makeSafe($data['selectedID']);
$idclient = makeSafe($data['matricule']);
$total_entrees = sqlValue("SELECT total_tous_entree FROM entrees WHERE matricule = '$id' ");
$total_sorties = sqlValue("SELECT total_tous_sortie FROM sorties WHERE matricule = '$id' ");
$soldes = ($total_entrees - $total_sorties); // calcul des benefice
sql("UPDATE clients SET total_entree ='$total_entrees' WHERE idclient ='$id' ", $eo);
sql("UPDATE clients SET total_sortie ='$total_sorties' WHERE idclient ='$id' ", $eo);
sql("UPDATE clients SET solde ='$soldes' WHERE idclient ='$id' ", $eo);
return TRUE;
}
but when I try to add a client from clients table, I get this error message
Incorrect decimal value: '' for column 'total_sortie' at row 1
Recherche:
UPDATE clients SET total_sortie ='' WHERE idclient ='4'
The above info is displayed because you are currently signed in as the super admin. Other users won't see this.
You could try fixing this issue from the Admin Area : Utilities menu : Rebuild Fields.
Any help is welcome
Thank you
- tables.jpg (39.52 KiB) Viewed 4068 times