Jump to content

Recommended Posts

Posted

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 .

Posted
  On 9/28/2016 at 12:07 PM, naja7host said:

ahhh, errors in link, client_main instead main .

Expand  

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

Posted

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/";

 

Posted
  On 10/2/2016 at 12:46 PM, naja7host said:

i have tested the plugin in v4, is working, this related only to v3 .

Expand  

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"});
            }
        ');
        ?>

Expand  

Whats wrong with the services:)?

Inovices: <span class="count_invoices">0</span>

Services: <span class="count_active_services">0</span>

  • 2 weeks later...
Posted

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

 

  • 9 months later...
Posted

 <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

  • 1 year later...
Posted

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...