Commit ff509ab6 authored by okhin's avatar okhin 🚴

Merge branch 'preprod' into 'master'

Preprod

See merge request !61
parents bb599f4f 0bd6723e
Pipeline #2257 passed with stages
in 1 minute and 13 seconds
......@@ -82,7 +82,7 @@ cs-lint: ## Lint
translations: locales/fr_FR/LC_MESSAGES/messages.mo locales/en_US/LC_MESSAGES/messages.mo ## Generate translations
messages.pot: app/*.php templates/*/*.html
messages.pot: app/*.php app/view/*/*.html
[ -r $@ ] || touch $@
xgettext --package-name=LQDNCampaign --package-version=2016.1 --force-po -o $@ --keyword=__ --keyword=_ --from-code=UTF-8 $^
......
......@@ -7,6 +7,7 @@ use LQDN\Command\AdminChangePasswordCommand;
use LQDN\Command\DonationValidateCommand;
use LQDN\Command\DonationInvalidateCommand;
use LQDN\Command\DonationResetPdfCommand;
use LQDN\Command\DonationCreateCommand;
use LQDN\Command\UserUpdateByAdminCommand;
class Admin extends Controller
......@@ -68,15 +69,15 @@ class Admin extends Controller
{
if ($f3->get('VERB')=='POST' && $f3->exists('POST.action')) {
switch ($f3->get('POST.action')) {
case 'valid':
$f3->get('container')['command_handler']->handle(new DonationValidateCommand($f3->get('POST.id')));
break;
case 'invalid':
$f3->get('container')['command_handler']->handle(new DonationInvalidateCommand($f3->get('POST.id')));
break;
case 'pdf':
$f3->get('container')['command_handler']->handle(new DonationResetPdfCommand($f3->get('POST.id')));
break;
case 'valid':
$f3->get('container')['command_handler']->handle(new DonationValidateCommand($f3->get('POST.id')));
break;
case 'invalid':
$f3->get('container')['command_handler']->handle(new DonationInvalidateCommand($f3->get('POST.id')));
break;
case 'pdf':
$f3->get('container')['command_handler']->handle(new DonationResetPdfCommand($f3->get('POST.id')));
break;
}
}
......@@ -143,7 +144,7 @@ class Admin extends Controller
"UPDATE dons
SET status = $status
WHERE id = ".\Utils::asl($id)
);
);
$db->query("UPDATE users
SET total = $total,
cumul = $cumul
......@@ -193,7 +194,7 @@ class Admin extends Controller
"UPDATE dons
SET status = $status
WHERE id = ".\Utils::asl($id)
);
);
$db->query("UPDATE users
SET total = $total,
cumul = $cumul
......@@ -241,8 +242,8 @@ class Admin extends Controller
if ($id=='') {
// We need to check if there's already a user with this email
$result = $db->query("SELECT id
FROM users
WHERE email='".\Utils::asl($email)."'");
FROM users
WHERE email='".\Utils::asl($email)."'");
if ($result) {
// The user already exist, lets get the user_id
$user_id = $result->fetch(\PDO::FETCH_ASSOC);
......@@ -250,53 +251,53 @@ class Admin extends Controller
} else {
// Let's create the account first
$db->query("INSERT INTO users
(email,
pseudo,
cumul,
total)
VALUES('".\Utils::asl($email)."',
'".\Utils::asl($pseudo)."',
'".\Utils::asl($somme)."',
'0')");
(email,
pseudo,
cumul,
total)
VALUES('".\Utils::asl($email)."',
'".\Utils::asl($pseudo)."',
'".\Utils::asl($somme)."',
'0')");
$user_id = $db->lastInsertId();
}
$db->query("INSERT INTO dons
(datec,
user_id,
somme,
lang,
abo,
public,
status)
VALUES
(now(),
'".\Utils::asl($user_id)."',
'".\Utils::asl($somme)."',
'".\Utils::asl($lang)."',
'".\Utils::asl($abo)."',
'".\Utils::asl($public)."',
1)");
(datec,
user_id,
somme,
lang,
abo,
public,
status)
VALUES
(now(),
'".\Utils::asl($user_id)."',
'".\Utils::asl($somme)."',
'".\Utils::asl($lang)."',
'".\Utils::asl($abo)."',
'".\Utils::asl($public)."',
1)");
// Récupération de l'id pour passage en mode édition
$id = $db->lastInsertId();
} else {
// We will get the ids associated to the gift first
$result = $db->query("SELECT adresse_id,
user_id
FROM dons
WHERE id = ".\Utils::asl($f3->get('POST.id')));
user_id
FROM dons
WHERE id = ".\Utils::asl($f3->get('POST.id')));
$result = $result->fetch(\PDO::FETCH_ASSOC);
// Let's update the adresse first or create the adress
$db->query("UPDATE users
SET email='".\Utils::asl($email)."',
pseudo='".\Utils::asl($pseudo)."'
WHERE id={$result['user_id']}");
SET email='".\Utils::asl($email)."',
pseudo='".\Utils::asl($pseudo)."'
WHERE id={$result['user_id']}");
$db->query("UPDATE dons
SET somme='".\Utils::asl($somme)."',
lang='".\Utils::asl($lang)."',
abo='".\Utils::asl($abo)."',
public='".\Utils::asl($public)."',
adresse_id='".$result['adresse_id']."'
WHERE id='".\Utils::asl($_POST['id'])."'");
SET somme='".\Utils::asl($somme)."',
lang='".\Utils::asl($lang)."',
abo='".\Utils::asl($abo)."',
public='".\Utils::asl($public)."',
adresse_id='".$result['adresse_id']."'
WHERE id='".\Utils::asl($_POST['id'])."'");
}
}
}
......@@ -304,17 +305,17 @@ class Admin extends Controller
if ($id!='') {
// Récupération du don, de l'adresse et de l'utilisateur
$result = $db->query("SELECT d.id AS id,
u.email AS email,
u.pseudo AS pseudo,
d.somme AS somme,
d.lang AS lang,
d.abo AS abo,
d.public AS public,
d.adresse_id AS adresse_id,
d.user_id AS user_id
FROM dons d
JOIN users u ON u.id = d.user_id
WHERE d.id=".$id);
u.email AS email,
u.pseudo AS pseudo,
d.somme AS somme,
d.lang AS lang,
d.abo AS abo,
d.public AS public,
d.adresse_id AS adresse_id,
d.user_id AS user_id
FROM dons d
JOIN users u ON u.id = d.user_id
WHERE d.id=".$id);
$don = $result->fetch(\PDO::FETCH_ASSOC);
} else {
$don = array(
......@@ -350,10 +351,10 @@ class Admin extends Controller
}
// Calcul des quantités
$query = "SELECT quoi,
status,
COUNT(status) AS qte
FROM contreparties
GROUP BY quoi, status;";
status,
COUNT(status) AS qte
FROM contreparties
GROUP BY quoi, status;";
$result = $db->query($query);
if ($result) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
......@@ -366,10 +367,10 @@ class Admin extends Controller
$f3->set('hoodie_t'.$i, 0);
}
$query = "SELECT quoi,
taille,
COUNT(taille) AS qte
FROM contreparties
GROUP BY quoi, taille;";
taille,
COUNT(taille) AS qte
FROM contreparties
GROUP BY quoi, taille;";
$result = $db->query($query);
if ($result) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
......@@ -428,34 +429,34 @@ class Admin extends Controller
}
$query = "SELECT c.id,
c.datec as datec,
c.quoi as quoi,
c.taille as taille,
c.status as status,
c.user_id as user_id,
u.email as email,
u.pseudo as pseudo,
u.commentaire as commentaire,
a.nom as nom,
a.adresse as adresse,
a.adresse2 as adresse2,
a.codepostal as codepostal,
a.ville as ville,
a.pays as pays
FROM contreparties c
INNER JOIN users u ON c.user_id = u.id
INNER JOIN adresses a ON c.adresse_id = a.id
WHERE 1=1 ";
c.datec as datec,
c.quoi as quoi,
c.taille as taille,
c.status as status,
c.user_id as user_id,
u.email as email,
u.pseudo as pseudo,
u.commentaire as commentaire,
a.nom as nom,
a.adresse as adresse,
a.adresse2 as adresse2,
a.codepostal as codepostal,
a.ville as ville,
a.pays as pays
FROM contreparties c
INNER JOIN users u ON c.user_id = u.id
INNER JOIN adresses a ON c.adresse_id = a.id
WHERE 1=1 ";
if ($texte) {
$query .= " AND (c.id like '%".$texte."%'
OR u.pseudo like '%".$texte."%'
OR u.email like '%".$texte."%'
OR a.nom like '%".$texte."%'
OR a.ville like '%".$texte."%'
OR a.pays like '%".$texte."%'
OR a.codepostal like '%".$texte."%'
OR a.adresse2 like '%".$texte."%'
OR a.adresse like '%".$texte."%')";
OR u.pseudo like '%".$texte."%'
OR u.email like '%".$texte."%'
OR a.nom like '%".$texte."%'
OR a.ville like '%".$texte."%'
OR a.pays like '%".$texte."%'
OR a.codepostal like '%".$texte."%'
OR a.adresse2 like '%".$texte."%'
OR a.adresse like '%".$texte."%')";
}
switch ($quoi) {
case 0:
......@@ -474,19 +475,19 @@ class Admin extends Controller
break;
default:
$query .= " AND datec IN (
SELECT datec
FROM contreparties
WHERE status=1
GROUP BY user_id, datec
HAVING SUM(
CASE quoi
WHEN 'pibag' THEN 1
WHEN 'piplome' THEN 2
WHEN 'pishirt' THEN 4
WHEN 'hoodie' THEN 8
END
)=$quoi)
";
SELECT datec
FROM contreparties
WHERE status=1
GROUP BY user_id, datec
HAVING SUM(
CASE quoi
WHEN 'pibag' THEN 1
WHEN 'piplome' THEN 2
WHEN 'pishirt' THEN 4
WHEN 'hoodie' THEN 8
END
)=$quoi)
";
}
if ($status) {
$query .= " AND c.status IN (".\Utils::asl($status).") ";
......@@ -501,11 +502,11 @@ class Admin extends Controller
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
if ($row['quoi']=='piplome') {
$pdf = $db->query("SELECT d.id AS id,
a.nom AS pseudo,
d.pdf AS pdf
FROM dons d
JOIN adresses a ON a.id = d.adresse_id
WHERE d.id='".$row['taille']."'");
a.nom AS pseudo,
d.pdf AS pdf
FROM dons d
JOIN adresses a ON a.id = d.adresse_id
WHERE d.id='".$row['taille']."'");
if ($pdf) {
$pdf = $pdf->fetch(\PDO::FETCH_ASSOC);
}
......@@ -635,38 +636,38 @@ class Admin extends Controller
if ($id!='') {
// First, let's retrieve the adresse from the adresse_id if it exists
$result = $db->query("SELECT adresse_id
FROM contreparties
WHERE id = '".\Utils::asl($f3->get('POST.id'))."'
AND adresse_id IS NOT NULL");
FROM contreparties
WHERE id = '".\Utils::asl($f3->get('POST.id'))."'
AND adresse_id IS NOT NULL");
$result = $result->fetch(\PDO::FETCH_ASSOC);
$adresse_id = $result['adresse_id'];
if (!$adresse_id or $adresse_id == 0) {
// We need to create an adresse_id
$db->query("INSERT INTO adresses
VALUES (nom='".\Utils::asl($nom)."',
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."')");
VALUES (nom='".\Utils::asl($nom)."',
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."')");
$adresse_id = $db->lastInsertId();
} else {
// Updating the adresses first
$db->query("UPDATE adresses
SET nom='".\Utils::asl($nom)."',
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."'
adresse='".\Utils::asl($adresse)."',
adresse2='".\Utils::asl($adresse2)."',
codepostal='".\Utils::asl($codepostal)."',
ville='".\Utils::asl($ville)."',
pays='".\Utils::asl($pays)."'
WHERE id = $adresse_id");
};
$db->query("UPDATE contreparties
SET quoi='".\Utils::asl($quoi)."',
taille='".\Utils::asl($taille)."',
status='".\Utils::asl($status)."'
WHERE id='".\Utils::asl($_POST['id'])."'");
SET quoi='".\Utils::asl($quoi)."',
taille='".\Utils::asl($taille)."',
status='".\Utils::asl($status)."'
WHERE id='".\Utils::asl($_POST['id'])."'");
// We will update the comment
$db->query("UPDATE users SET commentaire='".\Utils::asl($comment)."' WHERE id='".\Utils::asl($user_id)."'");
}
......@@ -693,13 +694,13 @@ class Admin extends Controller
$pdfs = array();
if ($contrepartie['quoi']=='piplome') {
$result = $db->query("SELECT d.id AS id,
d.pdf AS pdf,
a.nom AS nom
FROM dons d
INNER JOIN adresses a ON d.adresse_id = a.id
WHERE pdf<>''
AND d.status IN (1,4,101)
AND d.user_id='".$contrepartie['user_id']."'");
d.pdf AS pdf,
a.nom AS nom
FROM dons d
INNER JOIN adresses a ON d.adresse_id = a.id
WHERE pdf<>''
AND d.status IN (1,4,101)
AND d.user_id='".$contrepartie['user_id']."'");
if ($result) {
foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $pdf) {
$pdfs[] = $pdf;
......@@ -857,7 +858,7 @@ class Admin extends Controller
$query = "SELECT id, email, expiration, status FROM users WHERE identifier!='' AND identifier IS NOT NULL AND status != ''";
if ($texte!='') {
$query .= " AND (email like '%".$texte."%'
OR pseudo like '%".$texte."%')";
OR pseudo like '%".$texte."%')";
}
if ($status!='') {
$query .= " AND status='".$status."'";
......@@ -1037,12 +1038,12 @@ class Admin extends Controller
$db->query("UPDATE identifiers SET expiration='".$expire. "' WHERE identifier='".$identifier."'");
if ($expire_date<$today_date) {
$db->query("INSERT INTO dons SET
status = '103',
datec = NOW(),
somme = 0,
user_id = '" .$user_id ."',
identifier = '" . $identifier ."',
cumul = 0;");
status = '103',
datec = NOW(),
somme = 0,
user_id = '" .$user_id ."',
identifier = '" . $identifier ."',
cumul = 0;");
}
}
}
......@@ -1236,14 +1237,14 @@ class Admin extends Controller
));
// Pour un don récurrent, on recherche son équivalent qui peut ne pas exister
$result = $db->query("SELECT email
FROM users
JOIN identifiers
ON users.id = identifiers.user_id
AND identifiers.identifier='".$identifier. "'");
FROM users
JOIN identifiers
ON users.id = identifiers.user_id
AND identifiers.identifier='".$identifier. "'");
if ($result->rowCount() == 0) {
// Identifier does not exist, we must create it. We have either a pseudo or an email.
$user_field = explode("_", $identifier)[1];
$user = 'asfhjk';
$user = '';
if (strpos($user_field, '@')) {
// identifier is an email
......@@ -1271,35 +1272,50 @@ class Admin extends Controller
} else {
$emails[$email] = 1;
}
// On a besoin de l'utilisateur
$user = $f3->get('container')['user_finder']->findByEmail($email);
// Récupération de l'id du bon abonnement
$result = $db->query("SELECT d.id AS id
$stmt = $db->query("SELECT d.id AS id
FROM dons d
JOIN users u ON u.id = d.user_id
WHERE u.email='".$email. "'
WHERE u.email='".$email."'
AND d.status=101
AND d.id='".$transaction."' ");
print_r($result);
if ($result->rowCount() > 0) {
AND d.id=".$transaction);
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$result) {
// don non trouvé en statut 101. On le crée (la banque à raison)
// statut = cumul
$f3->get('container')['command_handler']
->handle(new DonationCreateCommand(
$user['id'],
101,
$new_effect,
$amount,
0,
0
));
// Et on le récupère
$cumul = $db->lastInsertId();
$don = $f3->get('container')['donation_finder']->findById($cumul);
} else {
$cumul = $result->fetch(\PDO::FETCH_ASSOC);
$cumul = $result['id'];
if ($cumul!='') {
$result = $db->query("SELECT COUNT(1)
FROM dons d
JOIN users u ON u.id = d.user_id
WHERE u.email='".$email. "'
AND d.status=102
AND d.datec='".$new_effect."'
AND d.cumul=".$cumul."
");
if ($result) {
$combien = $result->fetch();
if ($combien[0]==0) {
$update ++;
// Don récurrent non comptabilisé, on l'ajoute
$user_id = $db->query("SELECT id FROM users WHERE email='$email'");
$user_id = $user_id->fetch(\PDO::FETCH_ASSOC);
$user_id = $user_id['id'];
$query = "INSERT INTO dons (status,
}
// On regarde si le don n'as pas déjà été ajouté (en vérifiant la datec)
$result = $db->query("SELECT COUNT(1)
FROM dons d
JOIN users u ON u.id = d.user_id
WHERE u.email='".$email. "'
AND d.status=102
AND d.datec='".$new_effect."'
AND d.cumul=".$cumul."
");
if ($result) {
$combien = $result->fetch();
if ($combien[0]==0) {
$update ++;
// Don récurrent non comptabilisé, on l'ajoute
$query = "INSERT INTO dons (status,
datec,
somme,
user_id,
......@@ -1309,23 +1325,19 @@ class Admin extends Controller
102,
'".$new_effect."',
".$amount.",
'".$user_id."',
'".$user['id']."',
'".$cumul."',
'".$identifier."')";
if (!$testing) {
$db->query($query);
// On met alors à jour le cumul et le total de l'utilisateur concerné
$result = $db->query("UPDATE users
if (!$testing) {
$db->query($query);
// On met alors à jour le cumul et le total de l'utilisateur concerné
$result = $db->query("UPDATE users
SET cumul=cumul+".$amount.",
total=total+".$amount."
WHERE id='".$user_id."'");
}
} else {
$comptabilise[] = $identifier;
}
WHERE id='".$user['id']."'");
}
} else {
$sans_cumul[] = $email;
$comptabilise[] = $identifier;
}
}
}
......@@ -1339,6 +1351,7 @@ class Admin extends Controller
return $datas;
}
public function stats($f3, $args)
{
$startingDay = new \DateTime('2014-11-12');
......
......@@ -70,7 +70,7 @@ class DonationSeeder extends AbstractSeed
array(
'id' => 3,
'status' => 100,
'datec' => '2016-06-10 12:34',
'datec' => '2016-06-11 12:34',
'somme' => 100,
'lang' => 'fr_FR',
'cadeau' => 1,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: LQDNCampaign 2016.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-19 07:29+0200\n"
"POT-Creation-Date: 2018-11-19 14:57+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -16,286 +16,116 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: app/Controller.php:68 app/Controller.php:69 app/Controller.php:70
#: app/Controller.php:71 app/Controller.php:76 app/Admin.php:44
#: app/Admin.php:45 app/Admin.php:46 app/Admin.php:47 app/Admin.php:52
msgid "Coupe Homme, Taille"
msgstr ""
#: app/Controller.php:72 app/Controller.php:73 app/Controller.php:74
#: app/Controller.php:75 app/Controller.php:77 app/Admin.php:48
#: app/Admin.php:49 app/Admin.php:50 app/Admin.php:51 app/Admin.php:53
msgid "Coupe Femme, Taille"
msgstr ""
#: app/Perso.php:157
msgid "Mauvais identifiant ou mot de passe."
msgstr ""
#: app/Perso.php:162 app/Perso.php:238 app/Perso.php:265
msgid "Merci de renseigner une adresse mail."
msgstr ""
#: app/Perso.php:196
msgid "Renouvellement de mot de passe"
msgstr ""
#: app/Perso.php:202
#, php-format
msgid ""
"Bonjour,\n"
"\n"
" Un nouveau mot de passe vient de vous être attribuer "
"pour pouvoir vous connecter à votre page d'administration pour choisir vos "
"contreparties, et nous indiquer vos coordonnées :\n"
" %%URL_ADMIN%%\n"
" Identifiant : votre adresse email\n"
" Mot de passe : %%PASSWORD%%\n"
"\n"
" Encore merci pour votre soutien,\n"
" Toute l'équipe de La Quadrature du Net\n"
" "
msgstr ""
#: app/Perso.php:228
msgid "Nouveau mot de passe envoyé par mail."
msgstr ""
#: app/Perso.php:231
msgid "Oops"
msgstr ""
#: app/Perso.php:235
msgid "Vous n'avez pas encore de compte, merci de faire un don pour cela."
msgstr ""
#: app/Perso.php:262
msgid ""
"Vous avez déjà un compte associé à cette adresse mail, merci de demander un "
"nouveau mot de passe."
msgstr ""
#: app/Perso.php:290
msgid "Informations personnelles modifiées."
msgstr ""
#: app/Perso.php:319
msgid "Cette adresse existe déjà."
msgstr ""
#: app/Perso.php:348
msgid ""
"Cette adresse est utilisée et il vous n'avez pas définit d'adresse par "
"défault."
msgstr ""
#: app/Perso.php:408
msgid "Merci, vos contreparties seront envoyées dès que possible&nbsp;!"
msgstr ""
#: app/Perso.php:455
msgid "Janvier"
msgstr ""
#: app/Perso.php:456
msgid "Février"
msgstr ""
#: app/Perso.php:457
msgid "Mars"
msgstr ""
#: app/Perso.php:458
msgid "Avril"
msgstr ""
#: app/Perso.php:459
msgid "Mai"
msgstr ""
#: app/Perso.php:460
msgid "Juin"
msgstr ""
#: app/Perso.php:461
msgid "Juillet"
msgstr ""
#: app/Perso.php:462
msgid "Août"
msgstr ""
#: app/Perso.php:463
msgid "Septembre"
msgstr ""
#: app/Perso.php:464
msgid "Octobre"
msgstr ""
#: app/Perso.php:465
msgid "Novembre"
msgstr ""
#: app/Perso.php:466
msgid "Décembre"
msgstr ""
#: app/Bank.php:175
msgid "Merci de soutenir La Quadrature du Net !"
msgstr ""
#: app/Bank.php:179
#, php-format
msgid ""
"\n"
"Cher·e %%NAME%%,\n"
"\n"
"Toute l'équipe de La Quadrature vous remercie du fond du cœur pour votre "
"soutien à ses actions !\n"
"\n"
"Connectez-vous à votre page d'administration pour choisir vos contreparties, "
"et nous indiquer vos coordonnées :\n"
"%%URL_ADMIN%%\n"
"Identifiant : votre adresse email\n"
"\n"
"Grâce à vous et aux nombreux bénévoles qui agissent aux côtés de "
"l'association au quotidien, La Quadrature continuera à analyser, prendre "
"position, débattre, alerter, mobiliser, pour qu'Internet reste un espace de "