Index: branches/0.4/web/addons/job_monarch/libtoga.php
===================================================================
--- branches/0.4/web/addons/job_monarch/libtoga.php	(revision 777)
+++ branches/0.4/web/addons/job_monarch/libtoga.php	(revision 778)
@@ -97,4 +97,6 @@
 global $JOB_ARCHIVE_DIR;
 global $JOB_ARCHIVE_DBASE;
+global $JOB_ARCHIVE_SQL_USER;
+global $JOB_ARCHIVE_SQL_PASSWORD;
 global $skan_str;
 global $x_first, $y_first;
@@ -160,5 +162,5 @@
     var $ip, $dbase, $conn;
 
-    function TarchDbase( $ip = null, $dbase = null )
+    function TarchDbase( $ip = null, $dbase = null, $user =null, $password=null )
     {
         global $CLUSTER_CONFS, $clustername;
@@ -184,8 +186,27 @@
     function connect()
     {
+        global $JOB_ARCHIVE_SQL_USER, $JOB_ARCHIVE_SQL_PASSWORD;
+
+        $connect_args ='';
         if( $this->ip == null )
-            $this->conn = pg_connect( "dbname=".$this->dbase );
+        {
+            $connect_args .= "dbname=".$this->dbase;
+        }
         else
-            $this->conn = pg_connect( "host=".$this->ip." dbname=".$this->dbase );
+        {
+            $connect_args .= "host=".$this->ip." dbname=".$this->dbase;
+        }
+        if( isset($JOB_ARCHIVE_SQL_USER) )
+        {
+            $connect_args .= " user=".$JOB_ARCHIVE_SQL_USER;
+        }
+        if( isset($JOB_ARCHIVE_SQL_PASSWORD) )
+        {
+            $connect_args .= " password=".$JOB_ARCHIVE_SQL_PASSWORD;
+        }
+
+
+        $this->conn = pg_connect( $connect_args );
+
     }
 
@@ -260,4 +281,6 @@
 
         $ids = $this->queryDbase( $select_query );
+
+        //print_r( $ids );
 
         $ret = array();
@@ -335,14 +358,19 @@
     {
         $result_rows = array();
-    
-        if( !$this->conn )
+   
+        if( $this->conn == null )
         {
             $this->connect();
         }
 
+        if( $this->conn == null )
+        {
+            printf(" no connection!\n");
+        }
         $result = pg_query( $this->conn, $query );
 
         while ($row = pg_fetch_assoc($result))
         {
+            //print_r( $row );
             $result_rows[] = $row;
         }
Index: branches/0.4/web/addons/job_monarch/search.php
===================================================================
--- branches/0.4/web/addons/job_monarch/search.php	(revision 777)
+++ branches/0.4/web/addons/job_monarch/search.php	(revision 778)
@@ -33,5 +33,5 @@
     global $end_from_time, $end_to_time, $period_start, $period_stop, $tpl_data;
 
-    $error = 0;
+    $error = false;
     $error_msg = "<FONT COLOR=\"red\"><B>";
     $show_msg = 0;
@@ -40,5 +40,5 @@
 
     if( $id == '' and $owner== '' and $name == '' and $start_from_time == '' and $start_to_time == '' and $queue == '' and $end_from_time == '' and $end_to_time == '') {
-        $error = 1;
+        $error = true;
         $show_msg = 1;
         $error_msg .= "No search criteria set!";
@@ -48,5 +48,5 @@
     {
 
-        $error = 1;
+        $error = true;
         $show_msg = 1;
         $error_msg .= "Id must be a number";
@@ -64,4 +64,5 @@
 
                 $show_msg = 1;
+                $error = true;
                 $error_msg .= "Graph timeperiod reset: start date/time can't be later than end";
                 $period_stop = '';
@@ -70,4 +71,5 @@
 
                 $show_msg = 1;
+                $error = true;
                 $error_msg .= "Graph timeperiod reset: start and end date/time can't be the same";
                 $period_stop = '';
@@ -78,10 +80,6 @@
 
     $error_msg .= "</B></FONT>";
-    // doe checks en set error en error_msg in case shit
-
-    //if( $show_msg )
-        //$tpl_data->assign( "form_error_msg", $error_msg );
-
-    return ($error ? 0 : 1 );
+
+    return array( $error_msg, $error);
 }
 
@@ -256,6 +254,12 @@
     $tpl_data->assign( "end_to_value", rawurldecode( $end_to_time ) );
 
-    if( validateFormInput() ) {
-
+    list( $form_error_msg, $form_error ) = validateFormInput();
+
+    if( $form_error == true )
+    {
+        $tpl_data->assign( "form_error_msg", $form_error_msg );
+    } 
+    else if( $form_error == false ) 
+    {
         $tpl_data->assign( "search_results", "yes" );
         $tpl_data->assign( "sortby", $sortby);
@@ -268,6 +272,7 @@
         $search_ids = $tdb->searchDbase( $id, $queue, $owner, $name, $start_from_time, $start_to_time, $end_from_time, $end_to_time );
 
+        //print_r( $search_ids );
         if( ($tdb->resultcount) > (int) $SEARCH_RESULT_LIMIT ) {
-        
+       
             $tpl_data->assign( "form_error_msg", "Got " . $tdb->resultcount . " search results, output limited to last " . $SEARCH_RESULT_LIMIT . " jobs." );
         }
@@ -350,5 +355,6 @@
             $node_loop[]=$node_list;
         }
-        $tpl_data->assign("node_loop", $node_loop );
+        //print_r( $node_loop );
+        $tpl_data->assign("node_list", $node_loop );
 
         if( count( $search_ids ) == 1 ) {
@@ -463,6 +469,5 @@
                     $sorted_loop[]=$sorted_list;
                 }
-                $tpl_data->assign("sorted_loop", $sorted_loop );
-
+                $tpl_data->assign("sorted_list", $sorted_loop );
             }
         }
Index: branches/0.4/web/addons/job_monarch/templates/search.tpl
===================================================================
--- branches/0.4/web/addons/job_monarch/templates/search.tpl	(revision 777)
+++ branches/0.4/web/addons/job_monarch/templates/search.tpl	(revision 778)
@@ -197,5 +197,5 @@
 {$form_error_msg}<BR><BR>
 
-{if "$search_results" == " yes" }
+{if "$search_results" == "yes" }
 
 <INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{$sortby}">
@@ -223,5 +223,5 @@
 </TR>
 
-{loop $node}
+{loop $node_list}
   <TR CLASS="{$nodeclass}">
     <TD><A HREF="#" onClick="setFilter( 'id', '{$id}' )">{$id}</A></TD>
