diff --git a/includes/globals.php b/includes/globals.php
index b3ab2f7..dca5832 100755
--- a/includes/globals.php
+++ b/includes/globals.php
@@ -28,4 +28,4 @@ $GlobalPictureDir = "./pictures";
$GlobalDecimalPoint="."
-?>
+?>
diff --git a/includes/language.php b/includes/language.php
index 5158a55..0f3d08e 100755
--- a/includes/language.php
+++ b/includes/language.php
@@ -23,9 +23,9 @@ function LangSpellHtml ( $Sentence )
function LangSpell ( $Sentence )
{
global $GlobalLanguage;
-
+
$ReturnValue="";
-
+
if (file_exists("./languages/$GlobalLanguage.lng"))
$Language = file ("./languages/$GlobalLanguage.lng");
else
@@ -38,17 +38,17 @@ function LangSpell ( $Sentence )
$FileSentence=explode("=",$i,2);
if ( trim( $FileSentence[0] ) == $Sentence )
{
- $ReturnValue=trim($FileSentence[1]);
+ $ReturnValue=trim($FileSentence[1]);
break;
}
}
-
+
if (!$ReturnValue)
{
ErrorLog("[$GlobalLanguage.lng] Sentence \"$Sentence\" not found!");
$ReturnValue=$Sentence;
}
-
+
return $ReturnValue;
}
@@ -65,4 +65,4 @@ function LangGetAvailableLanguages ()
}
return $ReturnValue;
}
-?>
+?>
diff --git a/includes/other_functions.php b/includes/other_functions.php
index 94b4280..8f9093e 100755
--- a/includes/other_functions.php
+++ b/includes/other_functions.php
@@ -110,7 +110,7 @@ function OtherGetIcon ($IconName,$CssClass)
$IconDirectory='./templates/'.$GlobalTemplate.'/icons/';
$Error = 0;
$RetVal = "";
-
+
if (file_exists($IconDirectory.$IconName.".png")) $IconFile=$IconName.".png";
elseif (file_exists($IconDirectory.$IconName.".jpg")) $IconFile=$IconName.".jpg";
elseif (file_exists($IconDirectory.$IconName.".gif")) $IconFile=$IconName.".gif";
@@ -120,13 +120,35 @@ function OtherGetIcon ($IconName,$CssClass)
//log if template directory is existing - if not, anyone else will report this
if (file_exists("./templates/".$GlobalTemplate)) ErrorLog("Icon '$IconName' +[.png|.jpg|.gif] not found!");
}
-
+
if (!$Error)
{
$RetVal = "
";
}
-
+
return $RetVal;
}
-?>
+
+// Returns a html
tag
+function OtherGetPictureImg($part_id, $max_width=0, $max_height=0) {
+
+ // create anchor tag
+ $tag = "";
+
+ // create img tag
+ $tag .= "
0) $tag .= "&MaxWidth=$max_width";
+ if ($max_height > 0) $tag .= "&MaxHeight=$max_height";
+ $tag .= "\""; // finish src attribute
+ $tag .= " alt=\"picture of part $part_id\"";
+ $tag .= ">"; // finish img tag
+
+
+ // close link
+ $tag .= '';
+
+ return $tag;
+}
+
+?>
diff --git a/languages/English.lng b/languages/English.lng
index e2bb76c..05a2ef3 100755
--- a/languages/English.lng
+++ b/languages/English.lng
@@ -139,6 +139,8 @@ PartsObsolete = Obsolete
PartsObsoleteOnly = Only Obsolete
PartsObsoleteNon = Non Obsolete
PartsObsoleteAll = All Parts
+PartsPreviewImageYes = Show Preview Images
+PartsPreviewImageNo = Hide Preview Images
PartsType = Type
PartsStorage = Store
PartsValues = Values
diff --git a/languages/German.lng b/languages/German.lng
index 7682433..35e3968 100755
--- a/languages/German.lng
+++ b/languages/German.lng
@@ -139,6 +139,8 @@ PartsObsolete = Obsolet
PartsObsoleteOnly = nur Obsolet
PartsObsoleteNon = keine Obsolete
PartsObsoleteAll = alle Bauteile
+PartsPreviewImageYes = Vorschaubilder anzeigen
+PartsPreviewImageNo = keine Vorschaubilder
PartsType = Typ
PartsStorage = Lager
PartsValues = Werte
diff --git a/pages/parts_by_type.php b/pages/parts_by_type.php
index 4be3350..14f896a 100755
--- a/pages/parts_by_type.php
+++ b/pages/parts_by_type.php
@@ -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 .= "
\n";
+ $GlobalContent .= "\n";
else
- $GlobalContent .= "\n";
+ $GlobalContent .= "\n";
if (mysqli_num_rows($ListQuery))
{
@@ -106,6 +106,13 @@ $GlobalContent .= ''."\n";
/////////
// Filter
$GlobalContent .= ''."\n";
+//ShowImage
+if (!isset($_SESSION['FilterShowPreviewImage'])) $_SESSION['FilterShowPreviewImage'] = "TRUE";
+if (isset($_POST['FilterShowPreviewImage'])) $_SESSION['FilterShowPreviewImage']=$_POST['FilterShowPreviewImage'];
+$GlobalContent .= '
'."
\n";
//Obsolete Filter
if (!isset($_SESSION['FilterObsolete'])) $_SESSION['FilterObsolete']="NonObsolete";
if (isset($_POST['FilterObsolete'])) $_SESSION['FilterObsolete']=$_POST['FilterObsolete'];
@@ -143,19 +150,23 @@ $GlobalContent .= '
'."\n";
// PartList Table Head
$GlobalContent .= '';
+// PreviewImage
+if ($_SESSION['FilterShowPreviewImage'] == "TRUE") {
+ $GlobalContent .= '| Image | ';
+}
//Name
$GlobalContent .= '';
$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 .= ' | ';
//Value 1
if (isset($TypeValues[0][0]) && $TypeValues[0][0])
{
$GlobalContent .= '';
$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 .= ' | ';
}
//Value2
@@ -163,8 +174,8 @@ if (isset($TypeValues[1][0]) && $TypeValues[1][0])
{
$GlobalContent .= '';
$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 .= ' | ';
}
//Value3
@@ -172,27 +183,27 @@ if (isset($TypeValues[2][0]) && $TypeValues[2][0])
{
$GlobalContent .= '';
$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 .= ' | ';
}
//Package
$GlobalContent .= '';
$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 .= ' | ';
//Quantity
$GlobalContent .= '';
$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 .= ' | ';
//Price
$GlobalContent .= '';
$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 .= ' | ';
//Obsolete
$GlobalContent .= ''.LangSpellHtml('PartsObsolete').' | ';
@@ -211,28 +222,37 @@ $PartListQuery .= " ORDER BY `".$_SESSION['SortPartListBy']."` ".$_SESSION['Sort
$PartListQuery = mysqli_query($GlobalMysqlHandler, $PartListQuery);
while ($Parts = mysqli_fetch_array($PartListQuery))
{
-$GlobalContent .= '
';
-$GlobalContent .= ' | '.$Parts['Name'].' '.$Parts['ShortDesc'].' | ';
-if (isset($TypeValues[0][0]) && $TypeValues[0][0]) $GlobalContent .= ' '.OtherFloatToSiPrefix ($Parts['Value1']).$TypeValues[0][1].' | ';
-if (isset($TypeValues[1][0]) && $TypeValues[1][0]) $GlobalContent .= ' '.OtherFloatToSiPrefix ($Parts['Value2']).$TypeValues[1][1].' | ';
-if (isset($TypeValues[2][0]) && $TypeValues[2][0]) $GlobalContent .= ' '.OtherFloatToSiPrefix ($Parts['Value3']).$TypeValues[2][1].' | ';
- //////////
- // 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 .= ''.$Package['Name'].' | ';
- }
- else
- {
- $GlobalContent .= '- | ';
- }
-$GlobalContent .= ''.$Parts['Qty'].(($Parts['MinQty'])? "/".$Parts['MinQty']:"").' | ';
-$GlobalContent .= ''.OtherFormatPrice($Parts['Price']).' | ';
-$GlobalContent .= ''.((strtolower($Parts['Obsolete'])=="true")? LangSpellHtml('PartsObsolete'):"").' | ';
-$GlobalContent .= '
';
+ $GlobalContent .= ' ';
+
+ // PreviewImage
+ if ($_SESSION['FilterShowPreviewImage'] == "TRUE") {
+ $GlobalContent .= '| ';
+ if ($Parts['PicturePath'] != "") {
+ $GlobalContent .= OtherGetPictureImg($Parts['Id'], 100, 50);
+ }
+ $GlobalContent .= ' | ';
+ }
+
+ // Name, Value1, Value2, Value3
+ $GlobalContent .= ' '.$Parts['Name'].' '.$Parts['ShortDesc'].' | ';
+ if (isset($TypeValues[0][0]) && $TypeValues[0][0]) $GlobalContent .= ' '.OtherFloatToSiPrefix ($Parts['Value1']).$TypeValues[0][1].' | ';
+ if (isset($TypeValues[1][0]) && $TypeValues[1][0]) $GlobalContent .= ' '.OtherFloatToSiPrefix ($Parts['Value2']).$TypeValues[1][1].' | ';
+ if (isset($TypeValues[2][0]) && $TypeValues[2][0]) $GlobalContent .= ' '.OtherFloatToSiPrefix ($Parts['Value3']).$TypeValues[2][1].' | ';
+
+ //////////
+ // 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 .= ''.$Package['Name'].' | ';
+ } else {
+ $GlobalContent .= '- | ';
+ }
+ $GlobalContent .= ''.$Parts['Qty'].(($Parts['MinQty'])? "/".$Parts['MinQty']:"").' | ';
+ $GlobalContent .= ''.OtherFormatPrice($Parts['Price']).' | ';
+ $GlobalContent .= ''.((strtolower($Parts['Obsolete'])=="true")? LangSpellHtml('PartsObsolete'):"").' | ';
+ $GlobalContent .= '
';
}
$GlobalContent .= '
'."\n";
diff --git a/pages/show_part_show.php b/pages/show_part_show.php
index f6ce0e0..b530282 100755
--- a/pages/show_part_show.php
+++ b/pages/show_part_show.php
@@ -79,10 +79,9 @@ global $GlobalMysqlHandler;
$GlobalContent .= '
';
$GlobalContent .= '
';
}
- $GlobalContent .= '

