Commit a4333ed4 authored by thejoelinux's avatar thejoelinux

impression adhésion

parent d2280619
*.swp
uploads/*
webroot/vendor/*
webroot/uploads/*
......@@ -2,6 +2,7 @@
"require": {
"twig/twig": "~1.0",
"nette/mail": "^2.3",
"vlucas/valitron": "^1.2"
"vlucas/valitron": "^1.2",
"setasign/fpdf": "1.8.1"
}
}
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "c5d451cd88aaa48b4d5033f3e0607b58",
"content-hash": "51ede62ccdbaafa5ac9770f8ae6174a0",
"hash": "38cc9e2c947ee326db8e4a0df15d02a3",
"content-hash": "c8041006f30b9375d7503e74d14f6215",
"packages": [
{
"name": "nette/mail",
......@@ -117,6 +117,45 @@
"homepage": "https://nette.org",
"time": "2015-11-30 00:11:35"
},
{
"name": "setasign/fpdf",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/Setasign/FPDF.git",
"reference": "2c68c9e6c034ac3187d25968790139a73184cdb1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Setasign/FPDF/zipball/2c68c9e6c034ac3187d25968790139a73184cdb1",
"reference": "2c68c9e6c034ac3187d25968790139a73184cdb1",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"fpdf.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"no usage restriction"
],
"authors": [
{
"name": "Olivier Plathey",
"email": "oliver@fpdf.org",
"homepage": "http://fpdf.org/"
}
],
"description": "FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.",
"homepage": "http://www.fpdf.org",
"keywords": [
"fpdf",
"pdf"
],
"time": "2016-01-01 17:47:15"
},
{
"name": "twig/twig",
"version": "v1.23.1",
......
......@@ -232,6 +232,10 @@ class AppController {
$classname = $this->model;
$object = $classname::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($object->id != 0 && $object->delete()) {
if($this->format == "json") {
echo json_encode($object);
exit();
}
$this->set_message("Suppression effectuée");
$classname::fetch_all($objects);
$this->set("objects", $objects);
......
......@@ -14,10 +14,158 @@ class SubscriptionsController extends AppController {
function _new() {
$classname = $this->model;
$object = new $classname(0);
$object = new $classname(0);
$object->member_id = $_REQUEST["i"];
$this->set("object", $object);
$_REQUEST["i"] = 0;
return $_REQUEST["o"]."/edit";
$_REQUEST["i"] = 0;
return $_REQUEST["o"]."/edit";
}
function _print() {
try {
$subscription = Subscription::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
$member = Member::fetch($subscription->member_id);
} catch(data_exception $e) {
return "data_exception";
}
define('EURO', chr(128));
$pdf = new FPDF();
// the header
$pdf->AddPage();
$pdf->Image('uploads/ludotm_cazeres.png',10,6,60);
$pdf->SetY(25);
$pdf->SetFont('Arial','B',15);
$pdf->Cell(40,10,utf8_decode('Association Ludot\'m - Cazères'));
$pdf->SetFont('Arial','',10);
$pdf->Ln(5);
$pdf->Cell(40,10,utf8_decode('Impasse des Capucins'));
$pdf->Ln(5);
$pdf->Cell(40,10,'31220 CAZERES');
$pdf->Ln(5);
$pdf->Cell(40,10,'ludothequecazeres@gmail.com');
$pdf->Ln(5);
$pdf->Cell(40,10,'07 81 39 34 70');
// the member name and address
$pdf->SetXY(120,45);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(40, 10, utf8_decode($subscription->member_name));
$pdf->Ln(5);
$pdf->SetX(120);
$pdf->SetFont('Arial','', 10);
$pdf->Cell(40, 10, utf8_decode($member->address));
$pdf->Ln(5);
$pdf->SetX(120);
$pdf->Cell(40, 10, utf8_decode($member->po_town));
// subscription line
$pdf->SetXY(10,85);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(40,10,utf8_decode('Adhésion N°'.$subscription->id));
$pdf->Ln();
$pdf->SetFont('Arial','', 10);
$pdf->SetFillColor(200,200,200);
$pdf->Cell(150,8, utf8_decode('Désignation'), 1, 0, 'L', true);
$pdf->Cell(0,8, 'Prix', 1, 0, 'C', true);
$pdf->Ln();
$start_date = date_format(date_create_from_format('Y-m-d', $subscription->start_date),'d/m/Y');
$end_date = date_format(date_create_from_format('Y-m-d', $subscription->end_date),'d/m/Y');
$pdf->Cell(150,8, utf8_decode('Adhésion type '.$subscription->membership_type_name.' du '.
$start_date.' au '.$end_date), 1);
$pdf->Cell(0,8, $subscription->price." ".EURO, 1, 0, 'R');
$pdf->Ln();
// seal line
$pdf->SetXY(120, 130);
$pdf->Cell(40, 10, utf8_decode('À Cazères, le ').
date_format(date_create_from_format('Y-m-d H:i:s', $subscription->created_at),'d/m/Y')
);
// member card
$pdf->SetXY(18,221);
$pdf->SetFillColor(245,245,189);
$pdf->SetDrawColor(215,215,189);
$pdf->Cell(85,50,'',1,0,'C',1);
$pdf->Cell(85,50,'',1,0,'C',1);
$pdf->SetXY(21,222);
$pdf->Image('uploads/ludotm_cazeres.png',null, null, 50);
$pdf->SetXY(19,245);
$pdf->SetFont('Arial','B', 12);
$pdf->Cell(50, 2, utf8_decode($subscription->member_name),0,1);
$pdf->SetFont('Arial','', 10);
$pdf->SetX(19);
$pdf->Cell(50, 10, utf8_decode($member->po_town), 0, 1);
$pdf->SetXY(19, 263);
$pdf->Cell(50, 6, utf8_decode('Adhésion '.$subscription->membership_type_name.' du '.
$start_date.' au '.$end_date), 0, 1);
$x = 106;
$y = 225;
$n = 3;
$pdf->SetXY($x,$y);
$pdf->SetFont('Arial','B', 8);
$pdf->Cell(50, 2, utf8_decode("Périodes Scolaires"), 0, 1);
$y += $n;
$pdf->SetXY($x,$y);
$pdf->SetFont('Arial','', 8);
$pdf->Cell(15, 2, "Mercredi", 0);
$pdf->Cell(50, 2, utf8_decode("9h00 à 12h30 et 14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Jeudi", 0);
$pdf->Cell(50, 2, utf8_decode("14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Vendredi", 0);
$pdf->Cell(50, 2, utf8_decode("10h00 à 12h30"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Samedi", 0);
$pdf->Cell(50, 2, utf8_decode("10h00 à 12h30 et 14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->SetFont('Arial','B', 8);
$pdf->Cell(50, 2, utf8_decode("Vacances Scolaires"), 0, 1);
$pdf->SetFont('Arial','', 8);
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Mardi", 0);
$pdf->Cell(50, 2, utf8_decode("14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Mercredi", 0);
$pdf->Cell(50, 2, utf8_decode("10h00 à 12h30 et 14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Jeudi", 0);
$pdf->Cell(50, 2, utf8_decode("14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Vendredi", 0);
$pdf->Cell(50, 2, utf8_decode("14h30 à 18h00"));
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(15, 2, "Samedi", 0);
$pdf->Cell(50, 2, utf8_decode("10h00 à 12h30 et 14h30 à 18h00"));
$pdf->SetFont('Arial','B', 8);
$y += $n + 5;
$pdf->SetXY($x,$y);
$pdf->Cell(50, 2, "Contact : ludothequecazeres@gmail.com / 07 81 39 34 70");
$y += $n;
$pdf->SetXY($x,$y);
$pdf->Cell(50, 2, "http://ludotheque-cazeres.fr");
//$pdf->Output($file_name, ($_GET["a"] == "view" ? 'I' : 'D'));
$pdf->Output("adhesion.pdf", 'I');
exit();
}
}
......@@ -33,7 +33,7 @@
</thead>
<tbody>
{% for key, val in member.subscriptions %}
<tr>
<tr id="subs_{{ val.id }}">
<td>{{ val.start_date | date("d/m/Y") }}</td>
<td>{{ val.end_date | date("d/m/Y") }}</td>
<td>{{ val.membership_type_name }}</td>
......@@ -46,10 +46,12 @@
data-toggle="modal" data-target="#editModal" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-edit"></i>
</button>
<a onClick="if(confirm('Êtes vous sur ?')) { $('#a').val('delete_subscription'); $('#i').val('{{ val.id }}'); defaultform.submit()}" href="#">
<button type="button" class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</a>
<button type="button" class="btn btn-default btn-sm button_print" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-print"></i>
</button>
<button type="button" class="btn btn-danger btn-sm button_delete" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-trash"></i>
</button>
</td>
{% else %}
<tr>
......@@ -89,6 +91,24 @@ $(document).ready(function () {
$(this).find(".modal-content").empty();
});
$('#object_list').on('click', '.button_delete', function(e){
if(confirm('Êtes vous sur ?')) {
var button = $(e.currentTarget);
$.post('api.php', { o: 'subscriptions', a: 'delete',
i: button.data('id') })
.done(function(data) {
$('#subs_' + data.id).remove();
})
.fail(function() {
alert('Erreur lors de la suppression de l\'adhésion');
});
}
});
$('#object_list').on('click', '.button_print', function(e){
var button = $(e.currentTarget);
javascript:window.open('index.php?o=subscriptions&a=print&i=' + button.data('id'));
});
});
</script>
{% endblock %}
......@@ -34,9 +34,6 @@
</ul>
</li>
{% endif %}
{% if roles.admin %}
<li><a href="index.php?o=users&a=list">Comptes</a></li>
{% endif %}
{% if roles.games or roles.members %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
......
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