Location: PHPKode > projects > Ordertool > orders/admin/query/query.php
<HTML>
<HEAD>
<TITLE>Bestellung </TITLE>
</HEAD>
<body bgcolor=#ffffff link=#008000 vlink=#008000>
<?
/*========================================
ORDERTOOL written in PHP
code : uwe k <hide@address.com>
lic : Artistic License

For more information see LICENSE
==========================================*/
$migration="yes";			// MIGRATION
require ("../incl/conn.inc.php"); 	// Connection
$room="QUERY";				// Auth-Level
require ("../incl/auth.inc.php");	// Authorization

include ("../incl/header.inc.php");

  switch ($action) { 
   
   default;   
?>   
   <!-- Suche --> 
   <TABLE WIDTH=90% cellpadding=10 cellspacing=2
   BGCOLOR='#E5EDE0' align=center> 
   <FORM ACTION='query.php' METHOD=POST>
    <TR> 
    <TD align=center colspan=2>
    <font color=brown size=+2>&nbsp;<tt> Suchkriterien </tt></font>
    <small>  (* nicht erforderlich)</small>
    </TR><TR>
    <TD align=left><tt>&nbsp;<b>IBN</b></tt></TD>
    <TD>&nbsp;<INPUT NAME='ident' SIZE=10 MAXLENGTH=10></TD> 
    </TR><TR>
    <TD align=left><tt>&nbsp;MABS - Nr.</tt></TD>
    <TD>&nbsp;<INPUT NAME='mabs' SIZE=10 MAXLENGTH=10></TD>
    </TR><TR>
    <TD align=left><tt>&nbsp;Inventar-Nr.</tt></TD>
    <TD>&nbsp;<INPUT NAME='nr_inv' SIZE=10 MAXLENGTH=10></TD>
    </TR><TR>    
    <TD align=left><tt>&nbsp;Besteller (Login)</tt></TD>
    <TD>&nbsp;<INPUT NAME='u_login' SIZE=20 MAXLENGTH=20></TD>
    </TR><TR>    
    <TD align=left><tt>&nbsp;Kostenstelle</tt></TD>
    <TD>&nbsp;<INPUT NAME='kst' SIZE=10 MAXLENGTH=10></TD> 
    </TR><TR>
    <TD align=left><tt>&nbsp;Belegnummer</tt></TD>
    <TD>&nbsp;<INPUT NAME='nr_bel' SIZE=10 MAXLENGTH=10></TD>     
    </TR><TR>    
    <TD align=left><tt>&nbsp;Bezeichnung</tt></TD>
    <TD>&nbsp;<INPUT NAME='o_bez' SIZE=45 MAXLENGTH=50></TD>   
    </TR><TR><td>&nbsp;</td><TD align=left>
    <input TYPE=checkbox name=ARC value=ARCHIV>
    <font color=brown><tt>&nbsp;Archivsuche</tt> </font></TD>     
    </TR><TR>    
    <td ALIGN=left COLSPAN=1>
    <tt>Treffer sortiert nach <br></tt>
<? echo"<input TYPE=radio name=sortierung value=$id><tt> Bestell-Nr.</tt> <br>"; ?>
    <input TYPE=radio name=sortierung value=u_login><tt> Besteller</tt></td>
    <td BGCOLOR='#E5E0F0' ALIGN=left VALIGN=middle COLSPAN=1>
    <input TYPE=submit VALUE=' Suche beginnen '>&nbsp;&nbsp;&nbsp;&nbsp;
    <input TYPE=reset VALUE=' L&ouml;schen '></td></TR>
    <input TYPE=hidden name=action VALUE=search> 
    </FORM></TABLE> 
<?   
 break;
 
 case "search";		// ### SEARCH
  if ($ident!="" && !is_numeric($ident)) {
  	echo "<center>Bestell-Nr. ist nicht numerisch!!<br>";
	echo"<!-- Navigation Suche -->
   	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   	<A HREF='$PHP_SELF' NAME='Suche'><sub><- Zurück zur Suche</sub></A></center>";
	exit;
  } 
  // Aktive Bestellung 
  if (($nr_inv == "") && ($nr_bel == "") && ($ARC != "ARCHIV")) { 
   // BOOKING - Statement
   $worker_stat = "SELECT * from booking WHERE 1=1 ";
   if ($mabs == "") 
   	$worker_stat .= "AND i_nr = '$ident' ";
   else $worker_stat .= " AND mabs = $mabs ";
   $worker_result = $link->query($worker_stat);
   
   if ($worker_result) {
       $worker_row = $link->fetch_array($worker_result);
       if ($mabs != "") $ident=$worker_row[i_nr];
       if ($worker_row[sperre]) $arbeiter = $worker_row[sperre];
       else $arbeiter = $worker_row[editor];
   }
    
   // INQUIRY - Statement
 
   $search_stat = "SELECT *";
   $search_stat  .= " FROM inquiry d ";
   $search_stat .= "WHERE 1=1";
   if ($ident != "")
     $search_stat .= " AND d.$id = '$ident' ";
   if ($o_bez != "")
   $search_stat .= " AND d.o_bez LIKE '%$o_bez%' ";
   if ($kst != "")
   $search_stat .= " AND d.kst = '$kst' ";
   if ($bereich != "")
   $search_stat .= " AND d.bl LIKE '%$bereich%' ";
   if ($ausgabe != "")
   $search_stat .= " AND d.bv LIKE '%$ausgabe%' ";
   if ($u_login != "")
   $search_stat .= " AND d.u_login LIKE '%$u_login%' ";
   if ($sortierung != "")
   $search_stat .= " ORDER BY $sortierung ";
   // if ($development == 1) echo "$search_stat";
   $result = $link->query($search_stat);
   $search_num = $link -> num_rows ($result);
 }
  
  if ($search_num >0) {   
   if ($search_num > 1) 
   echo "<center><small>Detailinfos durch Suche mit Bestell-Nr.</small></center><br>";
   for ($i = 0; $i < $search_num; $i++) {
   $inq_row = $link->fetch_array($result);
   include ("../incl/inq.inc.php");	// Details einer Bestellung
    // Einkaufsbereich
    if ($worker_row[order_place] != "") {
      ereg( "([0-9]{2})-([0-9]{1,2})-([0-9]{1,2})", 
      $worker_row[order_date], $regs1 );
      ereg( "([0-9]{2})-([0-9]{1,2})-([0-9]{1,2})", 
      $worker_row[deadline], $regs2 );
      echo "<TD align=left colspan=3>
      Bestellt am <i>$regs1[3].$regs1[2].$regs1[1]</i>
      bei <i>$worker_row[order_place]</i> von <i>$arbeiter</i>. ";
      if ($worker_row[mabs]) echo "<b><i> MABS-Nr. : $worker_row[mabs]</i></b>";
      echo "<br>Vorraussichtliches Lieferdatum : <i>$regs2[3].$regs2[2].$regs2[1]</i> ";
      if ($worker_row[comment] != "")
       echo "<br>Kommentar : <tt>$worker_row[comment]</tt>";
      echo "</TD></TR>";    
    }
    // Priorität    include ("../incl/prioritaet.inc.php3");
    
    // Status  
    $s_res = $link->query("select name from status where $id=$inq_row[status]");
    $st_row = $link->fetch_array($s_res);
    
    echo "<TR><TD colspan=3>Status : 
    <font color=blue>($inq_row[status]) $st_row[name]</font></TD></TR>
    </TABLE>
    <BR clear=all><hr size='2' noshade width=90%>";
   
   } // for
  } // if
  
  else
 {
 $arc_stat = "SELECT *";
 $arc_stat  .= " FROM archive d ";
 $arc_stat .= "WHERE 1=1";     		   
 if ($ident != "")
   $arc_stat .= " AND d.$id = '$ident' ";
 if ($o_bez != "")
 $arc_stat .= " AND d.o_bez LIKE '%$o_bez%' ";
 if ($kst != "")
 $arc_stat .= " AND d.kst = '$kst' ";
 if ($bereich != "")
 $arc_stat .= " AND d.bl LIKE '%$bereich%' ";
 if ($ausgabe != "")
 $arc_stat .= " AND d.bv LIKE '%$ausgabe%' ";
 if ($u_login != "")
 $arc_stat .= " AND d.u_login LIKE '%$u_login%' "; 
 if ($mabs != "")
 $arc_stat .= " AND d.bv_comment LIKE '%$mabs%' ";
 if ($nr_inv != "")
 $arc_stat .= " AND d.inv_nr LIKE '%$nr_inv%' ";
 if ($nr_bel != "")
 $arc_stat .= " AND d.beleg_nr_bv LIKE '%$nr_bel%' ";
 if ($sortierung != "")
 $arc_stat .= " ORDER BY $sortierung ";
 $result = $link->query($arc_stat);
 $arc_num = $link->num_rows($result); 
 
 if ($arc_num > 0) {     
   echo"<!-- Navigation Suche -->
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <A HREF='$PHP_SELF' NAME='Suche'><sub><- Zurück zur Suche</sub></A>";
  echo "<br><table BORDER=0 WIDTH=50% cellpadding=5 align=center>
   <tr><td BGCOLOR=#FFEE00>Suchergebnis aus dem Ordertool-ARCHIV</td>
    </tr></table><br clear=all><br>";
     
 for ($i = 0; $i < $arc_num; $i++) {
 $arc_row = $link->fetch_array($result);
 
 // DATUM TT.MM.YYYY
 
 ereg( "([0-9]{2})-([0-9]{1,2})-([0-9]{1,2})", 
 $arc_row[inq_datum], $regs );
 
  echo "<B>Bestell-Nr. : $arc_row[$id]</b>, $arc_row[u_login], 
  $regs[3].$regs[2].$regs[1]<br><br>
  <B>Artikel :</b> $arc_row[o_amount] x $arc_row[o_bez] a´ $arc_row[o_preis]
  <br>";
  if ($arc_row[o_misc]) echo "<i>$arc_row[o_misc]</i><br>";
  echo "Kostenstelle : $arc_row[kst]";
  if ($arc_row[bv]) echo ", Abholstelle : $arc_row[bv]<br>";
  
  if ($arc_row[v_comment] || $arc_row[b_comment] || $arc_row[bv_comment])     
  echo "<br><b>Kommentare</b><br>"; 
  
  if ($arc_row[v_comment]) 
  echo "<I>Bereichsleiter :</I> $arc_row[v_comment]<br>";
  if ($arc_row[b_comment]) 
  echo "<I>Einkauf :</I> $arc_row[b_comment]<br>"; 
  if ($arc_row[bv_comment]) 
  echo "<I>Ausgabe :</I> $arc_row[bv_comment]<br>";
  
  if ( !(stristr($arc_row[last_action], "abgelehnt") )) {
  if ($arc_row[order_place] || $arc_row[order_date] || $arc_row[deadline]) 
  echo "<b>EINKAUF</b><br>";  
  if ($arc_row[order_place]) echo "Bestellt bei $arc_row[order_place] ";
  ereg( "([0-9]{2})-([0-9]{1,2})-([0-9]{1,2})", $arc_row[order_date], $regs );
  if ($arc_row[order_date]) echo " am $regs[3].$regs[2].$regs[1]. ";
  ereg( "([0-9]{2})-([0-9]{1,2})-([0-9]{1,2})", $arc_row[deadline], $regs );
  if ($arc_row[deadline]) 
  echo " Vorraussichtliches Lieferdatum war : $regs[3].$regs[2].$regs[1].";
  echo"<br><br>";
  }
  
  if ($arc_row[beleg_art_bv] || $arc_row[beleg_nr_bv]) {
  echo "<b>BELEGE</b><br>";
  echo "Beleg 1 : $arc_row[beleg_art_bv], $arc_row[beleg_nr_bv]"; 
  }
  if ($arc_row[beleg_art_acc] && $arc_row[beleg_nr_acc])
  echo "Beleg 2 : $arc_row[beleg_art_acc], $arc_row[beleg_nr_acc]<br>";
  
  if ($arc_row[inv_nr]) 
  echo "<br><center><b>Inventar-Nr. : $arc_row[inv_nr]</b></center>";
  echo "<hr width=20% align=left>
  <b>Letzte Aktion :</b> ($arc_row[exec]) -> $arc_row[last_action] 
  <br>";
  echo "<hr size='2' noshade><br>";
  
  } // for
 } // if
 } // else
  
  // Immer LOG-File
  
 if ($auth_row[b]!='X');
 else {
 	$log_stat = "SELECT *";
 	$log_stat  .= " FROM log ";
 	$log_stat .= "WHERE 1=1 AND i_nr = '$ident' order by $id";
 	$log_result = $link->query($log_stat,$link);
 	$num = $link->num_rows($log_result); 
 if ($num > 0) {  
  	echo "<BR><table BORDER=1 WIDTH=90% cellpadding=3 cellspacing=3 align=center>
   	<tr><td BGCOLOR=#FFEE00>Bestellhistorie</td>
    	</tr>
	<tr><td>Aktion</td><td>Wer ?</td><td>Misc</td><td>Datum</td></tr>";
		
	for ($i = 0; $i < $num; $i++) {
 	$log_row = $link->fetch_array($log_result);
 	   if ($log_row[action] != 'Statusabfrage') {
 	   ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})",
 	   $log_row[datum], $regl );
  	   echo "<tr><td>$log_row[action]</td>
	   <td>$log_row[exec]</td>
	   <td>$log_row[editor]</td>
	   <td>$regl[3].$regl[2].$regl[1]</td></tr>";
	   }
	} // for
	echo"</table><br clear=all><br>";
    } // if
  } // else
  
   echo"<!-- Navigation Suche -->
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <A HREF='$PHP_SELF' NAME='Suche'><sub><- Zurück zur Suche</sub></A>";

  if ($auth_row[b]=='X') 
   echo"<!-- Navigation Buchhaltung -->
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <A HREF='../buchhaltung/anla.php' NAME='Buchhaltung'> 
   <sub>Zurück zu Anla -> </sub></A>"; 
  
  break; // search
  
  } // switch ($action) 

include ("../incl/footer.inc.php");  

?></BODY></HTML>
Return current item: Ordertool