';
- echo "IMAGE: " . $Part['PicturePath'] . "
\n";
+ $GlobalContent .= OtherGetPictureImg($PartId, 300, 600);
$GlobalContent .= '
'."\n";
-
+
////////////////
// Detail Values
$GlobalContent .= ''."\n";
diff --git a/part_picture.php b/part_picture.php
new file mode 100644
index 0000000..6e8aeb7
--- /dev/null
+++ b/part_picture.php
@@ -0,0 +1,95 @@
+num_rows == 0) {
+ exit("ERROR: PartId not found!");
+}
+$source_path = $GlobalPictureDir . "/" . $db_result->fetch_array()['PicturePath'];
+
+
+// get image info
+list($source_width, $source_height) = getimagesize($source_path);
+$mime_type = mime_content_type($source_path);
+
+
+// calculate new With and Height
+$output_width = $source_width;
+$output_height = $source_height;
+$max_width = 0;
+if (isset($_GET['MaxWidth'])) {
+ $max_width = intval($_GET['MaxWidth']);
+ if ($output_width > $max_width) {
+ $scale_factor = $max_width / $output_width;
+ $output_width *= $scale_factor;
+ $output_height *= $scale_factor;
+ }
+}
+$max_height = 0;
+if (isset($_GET['MaxHeight'])) {
+ $max_height = intval($_GET['MaxHeight']);
+ if ($output_height > $max_height) {
+ $scale_factor = $max_height / $output_height;
+ $output_width *= $scale_factor;
+ $output_height *= $scale_factor;
+ }
+}
+
+
+// load image
+if ($mime_type == 'image/jpeg') {
+ $source_image = imagecreatefromjpeg($source_path);
+ $output_image = imagecreatetruecolor($output_width, $output_height);
+} else if ($mime_type == 'image/png') {
+ $source_image = imagecreatefrompng($source_path);
+ imagealphablending($source_image, true);
+ imagesavealpha($source_image, true);
+ $output_image = imagecreate($output_width, $output_height);
+} else {
+ ErrorLog("Unkown mime type: " . $mime_type . "!");
+ exit("Can't handle requested mime-type.");
+}
+
+
+// resize
+$res = imagecopyresized($output_image, $source_image, 0, 0, 0, 0, $output_width, $output_height, $source_width, $source_height);
+if ($res !== True) {
+ $msg = "Cannot resize image: " . $source_path . "\n";
+ $msg .= "source: " . $source_width . "x" . $source_height;
+ $msg .= ", max: " . $max_width . "x" . $max_height;
+ $msg .= ", output: " . $output_width . "x" . $output_height;
+ ErrorLog($msg);
+ exit("Cannot resize image!");
+}
+
+
+// output as png
+header('Content-Type: image/png');
+imagepng($output_image);
+imagedestroy($output_image);
+imagedestroy($source_width);
+?>