From 57ee8b7991be9fec477cf497ec9d8b5ccfceecd7 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 24 Feb 2019 21:15:11 +0100 Subject: [PATCH] Fix no JPG images in TakePOS and other image improvements. --- htdocs/takepos/css/pos.css | 12 +++++ htdocs/takepos/genimg/add.jpg | Bin 5419 -> 0 bytes htdocs/takepos/genimg/empty.jpg | Bin 2239 -> 0 bytes htdocs/takepos/genimg/empty.png | Bin 0 -> 156 bytes htdocs/takepos/genimg/index.php | 87 +++++++++----------------------- htdocs/takepos/takepos.php | 34 ++++++++----- 6 files changed, 57 insertions(+), 76 deletions(-) delete mode 100644 htdocs/takepos/genimg/add.jpg delete mode 100644 htdocs/takepos/genimg/empty.jpg create mode 100644 htdocs/takepos/genimg/empty.png diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index 87c74c8952d..cac9a23a8d9 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -110,6 +110,18 @@ div.description{ text-align:center; } +div.catwatermark{ + position:absolute; + top:3%; + left:3%; + width:20%; + background-color:black; + color:white; + text-align:center; + font-size: 20px; + display: none; +} + @media only screen and (max-aspect-ratio: 6/4) { div.description{ min-height:20%; diff --git a/htdocs/takepos/genimg/add.jpg b/htdocs/takepos/genimg/add.jpg deleted file mode 100644 index 976fd10697d47e06cc9d74f7efed36ab17d95ed7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5419 zcmeHL4OA0X7QRCW2>}g3z`xd@Kt-T>s!)GR01XNrgn$bE)KnDtJ1(^qLB$N>A7U*< zMYri9KPrf#DL*bA*117Cuv;;C3&)y~- zL^jWL(}#!$=JbnJ2Udw}f7VU?0Na`eP@0MEz;rOfFw^~GV=x(}W?^p5V6rS&ER(P; ztt{DW4x7c|4B&9Atm($G9LODDJ_g=$=LwOYrCD+u1`ioJ%;mk&u4CLhy*`{cY4VimGlc## zX9Wa?&7C(tJYvDZWy_;hM90L&eZD$z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F{fNpu5|HS1I;UcddRmDz!)aEim&ZIi+c|avS?xRRus*UsR+-rk zSxJ24K75&?KgwGDDp@t$AMghmPt-3n_!*y(N9LJHx}C@GJk-)Bl2gwMV0QD=h`)>* ZyZpQCQQ^@qmB0JF|GfWsej+2(_-~uMLm2=7 diff --git a/htdocs/takepos/genimg/empty.jpg b/htdocs/takepos/genimg/empty.jpg deleted file mode 100644 index 8883f7c9957bf151875278b6ded394d9594c8b25..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2239 zcmex=}T+5Ri6|E+FFJVCMj-APxLK zz#z!MsL5!;%&5e`B*@4t$oT&VgFMistiX@}1qKu_GBLBTvH_jM#SK)jRRHLGW@aX! zV_8{%-es%>$}_MCvI;30I#U-U>$dGXcJ4ZK_{h;?$4{I*b?NeztJkjIxOwa0 zqsLF4K70P+<*SdMK7aZ8?fZ|Pzd-(CWMGDP3+^*Ce+dHp#RQB47Iu)o7@5j}m|2j8 zRnd@5$T5&Tu~1masF6d&Y2w0-2RW6EgFc8R6KQ!#m{`Vr(cu+NC|SQA-3gL@3& ruUiZ}z=X*p$SlZU&+zxpqAm@FQ9K$3qiJ9?4UDFNVV?$=|K9`vEy2T8 diff --git a/htdocs/takepos/genimg/empty.png b/htdocs/takepos/genimg/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..63163e9f86953a5a1b1ef0a16f5e8189e63b8f1e GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-D$|!aQ9ZLn>~) qJ!r@Xfetch($id); + $upload_dir = $conf->categorie->multidir_output[$object->entity]; $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/"; $dir = $upload_dir.'/'.$pdir; + foreach ($object->liste_photos($dir) as $key => $obj) - { - $filename=$obj['photo']; - } - - // The file - $filename = $dir.$filename; - if (!file_exists($filename)) $filename="empty.jpg"; - - // Dimensions - list($width, $height) = getimagesize($filename); - $new_width = $w; - $new_height = $h; - - // Resample - $image_p = imagecreatetruecolor($new_width, $new_height); - $image = imagecreatefromjpeg($filename); - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - - // Add icon - $icon = imagecreatefromjpeg('add.jpg'); - list($width, $height) = getimagesize('add.jpg'); - $new_width = $w*0.3; - $new_height = $h*0.3; - $icon_p = imagecreatetruecolor($new_width, $new_height); - imagecopyresampled($icon_p, $icon, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - imagecopymerge($image_p, $icon_p, 0, 0, 0, 0, $new_width, $new_height, 100); - - // Output - imagejpeg($image_p, null, 100); + { + if ($obj['photo_vignette']) + { + $filename=$obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + $viewfilename=$obj['photo']; + $file=DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename); + header('Location: '.$file); + exit; + } + header('Location: ../../public/theme/common/nophoto.png'); } elseif ($query=="pro") { @@ -89,39 +76,13 @@ elseif ($query=="pro") $objProd = new Product($db); $objProd->fetch($id); - - $dir .= get_exdir(0, 0, 0, 0, $objProd, 'product').$objProd->ref.'/'; - $pdir .= get_exdir(0, 0, 0, 0, $objProd, 'product').$objProd->ref.'/'; - - foreach ($objProd->liste_photos($dir) as $key => $obj) - { - $filename=$obj['photo']; - } - $filename = $dir.$filename; - - if (!file_exists($filename)){ - $dir = $conf->product->multidir_output[$objProd->entity].'/'.$pdir; - foreach ($objProd->liste_photos($dir) as $key => $obj) - { - $filename=$obj['photo']; - } - $filename = $dir.$filename; - } - - if (!file_exists($filename)) $filename="empty.jpg"; - - // Dimensions - list($width, $height) = getimagesize($filename); - $new_width = $w; - $new_height = $h; - - // Resample - $image_p = imagecreatetruecolor($new_width, $new_height); - $image = imagecreatefromjpeg($filename); - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); - - // Output - imagejpeg($image_p, null, 100); + $image=$objProd->show_photos('product', $conf->product->multidir_output[$entity], 'small', 1); + + preg_match( '@src="([^"]+)"@' , $image, $match ); + $file = array_pop($match); + if ($file=="") header('Location: ../../public/theme/common/nophoto.png'); + else header('Location: '.$file); + } else { diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 4edab6c9bee..4b36bbbdd81 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -93,8 +93,9 @@ function PrintCategories(first){ for (i = 0; i < 14; i++) { if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") break; $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); - $("#catimg"+i).attr("src","genimg/?query=cat&w=55&h=50&id="+categories[parseInt(i)+parseInt(first)]['rowid']); + $("#catimg"+i).attr("src","genimg/?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); + $("#catwatermark"+i).show(); } } @@ -117,12 +118,14 @@ function MoreCategories(moreorless){ for (i = 0; i < 14; i++) { if (typeof (categories[i+(14*pagecategories)]) == "undefined"){ $("#catdesc"+i).text(""); - $("#catimg"+i).attr("src",""); + $("#catimg"+i).attr("src","genimg/empty.png"); + $("#catwatermark"+i).hide(); continue; } $("#catdesc"+i).text(categories[i+(14*pagecategories)]['label']); - $("#catimg"+i).attr("src","genimg/?query=cat&w=55&h=50&id="+categories[i+(14*pagecategories)]['rowid']); + $("#catimg"+i).attr("src","genimg/?query=cat&id="+categories[i+(14*pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+(14*pagecategories)]['rowid']); + $("#catwatermark"+i).show(); } } @@ -131,16 +134,17 @@ function LoadProducts(position, issubcat=false){ $('#catimg'+position).animate({opacity: '1'}, 100); if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); else currentcat=$('#catdiv'+position).data('rowid'); - if (currentcat=="") return; + if (currentcat==undefined) return; pageproducts=0; ishow=0; //product to show counter jQuery.each(subcategories, function(i, val) { if (currentcat==val.fk_parent){ $("#prodesc"+ishow).text(val.label); - $("#proimg"+ishow).attr("src","genimg/?query=cat&w=55&h=50&id="+val.rowid); + $("#proimg"+ishow).attr("src","genimg/?query=cat&id="+val.rowid); $("#prodiv"+ishow).data("rowid",val.rowid); $("#prodiv"+ishow).data("iscat",1); + $("#prowatermark"+ishow).show(); ishow++; } }); @@ -150,18 +154,19 @@ function LoadProducts(position, issubcat=false){ while (idata < 30 && ishow < 30) { if (typeof (data[idata]) == "undefined") { $("#prodesc"+ishow).text(""); - $("#proimg"+ishow).attr("src",""); + $("#proimg"+ishow).attr("src","genimg/empty.png"); $("#prodiv"+ishow).data("rowid",""); ishow++; //Next product to show after print data product } else if ((data[idata]['status']) == "1") { //Only show products with status=1 (for sell) $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); - $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']); + $("#proimg"+ishow).attr("src","genimg/?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); $("#prodiv"+ishow).data("iscat",0); ishow++; //Next product to show after print data product } + $("#prowatermark"+ishow).hide(); idata++; //Next data everytime } }); @@ -189,18 +194,19 @@ function MoreProducts(moreorless){ while (idata < (30*pageproducts)+30) { if (typeof (data[idata]) == "undefined") { $("#prodesc"+ishow).text(""); - $("#proimg"+ishow).attr("src",""); + $("#proimg"+ishow).attr("src","genimg/empty.png"); $("#prodiv"+ishow).data("rowid",""); ishow++; //Next product to show after print data product } else if ((data[idata]['status']) == "1") { //Only show products with status=1 (for sell) $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); - $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']); + $("#proimg"+ishow).attr("src","genimg/?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); $("#prodiv"+ishow).data("iscat",0); ishow++; //Next product to show after print data product } + $("#prowatermark"+ishow).hide(); idata++; //Next data everytime } }); @@ -261,12 +267,12 @@ function Search2(){ for (i = 0; i < 30; i++) { if (typeof (data[i]) == "undefined"){ $("#prodesc"+i).text(""); - $("#proimg"+i).attr("src",""); + $("#proimg"+i).attr("src","genimg/empty.png"); $("#prodiv"+i).data("rowid",""); continue; } $("#prodesc"+i).text(data[parseInt(i)]['label']); - $("#proimg"+i).attr("src","genimg/?query=pro&w=55&h=50&id="+data[i]['rowid']); + $("#proimg"+i).attr("src","genimg/?query=pro&id="+data[i]['rowid']); $("#prodiv"+i).data("rowid",data[i]['rowid']); $("#prodiv"+i).data("iscat",0); } @@ -491,10 +497,11 @@ foreach($menus as $menu) { { ?>
id='catdiv'> - width="98%" id='catimg'/> + width="100%" height="85%" id='catimg'/>
+
+
onclick="MoreProducts('less');" onclick="MoreProducts('more');" > - width="95%" id='proimg'/> + width="100%" height="85%" id='proimg'/>
+
+