mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
This commit is contained in:
parent
1d3d309582
commit
90f977bde1
@ -18,9 +18,30 @@ class SubmittedFormReportField extends FormField {
|
||||
* @return ComponentSet
|
||||
*/
|
||||
function Submissions() {
|
||||
return $this->form->getRecord()->Submissions();
|
||||
$pageStart = isset($_REQUEST['start']) && is_numeric($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||||
$pageLength = 10;
|
||||
|
||||
$items = $this->form->getRecord()->getComponents('Submissions', null, null, null, "$pageStart,$pageLength");
|
||||
$formId = $this->form->getRecord()->ID;
|
||||
|
||||
foreach(DB::query("SELECT COUNT(*) AS CountRows FROM SubmittedForm WHERE ParentID = $formId") as $r) $totalCount = $r['CountRows'];
|
||||
|
||||
$items->setPageLimits($pageStart, $pageLength, $totalCount);
|
||||
$items->NextStart = $pageStart + $pageLength;
|
||||
$items->PrevStart = $pageStart - $pageLength;
|
||||
$items->Start = $pageStart;
|
||||
$items->StartPlusOffset = $pageStart+$pageLength;
|
||||
$items->TotalCount = $totalCount;
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function getSubmissions() {
|
||||
return $this->customise(array(
|
||||
'Submissions' => $this->Submissions()
|
||||
))->renderWith(array('SubmittedFormReportField'));
|
||||
}
|
||||
|
||||
/**
|
||||
* ID of this forms record
|
||||
*
|
||||
|
@ -21,6 +21,19 @@
|
||||
</table>
|
||||
</div>
|
||||
<% end_control %>
|
||||
<% if Submissions.MoreThanOnePage %>
|
||||
<div class="pagination">
|
||||
<% if Submissions.NotFirstPage %>
|
||||
<a class="prev" href="javascript:void(0)" onclick="jQuery('.middleColumn').parent().load('/{$Top.Link}/getSubmissions/?start={$Submissions.PrevStart}');" title="View the previous page">Previous page</a>
|
||||
<% end_if %>
|
||||
|
||||
<span>Viewing rows $Submissions.Start - $Submissions.StartPlusOffset of $Submissions.TotalCount rows</span>
|
||||
|
||||
<% if Submissions.NotLastPage %>
|
||||
<a class="next" href="javascript:void(0)" onclick="jQuery('#FormSubmissions').parent().load('/{$Top.Link}/getSubmissions/?start={$Submissions.NextStart}');" title="View the next page">Next page</a>
|
||||
<% end_if %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
<% else %>
|
||||
<p><% _t('NOSUBMISSIONS', 'No Submissions') %></p>
|
||||
<% end_if %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user