error) { print pmb_bidi($cpte->error_message); exit; } function back_to_list() { global $show_transactions, $date_debut,$id_compte; print ""; } function back_to_main() { global $show_transactions, $date_debut,$id_compte,$cpte; print ""; } function encaisse_form($with_validated=false, $transacash_num=0) { global $id_compte,$solde,$date_debut,$val_transactions,$somme,$cpte,$charset; global $pmb_gestion_devise,$msg,$charset; $solde=$cpte->get_solde(); if ($solde<0) { print ""; print ""; if ($solde<=0) print "
".$msg["finance_enc_montant_valide"]." : ".comptes::format($somme*(-1))."
".$msg["finance_enc_montant_a_enc"]." : "; else if ($solde>0) print "".$msg["finance_enc_compte_cred"]." : "; print comptes::format($solde*(-1)); print "
"; print ""; print "
". htmlentities($msg['finance_mnt_percu'], ENT_QUOTES, $charset)."  ".$pmb_gestion_devise."  
"; } else { back_to_main(); } } function special_form() { global $id_compte,$solde,$date_debut,$val_transactions,$somme,$cpte,$charset,$msg, $pmb_gestion_devise; print "

".$msg["finance_but_cred"]."

"; print ""; print "
".$msg["finance_montant"]."  ".$pmb_gestion_devise."
 
 
 
 
".$msg["finance_enc_raison"]."

 
"; } if($pmb_printer_name) { $print_script="
"; } switch ($act) { case "valenc": //Validation de ce qui n'est pas valide $t=$cpte->get_transactions("","",0,0); $somme=0; $val_transactions=""; for ($i=0; $ivalidate_transaction($t[$i]->id_transaction)) { $somme+=$t[$i]->montant*$t[$i]->sens; $val_transactions.=" #".$t[$i]->id_transaction."#"; } } if(count($t)){ $transacash_num=$cpte->cashdesk_memo_transactions($t); } if ($val_transactions!="") $val_transactions=$msg["finance_enc_tr_lib_valider"]." : ".$val_transactions."\n"; $solde_avant=$cpte->get_solde(); if ($solde_avant!=0) $val_transactions.=$msg["finance_enc_tr_lib_etat_compte"]." : ".$solde_avant; $cpte->update_solde(); encaisse_form(true,$transacash_num); break; case "enc": if ($somme*1>0) { //Generation de la transaction if ($id_transaction=$cpte->record_transaction("",$somme,1,$val_transactions,1)) { $cpte->validate_transaction($id_transaction); $cpte->update_solde(); if(!$transacash_num){ $req="select MAX(transacash_num) from transactions where compte_id=".$cpte->id_compte.""; $resultat=mysql_query($req); if ($transacash_num=mysql_result($resultat,0,0)){ $req="update transactions set transacash_num = $transacash_num where compte_id=".$cpte->id_compte." and transacash_num=0"; mysql_query($req); } } $cpte->cashdesk_memo_encaissement($id_transaction,$transacash_num,$somme); } // print str_replace("!!transacash_id!!",$transacash_num,$print_script); back_to_main(); } else { back_to_list(); } break; case "transac_add": if ($transactype_total*1>0) { $transactype=new transactype($transactype_id); if($quantity) $aff_quantity=" ($quantity)"; //Generation de la transaction if ($id_transaction=$cpte->record_transaction("",$transactype_total,-1,$transactype->name.$aff_quantity,0,$transactype_id)) { //$cpte->validate_transaction($id_transaction); //$cpte->update_solde(); } back_to_main(); } else { back_to_list(); } break; case "val": if (!isset($trans)) $trans=array(); $i=0; foreach ($trans as $key=>$value){ $cpte->validate_transaction($key); $t[$i]->id_transaction=$key; $i++; } if(count($t)){ $transacash_num=$cpte->cashdesk_memo_transactions($t); } $cpte->update_solde(); back_to_main(); break; case "supr": if (!isset($trans)) $trans=array(); foreach ($trans as $key=>$value){ $cpte->delete_transaction($key); } $cpte->update_solde(); back_to_main(); break; case "encnoval": $solde=$cpte->get_solde(); $val_transactions.=$msg["finance_enc_tr_lib_etat_compte"]." : ".$solde; encaisse_form(); break; case "special": special_form(); break; case "enc_special": if ($somme*1>0) { switch ($typ_special) { case "1": //Crediter $signe=1; $caisse=0; break; case "2": //Debiter $signe=-1; $caisse=0; break; case "3": //Crediter et encaisser $signe=1; $caisse=1; break; case "4": //Debiter et decaisser $signe=-1; $caisse=1; break; } if ($id_transaction=$cpte->record_transaction("",$somme,$signe,stripslashes($commentaire),$caisse)) { $cpte->validate_transaction($id_transaction); //Traitement du passage en perte //Credit if (($typ_special==1)&&($credit_perte)) { //Ajout d'un transaction debit pour le compte 0 $requete="insert into transactions (compte_id,user_id,user_name,machine,date_enrgt,date_prevue,date_effective,montant,sens,realisee,commentaire,encaissement) values(0,$PMBuserid,'".$PMBusername."','".$_SERVER["REMOTE_ADDR"]."', now(), now(), now(), ".($somme*1).", -1, 1,'#".$id_transaction."# : ".$commentaire."',0)"; mysql_query($requete); } //Decaissement if (($typ_special==4)&&($dec_perte)) { //Credit sur le compte du lecteur if ($id_transaction_1=$cpte->record_transaction("",$somme,1,sprintf($msg["finance_enc_tr_lib_lost"]," #".$id_transaction."#")." : ".stripslashes($commentaire),0)) { $cpte->validate_transaction($id_transaction_1); //Debit sur le compte 0 $requete="insert into transactions (compte_id,user_id,user_name,machine,date_enrgt,date_prevue,date_effective,montant,sens,realisee,commentaire,encaissement) values(0,$PMBuserid,'".$PMBusername."','".$_SERVER["REMOTE_ADDR"]."', now(), now(), now(), ".($somme*1).", -1, 1,'#".$id_transaction_1."# : ".sprintf($msg["finance_enc_tr_lib_lost"],"#".$id_transaction."#")." : ".stripslashes($commentaire)."',0)"; mysql_query($requete); } } $cpte->update_solde(); } back_to_main(); } else { back_to_list(); } default: back_to_list(); break; } print ""; ?>