+function del_image($stock_id)
+{
+ foreach (array('jpg', 'png', 'gif') as $ext) {
+ $filename = company_path().'/images/'.item_img_name($stock_id).".".$ext;
+ if (file_exists($filename) && !unlink($filename))
+ return false;
+ }
+ return true;
+}
+
+function show_image($stock_id)
+{
+ global $SysPrefs;
+
+ $check_remove_image = false;
+ $stock_img_link = _("No image");
+
+ if (@$stock_id)
+ foreach (array('jpg', 'png', 'gif') as $ext)
+ {
+ $file = company_path().'/images/'.item_img_name($stock_id). ".$ext";
+ if (file_exists($file)) {
+ // rand() call is necessary here to avoid caching problems.
+ $check_remove_image = true; // fixme
+ $stock_img_link = "<img id='item_img' alt = '[".$stock_id.".$ext"."]' src='".$file."?nocache=".rand()."'"
+ ." height='".$SysPrefs->pic_height."' border='0'>";
+ break;
+ }
+ }
+
+ label_row(" ", $stock_img_link);
+ if ($check_remove_image)
+ check_row(_("Delete Image:"), 'del_image');
+}
+