function sellInstant($row, $guthaben, $price)
{
    $trade = singleRowQuery("Select id from trade where depotID = '" . $row["depotID"] . "' and stockID = '" . $row["stocksID"] . "'; ");
    //prüfen ob die aktie existiert
    $tradeID = $trade[0];
    $menge = singleRowQuery("Select menge from trade where id = '" . $tradeID . "'; ");
    //anzahl der vorherig gekauften Aktien abrufen
    $menge = $menge[0];
    if ($tradeID != "" and $menge >= $row["menge"]) {
        //aktie existiert
        if ($menge == $row["menge"]) {
            //kompletten datensatz löschen
            mysqlQuery("DELETE FROM trade WHERE id = '" . $tradeID . "';");
        } else {
            //datensatz nur updaten
            $menge = $menge - $row["menge"];
            //restmenge (nach dem verkauf)
            $startGeldNew = aktKurs($row["stocksID"]) * $menge;
            //neuer startwert (nach dem verkauf) berechnen
            mysqlQuery("UPDATE `trade` SET `menge`= '" . $menge . "', `startGeld`=  '" . $startGeldNew . "' WHERE `id` = '" . $tradeID . "';");
        }
        $bearbeitung = $price * 0.005 + 5;
        $price = $price + $bearbeitung;
        mysqlQuery("DELETE FROM auftrage WHERE id = '" . $row["id"] . "';");
        mysqlQuery("UPDATE `depot` SET `guthaben`= `guthaben` + '" . $price . "' WHERE `id` = '" . $row["depotID"] . "';");
        mysqlQuery("INSERT INTO history (`depotID`, `stocksID`, `type`, `limit`, `wert`, `menge`, `kurs`, `date`) VALUES \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t('" . $row["depotID"] . "','" . $row["stocksID"] . "','" . $row["type"] . "','" . $row["limit"] . "','" . $price . "','" . $row["menge"] . "','" . aktKurs($row["stocksID"]) . "','" . date("Y-m-d H:i:s") . "')");
    }
}
Exemplo n.º 2
0
<?php

require_once "../functions.php";
fenceGate();
if ($_POST["taskID"] != "") {
    $depotID = singleRowQuery("SELECT depotID FROM auftrage WHERE id = " . $_POST["taskID"] . "");
    $depotID = $depotID[0];
    if ($_SESSION['depot'] == $depotID) {
        mysqlQuery("DELETE FROM auftrage WHERE id = " . $_POST["taskID"] . "");
    }
    exit;
}
?>

<script type="text/javascript">

	function deleteTask(id) {
			if (confirm("Möchten Sie den Auftrag wirklich löschen ?") == true) {
				$.post( "index.php?p=tasks", { taskID: id }, function() { document.getElementById("openTask-"+id).style.display = "none"; } );			
			}
	}

</script>


<h1 class="page-header">Aufträge</h1>


<h3 class="sub-header">Laufende Aufträge</h3>

<div class="table-responsive">
Exemplo n.º 3
0
          <th>DepotID</th>
          <th>Gewinn</th>
        	<th></th>
      	</tr>
      </thead>
      <tbody>


<?php 
//abfrage für freunde
$abfrage = "SELECT \n`depot`.id as id, \n`depot`.name as name, \n(SELECT SUM(`trade`.menge) FROM `trade` WHERE `depotID` = `depot`.id) as menge, \n`depot`.pos sPos,\n`depot`.guthaben as guthaben\n\nFROM `depot`, `friends`\nWHERE (((`friends`.`depotID1` = `depot`.id AND `friends`.`depotID2` = '" . $_SESSION['depot'] . "') OR (`friends`.`depotID2` = `depot`.id AND `friends`.`depotID1` = '" . $_SESSION['depot'] . "')) AND `friends`.confirmed = '1') ;";
$result = multiRowQuery($abfrage);
$i = 1;
$werte = array();
while ($row = $result->fetch_assoc()) {
    $debotWert = singleRowQuery("SELECT wert FROM depotStats WHERE depotID = '" . $row["id"] . "' ORDER BY date DESC LIMIT 0,1;");
    $gewinn = round($debotWert[0] - 50000, 2);
    if ($row["menge"] == "") {
        $row["menge"] = 0;
    }
    //alle freunde in array schreiben
    $werte[$i]["name"] = $row["name"];
    $werte[$i]["id"] = $row["id"];
    $werte[$i]["menge"] = $row["menge"];
    $werte[$i]["sPos"] = $row["sPos"];
    $werte[$i]["gewinn"] = $gewinn;
    $i++;
}
//abfrage für mein Depot
$info = depotInfo($_SESSION['depot']);
$werte[0]["name"] = $info["name"];
Exemplo n.º 4
0
      <thead>
        <tr>
          <th>Wertpapier</th>
          <th>Stück</th>
          <th>Kurswert*</th>
        	<th>Kaufwert*</th>
        	<th>Gewinn/Verlust</th>
        	<th>Tendenz</th>
      	</tr>
      </thead>
      <tbody>

