'transaction' => 'staff',
'doEditTransaction' => 'staff',
'contribution' => 'staff',
+ 'contributionDates' => 'staff',
'attendance_sheet_details' => 'groupmanager',
'attendance_sheet' => 'groupmanager',
'entitleds' => 'staff',
*/
use Galette\Entity\Adherent;
+use Galette\Entity\Contribution;
+use Galette\Entity\ContributionsTypes;
$app->group(__('/ajax', 'routes'), function () use ($authenticate) {
$this->get(
return $response->withJson(['message' => _T('Thank you for registering!')]);
}
)->setName('setRegistered')->add($authenticate);
+
+ $this->post(
+ __('/contribution', 'routes') . __('/dates', 'routes'),
+ function ($request, $response) {
+ $post = $request->getParsedBody();
+
+ // contribution types
+ $ct = new ContributionsTypes($this->zdb);
+ $contributions_types = $ct->getList(true);
+
+ $contrib = new Contribution(
+ $this->zdb,
+ $this->login,
+ [
+ 'type' => __(array_keys($contributions_types)[$post['fee_id']], 'routes'),
+ 'adh' => (int)$post['member_id']
+ ]
+ );
+ $contribution['duree_mois_cotis'] = $this->preferences->pref_membership_ext;
+
+ return $response->withJson([
+ 'date_debut_cotis' => $contrib->begin_date,
+ 'date_fin_cotis' => $contrib->end_date
+ ]);
+ }
+ )->setName('contributionDates')->add($authenticate);
});
));
}
} else {
+ $id_type_cotis = 0;
+ if (isset($get[ContributionsTypes::PK])
+ && $get[ContributionsTypes::PK]
+ && $action === __('add', 'routes')
+ ) {
+ $id_type_cotis = $get[ContributionsTypes::PK];
+ }
$cparams = ['type' => __(array_keys($contributions_types)[0], 'routes')];
//member id
(count($cparams) > 0 ? $cparams : null)
);
+ if (isset($get['montant_cotis']) && $get['montant_cotis'] > 0 && $action === __('add', 'routes')) {
+ $contrib->amount = $get['montant_cotis'];
+ }
+
if ($contrib->isTransactionPart()) {
$id_adh = $contrib->member;
__('add', 'routes') . '|' . __('edit', 'routes') .'}[/{id:\d+}]',
function ($request, $response, $args) {
$post = $request->getParsedBody();
+
+ if (isset($post['btnreload'])) {
+ $reditect_url = $this->router->pathFor('contribution', $args);
+ $reditect_url .= '?' . Adherent::PK . '=' . $post[Adherent::PK] . '&' .
+ ContributionsTypes::PK . '=' . $post[ContributionsTypes::PK] . '&' .
+ 'montant_cotis=' . $post['montant_cotis'];
+ return $response
+ ->withStatus(301)
+ ->withHeader('Location', $reditect_url);
+ }
+
$error_detected = [];
$warning_detected = [];
$reditect_url = null;
{html_options options=$type_cotis_options selected=$selectedid}
</select>
</p>
+ {if $type eq {_T string="fee" domain="routes"}}
+ <noscript>
+ <div class="button-container" id="reloadcont">
+ <input type="submit" id="btnreload" name="btnreload" value="{_T string="Reload"}" title="{_T string="Reload date informations according to selected member and contribution type"}"/>
+ </div>
+ </noscript>
+ {/if}
</fieldset>
<fieldset class="cssform">
</form>
<script type="text/javascript">
$(function(){
- $.datepicker.setDefaults($.datepicker.regional['{$galette_lang}']);
- $('#date_debut_cotis, #date_fin_cotis, #date_enreg').datepicker({
- changeMonth: true,
- changeYear: true,
- showOn: 'button',
- buttonImage: '{base_url}/{$template_subdir}images/calendar.png',
- buttonImageOnly: true,
- buttonText: '{_T string="Select a date" escape="js"}'
- });
});
</script>
{else} {* No members *}
</div>
{/if}
{/block}
+
+{block name="javascripts"}
+<script type="text/javascript">
+ $(function() {
+ $.datepicker.setDefaults($.datepicker.regional['{$galette_lang}']);
+ $('#date_debut_cotis, #date_fin_cotis, #date_enreg').datepicker({
+ changeMonth: true,
+ changeYear: true,
+ showOn: 'button',
+ buttonImage: '{base_url}/{$template_subdir}images/calendar.png',
+ buttonImageOnly: true,
+ buttonText: '{_T string="Select a date" escape="js"}'
+ });
+
+ {if $type eq {_T string="fee" domain="routes"} and !$contribution->id}
+ $('#id_adh, #id_type_cotis').on('change', function() {
+ var _this = $(this);
+ var _member = $('#id_adh').val();
+ var _fee = $('#id_type_cotis').val();
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url : '{path_for name="contributionDates"}',
+ data: {
+ member_id: _member,
+ fee_id: _fee
+ },
+ {include file="js_loader.tpl"},
+ success: function(res){
+ $('#date_debut_cotis').val(res.date_debut_cotis);
+ $('#date_fin_cotis').val(res.date_fin_cotis);
+ },
+ error: function() {
+ alert("{_T string="An error occured retrieving dates :(" escape="js"}");
+ }
+ });
+
+ });
+ {/if}
+ });
+</script>
+{/block}