Blesta Addons Posted September 27, 2016 Report Share Posted September 27, 2016 Hello All . @Licensecart has request me to do a simple plugin to fetch client data and include it in your Html Template. The Plugin Is Available in Github https://github.com/Blesta-Addons/Client_Data Blesta Plugin That Allow Dev/Themers Get Client Data Info As Json Response , then they can use it in their Template or Plugin . This Plugin didn't need install, just upload the folder client_data to plugins and you are ready to go . Not all request should be Done Via Ajax , a direct call will return a blank page . Example of Requests : 1 - For Tickets, the last element is the Tickets status Get CLient's Open Tickets http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_tickets/open Get CLient's Closed Tickets http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_tickets/closed 2 - For Services, the last element is the Service status Get CLient's Active Services http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_services/active Get CLient's Suspended Services http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_services/suspended 3 - For Invoices, the last element is the Invoices status Get CLient's Open Invoices http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_invoices/open Get CLient's Vioded Invoices http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_invoices/vioded To get the info by Ajax request in template us this code <?php $this->Javascript->setInline(' $(document).ready(function() { fetchInvoices("open"); }); function fetchInvoices(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_invoices/") . '" + status, null, function(data) { if (data) $("#my_div_id_to_replace").html(data); }, null, {dataType:"json"}); } '); ?> To explain the code , you need to change the url and the div to put the requested data . ariq01 and a.daniello 2 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Report Share Posted September 27, 2016 Thank you mate you are a legend Sugar mate, I can't get a value and visiting the pages => 404. Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 28, 2016 Author Report Share Posted September 28, 2016 14 hours ago, Licensecart said: I can't get a value and visiting the pages => 404. ahhh, errors in link, client_main instead main . Michael 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 28, 2016 Report Share Posted September 28, 2016 23 minutes ago, naja7host said: ahhh, errors in link, client_main instead main . Tried both mate: Code: <?php $this->Javascript->setInline(' $(document).ready(function() { fetchTicketsOpen("open"); }); function fetchTicketsOpen(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_tickets/") . '" + status, null, function(data) { if (data) $(".count_ticket_open").html(data); }, null, {dataType:"json"}); } '); $this->Javascript->setInline(' $(document).ready(function() { fetchTicketsClosed("closed"); }); function fetchTicketsClosed(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_tickets/") . '" + status, null, function(data) { if (data) $(".count_ticket_closed").html(data); }, null, {dataType:"json"}); } '); ?> Html: <span class="count_ticket_open">0</span>/<span class="count_ticket_closed">0</span> Both show 0/0 should be 0/11 Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 28, 2016 Author Report Share Posted September 28, 2016 I have fixed the Ajax request, re-download the plugin now . Michael 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 28, 2016 Report Share Posted September 28, 2016 perfect thanks mate Quote Link to comment Share on other sites More sharing options...
Michael Posted October 1, 2016 Report Share Posted October 1, 2016 Since the base_uri only works on the portal pages (until 4.0 I believe) you can use this fix: Replace: $this->base_uri With: $site_url And Above this: $this->Javascript->setInline(' Put: $site_url = "https://yourdomain.com/blesta_folder/"; Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted October 1, 2016 Author Report Share Posted October 1, 2016 @Licensecart what is the exact link that is not working with $this->base_uri Quote Link to comment Share on other sites More sharing options...
Michael Posted October 1, 2016 Report Share Posted October 1, 2016 19 minutes ago, naja7host said: @Licensecart what is the exact link that is not working with $this->base_uri I got 0 for them until I changed it, I think it's related to: https://dev.blesta.com/browse/CORE-2168 Blesta Addons 1 Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted October 1, 2016 Author Report Share Posted October 1, 2016 1 hour ago, Licensecart said: I got 0 for them until I changed it, I think it's related to: https://dev.blesta.com/browse/CORE-2168 You call it from the structure.pdt ? Or from other template file ? Quote Link to comment Share on other sites More sharing options...
Michael Posted October 1, 2016 Report Share Posted October 1, 2016 13 minutes ago, naja7host said: You call it from the structure.pdt ? Or from other template file ? I use the blestacms so that's not the portal well (cms) so that might be why but oh well LOL. Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted October 2, 2016 Author Report Share Posted October 2, 2016 i have tested the plugin in v4, is working, this related only to v3 . Michael 1 Quote Link to comment Share on other sites More sharing options...
ZweiTiger Posted October 10, 2016 Report Share Posted October 10, 2016 On 2016. 10. 02. at 2:46 PM, naja7host said: i have tested the plugin in v4, is working, this related only to v3 . Hello The invoices are working but how to shoe the active services? I tried to figure out but none of them worked for me. Here is the code: Quote <?php $this->Javascript->setInline(' $(document).ready(function() { fetchInvoices("open"); }); function fetchInvoices(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_invoices/") . '" + status, null, function(data) { if (data) $(".count_invoices").html(data); }, null, {dataType:"json"}); } '); $this->Javascript->setInline(' $(document).ready(function() { fetchServices("active"); }); function fetchServices(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_services/active") . '" + status, null, function(data) { if (data) $(".count_active_services").html(data); }, null, {dataType:"json"}); } '); ?> Whats wrong with the services:)? Inovices: <span class="count_invoices">0</span> Services: <span class="count_active_services">0</span> Quote Link to comment Share on other sites More sharing options...
Michael Posted October 10, 2016 Report Share Posted October 10, 2016 Ah sorry Istok, just spotted it remove the active from the url so it's "plugin/client_data/client_main/count_services/" Blesta Addons 1 Quote Link to comment Share on other sites More sharing options...
ZweiTiger Posted October 10, 2016 Report Share Posted October 10, 2016 52 minutes ago, Licensecart said: Ah sorry Istok, just spotted it remove the active from the url so it's "plugin/client_data/client_main/count_services/" Thanks ,worked Michael 1 Quote Link to comment Share on other sites More sharing options...
Laflecha Posted October 18, 2016 Report Share Posted October 18, 2016 @naja7host You should create a video on youtube for us newbies ariq01 1 Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted October 18, 2016 Author Report Share Posted October 18, 2016 6 hours ago, Laflecha said: @naja7host You should create a video on youtube for us newbies Sorry . No time to make it now . But maybe mike can do it if he has free time . Quote Link to comment Share on other sites More sharing options...
JNdev Posted October 25, 2016 Report Share Posted October 25, 2016 Is there something wrong with my code? Did not show any value. But invoices and other works smoothly Div call <div class="count-active-service"></div> $this->Javascript->setInline(' $(document).ready(function() { fetchServices("active"); }); function fetchServices(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_services") . '" + status, null, function(data) { if (data) $(".count-active-service").html(data); }, null, {dataType:"json"}); } '); Quote Link to comment Share on other sites More sharing options...
Michael Posted October 25, 2016 Report Share Posted October 25, 2016 Think your missing the / on the end of the url mate. Blesta Addons 1 Quote Link to comment Share on other sites More sharing options...
JNdev Posted October 26, 2016 Report Share Posted October 26, 2016 Tanks mate, work with / Michael 1 Quote Link to comment Share on other sites More sharing options...
Laflecha Posted August 2, 2017 Report Share Posted August 2, 2017 <li class="dropdown messages-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-envelope"></i> <span class="label label-success">0</span> </a> </li> <!-- Notifications: style can be found in dropdown.less --> <li class="dropdown notifications-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-warning"></i> <span class="label label-warning">0</span> </a> </li> <!-- Tasks: style can be found in dropdown.less --> <li class="dropdown tasks-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-tasks"></i> <span class="label label-danger">0</span> </a> </li> I want to put the code to count the services, ticket, domain etc. how can I do this??? this is your adminLTE template @Blesta Addons Quote Link to comment Share on other sites More sharing options...
qatifserv Posted September 17, 2018 Report Share Posted September 17, 2018 any way to apply this to the quotes ? I tried to write this to the controller but still doesn't work /** * Get Quotes count */ public function count_quotes() { // Ensure a valid Status if (isset($this->get[0])) { $status = $this->get[0]; } else { $status = "open"; } if ($this->isAjax()) { // Load Model Only When we Need it !!! $this->uses(["QuotesSystem"]); $response = $this->QuotesSystem->getStatusCount($this->client_id, $status); // JSON encode the AJAX response $this->outputAsJson($response); return false; } return false; } everything else works Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 17, 2018 Author Report Share Posted September 17, 2018 Hello Sir change $this->uses(["QuotesSystem"]); by $this->uses(['Quotes.QuotesSystem']); try now. 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.