121 lines
4.1 KiB
Bash
121 lines
4.1 KiB
Bash
|
#!/bin/bash
|
||
|
# Make Billet fabrique l'image de 6 billets de monnaie libre
|
||
|
# Date de validité de 6 mois à compter du premier jour du mois courant
|
||
|
############################################################################
|
||
|
# INSTALLER convert et qrencode: sudo apt install imagemagick qrencode
|
||
|
# IMPRIMANTE (http://smspi:631/) : sudo apt install printer-driver-all cups
|
||
|
# https://junise.wordpress.com/2015/04/12/install-online-cups-printer-in-raspberry-pi/
|
||
|
############################################################################
|
||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||
|
# TEST:
|
||
|
# ./shell/sms_BILLET_MAKE.sh "nu me ro test" "se cr et" 100 LOVE 10.04 "https://g1sms.fr" G1SMS TEST
|
||
|
############################################################################
|
||
|
source "./shell/init.sh"
|
||
|
source "./shell/functions.sh"
|
||
|
|
||
|
NUMERO="$1"
|
||
|
SECRET="$2"
|
||
|
MONTANT="$3"
|
||
|
UNIT="$4"
|
||
|
DUFACTOR="$5"
|
||
|
NOTERIB="$6"
|
||
|
MEMBER="$7"
|
||
|
TRANSAC="$8"
|
||
|
log "X ./shell/sms_BILLET_MAKE.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$8\""
|
||
|
|
||
|
if [[ "$NOTERIB" == "" || "$MEMBER" == "" ]]
|
||
|
then
|
||
|
log "ERROR MAKE BILLET"
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
# VALIDITY? Calculate 6 month period dates
|
||
|
cm=$(date +%m)
|
||
|
cy=$(date +%Y)
|
||
|
valid=$(bc <<< "$cm + 6")
|
||
|
if [ $valid -gt 12 ]
|
||
|
then
|
||
|
valid=$(bc <<< "$valid - 12")
|
||
|
year=$(bc <<< "$cy + 1")
|
||
|
else
|
||
|
year=$cy
|
||
|
fi
|
||
|
valid="0${valid:0:2}"
|
||
|
# ADD VALIDITY to convert: -pointsize 20 -draw 'text 380,410 "'"A encaisser avant le 01/$valid/$year"'"' \
|
||
|
|
||
|
# Add G1sms logo (250px)
|
||
|
composite -compose Over -gravity SouthWest -geometry +50+50 "./shell/G1sms.png" "./shell/Oeuro.jpg" "/tmp/$NUMERO.jpg"
|
||
|
|
||
|
# Prepare BILLET qrcode verification URL
|
||
|
#qrencode "$NOTERIB" -o "/tmp/$NUMERO_NOTERIB.png"
|
||
|
REQ=$(echo $NUMERO | sed 's/ /_/g')
|
||
|
qrencode "https://www.g1sms.fr/$ADMINPSEUDO/check.php?code=$REQ" -o "/tmp/$NUMERO_NOTERIB.png"
|
||
|
|
||
|
# BILL PUBKEY => Someone can Add amount to it !!!
|
||
|
# Add verification QRCode
|
||
|
composite -compose Over -gravity NorthEast -geometry +40+40 "/tmp/$NUMERO_NOTERIB.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||
|
|
||
|
# Add June logo
|
||
|
case "$MONTANT" in
|
||
|
10)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill grey -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
20)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill green -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
50)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill orange -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
100)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill blue -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
200)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill purple -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
500)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill red -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
1000)
|
||
|
convert "./shell/g1.png" -fuzz 20% -fill black -opaque '#e5912b' "/tmp/g1.png"
|
||
|
;;
|
||
|
*)
|
||
|
cp "./shell/g1.png" "/tmp/g1.png"
|
||
|
;;
|
||
|
esac
|
||
|
composite -compose Over -gravity SouthEast -geometry +20+20 "/tmp/g1.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||
|
|
||
|
DUPART=$(bc -l <<< "scale=2; $MONTANT / 100")
|
||
|
# ADD 0 to <1 DUPART
|
||
|
testdu=$( echo "${DUPART} < 1" | bc -l )
|
||
|
if [[ "$testdu" -eq "1" ]]; then
|
||
|
DUPART="0${DUPART}"
|
||
|
fi
|
||
|
#SECRET=$(echo $SECRET | sed 's/ /\n/g')
|
||
|
|
||
|
convert -font 'Liberation-Sans' \
|
||
|
-pointsize 120 -fill black -draw 'text 200,220 "'"$DUPART DU"'"' \
|
||
|
-pointsize 45 -draw 'text 550,270 "'"$MONTANT $UNIT"'"' \
|
||
|
-pointsize 35 -draw 'text 50,60 "'"[G1sms] 06 66 80 57 20"'"' \
|
||
|
-pointsize 30 -draw 'text 60,100 "'"CHK $NUMERO"'"' \
|
||
|
-pointsize 22 -fill black -draw 'text 520,340 "'"$SECRET"'"' \
|
||
|
-pointsize 22 -fill black -draw 'text 400,410 "'"Encaisser avant le 01/$valid/$year"'"' \
|
||
|
-pointsize 20 -draw 'text 50,444 "'"Envoyer par sms, CHK $NUMERO + les mots découverts sous la zone à gratter"'"' \
|
||
|
"/tmp/$NUMERO.jpg" "/tmp/BILL.$year.$valid.$NUMERO.$MONTANT.$UNIT.jpg"
|
||
|
|
||
|
# Payable par SMS en envoyant les codes grattant la case comportant le SECRET
|
||
|
# "CHK $NUMERO $SECRET"
|
||
|
|
||
|
if [[ "$TRANSAC" == "TEST" ]]; then
|
||
|
exit
|
||
|
else
|
||
|
# Move billet to MEMBER folder 6 month later
|
||
|
mkdir -p "./billets/MEMBERS/$MEMBER/"
|
||
|
mv "/tmp/BILL.$year.$valid.$NUMERO.$MONTANT.$UNIT.jpg" "./billets/MEMBERS/$MEMBER/"
|
||
|
# Clean TEMP files
|
||
|
rm "/tmp/$NUMERO_NOTERIB.png"
|
||
|
rm "/tmp/$NUMERO.jpg"
|
||
|
fi
|
||
|
|
||
|
log "END sms_BILLET_MAKE.sh"
|
||
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|