lgilliver
lgilliver
Offline
0
I noticed a lack of a Download/Email button from within the Invoice Details pages, it would be great to generate either of these things from the details page instead of having to go back to the Invoices list and finding the invoice in the list, then hitting the send etc, so I've implemented the following in my install which may want to be included in the next release?

site/components/com_invoices/helpers/helpers.php
Added the following two functions (based on the original two found in there at lines 115 onwards.
The only variation is the printed output, this gives a bootstrap formatted button with text and icon, instead of the basic image, but isn't strictly necessary.

static function download_pdf_button_backend($id){
$version = PHP_VERSION >= 5.0 ? true : false ;
$quotes = get_magic_quotes_gpc();
//echo $quotes;die;
if(file_exists(JPATH_SITE.DS.'components'.DS.'com_invoices'.DS.'helpers'.DS.'dompdf'.DS.'dompdf_config.inc.php') && $version && !$quotes){
$mainframe = JFactory::getApplication();
$uri = JFactory::getURI();
if(!$mainframe->isSite()){
//$url = $uri->root().'index.php?option=com_invoices&view=invoice&format=dompdf&id='.$id;
$url = JRoute::_('index.php?option=com_invoices&view=invoice&format=dompdf&cid[]='.$id);
}
else $url = JRoute::_('index.php?option=com_invoices&view=invoice&format=dompdf&id='.$id);
$return = '<i class="icon-download icon-white"></i>'.JText::_('DOWNLOAD_INVOICE_PDF').'' ;
}
else $return = "";
return $return ;
}

static function send_email_button_backend($id, $type = "invoice"){
$mainframe = JFactory::getApplication();
if(!$mainframe->isSite()){
$url = JRoute::_('index.php?option=com_invoices&controller='.$type.'&task=send_email&cid[]='.$id);
}
else{
$url = JRoute::_('index.php?option=com_invoices&task=send&id='.$id);
}
$return = '<a href="'.$url.'" title="'.JText::_('SEND_INVOICE').'" class="btn btn-info\"><i class="icon-envelope icon-white"></i>'.JText::_('SEND_INVOICE').'</a>' ;
return $return ;
}
Responses (2)
  • Accepted Answer

    lgilliver
    lgilliver
    Offline
    Sunday, April 26 2015, 08:46 AM - #Permalink
    0
    (sorry for multi reply, there seems to be a submission limit)

    Then to add the buttons to the views, I used template overrides for the following two files:

    All the views do is add the two boostrapped buttons defined in the Helper above, it perhaps would be better to have them on the Joomla toolbar along with the save button etc, but I jus threw them here at the top.

    site/administrator/components/com_invoices/views/invoice/tmpl/form.php around line 24

    <div class="row-fluid">
    <div class="span12">
    <?php echo InvoicesHelper::send_email_button_backend($this->invoice->id); ?>
    <?php echo InvoicesHelper::download_pdf_button_backend($this->invoice->id); ?>
    <p></p>
    </div>
    </div>
    The reply is currently minimized Show
  • Accepted Answer

    lgilliver
    lgilliver
    Offline
    Sunday, April 26 2015, 08:47 AM - #Permalink
    0
    (sorry for multi reply, there seems to be a submission limit)

    site/administrator/components/com_invoices/views/quote/tmpl/form.php around line 24

    <div class="row-fluid">
    <div class="span12">
    <?php echo InvoicesHelper::send_email_button_backend($this->invoice->id,'quote'); ?>
    <?php echo InvoicesHelper::download_pdf_button_backend($this->invoice->id); ?>
    <p></p>
    </div>
    </div>


    Hope this helps someone else.
    The reply is currently minimized Show
Your Reply