Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/GaletteHelloasso/HelloassoHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ public function add(array|string $action, string $argument = '', string $query =
$values = [
'history_date' => date('Y-m-d H:i:s'),
'checkout_id' => $request['data']['id'],
'amount' => $request['data']['amount'] / 100,
'payer_name' => mb_strtoupper($request['data']['payer']['lastName'], 'UTF-8') . ' ' . $request['data']['payer']['firstName'],
'member_id' => $request['metadata']['member_id'] ?? 0,
'comments' => $request['metadata']['item_name'],
'request' => Galette::jsonEncode($request),
'state' => self::STATE_NONE
'amount' => $request['data']['amount'] / 100,
'method' => $request['data']['paymentMeans'],
'state' => self::STATE_NONE,
'receipt_url' => $request['data']['paymentReceiptUrl'],
'request' => Galette::jsonEncode($request)
];

$insert = $this->zdb->insert($this->getTableName());
Expand Down Expand Up @@ -134,9 +138,7 @@ public function getHelloassoHistory(): array
$oa = Galette::jsonDecode($o['request']);
}

$member_id = $oa['metadata']['member_id'] ?? 0;

$o['member_fullname'] = $this->getMemberFullName($member_id);
$o['member_fullname'] = $this->getMemberFullName($o['member_id']);
$o['raw_request'] = print_r($oa, true);
$o['request'] = $oa;

Expand Down Expand Up @@ -169,7 +171,7 @@ protected function getMemberFullName(int $id): string
$row = $result->current();

if ($row) {
$fullname = mb_strtoupper($row['nom_adh']) . ' ' . $row['prenom_adh'];
$fullname = mb_strtoupper($row['nom_adh'], 'UTF-8') . ' ' . $row['prenom_adh'];
}

