Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
ludotheque
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
18
Issues
18
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Denis S. Valdenaire
ludotheque
Commits
32d3e9cc
Commit
32d3e9cc
authored
Aug 02, 2016
by
Denis S. Valdenaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in progress
parent
f1d1d307
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
42 deletions
+109
-42
webroot/classes/payment.php
webroot/classes/payment.php
+44
-0
webroot/classes/subscription.php
webroot/classes/subscription.php
+14
-9
webroot/controllers/app.php
webroot/controllers/app.php
+12
-8
webroot/controllers/subscriptions.php
webroot/controllers/subscriptions.php
+16
-0
webroot/views/members/subscriptions.html
webroot/views/members/subscriptions.html
+21
-4
webroot/views/subscriptions/edit.html
webroot/views/subscriptions/edit.html
+2
-21
No files found.
webroot/classes/payment.php
0 → 100644
View file @
32d3e9cc
<?php
class
Payment
extends
Record
{
public
$id
;
public
$subscription_id
,
$payment_method_id
;
public
$amount
,
$comment
;
public
$check_bank_name
,
$check_owner_name
;
public
$created_at
;
public
static
$table
=
"lud_payments"
;
public
function
__construct
(
$id
=
0
)
{
if
(
!
$this
->
id
)
{
$this
->
id
=
$id
;
}
}
/*
* function fetch_all
* fetches all payments for a given subscription, in an array by ref
* @return the number of payments
*/
public
static
function
fetch_all
(
&
$payments
,
$subscription_id
)
{
$payments
=
array
();
// SQL SELECT lud_payments
$sql
=
"SELECT id, payment_method_id, amount, comment,
check_bank_name, check_owner_name, created_at
FROM "
.
Payment
::
$table
.
"
WHERE subscription_id =
$subscription_id
ORDER BY id"
;
$GLOBALS
[
"data"
]
->
select
(
$sql
,
$payments
,
"Payment"
,
1
);
return
sizeof
(
$payments
);
}
public
static
function
fetch
(
$id
)
{
// SQL SELECT lud_payments
$sql
=
"SELECT id, payment_method_id, amount, comment,
check_bank_name, check_owner_name, created_at
FROM "
.
Payment
::
$table
.
"
WHERE id = "
.
$id
;
$GLOBALS
[
"data"
]
->
select
(
$sql
,
$payment
,
"Payment"
);
return
$payment
;
}
}
webroot/classes/subscription.php
View file @
32d3e9cc
...
...
@@ -21,35 +21,40 @@ class Subscription extends Record {
}
public
static
function
fetch
(
$id
)
{
// SQL SELECT lud_subscriptions lud_membership_types lud_
payment_methods lud_
members
// SQL SELECT lud_subscriptions lud_membership_types lud_members
$sql
=
" SELECT ms.id, start_date, end_date, ms.member_id, CONCAT(m.lastname, ' ', m.firstname) as member_name,
ms.membership_type_id, mt.name as membership_type_name,
ms.payment_method_id, pm.name as payment_method_name
,
COUNT(p.id) AS num_payment, sum(p.amount) AS total_payment
,
ms.price, credit, ms.comments, ms.created_at, ms.updated_at,
DATEDIFF(end_date, curdate()) as remaining_days
FROM "
.
Subscription
::
$table
.
" ms, "
.
Member
::
$table
.
" m, "
.
Membership_Type
::
$table
.
" mt, "
.
Payment
_Method
::
$table
.
" pm
FROM "
.
Subscription
::
$table
.
" ms, "
.
Member
::
$table
.
" m, "
.
Membership_Type
::
$table
.
" mt, "
.
Payment
::
$table
.
" p
WHERE ms.id = "
.
$id
.
"
AND ms.member_id = m.id
AND ms.membership_type_id = mt.id
AND ms.
payment_method_id = pm.
id
AND ms.
id = p.subscription_
id
"
;
$GLOBALS
[
"data"
]
->
select
(
$sql
,
$subscription
,
"Subscription"
);
return
$subscription
;
}
/*
* function fetch_all
* fetches all subscriptions for a member in an array by ref
* @return the number of subscriptions
*/
public
static
function
fetch_all
(
&
$subscriptions
,
$member_id
)
{
$subscriptions
=
array
();
// SQL SELECT lud_subscriptions lud_members lud_membership_types
lud_payment_methods
// SQL SELECT lud_subscriptions lud_members lud_membership_types
$sql
=
" SELECT ms.id, start_date, end_date, ms.member_id, CONCAT(m.lastname, ' ', m.firstname) as member_name,
ms.membership_type_id, mt.name as membership_type_name,
ms.payment_method_id, pm.name as payment_method_name
,
ms.membership_type_id, mt.name as membership_type_name,
COUNT(p.id) AS num_payment, sum(p.amount) AS total_payment
,
ms.price, credit, ms.comments, ms.created_at, ms.updated_at,
DATEDIFF(end_date, curdate()) as remaining_days
FROM "
.
Subscription
::
$table
.
" ms, "
.
Member
::
$table
.
" m, "
.
Membership_Type
::
$table
.
" mt, "
.
Payment
_Method
::
$table
.
" pm
FROM "
.
Subscription
::
$table
.
" ms, "
.
Member
::
$table
.
" m, "
.
Membership_Type
::
$table
.
" mt, "
.
Payment
::
$table
.
" p
WHERE member_id = "
.
$member_id
.
"
AND ms.member_id = m.id
AND ms.membership_type_id = mt.id
AND ms.
payment_method_id = pm.
id
AND ms.
id = p.subscription_
id
ORDER BY end_date DESC
"
;
$GLOBALS
[
"data"
]
->
select
(
$sql
,
$subscriptions
,
"Subscription"
,
true
);
...
...
webroot/controllers/app.php
View file @
32d3e9cc
...
...
@@ -196,14 +196,18 @@ class AppController {
}
function
_edit
(
$success
=
"edit"
)
{
$classname
=
$this
->
model
;
$object
=
$classname
::
fetch
(
$GLOBALS
[
"data"
]
->
db_escape_string
(
$_REQUEST
[
"i"
]));
if
(
$this
->
format
==
"json"
)
{
echo
json_encode
(
$object
);
exit
();
}
$this
->
set
(
"object"
,
$object
);
return
$_REQUEST
[
"o"
]
.
"/"
.
$success
;
try
{
$classname
=
$this
->
model
;
$object
=
$classname
::
fetch
(
$GLOBALS
[
"data"
]
->
db_escape_string
(
$_REQUEST
[
"i"
]));
if
(
$this
->
format
==
"json"
)
{
echo
json_encode
(
$object
);
exit
();
}
$this
->
set
(
"object"
,
$object
);
return
$_REQUEST
[
"o"
]
.
"/"
.
$success
;
}
catch
(
data_exception
$e
)
{
return
"data_exception"
;
}
}
function
_update
()
{
...
...
webroot/controllers/subscriptions.php
View file @
32d3e9cc
...
...
@@ -21,6 +21,22 @@ class SubscriptionsController extends AppController {
return
$_REQUEST
[
"o"
]
.
"/edit"
;
}
function
_payments
()
{
try
{
$subscription
=
Subscription
::
fetch
(
$GLOBALS
[
"data"
]
->
db_escape_string
(
$_REQUEST
[
"i"
]));
$payments
=
array
();
Payment
::
fetch_all
(
$payments
,
$subscription
->
id
);
if
(
$this
->
format
==
"json"
)
{
echo
json_encode
(
$payments
);
exit
();
}
else
{
return
"payments/list"
;
}
}
catch
(
data_exception
$e
)
{
return
"data_exception"
;
}
}
function
_print
()
{
try
{
$subscription
=
Subscription
::
fetch
(
$GLOBALS
[
"data"
]
->
db_escape_string
(
$_REQUEST
[
"i"
]));
...
...
webroot/views/members/subscriptions.html
View file @
32d3e9cc
...
...
@@ -24,9 +24,9 @@
<th>
Début
</th>
<th>
Fin
</th>
<th>
Type
</th>
<th>
Prix
</th>
<th>
Paiement
</th>
<th>
Crédit
</th>
<th>
Prix
</th>
<th>
Notes
</th>
<th>
Actions
</th>
</tr>
...
...
@@ -37,15 +37,19 @@
<td>
{{ val.start_date | date("d/m/Y") }}
</td>
<td>
{{ val.end_date | date("d/m/Y") }}
</td>
<td>
{{ val.membership_type_name }}
</td>
<td>
{{ val.payment_method_name }}
</td>
<td>
{{ val.credit ? "Oui" : "Non" }}
</td>
<td>
{{ val.price }}
</td>
<td>
{{ val.total_payment }}
</td>
<td>
{{ val.credit ? "Oui" : "Non" }}
</td>
<td>
{{ val.comments }}
</td>
<td>
<button
type=
"button"
class=
"btn btn-success btn-sm"
data-toggle=
"modal"
data-target=
"#editModal"
data-id=
"{{ val.id }}"
>
<i
class=
"glyphicon glyphicon-edit"
></i>
</button>
<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>
<button
type=
"button"
class=
"btn btn-default btn-sm button_print"
data-id=
"{{ val.id }}"
>
<i
class=
"glyphicon glyphicon-print"
></i>
</button>
...
...
@@ -74,6 +78,14 @@
</div>
</div>
<!-- end edit modal -->
<!-- payment modal skel -->
<div
class=
"modal fade"
id=
"paymentModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"paymentModalLabel"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
</div>
</div>
</div>
<!-- end edit modal -->
<script>
$
(
document
).
ready
(
function
()
{
...
...
@@ -89,7 +101,12 @@ $(document).ready(function () {
}
}).
on
(
"
hidden.bs.modal
"
,
function
(
e
)
{
$
(
this
).
find
(
"
.modal-content
"
).
empty
();
});
$
(
"
#paymentModal
"
).
on
(
"
show.bs.modal
"
,
function
(
e
)
{
var
button
=
$
(
e
.
relatedTarget
);
$
(
this
).
find
(
"
.modal-content
"
).
load
(
"
index.php?o=
"
+
$
(
'
#a
'
).
val
()
+
"
&a=payments&i=
"
+
button
.
data
(
'
id
'
));
}).
on
(
"
hidden.bs.modal
"
,
function
(
e
)
{
$
(
this
).
find
(
"
.modal-content
"
).
empty
();
});
$
(
'
#object_list
'
).
on
(
'
click
'
,
'
.button_delete
'
,
function
(
e
){
if
(
confirm
(
'
Êtes vous sur ?
'
))
{
...
...
webroot/views/subscriptions/edit.html
View file @
32d3e9cc
...
...
@@ -77,28 +77,9 @@
}});
</script>
</div>
<label
class=
"control-label col-sm-2"
for=
"payment_method_id"
>
Méthode de paiement
</label>
<label
class=
"control-label col-sm-2"
for=
"payment_method_id"
>
Paiements
</label>
<div
class=
"col-sm-4"
>
<select
id=
"payment_method_id"
name=
"payment_method_id"
class=
"form-control"
>
</select>
<script>
$
(
'
#payment_method_id
'
).
html
(
'
<option value="">Loading...</option>
'
);
$
.
ajax
({
url
:
'
api.php?o=payment_methods&a=list
'
,
success
:
function
(
output
)
{
var
html
=
''
;
$
.
each
(
output
,
function
(
key
,
val
){
html
=
html
+
'
<option value="
'
+
val
.
id
+
'
"
'
+
(
val
.
id
==
{{
object
.
payment_method_id
?:
0
}}
?
'
selected
'
:
''
)
+
'
>
'
+
val
.
name
+
'
</option>
'
;
});
$
(
'
#payment_method_id
'
).
html
(
html
);
},
error
:
function
(
xhr
,
ajaxOptions
,
thrownError
)
{
// well, that's weird, ok :)
$
(
'
#payment_method_id
'
).
html
(
'
<option value="">
'
+
xhr
.
status
+
'
'
+
thrownError
+
'
</option>
'
);
// alert(xhr.status + " " + thrownError);
}});
</script>
FIXME : link
</div>
</div>
<div
class=
"form-group"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment