zitu4life Posted December 28, 2022 Share Posted December 28, 2022 (edited) Hello there I would like to add some pictures on each customer Summary page on add File native whmcs inbuilt option. No problem with it, but the issue is...after upload picture, if I need to watch it,but the way WHMCS process it now, it will request me to download that attached picture, but i just need to see it online and not download it. After add a picture, it only allow me to download it, and not see it online. I understand it where design to be like this, but as clientsummary.tpl is not encrypted I was wondering if this can be changed or add an option to see it online or choose to download it. WHMCS support my requests because on project management add on I can do that (see picture online), please see picture for project management. Thank you!!! PS: How this can help me. Not all countries has a reliable GPS address where you can just add address and google maps shows you exactly location even some cases on 3D with pictures of front house. My company provides support to hundred of customers and having accurate address will less stress information to be passed inter-staff...WHMCS is nice because it centralize information for all. So, for country on 3rd world GPS will takes years to be like Europe or USA...So we have update our terms and service that allows consent for customers to treat these information for better customers support and time saver. So with address together with picture, a staff will know exactly customers building. Edited December 28, 2022 by zitu4life 0 Quote Link to comment Share on other sites More sharing options...
ShahidMalla Posted December 31, 2022 Share Posted December 31, 2022 <img src="{$filename}" alt="Attached Picture"> 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted January 1, 2023 Share Posted January 1, 2023 (edited) You could preview images in a modal with jQuery in AdminAreaHeadOutput action hook but first you need to retrieve the full URL to the image. All files in Client Summary in fact are accessible only via GET request to dl.php that forces download. You can't do much with it. This is what you should do. First use AdminAreaPage hook point to loop through $files array on clientssummary.php page. Check every $files.title element to locate images by file extension with something like follows: <?php foreach ($vars['files'] as $file) { if (in_array(pathinfo($file['title'])['extension'], [ 'png', 'jpg', 'jpeg', 'gif' ])) { // Gotcha! You are an image file } } Now that we know that asdsa.png is an image, we need to retreive the full path to the image with $file.id so that jQuery can preview it. You need to perform a query to tblclientsfiles like follows: SELECT filename FROM tblclientsfiles WHERE id = $file.id LIMIT 1 /* Note: in case you're using custom paths instead of /attachments you should join this query with tblstorageconfigurations */ Return the full path to the image you just found. Basically you need to add a new element - let's call it path_to_image - to the previously posted array right next to id, title, adminonly and date then edit clientssummary.tpl to add an icon or a class to this specific attachment so that you can preview it with jQuery. Personally I don't like this approach since it requires you to edit this tpl file every time you update WHMCS. I would do this instead. With PHP replace the existing {$file.title} variable in clientsummary.tpl so that it changes from: asdsa.png to: asdsa.png <span class="preview_on_click" data-path-to-image="{$file.path_to_image}">[Preview]</span> In essence I'm simply adding a span at the end of the existing string. Here I add everything needed to run jQuery namely the trigger (preview_on_click class) and the path (data-path-to-image). Move to AdminAreaHeadOutput hook point and do something like this. <?php add_hook('AdminAreaHeadOutput', 1, function($vars) { return <<<HTML <script type="text/javascript"> $(document).ready(function() { $('span["preview_on_click"]').on('click', function(e) { e.preventDefault(); // Open a modal, access data-path-to-image and display it inside modal-body }); }); </script> HTML; }); On 12/28/2022 at 6:27 PM, zitu4life said: Not all countries has a reliable GPS address where you can just add address and google maps shows you exactly location even some cases on 3D with pictures of front house. My company provides support to hundred of customers and having accurate address will less stress information to be passed inter-staff...WHMCS is nice because it centralize information for all. So, for country on 3rd world GPS will takes years to be like Europe or USA...So we have update our terms and service that allows consent for customers to treat these information for better customers support and time saver. So with address together with picture, a staff will know exactly customers building. I would add a dedicated page from which customers upload pictures. It would be more flexible than the mess I just described. Edited January 1, 2023 by Kian 0 Quote Link to comment Share on other sites More sharing options...
zitu4life Posted January 3, 2023 Author Share Posted January 3, 2023 Many thanks @Kian for taking your time to point me the diretion how can I achieve my needs, I will try on the next 2 3 days, as my coding skills are limited, but as the code gets job done, I am happy with it. Thank you! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.