Location: PHPKode > projects > Modular Railroad Asset/Meeting Mgmt > fredl-2-1-9-Release/loco/deleteloco.php
<?php
    require_once('../php/fredlSession.php');
    /****************************************************************
     * FREMO Asset Management
     * Module: deleteloco.php
     * Description: Delete a loco from the database
     *
     * Created: 6/2004, Dirk Jahnke
     * Parameter:
     *   locoid
     *   backuri = link back to calling page
     *
     * $Log: deleteloco.php,v $
     * Revision 1.7  2005/11/02 12:59:09  klk32002
     * Added deletion of community.
     *
     * Revision 1.6  2005/06/07 21:53:30  dirkj
     * Added logDebug calls.
     *
     * Revision 1.5  2005/06/01 23:58:57  dirkj
     * Made multilingual.
     *
     * Revision 1.4  2004/11/01 12:35:47  dirkj
     * Modified session handling.
     *
     * Revision 1.3  2004/09/22 21:39:04  dirkj
     * Loco: Changed Baureihe zu Betriebsnummer.
     *
     * Revision 1.2  2004/07/24 14:46:38  klk32002
     * Changed message "... geloescht".
     *
     * Revision 1.1  2004/06/23 19:12:57  dirkj
     * Delete loco entry in database.
     *
     ****************************************************************/
    require_once '../php/sessionhelpers.inc.php';
    require_once '../php/uihelpers.inc.php';
    require_once '../lib/lang.php';
    $objUser=getUserObject();
    $l = new Lang($usrObj->langid, 'loco-delete', 'loco,general');

    print "<html>";
    print "<head>";
    print '<link rel="stylesheet" type="text/css" href="../'.$myStyleSheet.'">';
    print "</head>";
    print '<body class=right><h1>'.$l->get('loco-delete-title','Triebfahrzeug löschen').'</h1>';

   $backuri=$_GET['backuri'];
   $locoid=$_GET['locoid'];
   $thisuri=$_SERVER['REQUEST_URI'];

   logDebug("loco-delete locoid=$locoid | backuri=$backuri");


   // echo "<p>backuri=$backuri</p>";
   // echo "<p>locoid=$locoid</p>";
      $sql = "SELECT loco.*, lookup.valueVal as locotype
              FROM   loco, lookup
              WHERE  loco.locoid=$locoid
	        AND  lookup.lookupName='locotype'
		AND  lookup.langid={$usrObj->langid}
	        AND  loco.type=lookup.valueID";
      $result=mysql_query($sql) or die(mysql_error()."<br>sql=$sql");
      $loco=mysql_fetch_object($result);

   echo "<form action='deleteloco.php?locoid=$locoid&backuri=$backuri' method='post'>";
   echo "<table>";


   echo  "<tr><td><label>".$l->get('loco-id','Tfz-ID:')." </label></td><td>$loco->locoid</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-type','Typ:')." </label></td><td>$loco->locotype</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-number','Betriebsnummer:')." </label></td><td>$loco->baureihe</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-since','Einsatz von:')." </label></td><td>$loco->einsatzvon</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-until','Einsatz bis:')." </label></td><td>$loco->einsatzbis</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-dcc-adress','DCC Adresse:')." </label></td><td>$loco->dccadr</td></tr>";
   echo  "<tr><td><label>".$l->get('general-description-colon','Beschreibung:')." </label></td><td>$loco->description</td></tr>";
   echo  "<tr><td><label>".$l->get('general-vmax-colon','Vmax:')." </label></td><td>$loco->vmax</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-passenger-train','Einsatz im P-Zug:')." </label></td><td>";
   echo $loco->passenger? $l->get('general-yes',"Ja"):$l->get('general-no',"Nein");
   "</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-cargo-train','Einsatz im G-Zug:')." </label></td><td>";
   echo $loco->cargo? $l->get('general-yes',"Ja"):$l->get('general-no',"Nein");
   echo "</td></tr>";
   echo  "<tr><td><label>".$l->get('loco-shunter','Einsatz als Rangierlok:')." </label></td><td>";
   echo $loco->shunter? $l->get('general-yes',"Ja"):$l->get('general-no',"Nein");
   echo "</td></tr>";
   echo  "<tr><td><label>".$l->get('general-company-colon','Gesellschaft:')." </label></td><td>$loco->company</td></tr>";
   echo  "<tr><td></td></tr>";

   if (isset($_POST['doDelLoco']))
   {
      echo "<tr><td><b>".$l->get('general-delete','Löschen')." ...</b></td>";
      $sql="DELETE FROM loco WHERE locoid=$locoid";
      $result=mysql_query($sql) or die(mysql_error()."<br>sql=$sql<br>");
      $msg = sprintf($l->get('loco-deleted-msg','Tfz %s gelöscht'), $loco->baureihe);
      echo "<td><b>$msg</b></td></tr>";
      logAudit("deleteloco.php: $msg");
	  // addWnfm($usrObj->id, "del loco", "Tfz ".$loco->baureihe." gelöscht.");
	  // delete community relationships
	  $sql="DELETE FROM community_loco WHERE locoid=$locoid";
	  $result=mysql_query($sql) or die(mysql_error()."<br>sql=$sql<br>");
	  echo "<tr>";
   }
   else
   {
      echo '<tr><td><input class="cmd" type="Submit" name="doDelLoco" value="'.$l->get('general-delete').'"></td>';
   }
   echo "<td>";
   echo '<input type="Button" 
                class="cmd" 
	        onClick=\'parent.frames["rechts"].location.href="'.$backuri.'"\' 
	        value="'.$l->get('general-back-button').'" >';
   echo "</td></tr>";
   echo "</table></form>";

   print $l->getTranslationHelperUI();
   print '</body></html>';

?>
Return current item: Modular Railroad Asset/Meeting Mgmt