webERP Forum
Show Part Picture (if available) Issue - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (/forumdisplay.php?fid=1)
+--- Forum: Problems / Bugs? (/forumdisplay.php?fid=8)
+--- Thread: Show Part Picture (if available) Issue (/showthread.php?tid=7873)



Show Part Picture (if available) Issue - VortecCPI - 09-09-2017 07:22 AM

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?


RE: Show Part Picture (if available) Issue - falkoner - 09-09-2017 04:07 PM

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


RE: Show Part Picture (if available) Issue - VortecCPI - 09-09-2017 09:25 PM

(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.


RE: Show Part Picture (if available) Issue - VortecCPI - 09-15-2017 10:25 PM

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>';
}


RE: Show Part Picture (if available) Issue - phil - 09-17-2017 11:39 AM

Thanks - I've committed to SVN.


RE: Show Part Picture (if available) Issue - VortecCPI - 09-18-2017 06:25 AM

(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.