'doRemoveEntitled' => 'staff',
'dynamicTranslations' => 'staff',
'editDynamicTranslation' => 'staff',
- 'printContribution' => 'staff',
+ 'printContribution' => 'member',
'attach_contribution' => 'staff',
'detach_contribution' => 'staff',
'removeContribution' => 'staff',
'/contribution/print/{id:\d+}',
function ($request, $response, $args) {
$contribution = new Contribution($this->zdb, $this->login, (int)$args['id']);
- $pdf = new PdfContribution($contribution, $this->zdb, $this->preferences);
-
- $response = $this->response->withHeader('Content-type', 'application/pdf')
- ->withHeader('Content-Disposition', 'attachment;filename="' . $pdf->getFileName() . '"');
- $response->write($pdf->download());
- return $response;
+ if ($contribution->id == '') {
+ //not possible to load contribution, exit
+ $this->flash->addMessage(
+ 'error_detected',
+ str_replace(
+ '%id',
+ $args['id'],
+ _T("Unable to load contribution #%id!")
+ )
+ );
+ return $response
+ ->withStatus(301)
+ ->withHeader('Location', $this->router->pathFor(
+ 'contributions',
+ ['type' => 'contributions']
+ ));
+ }
+ else {
+ $pdf = new PdfContribution($contribution, $this->zdb, $this->preferences);
+
+ $response = $this->response->withHeader('Content-type', 'application/pdf')
+ ->withHeader('Content-Disposition', 'attachment;filename="' . $pdf->getFileName() . '"');
+ $response->write($pdf->download());
+
+ return $response;
+ }
}
)->setName('printContribution')->add($authenticate);
<th class="left">
{_T string="Duration"}
</th>
-{if ($login->isAdmin() or $login->isStaff()) and $mode neq 'ajax'}
+{if $mode neq 'ajax'}
<th class="nowrap actions_row">{_T string="Actions"}</th>
{/if}
</tr>
<td class="{$cclass} nowrap" data-title="{_T string="Amount"}">{$contribution->amount}</td>
<td class="{$cclass} nowrap" data-title="{_T string="Payment type"}">{$contribution->spayment_type}</td>
<td class="{$cclass} nowrap" data-title="{_T string="Duration"}">{$contribution->duration}</td>
- {if ($login->isAdmin() or $login->isStaff()) and $mode neq 'ajax'}
+ {if $mode neq 'ajax'}
<td class="{$cclass} center nowrap">
<a
href="{path_for name="printContribution" data=["id" => $contribution->id]}"
<i class="fas fa-file-pdf"></i>
<span class="sr-only">{_T string="Print an invoice or a receipt (depending on contribution type)"}</span>
</a>
+ {if ($login->isAdmin() or $login->isStaff()) and $mode neq 'ajax'}
{if $contribution->isCotis()}
{assign var="ctype" value="fee"}
{else}
<i class="fas fa-trash"></i>
<span class="sr-only">{_T string="Delete the contribution"}</span>
</a>
+ {/if}
</td>
{/if}
</tr>