<?php 
$result = multiRowQuery("SELECT * FROM trade WHERE depotID = '" . $_SESSION['depot'] . "' ORDER BY date ASC;");
while ($row = $result->fetch_assoc()) {
    $name = singleRowQuery("SELECT name FROM stocks WHERE id = '" . $row["stockID"] . "'; ");
    $name = $name[0];
    $diff = date_diff(date_create($row["date"]), date_create(date("m.d.y")));
    $dateDiff = $diff->format('%a');
    if ($dateDiff == 0) {
        $dateDiff++;
    }
    $kurswert = aktKurs($row["stockID"]) * $row["menge"];
    $diffW = round($kurswert - $row["startGeld"], 2);
    $tendenz = round($diffW / ($row["startGeld"] * 0.01), 2);
    ?>
				
				<tr>
        	<td><?php 
    echo $name;
    ?>
    echo "[Date.UTC(" . $date . ")," . ($row["wert"] - 50000) . "],";
}
?>
            ],
            
        }]
    });
});
</script>

<?php 
$top = singleRowQuery("SELECT `stockID`,  \n\t\t\t\t\t\t\t\t\t\t\t\t @aktwert := (`menge` * (SELECT stocks.price FROM stocks WHERE stocks.id = `stockID`)) as aktwert, \n\t\t\t\t\t\t\t\t\t\t\t\t @gewinn := (@aktwert - startGeld) as gewinn,\n\t\t\t\t\t\t\t\t\t\t\t\t (@gewinn / (startGeld * 0.01)) as tendenz\n\t\t\t\t\t\t\t\t\t\t\t\t FROM trade WHERE `depotID` = '" . $_SESSION['depot'] . "' \n\t\t\t\t\t\t\t\t\t\t\t\t ORDER BY tendenz DESC \n\t\t\t\t\t\t\t\t\t\t\t\t LIMIT 0,1");
$topID = $top[0];
$topTendenz = round($top[3], 2);
$topName = getNameFromStockID($topID);
$flop = singleRowQuery("SELECT `stockID`,  \n\t\t\t\t\t\t\t\t\t\t\t\t @aktwert := (`menge` * (SELECT stocks.price FROM stocks WHERE stocks.id = `stockID`)) as aktwert, \n\t\t\t\t\t\t\t\t\t\t\t\t @gewinn := (@aktwert - startGeld) as gewinn,\n\t\t\t\t\t\t\t\t\t\t\t\t (@gewinn / (startGeld * 0.01)) as tendenz\n\t\t\t\t\t\t\t\t\t\t\t\t FROM trade WHERE `depotID` = '" . $_SESSION['depot'] . "' AND stockID <> '" . $topID . "'\n\t\t\t\t\t\t\t\t\t\t\t\t ORDER BY tendenz ASC \n\t\t\t\t\t\t\t\t\t\t\t\t LIMIT 0,1");
$flopID = $flop[0];
$flopTendenz = round($flop[3], 2);
$flopName = getNameFromStockID($flopID);
if ($topTendenz >= 0) {
    $topClass = "glyphicon glyphicon-arrow-up text-success";
} else {
    $topClass = "glyphicon glyphicon-arrow-down text-danger";
}
if ($flopTendenz >= 0) {
    $flopClass = "glyphicon glyphicon-arrow-up text-success";
} else {
    $flopClass = "glyphicon glyphicon-arrow-down text-danger";
}
if ($topName == "") {
    $topName = "N/A";
<?php

require_once "../functions.php";
fenceGate();
//Depotname herausfinden
$depotName = singleRowQuery("SELECT name FROM depot WHERE id = " . $_SESSION['depot']);
$depotName = $depotName[0];
//Anzeige-Seite bestimmen
if (!isset($_GET["p"])) {
    $_GET["p"] = "";
}
switch ($_GET["p"]) {
    case "dashboard":
        $activePage[$_GET["p"]] = "active";
        $_Page = $_GET["p"];
        break;
    case "depot":
        $activePage[$_GET["p"]] = "active";
        $_Page = $_GET["p"];
        break;
    case "tasks":
        $activePage[$_GET["p"]] = "active";
        $_Page = $_GET["p"];
        break;
    case "stocks":
        $activePage[$_GET["p"]] = "active";
        $_Page = $_GET["p"];
        break;
    case "friends":
        $activePage[$_GET["p"]] = "active";
        $_Page = $_GET["p"];
function getShortcutFromID($id)
{
    $result = singleRowQuery("SELECT shortcut FROM stocks WHERE id = '" . $id . "'; ");
    return $result[0];
}
<?php

require_once "../functions.php";
fenceGate();
//Passwort Ändern ...
if ($_POST["passOld"] != "" or $_POST["passNew"] != "" or $_POST["passNew1"] != "") {
    if ($_POST["passOld"] != "" and $_POST["passNew"] != "" and $_POST["passNew1"] != "") {
        $altesPass = singleRowQuery("SELECT pass FROM depot WHERE id = '" . $_SESSION['depot'] . "'");
        $altesPass = $altesPass[0];
        if (md5($_POST["passOld"]) == $altesPass) {
            if ($_POST["passNew"] == $_POST["passNew1"]) {
                mysqlQuery("UPDATE `depot` SET `pass` = '" . md5($_POST["passNew"]) . "' WHERE `id` = " . $_SESSION['depot'] . "; ");
                $pass_error = "Das neue Passwort wurde gespeichert !";
            } else {
                $pass_error = "Die neuen Passwörter stimmen nicht überein !";
            }
        } else {
            $pass_error = "Das Alte Passwort ist inkorrekt !";
        }
    } else {
        $pass_error = "Sie müssen alle Felder Ausfüllen !";
    }
}
//Vorschlag speichen
if ($_POST["suggestion"] != "") {
    mysqlQuery("INSERT INTO `suggestions` (`type`, `wert`, `depotID`, `date`) VALUES ('wertpapier', '" . $_POST["suggestion"] . "', '" . $_SESSION['depot'] . "', '" . date("Y-m-d H:i:s") . "'); ");
    $suggestion_error = "Ihr Vorschlag wurde gespeichert und wird in kürze angewandt !";
}
?>

<h1 class="page-header">Einstellungen</h1>
Exemplo n.º 9
0
         //für jedes depot
         $rang = singleRowQuery("SELECT count(`id`) as `pos` FROM `depotStats` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `wert` >= (SELECT wert FROM `depotStats` WHERE HOUR(`date`) = HOUR('" . $updateDate . "') AND DAY(`date`) = DAY('" . $updateDate . "') AND MONTH(`date`) = MONTH('" . $updateDate . "')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND YEAR(`date`) = YEAR('" . $updateDate . "') AND `depotID` = '" . $row["id"] . "' ) AND HOUR(`date`) = HOUR('" . $updateDate . "')\n\t\t\t\t\t\t\t  \t\t\t\t\t\tAND DAY(`date`) = DAY('" . $updateDate . "') AND MONTH(`date`) = MONTH('" . $updateDate . "') AND YEAR(`date`) = YEAR('" . $updateDate . "') ; ");
         $rang = $rang[0];
         mysqlQuery("UPDATE `depot` SET `pos` = '" . $rang . "' WHERE `id` = '" . $row["id"] . "'; ");
     }
 }
 //close if hourly
 //-------------------------------
 //  	Nur Täglich ausführen
 //-------------------------------
 if (intval(date("H")) == $_config["dailyUpdateHour"] and intval(date("i")) >= $_config["hourlyUpdateMin"] - 1 and intval(date("i")) < $_config["hourlyUpdateMin"] + 2) {
     //Strafgeld
     $res = multiRowQuery("SELECT id,guthaben FROM depot WHERE confirmed = '1';");
     while ($row = $res->fetch_assoc()) {
         //für jedes depot
         $count = singleRowQuery("SELECT COUNT(id) FROM trade WHERE depotID = '" . $row["id"] . "'; ");
         $count = $count[0];
         if ($count == 0) {
             $strafe = $row["guthaben"] * 2.0E-5;
             mysqlQuery("UPDATE `depot` SET `guthaben`= `guthaben` - '" . $strafe . "' WHERE `id` = '" . $row["id"] . "';");
         }
     }
     unset($res);
     //alte freundschaftsanfragen
     $res = multiRowQuerry("SELECT * FROM friends");
     while ($row = $res->fetch_assoc()) {
         $diff = date_diff(date_create($row["date"]), date_create(date("m.d.y")));
         $diff_days = $diff->format('%a');
         if ($diff_days > 20) {
             mysqlQuery("DELETE FROM friends WHERE id = '" . $row["id"] . "';");
         }