jablonka.czprosek.czf

is

Subversion Repositories:
[/] [trunk/] [html/] [edit_majetek.php] - Rev 6 Go to most recent revision

Compare with Previous - Blame - Download


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<style type="text/css" media="screen"> @import "style.css"; </style>
<title>db.jablonka.cz - Editace majetku</title>
</head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body topmargin=0 leftmargin=10>
<?
include("header.htm");
require('grab_globals.lib.php');
include ("fce.php");
$spojeni = MySQL_Connect($db_host, $db_user, $db_pass);
MySQL_Select_DB($db_name);
$aktualnidatum=date("d.m.Y");
$aktualnirok=date("Y");

if(!@$action)
{
$dbmajetek=MySQL_Query("SELECT * from majetek WHERE id=$id");
$dbmajetek=MySQL_Fetch_Array($dbmajetek);

$clen=$dbmajetek["clen"];

echo '
<b>Editace majetku (id='.$id.') uživatele '.id_to_name($dbmajetek["clen"]).':</b><br>

<form action="edit_majetek.php?action=zapis" method=POST>
<br>
<table>
  <tr>
    <td class=text>Člen:</td><td colspan=1>
      <select class=field name="clen">'."\n";
      #vypis vsech moznosti a predvybrani podle clena
      $string=MySQL_Query("SELECT c.id as cid, c.*, i.id as iid, i.* FROM cleni c LEFT JOIN ipecka i ON c.id = i.clen WHERE active=1 ORDER BY prijmeni");
      while($vysledek=MySQL_Fetch_Array($string))
      {
        echo '<option '; if($clen==$vysledek["cid"]){ echo 'selected';} echo' value='.$vysledek["cid"].'>'.$vysledek["prijmeni"]." ".$vysledek["jmeno"]." ".$vysledek["ip"]." ".$vysledek["vs"].'</option>'."\n";
      }
      echo '
      </select>
    </td>
    <td class=text>Adresa:</td><td colspan=3>
      <select class=field name="adresa">'."\n";
      #vypis vsech moznosti a predvybrani podle clena
      $string=MySQL_Query("SELECT * FROM adresy WHERE clen=$clen ORDER BY id");
      while($vysledek=MySQL_Fetch_Array($string))
      {
        echo '<option '; if($dbmajetek["adresa"]==$vysledek["id"]){ echo 'selected';} echo' value='.$vysledek["id"].'>'.$vysledek["ulice"]." ".$vysledek["cp"]." ".$vysledek["byt"].'</option>'."\n";
      }
      echo '
      </select>
    </td>
    <td class=text><a href=del_majetek.php?id='.$id.'>Smazat tento majetek!</a></td>
  </tr>

  <tr>  <td>  <hr>  </td>  </tr>

  <tr>
    <td class=text>Zařízení:</td>
    <td>
                <select class=field name="zarizeni">';
                $dotaz=MySQL_Query("SELECT * from zarizeni ORDER BY id");
                $count=MySQL_Num_Rows($dotaz);
                $count++;
                for ($i=1;$i<$count;$i++)
                {
                         $radek=MySQL_Fetch_Array($dotaz);
                         echo '<option '; if($dbmajetek["zarizeni"]==$radek["id"]){ echo 'selected';} echo' value='.$radek["id"].'>'.$radek["nazev"].'</option>';
                         echo '
                          ';
                         Next($string);
                }
                echo '</select>
           </td>
  </tr>
  <tr>
    <td class=text>Sériové číslo:</td><td><input class=field name="scislo" type="text" value="'.$dbmajetek["scislo"].'" size=35></td>
    <td class=text>Spotřeba [W]:</td><td><input class=field name="spotreba" type="text" value="'.$dbmajetek["spotreba"].'" size=15></td>
  </tr>
  <tr>
    <td class=text>MAC:</td><td><input class=field name="mac" type="text" value="'.$dbmajetek["mac"].'" size=35></td>
  </tr>

  <tr>  <td>  <hr>  </td>  </tr>

        <tr>
           <td class=text>Finance(účtenka):</td>
           <td colspan=3>
                <select class=field name="finance">';
                $dotaz=MySQL_Query("SELECT * from finance WHERE platba=9 ORDER BY datum");
                $count=MySQL_Num_Rows($dotaz);
                $count++;
                echo '<option value=null>není</option>';
                for ($i=1;$i<$count;$i++)
                {
                         $radek=MySQL_Fetch_Array($dotaz);
                         echo '<option '; if($dbmajetek["finance"]==$radek["id"]){ echo 'selected';} echo' value='.$radek["id"].'>'.$radek["id"]." ".sql2datum($radek["datum"])." ".substr($radek["komentar"],0,70).'</option>';
                         echo '
                          ';
                         Next($string);
                }
                echo '</select>
           </td>

  </tr>
  <tr> 

           <td class=text>Součást:</td>
           <td>
                <select class=field name="soucast">';
                $dotaz=MySQL_Query("SELECT * from majetek ORDER BY id");
                $count=MySQL_Num_Rows($dotaz);
                $count++;
                echo '<option value=null>není</option>';
                for ($i=1;$i<$count;$i++)
                {
                         $radek=MySQL_Fetch_Array($dotaz);
                         echo '<option '; if($dbmajetek["soucast"]==$radek["id"]){ echo 'selected';} echo' value='.$radek["id"].'>'.$radek["id"]." ".substr(id_to_majetek($radek["id"])." ".$radek["komentar"],0,70).'</option>';
                         echo '
                          ';
                         Next($string);
                }
                echo '</select>
           </td>
        </tr>
        <tr>
           <td class=text valign=top>Komentář:</td><td colspan=3><textarea class=fieldthin name="komentar" rows=4 cols=100>'.$dbmajetek["komentar"].'</textarea></td>
        </tr>
</table>
<br><br>
<input class=field type="submit" name="OK" value="&nbsp;Uložit změny&nbsp;">
<input name="id" type="hidden" value="'.$id.'">
</form>
<br>
Úkony spojené s tímto majetkem:
<br>
';

  $ukony=MySQL_Query("SELECT * FROM ukony WHERE majetek=$id ORDER BY datum ASC");
  while ($ukon=MySQL_Fetch_Array($ukony)) {
    echo '<a href="edit_ukon.php?id='.$ukon["id"].'">'.id_to_ukon($ukon["id"]).'</a><br>';
  }

echo '
<br>
<br>
<a href="add_ukon.php?clen='.$clen.'&majetek='.$id.'">Přidat úkon k tomuto majetku</a>
';
}
else
{

$result = MySQL_Query("UPDATE majetek SET clen='$clen',adresa='$adresa',zarizeni='$zarizeni',finance='$finance',spotreba='$spotreba',soucast='$soucast',scislo='$scislo',komentar='$komentar',mac='$mac' WHERE id='$id'");

if (!$result) {
echo "<br><b>Výsledek : ".mysql_error()."</b>";
} else {
echo "<br><b>Majetek uživatele ".id_to_name($clen)." byl úspěšně upraven!</b>";
}

echo '
<br><br>
<img src=images/arrow.jpg>&nbsp;<a href="javascript:history.go(-2)" class=odkaz>zpět</a>
<img src=images/arrow.jpg>&nbsp;<a href="majetek.php" class=odkaz>zpět na majetek</a>
';
}
MySQL_Close($spojeni);
?>
</body>
</html>

Powered by WebSVN 2.2.1