#!/bin/sh

SRCDIR=/opt/fah/folding
DESTDIR=/var/www/html

cd $DESTDIR
mkdir -p DK_proof

# To have the DATE in a good format
CURRENT_DATE=$(date +"%Y%m%d")
# echo "DATE=$CURRENT_DATE"

# Adding the date to the name of files
\cp -f Zebulon.html DK_proof/${CURRENT_DATE}_Zebulon.html
\cp -f Zebulon.txt DK_proof/${CURRENT_DATE}_Zebulon.txt
\cp -f miniteam.html DK_proof/${CURRENT_DATE}_miniteam.html
\cp -f Alliance.html DK_proof/${CURRENT_DATE}_Alliance.html
\cp -f Alliance.txt DK_proof/${CURRENT_DATE}_Alliance.txt
\cp -f message.html DK_proof/${CURRENT_DATE}_message.html
\cp -f team51.txt DK_proof/${CURRENT_DATE}_team51.txt
#\cp -f AllTeam51.txt DK_proof/${CURRENT_DATE}_AllTeam51.txt
#\cp -f Non-associes.txt DK_proof/${CURRENT_DATE}_Non-associes.txt
\cp -f topprod.html DK_proof/${CURRENT_DATE}_topprod.html
\cp -f effectif.html DK_proof/${CURRENT_DATE}_effectif.html

# Adding the graphs in DK_proof.7z
mkdir -p DK_proof/${CURRENT_DATE}_graphs
\cp -f graphique1.png DK_proof/${CURRENT_DATE}_graphs/graphique1.png
\cp -f graphique1a.png DK_proof/${CURRENT_DATE}_graphs/graphique1a.png
\cp -f graphique2.png DK_proof/${CURRENT_DATE}_graphs/graphique2.png
\cp -f graphique2a.png DK_proof/${CURRENT_DATE}_graphs/graphique2a.png
\cp -f graphique2b.png DK_proof/${CURRENT_DATE}_graphs/graphique2b.png
\cp -f graphique3.png DK_proof/${CURRENT_DATE}_graphs/graphique3.png
\cp -f graphique3a.png DK_proof/${CURRENT_DATE}_graphs/graphique3a.png
\cp -f graphique3b.png DK_proof/${CURRENT_DATE}_graphs/graphique3b.png
\cp -f graphique4.png DK_proof/${CURRENT_DATE}_graphs/graphique4.png
\cp -f graphique4a.png DK_proof/${CURRENT_DATE}_graphs/graphique4a.png
\cp -f graphique4b.png DK_proof/${CURRENT_DATE}_graphs/graphique4b.png
\cp -f graphique5.png DK_proof/${CURRENT_DATE}_graphs/graphique5.png
\cp -f graphs.html DK_proof/${CURRENT_DATE}_graphs/${CURRENT_DATE}_graphs.html

jour=$(date +"%u")

# echo "Aujourd'hui = $jour"

if [ "$jour" = "0" ]; then
  # Dimanche
  $SRCDIR/go_Dimanche.sh ${CURRENT_DATE}

  # Pays
  \cp -f Belge.html DK_proof/${CURRENT_DATE}_Belge.html
  \cp -f Belge.txt DK_proof/${CURRENT_DATE}_Belge.txt
  \cp -f France.html DK_proof/${CURRENT_DATE}_France.html
  \cp -f France.txt DK_proof/${CURRENT_DATE}_France.txt
  \cp -f Quebec.html DK_proof/${CURRENT_DATE}_Quebec.html
  \cp -f Quebec.txt DK_proof/${CURRENT_DATE}_Quebec.txt
  \cp -f Suisse.html DK_proof/${CURRENT_DATE}_Suisse.html
  \cp -f Suisse.txt DK_proof/${CURRENT_DATE}_Suisse.txt

  # Autres
  \cp -f meilleur.html DK_proof/${CURRENT_DATE}_meilleur.html
  \cp -f score2.html DK_proof/${CURRENT_DATE}_score2.html
  \cp -f score3.html DK_proof/${CURRENT_DATE}_score3.html
  \cp -f score4.html DK_proof/${CURRENT_DATE}_score4.html
fi

7z a -y DK_proof.7z DK_proof
rm -Rf DK_proof

