new image show system, allowing dynamic preview images

This commit is contained in:
Thomas Weinhold 2020-09-26 21:32:58 +02:00
commit dfda07ae1c
8 changed files with 193 additions and 53 deletions

View file

@ -7,14 +7,14 @@ function WriteTypeSelector ($ParentId)
global $GlobalMysqlHandler;
global $GlobalContent;
global $GlobalTemplate;
$ListQuery="SELECT * FROM `Types` WHERE `ParentId` =$ParentId";
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'PartTypeSelector'))
$GlobalContent .= "<ul style=\"display:block;\">\n";
$GlobalContent .= "<ul style=\"display:block;\">\n";
else
$GlobalContent .= "<ul style=\"display:none;\">\n";
$GlobalContent .= "<ul style=\"display:none;\">\n";
if (mysqli_num_rows($ListQuery))
{
@ -106,6 +106,13 @@ $GlobalContent .= '</div>'."\n";
/////////
// Filter
$GlobalContent .= '<div id="PartFilter">'."\n";
//ShowImage
if (!isset($_SESSION['FilterShowPreviewImage'])) $_SESSION['FilterShowPreviewImage'] = "TRUE";
if (isset($_POST['FilterShowPreviewImage'])) $_SESSION['FilterShowPreviewImage']=$_POST['FilterShowPreviewImage'];
$GlobalContent .= ' <form action="index.php?Page=PartsByType" method="post">'."\n";
$GlobalContent .= ' <input type="radio" name="FilterShowPreviewImage" value="TRUE" onClick="javascript:this.form.submit()" '.(($_SESSION['FilterShowPreviewImage']=="TRUE")? "checked":"").'>'.LangSpellHtml('PartsPreviewImageYes')."\n";
$GlobalContent .= ' <input type="radio" name="FilterShowPreviewImage" value="FALSE" onClick="javascript:this.form.submit()" '.(($_SESSION['FilterShowPreviewImage']!="TRUE")? "checked":"").'>'.LangSpellHtml('PartsPreviewImageNo')."\n";
$GlobalContent .= ' </form>'."<br>\n";
//Obsolete Filter
if (!isset($_SESSION['FilterObsolete'])) $_SESSION['FilterObsolete']="NonObsolete";
if (isset($_POST['FilterObsolete'])) $_SESSION['FilterObsolete']=$_POST['FilterObsolete'];
@ -143,19 +150,23 @@ $GlobalContent .= '<table>'."\n";
// PartList Table Head
$GlobalContent .= '<tr>';
// PreviewImage
if ($_SESSION['FilterShowPreviewImage'] == "TRUE") {
$GlobalContent .= '<th>Image</th>';
}
//Name
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Name" target="_top">';
$GlobalContent .= LangSpellHtml('PartsName')." ";
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
//Value 1
if (isset($TypeValues[0][0]) && $TypeValues[0][0])
{
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Value1" target="_top">';
$GlobalContent .= $TypeValues[0][0]." ";
if ($_SESSION['SortPartListBy']=="Value1" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Value1" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="Value1" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Value1" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
}
//Value2
@ -163,8 +174,8 @@ if (isset($TypeValues[1][0]) && $TypeValues[1][0])
{
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Value2" target="_top">';
$GlobalContent .= $TypeValues[1][0]." ";
if ($_SESSION['SortPartListBy']=="Value2" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Value2" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="Value2" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Value2" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
}
//Value3
@ -172,27 +183,27 @@ if (isset($TypeValues[2][0]) && $TypeValues[2][0])
{
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Value3" target="_top">';
$GlobalContent .= $TypeValues[2][0]." ";
if ($_SESSION['SortPartListBy']=="Value3" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Value3" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="Value3" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Value3" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
}
//Package
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=PackageId" target="_top">';
$GlobalContent .= LangSpellHtml('PartsPackage')." ";
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
//Quantity
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Qty" target="_top">';
$GlobalContent .= LangSpellHtml('PartsQuantity')." ";
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
//Price
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Price" target="_top">';
$GlobalContent .= LangSpellHtml('PartsPrice')." ";
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
$GlobalContent .= '</a></th>';
//Obsolete
$GlobalContent .= '<th>'.LangSpellHtml('PartsObsolete').'</th>';
@ -211,28 +222,37 @@ $PartListQuery .= " ORDER BY `".$_SESSION['SortPartListBy']."` ".$_SESSION['Sort
$PartListQuery = mysqli_query($GlobalMysqlHandler, $PartListQuery);
while ($Parts = mysqli_fetch_array($PartListQuery))
{
$GlobalContent .= ' <tr>';
$GlobalContent .= ' <td><a href="index.php?Page=ShowPart&PartId='.$Parts['Id'].'" target="_top"><strong>'.$Parts['Name'].'</strong></a> '.$Parts['ShortDesc'].' </td>';
if (isset($TypeValues[0][0]) && $TypeValues[0][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value1']).$TypeValues[0][1].'</td>';
if (isset($TypeValues[1][0]) && $TypeValues[1][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value2']).$TypeValues[1][1].'</td>';
if (isset($TypeValues[2][0]) && $TypeValues[2][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value3']).$TypeValues[2][1].'</td>';
//////////
// Package
$PackageQuery = "SELECT `Name` FROM `Packages` WHERE `Id` = ".$Parts['PackageId'];
$PackageQuery = mysqli_query($GlobalMysqlHandler, $PackageQuery);
if (mysqli_num_rows($PackageQuery))
{
$Package=mysqli_fetch_array($PackageQuery);
$GlobalContent .= '<td>'.$Package['Name'].'</td>';
}
else
{
$GlobalContent .= '<td>-</td>';
}
$GlobalContent .= '<td>'.$Parts['Qty'].(($Parts['MinQty'])? "/".$Parts['MinQty']:"").'</td>';
$GlobalContent .= '<td>'.OtherFormatPrice($Parts['Price']).'</td>';
$GlobalContent .= '<td>'.((strtolower($Parts['Obsolete'])=="true")? LangSpellHtml('PartsObsolete'):"").'</td>';
$GlobalContent .= ' </tr>';
$GlobalContent .= ' <tr>';
// PreviewImage
if ($_SESSION['FilterShowPreviewImage'] == "TRUE") {
$GlobalContent .= '<td>';
if ($Parts['PicturePath'] != "") {
$GlobalContent .= OtherGetPictureImg($Parts['Id'], 100, 50);
}
$GlobalContent .= '</td>';
}
// Name, Value1, Value2, Value3
$GlobalContent .= ' <td><a href="index.php?Page=ShowPart&PartId='.$Parts['Id'].'" target="_top"><strong>'.$Parts['Name'].'</strong></a> '.$Parts['ShortDesc'].' </td>';
if (isset($TypeValues[0][0]) && $TypeValues[0][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value1']).$TypeValues[0][1].'</td>';
if (isset($TypeValues[1][0]) && $TypeValues[1][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value2']).$TypeValues[1][1].'</td>';
if (isset($TypeValues[2][0]) && $TypeValues[2][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value3']).$TypeValues[2][1].'</td>';
//////////
// Package
$PackageQuery = "SELECT `Name` FROM `Packages` WHERE `Id` = ".$Parts['PackageId'];
$PackageQuery = mysqli_query($GlobalMysqlHandler, $PackageQuery);
if (mysqli_num_rows($PackageQuery)) {
$Package=mysqli_fetch_array($PackageQuery);
$GlobalContent .= '<td>'.$Package['Name'].'</td>';
} else {
$GlobalContent .= '<td>-</td>';
}
$GlobalContent .= '<td>'.$Parts['Qty'].(($Parts['MinQty'])? "/".$Parts['MinQty']:"").'</td>';
$GlobalContent .= '<td>'.OtherFormatPrice($Parts['Price']).'</td>';
$GlobalContent .= '<td>'.((strtolower($Parts['Obsolete'])=="true")? LangSpellHtml('PartsObsolete'):"").'</td>';
$GlobalContent .= ' </tr>';
}
$GlobalContent .= '</table>'."\n";

View file

@ -79,10 +79,9 @@ global $GlobalMysqlHandler;
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonUpload').'"class="Button">';
$GlobalContent .= '</form><br>';
}
$GlobalContent .= '<img src="'.$GlobalPictureDir.'/'.$Part['PicturePath'].'"><br><br>';
echo "IMAGE: " . $Part['PicturePath'] . "<br>\n";
$GlobalContent .= OtherGetPictureImg($PartId, 300, 600);
$GlobalContent .= '</div>'."\n";
////////////////
// Detail Values
$GlobalContent .= '<div id="ShowPartValues" style="float:left; margin-left:10px;">'."\n";