Browse Source

Beginnings on company partners, minor touchups

master
OliverParoczai 4 years ago
parent
commit
3cc26b7156
  1. 83
      header.php

83
header.php

@ -32,13 +32,15 @@ if ($conn->connect_error) {
echo json_encode(array('response' => "Database connection error (".$conn->connect_error.")")); echo json_encode(array('response' => "Database connection error (".$conn->connect_error.")"));
exit; exit;
} }
if(isset($_POST["selectedcompany"]) && $loggedin){
if(isset($_POST["selectedschool"]) && $loggedin){ $_SESSION["selectedcompany"] = $_POST["selectedcompany"];
}elseif(isset($_POST["selectedschool"]) && $loggedin){
$_SESSION["selectedschool"] = $_POST["selectedschool"]; $_SESSION["selectedschool"] = $_POST["selectedschool"];
} }
if(!isset($liteload) && !$loggedin && $isadmin){ if(!isset($liteload) && !$loggedin && $isadmin && ($type == 1 || $type == 2)){
header("Location: ".$curdir."login.php"); header("Location: ".$curdir."login.php");
die();
}else{ }else{
if($loggedin == true){ if($loggedin == true){
$id = $_SESSION["id"]; $id = $_SESSION["id"];
@ -49,7 +51,11 @@ if(!isset($liteload) && !$loggedin && $isadmin){
$sqlvals = $result->fetch_assoc(); $sqlvals = $result->fetch_assoc();
$username = $sqlvals["username"]; $username = $sqlvals["username"];
$type = $sqlvals["type"]; $type = $sqlvals["type"];
if($type == 2){
$connctdcmps = explode(",", $sqlvals["connectedcompanyids"]);
}else{
$connctdschids = explode(",", $sqlvals["connectedschoolids"]); $connctdschids = explode(",", $sqlvals["connectedschoolids"]);
}
$sql = "SELECT * FROM `acctypes` WHERE `id` = '".$type."'"; $sql = "SELECT * FROM `acctypes` WHERE `id` = '".$type."'";
mysqli_free_result($result); mysqli_free_result($result);
$result = $conn->query($sql); $result = $conn->query($sql);
@ -77,6 +83,21 @@ if(!isset($liteload) && !$loggedin && $isadmin){
} }
} }
if($type == 2){
for($i = 0; $i<count($connctdcmps); $i++){
$viewsql = "SELECT * FROM `companies` WHERE `id` = ".$connctdcmps[$i];
$result = $conn->query($viewsql);
if ($result == TRUE) {
if(!isset($_SESSION["selectedcompany"])) {
$_SESSION["selectedcompany"] = "c".$connctdcmps[$i];
}
if (empty($result) || $result->num_rows == 0) {
$modsql = "INSERT INTO `companies` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`, `emailaddress`) VALUES ('".$connctdcmps[$i]."', '', '', '', '', '', '', '', '')";
$conn->query($modsql);
}
}
}
}else{
for($i = 0; $i<count($connctdschids); $i++){ for($i = 0; $i<count($connctdschids); $i++){
$viewsql = "SELECT * FROM `schools` WHERE `id` = ".$connctdschids[$i]; $viewsql = "SELECT * FROM `schools` WHERE `id` = ".$connctdschids[$i];
$result = $conn->query($viewsql); $result = $conn->query($viewsql);
@ -85,13 +106,28 @@ if(!isset($liteload) && !$loggedin && $isadmin){
$_SESSION["selectedschool"] = "s".$connctdschids[$i]; $_SESSION["selectedschool"] = "s".$connctdschids[$i];
} }
if (empty($result) || $result->num_rows == 0) { if (empty($result) || $result->num_rows == 0) {
$modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`, `email`) VALUES ('".$connctdschids[$i]."', '', '', '', '', '', '', '', '')"; $modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`, `emailaddress`) VALUES ('".$connctdschids[$i]."', '', '', '', '', '', '', '', '')";
$conn->query($modsql); $conn->query($modsql);
} }
} }
} }
}
mysqli_free_result($result); mysqli_free_result($result);
if($type == 2){
$viewsql = "SELECT * FROM `companies` WHERE `id` = ".substr($_SESSION["selectedcompany"], 1);
$result = $conn->query($viewsql);
if ($result == TRUE) {
if (!empty($result) && $result->num_rows > 0) {
$selcomvals = $result->fetch_assoc();
}
//else{
//$modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`) VALUES ('".substr($_SESSION["selectedschool"], 1)."', '', '', '', '', '', '', '')";
//$conn->query($modsql);
//header("Refresh:0");
//}
}
}else{
$viewsql = "SELECT * FROM `schools` WHERE `id` = ".substr($_SESSION["selectedschool"], 1); $viewsql = "SELECT * FROM `schools` WHERE `id` = ".substr($_SESSION["selectedschool"], 1);
$result = $conn->query($viewsql); $result = $conn->query($viewsql);
if ($result == TRUE) { if ($result == TRUE) {
@ -104,6 +140,7 @@ if(!isset($liteload) && !$loggedin && $isadmin){
//header("Refresh:0"); //header("Refresh:0");
//} //}
} }
}
mysqli_free_result($result); mysqli_free_result($result);
}else{ }else{
$username = "Vendég"; $username = "Vendég";
@ -279,11 +316,42 @@ if(!isset($liteload) && !$loggedin && $isadmin){
<i class="material-icons">business</i> <i class="material-icons">business</i>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header">INTÉZMÉNYVÁLASZTÁS</li> <li class="header"><?php if($type == 2) { echo "VÁLLALATVÁLASZTÁS"; } else { echo "INTÉZMÉNYVÁLASZTÁS"; } ?></li>
<li class="body"> <li class="body">
<ul class="menu"> <ul class="menu">
<form method="POST" action="#"> <form method="POST" action="#">
<?php <?php
if($type == 2){
$ssname = "Nincs vállalat kiválasztva";
for($i = 0; $i < count($connctdcmps); $i++){
$sql = "SELECT * FROM `companies` WHERE `id` = ".$connctdcmps[$i];
$result = $conn->query($sql);
if ($result == TRUE) {
if(!isset($_SESSION["selectedcompany"])){
$_SESSION["selectedcompany"] = "c".$sqlvals["id"];
}
if (!empty($result) && $result->num_rows > 0) {
$sqlvals = $result->fetch_assoc();
if($sqlvals["name"] == ""){
$sname = "Ismeretlen";
}else{
$sname = $sqlvals["name"];
}
if(("c".$sqlvals["id"]) == $_SESSION["selectedcompany"]){
$ssname = $sname;
$sname = "(<b>Kiválasztott</b>) ".$sname;
}
echo '<button type="submit" name="selectedcompany" value="c'.$sqlvals["id"].'" class="btn bg-transparent waves-effect" style="width: 100%; box-shadow: 0 0 0 0 !important; -webkit-border-radius: 0px;">
'.$sname.' (#'.$sqlvals["id"].')
</button>';
}else{
echo '<button type="submit" name="selectedcompany" value="c'.$connctdcmps[$i].'" class="btn bg-transparent waves-effect" style="width: 100%; box-shadow: 0 0 0 0 !important;">
Ismeretlen (#'.$connctdcmps[$i].')
</button>';
}
}
}
}else{
$ssname = "Nincs iskola kiválasztva"; $ssname = "Nincs iskola kiválasztva";
for($i = 0; $i < count($connctdschids); $i++){ for($i = 0; $i < count($connctdschids); $i++){
$sql = "SELECT * FROM `schools` WHERE `id` = ".$connctdschids[$i]; $sql = "SELECT * FROM `schools` WHERE `id` = ".$connctdschids[$i];
@ -313,12 +381,13 @@ if(!isset($liteload) && !$loggedin && $isadmin){
} }
} }
} }
}
?> ?>
</form> </form>
</ul> </ul>
</li> </li>
<li class="footer"> <li class="footer">
<a href="javascript:void(0);">Intézmények kezelése</a> <a href="javascript:void(0);"><?php if($type == 2) { echo "Vállalkozások kezelése"; }else{ echo "Intézmények kezelése"; } ?></a>
</li> </li>
</ul> </ul>
</li> </li>
@ -358,7 +427,7 @@ if(!isset($liteload) && !$loggedin && $isadmin){
<div class="menu"> <div class="menu">
<ul class="list"> <ul class="list">
<?php if(!$isadmin){ <?php if(!$isadmin){
if($type == 1){ ?> if($type == 1 || $type == 2){ #School admin and partner ?>
<li class="header">ADMINISZTRÁTOR</li> <li class="header">ADMINISZTRÁTOR</li>
<li> <li>
<a href="admin"> <a href="admin">

Loading…
Cancel
Save