Example #1
0
$action = be("all", "action");
$stype = be("get", "type");
if (isN($stype)) {
    $stype = 0;
} else {
    $stype = intval($stype);
}
switch ($action) {
    case "cls":
        cls();
        break;
    case "upto":
        update();
        break;
    case "uptodata":
        updatedata();
        break;
    case "uptofile":
        updatefile();
        break;
    case "uptoindex":
        updateindex();
        break;
    default:
        headAdmin("缓存管理");
        main();
        break;
}
dispseObj();
function update()
{
<?php

require_once 'config.php';
$avoirid = $_POST['avoirid'];
$facturecode = $_POST['facturecode'];
$montant = $_POST['montant'];
$typefacture = substr($facturecode, 0, 4);
$factureid = substr($facturecode, 4);
$restearegler = getfactureamount($factureid);
$communeid = getfacturenumber($avoirid);
updatedata($avoirid, $typefacture, $factureid, $montant, $restearegler, $communeid);
///////////////////////////functions////////////////////////////////////////////
function updatedata($avoirid, $typefacture, $factureid, $avoir, $restearegler, $communeid)
{
    $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
    $difference = $restearegler - $avoir;
    if ($difference < 0) {
        $avoirleft = $avoir - $restearegler;
        $appliedavoir = $restearegler;
        $difference = 0;
    } else {
        $avoirleft = 0;
        $appliedavoir = $avoir;
    }
    if ($difference == '0') {
        $query = "UPDATE `factures_cantine` SET  `avoir` =  '{$appliedavoir}', `restearegler` = '{$difference}', `avoir_on_id` = '{$communeid}', `comment`=CONCAT(`comment`,' ; R&eacute;gl&eacute;e par application avoir'), `reglement` = '1' WHERE  `idfacture` = '{$factureid}'";
    } else {
        $query = "UPDATE `factures_cantine` SET  `avoir` =  '{$appliedavoir}', `restearegler` = '{$difference}', `avoir_on_id` = '{$communeid}', `comment`=CONCAT(`comment`,' ; Application avoir') WHERE  `idfacture` = '{$factureid}'";
    }
    $mysqli->query($query);
    $query = "UPDATE `avoirs` SET  `reste` =  '{$avoirleft}' WHERE  `idavoir` = '{$avoirid}'";