return $fullname;
Expand Down
10 changes: 7 additions & 3 deletions scripts/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ DROP TABLE IF EXISTS galette_helloasso_history;
CREATE TABLE galette_helloasso_history (
id_helloasso int(11) NOT NULL auto_increment,
history_date datetime NOT NULL,
checkout_id varchar(255) COLLATE utf8_unicode_ci,
checkout_id varchar(255),
amount double NOT NULL,
comments varchar(255) COLLATE utf8_unicode_ci,
request text COLLATE utf8_unicode_ci,
comments varchar(255),
request text,
state tinyint(4) NOT NULL DEFAULT 0,
payer_name varchar(255) NOT NULL,
member_id int(10) NOT NULL,
method varchar(10) NOT NULL,
receipt_url varchar(255) NOT NULL,
PRIMARY KEY (`id_helloasso`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

Expand Down
36 changes: 20 additions & 16 deletions scripts/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

DROP SEQUENCE IF EXISTS galette_helloasso_history_id_seq;
CREATE SEQUENCE galette_helloasso_history_id_seq
START 1
INCREMENT 1
MAXVALUE 2147483647
MINVALUE 1
CACHE 1;
START 1
INCREMENT 1
MAXVALUE 2147483647
MINVALUE 1
CACHE 1;

DROP TABLE IF EXISTS galette_helloasso_history;
CREATE TABLE galette_helloasso_history (
Expand All @@ -21,6 +21,10 @@ CREATE TABLE galette_helloasso_history (
comments character varying(255),
request text,
state smallint DEFAULT 0 NOT NULL,
payer_name character varying(255) NOT NULL,
member_id integer NOT NULL,
method character varying(10) NOT NULL,
receipt_url character varying(255) NOT NULL,
PRIMARY KEY (id_helloasso)
);

Expand All @@ -29,18 +33,18 @@ CREATE TABLE galette_helloasso_history (
--
DROP SEQUENCE IF EXISTS galette_helloasso_preferences_id_seq;
CREATE SEQUENCE galette_helloasso_preferences_id_seq
START 1
INCREMENT 1
MAXVALUE 2147483647
MINVALUE 1
CACHE 1;
START 1
INCREMENT 1
MAXVALUE 2147483647
MINVALUE 1
CACHE 1;

DROP TABLE IF EXISTS galette_helloasso_preferences;
CREATE TABLE galette_helloasso_preferences (
id_pref integer DEFAULT nextval('galette_helloasso_preferences_id_seq'::text) NOT NULL,
nom_pref character varying(100) NOT NULL default '',
val_pref character varying(200) NOT NULL default '',
PRIMARY KEY (id_pref)
PRIMARY KEY (id_pref)
);

CREATE UNIQUE INDEX galette_helloasso_preferences_unique_idx ON galette_helloasso_preferences (nom_pref);
Expand All @@ -57,11 +61,11 @@ INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloass
--
DROP SEQUENCE IF EXISTS galette_helloasso_tokens_id_seq;
CREATE SEQUENCE galette_helloasso_tokens_id_seq
START 1
INCREMENT 1
MAXVALUE 2147483647
MINVALUE 1
CACHE 1;
START 1
INCREMENT 1
MAXVALUE 2147483647
MINVALUE 1
CACHE 1;

DROP TABLE IF EXISTS galette_helloasso_tokens;
CREATE TABLE galette_helloasso_tokens (
Expand Down
30 changes: 29 additions & 1 deletion scripts/upgrade-to-1.1.0-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,33 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
--

UPDATE galette_helloasso_history SET state = 3 WHERE state = 0;
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_sepa_option', '');

ALTER TABLE galette_helloasso_history
MODIFY checkout_id varchar(255) COLLATE utf8mb4_unicode_520_ci,
MODIFY comments varchar(255) COLLATE utf8mb4_unicode_520_ci,
MODIFY request text COLLATE utf8mb4_unicode_520_ci;

ALTER TABLE galette_helloasso_history
ADD COLUMN payer_name VARCHAR(255) NOT NULL,
ADD COLUMN member_id INT(10) NOT NULL,
ADD COLUMN method VARCHAR(10) NOT NULL,
ADD COLUMN receipt_url VARCHAR(255) NOT NULL;

UPDATE galette_helloasso_history
SET
state = CASE
WHEN state = 0 THEN 3
ELSE state
END,
payer_name = CONCAT(
UPPER(JSON_UNQUOTE(JSON_EXTRACT(request, '$.data.payer.lastName'))),
' ',
JSON_UNQUOTE(JSON_EXTRACT(request, '$.data.payer.firstName'))
),
member_id = COALESCE(
CAST(JSON_UNQUOTE(JSON_EXTRACT(request, '$.metadata.member_id')) AS UNSIGNED),
0
),
method = JSON_UNQUOTE(JSON_EXTRACT(request, '$.data.paymentMeans')),
receipt_url = JSON_UNQUOTE(JSON_EXTRACT(request, '$.data.paymentReceiptUrl'));
25 changes: 24 additions & 1 deletion scripts/upgrade-to-1.1.0-pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,28 @@
-- SPDX-License-Identifier: GPL-3.0-or-later
--

UPDATE galette_helloasso_history SET state = 3 WHERE state = 0;
INSERT INTO galette_helloasso_preferences (nom_pref, val_pref) VALUES ('helloasso_sepa_option', '');

ALTER TABLE galette_helloasso_history
ADD COLUMN payer_name character varying(255) NOT NULL,
ADD COLUMN member_id integer NOT NULL,
ADD COLUMN method character varying(10) NOT NULL,
ADD COLUMN receipt_url character varying(255) NOT NULL;

UPDATE galette_helloasso_history
SET
state = CASE
WHEN state = 0 THEN 3
ELSE state
END,
payer_name = CONCAT(
UPPER((request->'data'->'payer'->>'lastName')),
' ',
(request->'data'->'payer'->>'firstName')
),
member_id = COALESCE(
(request->'metadata'->>'member_id')::int,
0
),
method = request->'data'->>'paymentMeans',
receipt_url = request->'data'->>'paymentReceiptUrl';
56 changes: 16 additions & 40 deletions templates/default/helloasso_history.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -87,45 +87,25 @@
{{ log.checkout_id }}
</td>
<td class="left collapsing" data-col-label="{{ _T("Payer name", "helloasso") }}">
{% if log.request is iterable %}
{{ log.request.data.payer.lastName|upper }} {{ log.request.data.payer.firstName }}
{% else %}
{{ _T("No request or unable to read request.", "helloasso") }}
{% endif %}
{{ log.payer_name }}
</td>
<td class="left collapsing" data-col-label="{{ _T("Member") }}">
{% if log.request is iterable %}
{% if log.request.metadata.member_id is defined %}
<a href="{{ url_for("member", {"id": log.request.metadata.member_id}) }}">
{% endif %}
{{ log.member_fullname }}
{% if log.request.metadata.member_id is defined %}
</a>
{% endif %}
{% else %}
{{ _T("No request or unable to read request.", "helloasso") }}
{% endif %}
{% if log.member_id != 0 %}
<a href="{{ url_for("member", {"id": log.member_id}) }}">
{% endif %}
{{ log.member_fullname }}
{% if log.member_id != 0 %}
</a>
{% endif %}
</td>
<td class="left collapsing" data-col-label="{{ _T("Contribution type") }}">
{% if log.request is iterable %}
{% if log.request.metadata.item_name is defined %}
{{ log.request.metadata.item_name }}
{% endif %}
{% else %}
{{ _T("No request or unable to read request.", "helloasso") }}
{% endif %}
{{ log.comments }}
</td>
<td class="right collapsing" data-col-label="{{ _T("Amount") }}">
{{ log.amount }}
</td>
<td class="left collapsing" data-col-label="{{ _T("Method", "helloasso") }}">
{% if log.request is iterable %}
{% if log.request.data.paymentMeans is defined %}
{{ log.request.data.paymentMeans }}
{% endif %}
{% else %}
{{ _T("No request or unable to read request.", "helloasso") }}
{% endif %}
{{ log.method }}
</td>
<td class="left collapsing" data-col-label="{{ _T("Status", "helloasso") }}">
{% if log.state == constant('GaletteHelloasso\\HelloassoHistory::STATE_PUBLIC') or log.state == constant('GaletteHelloasso\\HelloassoHistory::STATE_PROCESSED') %}
Expand All @@ -152,16 +132,12 @@
{% endif %}
</td>
<td class="left" data-col-label="{{ _T("Actions") }}">
{% if log.request is iterable %}
{% if log.request.data.paymentReceiptUrl is defined %}
<a href="{{ log.request.data.paymentReceiptUrl }}" class="icon-only" target="_blank">
<i class="file pdf green icon" aria-hidden="true"></i>
<span class="visually-hidden">
{{ _T("Download HelloAsso payment confirmation of payment nb. %1$s", "helloasso")|replace({"%1$s": log.checkout_id}) }}
</span>
</a>
{% endif %}
{% endif %}
<a href="{{ log.receipt_url }}" class="icon-only" target="_blank">
<i class="file pdf green icon" aria-hidden="true"></i>
<span class="visually-hidden">
{{ _T("Download HelloAsso payment confirmation of payment nb. %1$s", "helloasso")|replace({"%1$s": log.checkout_id}) }}
</span>
</a>
<a href="#" class="icon-only view-request" data-modal="modal-{{ loop.index }}">
<i class="info circle blue icon" aria-hidden="true"></i>
<span class="visually-hidden">
Expand Down
Loading