Пример #1
0
function list_incidents()
{
    require_once "requetes.inc.php";
    $iniFile = parse_ini_file(CONFIG . '/conf_incidents.ini', TRUE);
    $champs1['priorite'] = 'inc.priorite';
    $champs1['responsabilite'] = 'inc.responsabilite';
    $champs1['serviceacteur'] = 'inc.serviceacteur';
    $champs1['severite'] = 'imp.severite';
    $champs2['trigramme'] = 'app.trigramme';
    $champs2['impact'] = 'imp.description';
    $champs2['enseigne'] = 'app.enseigne';
    $champs2['cause'] = 'stat.typecause';
    $champs2['application'] = 'app.libelle';
    $champs2['n_incident'] = array('inc.incident', 'inc.incidentsConnexes');
    $addSql = null;
    foreach (array_keys($champs1) as $champ) {
        $addSql .= add_sql($champ, $champs1[$champ], $_POST, 'eq');
    }
    //	if(isset($_POST['application']) && $_POST['application'] ){
    //		$addSql .= " and (lower(app.libelle) like '%". strtolower($_POST['application']) ."%'";
    //	}
    foreach (array_keys($champs2) as $champ) {
        $addSql .= add_sql($champ, $champs2[$champ], $_POST, null);
    }
    $date1 = '';
    $date2 = '';
    if (isset($_POST['date_1']) && $_POST['date_1']) {
        $date1 = $_POST['date_1'];
    }
    if (isset($_POST['date_2']) && $_POST['date_2']) {
        $date2 = $_POST['date_2'];
    }
    $date1f = preg_replace("/(\\d{2})\\/(\\d{2})\\/(\\d{4})/", "\$3-\$2-\$1", $date1);
    $date2f = preg_replace("/(\\d{2})\\/(\\d{2})\\/(\\d{4})/", "\$3-\$2-\$1", $date2);
    //$reqDates = "where imp.datestart between '$date1f' and '$date2f'";
    $reqDates = "where imp.datestart between TO_DATE('{$date1f}','YYYY-MM-DD') and TO_DATE('{$date2f}','YYYY-MM-DD')";
    //oracle
    $select = $req['tout'] . " {$reqDates} {$addSql} order by date_start DESC";
    $dbcnx = connex_db();
    $rech = res_sel($select, $dbcnx)['res'];
    // pg_close($dbcnx);
    oci_close($dbcnx);
    //oracle
    $arrInc = array();
    foreach (array_keys($iniFile) as $c) {
        if ($c != 'duree_impact' && isset($rech[$c])) {
            $arrInc[$c] = $rech[$c];
        }
    }
    $html = "<meta charset='UTF-8'>";
    $html .= "<table style='width: 3000px; table-layout:fixed;' id='tab_inc' border='1' cellspacing='0' cellpadding='3' ><thead><TR>";
    foreach (array_keys($arrInc) as $c) {
        $t = $c;
        if (in_array($c, array_keys($iniFile))) {
            $t = $iniFile[$c];
        }
        if ($c === 'incident') {
            $hrf = "href=javascript:SortTable(0,'T','tab_inc');";
            $html .= "<TH style='min-width: 150px; width: 150px;'><a {$hrf} >{$t}</a></TH>";
        } elseif ($c === 'date_start' or $c === 'date_end') {
            $hrf = "href=javascript:SortTable(1,'D','tab_inc');";
            $html .= "<TH  style='min-width: 150px; width: 150px;'><a {$hrf} >{$t}</a></TH>";
        } elseif (in_array($c, array('description_inc', 'cause', 'description_imp'))) {
            $html .= "<TH style='min-width: 350px; width: 350px;'>{$t}</TH>";
        } else {
            $html .= "<TH  style='min-width: 180px; width: 180px;'>{$t}</TH>";
        }
    }
    $html .= "</TR></THEAD><TBODY>";
    $tab = array();
    // $j = 0;
    $l = -1;
    foreach ($arrInc as $c => $v1) {
        foreach ($v1 as $l => $v2) {
            $tab[$l][$c] = $v2;
        }
        // $j++;
    }
    $nb = $l + 1;
    if ($nb == 0) {
        $html = null;
    } else {
        for ($i = 0; $i < $nb; $i++) {
            $html .= "<TR>";
            foreach (array_keys($arrInc) as $c) {
                $vtd = '&nbsp;';
                if ($tab[$i][$c]) {
                    $vtd = $tab[$i][$c];
                }
                if ($c == 'incident') {
                    $html .= "<TD style='white-space:nowrap'><a href='/edit/" . $rech['id_incident'][$i] . "' target='_parent'>" . $vtd . "</a></TD>";
                } elseif (in_array($c, array('date_start', 'date_end', 'datepublication'))) {
                    $html .= "<TD style='white-space: nowrap'>" . $vtd . "</TD>";
                } else {
                    $html .= "<TD>" . $vtd . "</TD>";
                }
            }
            $html .= "</TR>";
        }
        $html .= "</tbody></TABLE>";
        $html = "<B> {$nb} incidents </B><br> {$html}";
    }
    return $html;
}
Пример #2
0
        $stmt = set_stmt($stmt, $menu, $place, $scene, $gate, $price);
        break;
    case "価格":
        $sql = 'SELECT DISTINCT id,name,comment FROM wasemeshi_list NATURAL JOIN menu_list NATURAL JOIN scene_list WHERE price BETWEEN :PRICE2 AND :PRICE';
        $sql = add_sql($sql, $menu, $place, $scene, $gate, $price);
        $stmt = $pdo->prepare($sql);
        $price_set = price_set($tag);
        $priceX = $price_set[0];
        $priceX2 = $price_set[1];
        $stmt->bindValue(':PRICE', $priceX, PDO::PARAM_INT);
        $stmt->bindValue(':PRICE2', $priceX2, PDO::PARAM_INT);
        $stmt = set_stmt($stmt, $menu, $place, $scene, $gate, $price);
        break;
    case "シーン":
        $sql = 'SELECT DISTINCT id,name,comment FROM wasemeshi_list NATURAL JOIN menu_list NATURAL JOIN scene_list WHERE ';
        $sql = add_sql($sql, $menu, $place, $scene, $gate, $price);
        $stmt = $pdo->prepare($sql);
        $stmt = set_stmt($stmt, $menu, $place, $scene, $gate, $price);
        break;
    default:
        print "error";
        break;
}
//件数表示
$stmt->execute();
$resultset = $stmt->fetchAll();
$resultNum = count($resultset);
$stmt->execute();
$pdo = null;
?>