webERP Forum

Full Version: Show Part Picture (if available) Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If using the "#" symbol in a part number the "Show Part Picture (if available)" link does not work. I changed line 406 in SelectProduct.php

From this :

echo '<a href="' . $RootPath . '/' . $imagefile . '" target="_blank">' . _('Show Part Picture (if available)') . '</a><br />';

To this:

echo '<a href="' . $RootPath . '/' . str_replace('#', '%23', $imagefile) . '" target="_blank">' . _('Show Part Picture (if available)') . '</a><br />';

Though the ToolTip at Item Code states alpha-numeric only webERP accepted use of the "#" symbol in the Item Code.

Perhaps we should add the "#" symbol to the list of prohibited characters?
I am not in a position to test it, but I think it should work by using urlencode($imagefile) instead of just $imagefile.

urlencode() should be used for all variables used in a URL.

Tim
(09-09-2017 04:07 PM)falkoner Wrote: [ -> ]I am not in a position to test it, but I think it should work by using urlencode($imagefile) instead of just $imagefile.

urlencode() should be used for all variables used in a URL.

Tim

Very interesting. I am only a novice PHP guy (at best) so I was unaware of this function. urlencode is used for $StockID elsewhere but not for the pictures in this case on lines 405 or 861.

I will leave the solution up to you as opposed to beating and hacking the code into submission.

Thank you for the insight.
I recently noticed pictures showed correctly for Work Order entry so I had a look at the code for showing pictures for each page.

Two comments:

#1: Adding "$SupportedImgExt = array('png','jpg','jpeg');" on line 861 in SelectProducts.php fixed the issue.

#2: The code to manage images here is a bit different and could likely be made more consistent if not the same.

In an effort to be more consistent I chose to change the code at line 861 to match that found elsewhere in webERP:

$SupportedImgExt = array('png','jpg','jpeg');
$imagefile = reset((glob($_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.{' . implode(",", $SupportedImgExt) . '}', GLOB_BRACE)));
if(extension_loaded('gd') && function_exists('gd_info') && file_exists ($imagefile) ) {
$StockImgLink = '<img src="GetStockImage.php?automake=1&amp;textcolor=FFFFFF&amp;bgcolor=CCCCCC'.
'&amp;StockID='.urlencode($myrow['stockid']).
'&amp;text='. //$myrow['stockid'] .
'&amp;width=100'.
'&amp;height=100'.
'" alt="" />';
} else if(file_exists ($imagefile)) {
$StockImgLink = '<img src="' . $imagefile . '" height="100" width="100" />';
} else {
$StockImgLink = '<p>'._('No Image').'</p>';
}
Thanks - I've committed to SVN.
(09-17-2017 11:39 AM)phil Wrote: [ -> ]Thanks - I've committed to SVN.

Phil,

Thank you so much for checking my work and for merging it back into the main source trunk.
Reference URL's