gestion/controle_cotisation/get_impayes.sh

13 lines
708 B
Bash
Executable File

#!/bin/bash
PASSWORD=$(cat ~/.secret/gestion_api_password)
requete_impaye=$(curl https://api666:$PASSWORD@gestion.a-lec.org/api/sql/ -s -d 'SELECT id_user FROM
services_users su
INNER JOIN membres m ON m.id = su.id_user
INNER JOIN services s ON s.id = su.id_service
LEFT JOIN services_fees sf ON sf.id = su.id_fee
INNER JOIN (SELECT id, MAX(date) FROM services_users GROUP BY id_user, id_service) AS su2 ON su2.id = su.id
WHERE su.id_service = 1 AND su.paid = 0 AND NOT (m.id_category = 10 OR m.id_category = 3 OR m.id_category = 2 OR m.id_category = 8);')
# Note: su.id_service = 1 parceque la cotisation correspond au service 1
echo $requete_impaye | tr "," "\n" | sed 's/[^[:digit:]]\+//g' | tr "\n" " "