Galera, bom dia.
Estou desenvolvendo um pequeno componente apenas para registro de pedidos de serviço de manutenção, e necessito, que um botão na Toolbar do backend imprima, dentro da lista de itens, apenas os selecionados.
Tenho os seguintes códigos em funcionamento:
helper/html/toolbar.php
abstract class ServiceToolBarHelper extends JToolBarHelper
{
public static function printList($task = 'printList', $alt = 'COM_SERVICE_TOOLBAR_PRINT')
{
require_once (JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers/html/print.php');
$bar = JToolbar::getInstance('toolbar');
$bar->appendButton('Standard', 'print', $alt, $task);
}
}
controllers/services.php
public function printList()
{
// Check for request forgeries
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// Get items to print from the request.
$cid = JRequest::getVar('cid', array(), '', 'array');
if (empty($cid))
{
JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
}
else
{
// Make sure the item ids are integers
JArrayHelper::toInteger($cid);
$cid = implode(',', $cid);
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . '&layout=print&tmpl=component&filter_search=id:' . $cid, false));
}
}
views/services/view.html.php
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/html/toolbar.php';
ServiceToolBarHelper::printList('services.printlist');
}
Desta forma o link abre uma nova página apenas com os dados selecionados, o que eu gostaria era de imprimir diretamente os registros.
Grato.