Commit 6df150c2 authored by thejoelinux's avatar thejoelinux

creation compte pour membre + placeholder sur paiements

parent b0eff0ad
......@@ -217,6 +217,26 @@ class MembersController extends AppController {
}
}
// API CALL
function _create_account() {
try {
$member = Member::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($member->id != 0) {
if(!$member->account_id) {
$member->account_id = Account::create_for_member("Adhérent #".$member->id.
" - ".$member->firstname." ".$member->lastname);
$member->save_account();
}
echo json_encode($member);
} else {
AppController::http_error(404);
}
} catch(data_exception $e) {
AppController::http_error();
}
exit();
}
function _create_subscription() {
$_REQUEST["a"] = "subscriptions";
$this->context["request"] = $_REQUEST;
......
......@@ -15,10 +15,14 @@
<span>Nouvelle adhésion...</span>
</button>
{% if member.account_id == 0 %}
<button type="button" class="btn btn-danger btn-md" style="float: right">
<button type="button" class="btn btn-danger btn-md account_create_button"
data-id="{{ member.id }}" style="float: right; margin-right:0.25em">
<i class="glyphicon glyphicon-plus"></i>
<span>Créer le compte !</span>
</button>
</button>&nbsp;
{% else %}
<span class="label label-info "
style="float: right; margin-right:0.25em; font-size: 150%;">Compte #{{ member.account_id }}</span>
{% endif %}
</div>
<div class="panel-body">
......@@ -50,10 +54,12 @@
data-toggle="modal" data-target="#editModal" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-edit"></i>
</button>
{% if member.account_id %}
<button type="button" class="btn btn-success btn-sm"
data-toggle="modal" data-target="#paymentModal" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-euro"></i>
</button>
{% endif %}
<button type="button" class="btn btn-default btn-sm button_print" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-print"></i>
</button>
......@@ -114,6 +120,19 @@ $(document).ready(function () {
}).on("hidden.bs.modal", function(e) {
$(this).find(".modal-content").empty();
});
$('.account_create_button').on('click', function(e) {
var button = $(e.currentTarget);
$.post('api.php', { o: 'members', a: 'create_account',
i: button.data('id')
})
.done(function(data) {
alert('Compte créé : #' + data.account_id);
window.location.href = 'index.php?o=members&a=subscriptions&i=' + $('#i').val();
})
.fail(function(data) {
alert('Erreur lors de la création du compte');
});
});
$('#object_list').on('click', '.button_delete', function(e){
if(confirm('Êtes vous sur ?')) {
var button = $(e.currentTarget);
......
......@@ -33,7 +33,8 @@
<label class="control-label col-md-2" for="comments">Note</label>
<div class="col-md-7">
<input type="text" class="form-control"
name="comments" id="comments" align="right" value=""></div>
name="comments" id="comments" align="right" value=""
placeholder="Numéro de chèque / Banque / Nom"></div>
<div class="col-md-1 col-md-offset-1">
<button type="button" class="save_payment_button btn btn-primary btn-md" data-id="0">
<i class="glyphicon glyphicon-floppy-save"></i>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment