Exemplo n.º 1
0
function selectobso($input)
{
    $conn = new PDO("mysql:host=localhost;dbname=csv", 'root', 'root', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $input = strtoupper($input);
    $sql_select_basicat = "SELECT HostName,Code,Basicat,ID_Appli,Appli FROM ressources WHERE UCASE(Basicat)='{$input}'";
    $sql_select_id = "SELECT HostName,Code,Basicat,ID_Appli,Appli FROM ressources WHERE ID_Appli='{$input}'";
    $sql_select_name = "SELECT HostName, Code,Basicat,ID_Appli,Appli FROM ressources WHERE UCASE(Appli) LIKE '{$input}%'";
    $stmt0 = $conn->prepare($sql_select_basicat);
    $stmt1 = $conn->prepare($sql_select_id);
    $stmt2 = $conn->prepare($sql_select_name);
    $stmt0->execute();
    $result0 = $stmt0->fetchAll();
    if (!empty($result0)) {
        $numOfCode = count($result0);
        for ($i = 0; $i < $numOfCode; $i++) {
            selectPLI($result0[$i]["Basicat"], $result0[$i]["ID_Appli"], $result0[$i]["Appli"], $result0[$i]["HostName"], ltrim($result0[$i]["Code"], '0'));
        }
    } else {
        $stmt1->execute();
        $result1 = $stmt1->fetchAll();
        if (!empty($result1)) {
            $numOfCode = count($result1);
            for ($i = 0; $i < $numOfCode; $i++) {
                selectPLI($result1[$i]["Basicat"], $result1[$i]["ID_Appli"], $result1[$i]["Appli"], $result1[$i]["HostName"], ltrim($result1[$i]["Code"], '0'));
            }
        } else {
            $stmt2->execute();
            $result2 = $stmt2->fetchAll();
            if (!empty($result2)) {
                $numOfCode = count($result2);
                for ($i = 0; $i < $numOfCode; $i++) {
                    selectPLI($result2[$i]["Basicat"], $result2[$i]["ID_Appli"], $result2[$i]["Appli"], $result2[$i]["HostName"], ltrim($result2[$i]["Code"], '0'));
                }
            } else {
                echo $input . ' NE PAS EXISTER' . '<br/>';
            }
        }
    }
}
Exemplo n.º 2
0
	function selectobso($input){
        error_reporting(0);
        set_time_limit(0);
		try {
            session_start();
   			$conn = new PDO("mysql:host=localhost;dbname=csv", 'root', 'root',array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    		// set the PDO error mode to exception
            
    		$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $input=strtoupper($input);
            //echo $input;
            $sql_select_basicat="SELECT HostName,Code,Basicat,ID_Appli,Appli FROM ressources WHERE UCASE(Basicat)='$input'";
   			$sql_select_id="SELECT HostName,Code,Basicat,ID_Appli,Appli FROM ressources WHERE ID_Appli='$input'";
            $sql_select_name="SELECT HostName, Code,Basicat,ID_Appli,Appli FROM ressources WHERE UCASE(Appli) LIKE '$input%'";
            $stmt0 = $conn->prepare($sql_select_basicat);
            $stmt1 = $conn->prepare($sql_select_id);
            $stmt2 = $conn->prepare($sql_select_name);
    		$stmt0->execute();
    		$result0=$stmt0->fetchAll();
           
            if (!empty($result0)){
                $_SESSION['obso_result']=$result0;
                echo 'Il y a<code><b> '.count($result0).'</b></code> serveurs<br/>';
                echo 'Input is basicat'.'<br/><br/>';

                echo '<div class="btn-group">';
                echo '<button class="btn btn-warning btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bars"></i> Export Table Data</button>';
                echo '<ul class="dropdown-menu " role="menu">';
                echo '<li><a target="_blank" href="obso2csv.php"><img src=\'images/csv.png\' width=\'24px\'>CSV</a></li>';
                echo '<li><a target="_blank" href="obso2pdf.php"><img src=\'images/pdf.png\' width=\'24px\'>PDF</a></li></ul>';
                echo '</div>';
                ob_start();
                $appli_nom=explode('-',$result0[0]['Appli']);
                $nom=$appli_nom[0];
                echo "<table id='table_obso' border='5' width='100%' class='sortable table table-condensed table-bordered table-striped table-hover'>";
                $caption="ID_Appli: ".$result0[0]['ID_Appli']."<br/>"."Appli: ".$nom."<br/>"."Basicat: ".$result0[0]['Basicat'];
                echo '<caption style="color:#FF6600">'.$caption.'</caption><br/>';
                echo "<thead><tr>
                        <th>HostName</th>
                        <th>Code_Serveur</th>
                        <th>Nom_PLI</th>
                        <th>Version</th>
                        <th>Date_maj</th>
                        <th>Date_fin_support1</th>
                        <th>Date_fin_support2</th>
                        <th>Status_support</th>
                        <th>Soumis_a_licence</th>
                        </tr></thead><tbody>
                    ";
                $numOfCode=count($result0);
                $GLOBALS['csv']=array();
                for($i=0;$i<$numOfCode;$i++){

                    selectPLI($result0[$i]["HostName"],ltrim($result0[$i]["Code"],'0'));
                }
                echo "</tbody></table>";
                $obso_table=ob_get_contents();
                $_SESSION['obso_pdf']=$obso_table;
                $_SESSION['table_obso_csv']=$GLOBALS['csv'];
               // echo 'Debug: '.$final_result_csv;
                //$_SESSION["obso_sql_result"]=$result0;
                //displayContentsOfObso($result0);
                }
                //echo $result['ID_Appli'].'<br/>';
            else{
                $stmt1->execute();
                $result1=$stmt1->fetchAll();
               
                if(!empty($result1)){  
                     $_SESSION['obso_result']=$result1;
                    echo 'Il y a<code><b> '.count($result1).'</b></code> serveurs<br/>'; 
                    echo 'Input is ID_Appli'.'<br/><br/>'; 

                     echo '<div class="btn-group">';
                echo '<button class="btn btn-warning btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bars"></i> Export Table Data</button>';
                echo '<ul class="dropdown-menu " role="menu">';
                echo '<li><a target="_blank" href="obso2csv.php"><img src=\'images/csv.png\' width=\'24px\'>CSV</a></li>';
                echo '<li><a target="_blank" href="obso2pdf.php"><img src=\'images/pdf.png\' width=\'24px\'>PDF</a></li></ul>';
                echo '</div>';
                    ob_start();
                    $appli_nom=explode('-',$result1[0]['Appli']);
                    $nom=$appli_nom[0];
                    echo "<table id='table_obso' border='5' width='100%' class='sortable table table-condensed table-bordered table-striped table-hover'>";
                    $caption="ID_Appli: ".$result1[0]['ID_Appli']."<br/>"."Appli: ".$nom."<br/>"."Basicat: ".$result1[0]['Basicat'];
                echo '<caption style="color:#FF6600">'.$caption.'</caption><br/>';
                    echo "<thead><tr>
                        <th>HostName</th>
                        <th>Code_Serveur</th>
                        <th>Nom_PLI</th>
                        <th>Version</th>
                        <th>Date_maj</th>
                        <th>Date_fin_support1</th>
                        <th>Date_fin_support2</th>
                        <th>Status_support</th>
                        <th>Soumis_a_licence</th>
                       </tr></thead><tbody>";
                $numOfCode=count($result1);
                $GLOBALS['csv']=array();
                for($i=0;$i<$numOfCode;$i++){
                    selectPLI($result1[$i]["HostName"],ltrim($result1[$i]["Code"],'0'));
                }
                echo "</tbody></table>";
                $obso_table=ob_get_contents();
                $_SESSION['obso_pdf']=$obso_table;
                $_SESSION['table_obso_csv']=$GLOBALS['csv'];
                //echo 'Debug: '.$final_result_csv;
                }else{
                    $stmt2->execute();
                    $result2=$stmt2->fetchAll();
                    if(!empty($result2)){
                         $_SESSION['obso_result']=$result2;
                        echo 'Il y a<code><b> '.count($result2).'</b></code> serveurs<br/>';
                        echo 'Input is Appli Nom'.'<br/><br/>';

                         echo '<div class="btn-group">';
                echo '<button class="btn btn-warning btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bars"></i> Export Table Data</button>';
                echo '<ul class="dropdown-menu " role="menu">';
                echo '<li><a target="_blank" href="obso2csv.php"><img src=\'images/csv.png\' width=\'24px\'>CSV</a></li>';
                echo '<li><a target="_blank" href="obso2pdf.php"><img src=\'images/pdf.png\' width=\'24px\'>PDF</a></li></ul>';
                echo '</div>';
                        ob_start();
                        $appli_nom=explode('-',$result2[0]['Appli']);
                $nom=$appli_nom[0];
                        echo "<table id='table_obso' border='5' width='100%' class='sortable table table-condensed table-bordered table-striped table-hover'>";
                        $caption="ID_Appli: ".$result2[0]['ID_Appli']."<br/>"."Appli: ".$nom."<br/>"."Basicat: ".$result2[0]['Basicat'];
                    echo '<caption style="color:#FF6600">'.$caption.'</caption><br/>';
                    echo "<thead><tr>
                        <th>HostName</th>
                        <th>Code_Serveur</th>
                        <th>Nom_PLI</th>
                        <th>Version</th>
                        <th>Date_maj</th>
                        <th>Date_fin_support1</th>
                        <th>Date_fin_support2</th>
                        <th>Status_support</th>
                        <th>Soumis_a_licence</th>
                       </tr></thead><tbody>";
                $numOfCode=count($result2);
                $GLOBALS['csv']=array();
                for($i=0;$i<$numOfCode;$i++){
                    //echo 'debug out: '.$final_result_csv;
                    selectPLI($result2[$i]["HostName"],ltrim($result2[$i]["Code"],'0'));
                    //echo count($final_result_csv);
                }
                echo "</tbody></table>";
                $obso_table=ob_get_contents();
                $_SESSION['obso_pdf']=$obso_table;
                //echo count($GLOBALS['csv']);
                $_SESSION['table_obso_csv']=$GLOBALS['csv'];
                    
                    }else{
                        echo 'NE PAS EXISTER'.'<br/>';
                    }
                }
            }

        }
		catch(PDOException $e){
    		echo '<br/>' . $e->getMessage().'<br/>';
    	}
        $conn = null;

    }