if (pmb_mysql_result($resultat, 0, 0)) {
            show_lines_list();
        } else {
            print "<script>document.location='./circ.php?categ=relance&sub=recouvr&act=recouvr_liste';</script>";
        }
        break;
    case "solde":
        $requete = "select sum(montant) from recouvrements where empr_id='{$id_empr}'";
        $resultat = pmb_mysql_query($requete);
        $solde = @pmb_mysql_result($resultat, 0, 0);
        if ($solde) {
            //Crédit du compte lecteur
            $compte_id = comptes::get_compte_id_from_empr($id_empr, 2);
            if ($compte_id) {
                $cpte = new comptes($compte_id);
                $id_transaction = $cpte->record_transaction("", $solde, 1, $comment = $msg["relance_recouvrement_solde_recouvr"], $encaissement = 0);
                if ($id_transaction) {
                    $cpte->validate_transaction($id_transaction);
                    //Débit du compte bibliothèque
                    $requete = "insert into transactions (compte_id,user_id,user_name,machine,date_enrgt,date_prevue,date_effective,montant,sens,realisee,commentaire,encaissement) \n\t\t\t\t\tvalues(\n\t\t\t\t\t\t0,{$PMBuserid},'" . $PMBusername . "','" . $_SERVER["REMOTE_ADDR"] . "',now(),now(),now(),\n\t\t\t\t\t\t{$solde},-1,1,'" . sprintf($msg["relance_recouvrement_solde_recouvr_bibli"], $id_empr) . "',0)";
                }
            }
        }
        pmb_mysql_query("delete from recouvrements where empr_id='" . $id_empr . "'");
        print "<script>document.location='./circ.php?categ=relance&sub=recouvr&act=recouvr_liste';</script>";
        break;
    default:
        show_lines_list();
        break;
}
print "\n</form>\n<script type='text/javascript'>parse_dynamic_elts();</script>\n";
Esempio n. 2
0
    global $id_compte, $solde, $date_debut, $val_transactions, $somme, $cpte, $charset, $msg, $pmb_gestion_devise;
    print "<h3>" . $msg["finance_but_cred"] . "</h3>";
    print "<script type='text/javascript' >function check_somme(f) {\n\t\tmessage='';\n\t\tif (isNaN(f.somme.value)) {\n\t\t\tmessage='" . addslashes($msg["finance_enc_nan"]) . "';\n\t\t} else {\n\t\t\tif (f.somme.value<=0)\n\t\t\t\tmessage='" . addslashes($msg["finance_enc_mnt_neg"]) . "';\n\t\t}\n\t\tif (message) {\n\t\t\talert(message);\n\t\t\treturn false;\n\t\t} else return true;\n\t}\n\t</script>";
    print "<form name='form_special' action='encaissement.php?id_compte={$id_compte}&show_transactions={$show_transactions}&date_debut=" . rawurlencode(stripslashes($date_debut)) . "' method='post'>\n\t\t<input type='hidden' name='act' value='enc_special'/>\n\t\t" . $msg["finance_montant"] . " <input type='text' value='' name='somme' class='saisie-5em' style='text-align:right'>&nbsp;" . $pmb_gestion_devise . "<br />\n\t\t<input type='radio' value='1' name='typ_special' id='typ_special_1' checked>&nbsp;<label for='typ_special_1'>" . $msg["finance_enc_spe_crediter"] . "&nbsp;<input type='checkbox' name='credit_perte' value='1'>&nbsp;" . $msg["finance_enc_spe_perte"] . "</label><br /><input type='radio' value='2' name='typ_special' id='typ_special_2'>&nbsp;<label for='typ_special_2'>" . $msg["finance_enc_debiter"] . "</label><br />\n\t\t<input type='radio' value='3' name='typ_special' id='typ_special_3'>&nbsp;<label for='typ_special_3'>" . $msg["finance_enc_crediter_enc"] . "</label><br /><input type='radio' value='4' name='typ_special' id='typ_special_4'>&nbsp;<label for='typ_special_4'>" . $msg["finance_enc_debiter_enc"] . " <input type='checkbox' name='dec_perte' value='1'>&nbsp;" . $msg["finance_enc_spe_perte"] . "</label><br />\n\t\t" . $msg["finance_enc_raison"] . "<br />\n\t\t<textarea cols='80' rows='2' wrap='virtual' name='commentaire'></textarea><br />\n\t\t<input type='submit' value='" . $msg["finance_enc_valider"] . "' class='bouton' onClick=\"return check_somme(this.form)\"/>&nbsp;<input type='button' value='" . $msg["76"] . "' class='bouton' onClick=\"document.form_special.act.value=''; document.form_special.submit();\"/>\n\t\t</form>\n\t\t";
}
if ($pmb_printer_name) {
    $print_script = "\n<div id='printer_script'></div>\n<script type='text/javascript'>\n\t\n\tfunction printer_get_jzebra() {\n\t\tif(!document.jzebra) {\n\t\t\tvar req = new http_request();\n\t\t\treq.request('{$base_path}/ajax.php?module=circ&categ=zebra_print_pret&sub=get_script');\n\t\t\tdocument.getElementById('printer_script').innerHTML=req.get_text();\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction printer_jzebra_send_ticket(text,printer,encoding) {\n\t\tconsole.log(text);\n\t\tconsole.log(printer);\n\t\tconsole.log(encoding);\t\n\t\tvar applet = document.jzebra;\n\t\tvar found=false;\n\t\tif(applet!=null) {\n\t\t\tapplet.findPrinter(printer);\n\t\t\twhile (!applet.isDoneFinding()) {}\n\t\t\tif(printer == applet.getPrinter()) {\n\t\t\t\tfound = true; \n\t\t\t\tif(encoding) {\n\t\t\t\t\tapplet.setEncoding(encoding);\n\t\t\t\t}\n\t\t\t\tapplet.append(text);\n\t\t\t\tapplet.print();\n\t\t\t}\n\t\t}\n\t\tif(!found) {\t\t     \t     \t\t\t\t\n       \t\talert('" . $msg['printer_not_found'] . "');\n       \t}\n    } \n\t\t\t\t\n\tfunction printer_jzebra_print_ticket(url) {\n\t\tprinter_get_jzebra();\n\t\tvar req = new http_request();\n\t\tif(req.request(url)){\n\t\t\t// Il y a une erreur. \n\t\t\talert ( req.get_text() );\t\t\t\n\t\t}else { \n\t\t\talert ( req.get_text() );\t\n\t\t\tprinter_jzebra_send_ticket(req.get_text(),'" . $pmb_printer_name . "','850');\n\t\t\treturn 1;\t\n\t\t}\n\t}\n\tprinter_jzebra_print_ticket('{$base_path}/ajax.php?module=circ&categ=zebra_print_pret&sub=transacash_ticket&transacash_id=!!transacash_id!!');\n</script>\t";
}
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; $i < count($t); $i++) {
            if ($cpte->validate_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();
Esempio n. 3
0
function do_action($id_empr)
{
    global $pmb_gestion_amende, $lang, $include_path;
    global $finance_recouvrement_lecteur_statut;
    $action = "action_" . $id_empr;
    global ${$action}, $msg, $charset, $finance_statut_perdu;
    $act = ${$action};
    //Récupération du solde du compte
    $frais_relance = 0;
    $id_compte = comptes::get_compte_id_from_empr($id_empr, 2);
    if ($id_compte) {
        $cpte = new comptes($id_compte);
        $frais_relance = $cpte->summarize_transactions("", "", 0, $realisee = -1);
        if ($frais_relance && $frais_relance < 0) {
            $frais_relance = -$frais_relance;
        } else {
            $frais_relance = 0;
        }
    }
    //Si action différent de zéro, alors changement
    $quatre = false;
    if ($act != 0) {
        //Récupération de la liste des prêts
        $amende = new amende($id_empr);
        // on efface le cache pour qu'il soit remis à jour au prochain accès
        $req = "delete from cache_amendes where id_empr={$id_empr} ";
        pmb_mysql_query($req);
        $montant_total = 0;
        for ($j = 0; $j < count($amende->t_id_expl); $j++) {
            $params = $amende->t_id_expl[$j];
            //Si c'est juste un changement de niveau
            if ($act < 4) {
                //Si il y a attente de changement d'état
                if ($params["amende"]["niveau_relance"] < $params["amende"]["niveau"]) {
                    //Si le niveau attendu est supérieur ou égal au niveau demandé
                    if ($params["amende"]["niveau"] >= $act) {
                        //On passe au niveau demandé
                        $niveau = $act;
                    } else {
                        //Sinon on passe au niveau prévu
                        $niveau = $params["amende"]["niveau"];
                    }
                    //Enregistrement du changement de niveau
                    $requete = "update pret set niveau_relance={$niveau}, date_relance=now(), printed=0 where pret_idempr={$id_empr} and pret_idexpl=" . $params["id_expl"];
                    pmb_mysql_query($requete);
                }
                //Si le niveau supposé est inférieur au dernier niveau validé (ex : prolongations,...), on peut revenir..
                if ($params["amende"]["niveau"] < $params["amende"]["niveau_relance"]) {
                    if ($params["amende"]["niveau_relance"] >= $act) {
                        //On passe au niveau demandé
                        $niveau = $act;
                    } else {
                        //Sinon on passe au niveau prévu
                        $niveau = $params["amende"]["niveau"];
                    }
                    //Enregistrement du changement de niveau
                    $requete = "update pret set niveau_relance={$niveau}, date_relance=now(), printed=0 where pret_idempr={$id_empr} and pret_idexpl=" . $params["id_expl"];
                    pmb_mysql_query($requete);
                }
            } else {
                //Sinon, c'est plus grave, on passe en recouvrement !!
                $quatre = true;
                //Si niveau prévu = 4
                if ($params["amende"]["niveau"] == 4) {
                    //Passage des ouvrages en statut perdu
                    $requete = "update exemplaires set expl_statut={$finance_statut_perdu} where expl_id=" . $params["id_expl"];
                    pmb_mysql_query($requete);
                    //Débit du compte lecteur + tarif des relances
                    $debit = $amende->get_amende($params["id_expl"]);
                    $debit = $debit["valeur"];
                    $id_compte = comptes::get_compte_id_from_empr($id_empr, 2);
                    if ($id_compte) {
                        //&&($debit)
                        $compte = new comptes($id_compte);
                        //Enregistrement transaction
                        $id_transaction = $compte->record_transaction("", $debit, -1, sprintf($msg["relance_recouvr_transaction"], $params["id_expl"]), 0);
                        //Validation
                        $compte->validate_transaction($id_transaction);
                        $montant_total += $debit;
                        $requete = "select pret_date from pret where pret_idexpl=" . $params["id_expl"];
                        $resultat = pmb_mysql_query($requete);
                        $r = pmb_mysql_fetch_object($resultat);
                        $req_pret_date = ", date_pret='" . $r->pret_date . "' ";
                        $requete = "select  log.date_log as date_log, log.niveau_reel as niv\n\t\t\t\t\t\tfrom log_expl_retard as expl,log_retard as log \n\t\t\t\t\t\twhere expl.num_log_retard=log.id_log and  log.idempr={$id_empr} and expl.expl_id=" . $params["id_expl"] . " order by log.date_log limit 3";
                        $res = pmb_mysql_query($requete);
                        $req_date_relance = "";
                        $i = 1;
                        while ($log = pmb_mysql_fetch_object($res)) {
                            $req_date_relance .= ", date_relance" . $i++ . "='" . $log->date_log . "' ";
                        }
                        $requete = "insert into recouvrements set empr_id={$id_empr}, id_expl=" . $params["id_expl"] . ", date_rec= now(), libelle='',recouvr_type=0, montant='{$debit}' {$req_pret_date} {$req_date_relance}";
                        pmb_mysql_query($requete);
                        // Essayer de retrouver le prix de l'exemplaire
                        $requete = "select expl_prix, prix from exemplaires, notices where (notice_id=expl_notice or notice_id=expl_bulletin) and expl_id =" . $params["id_expl"];
                        $resultat = pmb_mysql_query($requete);
                        $prix = 0;
                        if ($r = pmb_mysql_fetch_object($resultat)) {
                            if (!($prix = 1 * $r->expl_prix)) {
                                $prix = 1 * $r->prix;
                            }
                        }
                        $requete = "insert into recouvrements set empr_id={$id_empr}, id_expl=" . $params["id_expl"] . ", date_rec=now(), libelle='', recouvr_type=1, montant='{$prix}' {$req_pret_date} {$req_date_relance}";
                        pmb_mysql_query($requete);
                        // on modifie le status du lecteur si demandé
                        if ($finance_recouvrement_lecteur_statut) {
                            $requete = "update empr set empr_statut={$finance_recouvrement_lecteur_statut} where id_empr={$id_empr}";
                            pmb_mysql_query($requete);
                        }
                    }
                    //Supression du pret
                    $requete = "delete from pret where pret_idexpl=" . $params["id_expl"];
                    pmb_mysql_query($requete);
                    $requete = "update exemplaires set expl_note=concat(expl_note,' ','" . $msg["relance_non_rendu_expl"] . "'),expl_lastempr='" . $id_empr . "' where expl_id=" . $params["id_expl"];
                    pmb_mysql_query($requete);
                    $requete = "update empr set empr_msg=trim(concat(empr_msg,' ','" . addslashes($msg["relance_recouvrement"]) . "')) where id_empr=" . $id_empr;
                    pmb_mysql_query($requete);
                }
            }
            //Ajout solde du compte amendes
            if ($quatre) {
                if ($frais_relance) {
                    $requete = "insert into recouvrements (empr_id,id_expl,date_rec,libelle,montant) values({$id_empr},0,now(),'" . $msg["relance_frais_relance"] . "'," . $frais_relance . ")";
                    pmb_mysql_query($requete);
                    $montant_total += $frais_relance;
                }
                //Passage en perte pour la bibliothèque
                //Débit sur le compte 0
                //if ($montant_total) {
                //	$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(), ".($montant_total*1).", -1, 1,'Recouvrement lecteur : ".$params["id_expl"]."',0)";
                //	pmb_mysql_query($requete);
                //}
            }
        }
        //Traitement des frais
        $niveau_min = $act;
        $the_frais = 0;
        if ($pmb_gestion_amende == 1) {
            $frais = "finance_relance_" . $niveau_min;
            global ${$frais};
            $the_frais = ${$frais};
        } else {
            $quota_name = "";
            switch ($niveau_min) {
                case 1:
                    $quota_name = "AMENDERELANCE_FRAISPREMIERERELANCE";
                    break;
                case 2:
                    $quota_name = "AMENDERELANCE_FRAISDEUXIEMERELANCE";
                    break;
                case 3:
                    $quota_name = "AMENDERELANCE_FRAISTROISIEMERELANCE";
                    break;
                default:
                    break;
            }
            $qt = new quota($quota_name, "{$include_path}/quotas/own/{$lang}/finances.xml");
            $struct["READER"] = $id_empr;
            $the_frais = $qt->get_quota_value($struct);
            if ($the_frais == -1) {
                $the_frais = 0;
            }
        }
        if ($the_frais) {
            if ($id_compte) {
                $compte = new comptes($id_compte);
                //Enregistrement transaction
                $cpte->record_transaction("", $the_frais, -1, sprintf($msg["relance_frais_relance_level"], $niveau_min));
            }
        }
    }
}