@echo off

rem ------------------------------------------------------------
rem SET VARIABLES
rem ------------------------------------------------------------

set ZTAPPSDIR=\Flash Disk\ZTApps
set TEMPLATESDIR=Templates
set OLD_DOCUMENTS_PLUGIN=\Flash Disk\WorkFlowAT\Plugins\HRTotem_Documenti.dll

rem ------------------------------------------------------------
rem START PROCEDURE
rem ------------------------------------------------------------

echo ----------------------------------------
echo ---------  Zucchetti - ZTApps  ---------
echo ----------------------------------------
echo Performing installation tasks ...

del "\Flash Disk\ZTApps\ZTApps.exe.config"
del "\Flash Disk\ZTApps\SQLite.Interop.087.dll"

rem ------------------------------------------------------------
rem STARTUP
rem ------------------------------------------------------------

echo Handling startup links ...

del "\Flash Disk\Startup\*.lnk"
copy "\Temp\work\Startup\*.lnk" "\Flash Disk\Startup\"

rem ------------------------------------------------------------
rem PRINT TEMPLATES
rem ------------------------------------------------------------

echo Installing missing print templates ...

if not exist "%ZTAPPSDIR%\%TEMPLATESDIR%\TandA.txt"     copy "%ZTAPPSDIR%\%TEMPLATESDIR%\TandA_template.txt"     "%ZTAPPSDIR%\%TEMPLATESDIR%\TandA.txt"
if not exist "%ZTAPPSDIR%\%TEMPLATESDIR%\HM3.txt"       copy "%ZTAPPSDIR%\%TEMPLATESDIR%\HM3_template.txt"       "%ZTAPPSDIR%\%TEMPLATESDIR%\HM3.txt"
if not exist "%ZTAPPSDIR%\%TEMPLATESDIR%\HM3_DELIV.txt" copy "%ZTAPPSDIR%\%TEMPLATESDIR%\HM3_DELIV_template.txt" "%ZTAPPSDIR%\%TEMPLATESDIR%\HM3_DELIV.txt"

rem ------------------------------------------------------------
rem OLD DOCUMENT PLUGIN (WorkFlowAT)
rem ------------------------------------------------------------

if not exist "%OLD_DOCUMENTS_PLUGIN%" goto WORKFLOW_END

echo WorkFlowAT handling ...
del /F /Q "%OLD_DOCUMENTS_PLUGIN%"
echo WorkFlowAT Documents plugin succesfully removed.

:WORKFLOW_END

rem ------------------------------------------------------------
rem RESTART
rem ------------------------------------------------------------

echo installation tasks completed.
rem pause

restart.exe
