Skip to content

Commit

Permalink
Fix for form print link when used on backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Jun 17, 2016
1 parent 734f3ed commit 9798810
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
17 changes: 13 additions & 4 deletions components/com_fabrik/helpers/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,19 @@ public static function printURL($formModel)
$package = $app->getUserState('com_fabrik.package', 'fabrik');
$table = $formModel->getTable();

$url = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $package . '&view=details&tmpl=component&formid=' . $form->id . '&listid=' . $table->id
. '&rowid=' . $formModel->getRowId() . '&iframe=1&print=1';
if ($app->isAdmin())
{
$url = 'index.php?option=com_' . $package . '&task=details.view&tmpl=component&formid=' . $form->id . '&listid=' . $table->id
. '&rowid=' . $formModel->getRowId(). '&iframe=1&print=1';
}
else
{
//$this->pdfURL = 'index.php?option=com_' . $this->package . '&view=details&formid=' . $model->getId() . '&rowid=' . $model->getRowId() . '&format=pdf';
$url = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $package . '&view=details&tmpl=component&formid=' . $form->id . '&listid=' . $table->id
. '&rowid=' . $formModel->getRowId() . '&iframe=1&print=1';

$url .= '&Itemid=' . FabrikWorker::itemId();
$url .= '&Itemid=' . FabrikWorker::itemId();
}

/* $$$ hugh - @TODO - FIXME - if they were using rowid=-1, we don't need this, as rowid has already been transmogrified
* to the correct (PK based) rowid. but how to tell if original rowid was -1???
Expand All @@ -434,7 +443,7 @@ public static function printURL($formModel)
$url = JRoute::_($url);

// $$$ rob for some reason JRoute wasn't doing this ???
$url = str_replace('&', '&', $url);
//$url = str_replace('&', '&', $url);
self::$printURL = $url;

return self::$printURL;
Expand Down
4 changes: 4 additions & 0 deletions components/com_fabrik/models/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,7 @@ protected function addSelectBoxAndLinks(&$data)
$displayData->rowData = $row;
$displayData->rowId = $rowId;
$displayData->isAjax = $isAjax;
$displayData->isCustom = $this->getCustomLink('url', 'edit') !== '';
$layout = $this->getLayout('listactions.fabrik-edit-button');
$editLink = $layout->render($displayData);
}
Expand Down Expand Up @@ -1495,6 +1496,7 @@ protected function addSelectBoxAndLinks(&$data)
$displayData->rowData = $row;
$displayData->rowId = $rowId;
$displayData->isAjax = $isAjax;
$displayData->isCustom = $this->getCustomLink('url', 'details') !== '';
$displayData->list_detail_link_icon = $params->get('list_detail_link_icon', 'search.png');
$layout = $this->getLayout('listactions.fabrik-view-button');
$viewLink = $layout->render($displayData);
Expand Down Expand Up @@ -2245,11 +2247,13 @@ public function _addLink($data, &$elementModel, $row, $repeatCounter = 0)
$dataList = 'list_' . $this->getRenderContext();
$rowId = $this->getSlug($row);
$isAjax = $this->isAjaxLinks() ? '1' : '0';
$isCustom = $customLink === '' ? '0' : '1';
if ($target !== '') $target = 'target="' . $target . '"';
$data = '<a data-loadmethod="' . $loadMethod
. '" data-list="' . $dataList
. '" data-rowid="' . $rowId
. '" data-isajax="' . $isAjax
. '" data-iscustom="' . $isCustom
. '" class="' . $class
. '" href="' . $link
. '"' . $target . '>' . $data
Expand Down
5 changes: 2 additions & 3 deletions media/com_fabrik/js/dist/form.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions media/com_fabrik/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ define(['jquery', 'fab/encoder', 'fab/fabrik', 'lib/debounce/jquery.ba-throttle-
window.print();
} else {
// Build URL as we could have changed the rowid via ajax pagination
/*
var url = 'index.php?option=com_' + Fabrik.package + '&view=details&tmpl=component&formid=' + this.id +
'&listid=' + this.options.listid + '&rowid=' + this.options.rowid + '&iframe=1&print=1';
*/
var url = jQuery(e.target).prop('href');
url = url.replace(/&rowid=\d+/, '&rowid=' + this.options.rowid);
if (this.options.lang !== false) {
url += '&lang=' + this.options.lang;
}
Expand Down

0 comments on commit 9798810

Please sign in to comment.