<?php

// a Trigger to display full genotype
$all = $this->myQuery("SELECT * FROM " . $this->tb);
// reach the strain displayed
$found = 0;
while (!$found && ($strain = mysql_fetch_object($all))) {
    if ($strain->EKY == $this->rec) {
        $found = 1;
    }
}
if ($strain) {
    // print full genotype
    echo dump_genotype($strain);
    /*	
    // find author in table labmembers
    $allauth = $this->myQuery("SELECT * FROM labmembers");
    if ($allauth){
       $found = 0;
       while(!$found && $labm = mysql_fetch_object($allauth)){
    	   if ($labm->id == $strain->author_id)
    		   $found = 1;
       }
    }
    // print author's name
    echo 	"Author: " .
    	$labm->Firstname . " ".
    	$labm->Name .
    	"<BR>". "<BR>";
    */
}
if (isset($_REQUEST["action"])) {
    // print_r($_REQUEST);
    $ids = $_REQUEST["ids"];
    $all_ids = preg_split("/([^0-9]+)/", $ids, -1, PREG_SPLIT_NO_EMPTY);
    // print("<pre>");
    // print_r($all_ids);
    // print("</pre>");
    if ($_REQUEST["action"] == "publish_genotypes") {
        $where_clause = "id IN (" . implode(",", $all_ids) . ")";
        $qry = "SELECT * FROM strains WHERE {$where_clause}";
        $result = mysql_query($qry, $connexion);
        while ($strain = mysql_fetch_object($result)) {
            // print("<pre>");
            // print_r($strain);
            // print("</pre>");
            $output .= dump_genotype($strain);
        }
    }
}
$output .= "<p>Enter IDs of strains (blank separated) that you want to publish genotypes.</p>";
$output .= "<form>";
$output .= "<textarea name='ids' cols='25' rows='5'>{$ids}</textarea><br>";
$output .= "<input type='hidden' name='action' value='publish_genotypes'>\n";
$output .= "<br><input type='submit' value='Extract genotypes.'>\n";
$output .= "</form>";
echo $output;
// session_start ();
require "footers.php";
?>