#!/bin/bash
 # include modpatch function
 . ${include_modpatch}
# is no ISTN Terminal equiptment "TE"
DIRII="usr/www/${HTML}/de/fon_config"
if  [ -f "$1"/$DIRII/fon_config_msn.html ]; then
    #remove auswal Analog / ISDN
    #.76 variante
    if `cat $1/${DIRII}/fon_config_msn.html | grep -q 'Isdn' ` ; then  
	echo2 "  -- remove ISDN option from Festnetzmenue"
	sed -i -e "/uiIsdn/,/<\/div>/d" "$1"/${DIRII}/fon_config_msn.html
	sed -i -e "/die Art Ihres Festnetzanschlusses aus/d" "$1"/${DIRII}/fon_config_msn.html
	sed -i -e "/uiViewIsdn/d" "$1"/${DIRII}/fon_config_msn.html
    fi
fi
DIRI="usr/www/${HTML}/de/home" 
if ! [ -f "$1"/$DIRI/msn.html ]; then
   DIRI="usr/www/${HTML}/de/fon"
fi
if  [ -f "$1"/$DIRI/msn.html ]; then
    #remove auswal Analog / ISDN
    #all in one 11945 varinate
    if `cat $1/${DIRI}/msn.html | grep -q 'uiIsdn' ` ; then  
	echo2 "  -- remove ISDN option from Festnetzmenue"
	sed -i -e "/uiIsdn/,/usePSTN/d" "$1"/${DIRI}/msn.html
	sed -i -e "/die Art Ihres Festnetzanschlusses aus/d" "$1"/${DIRI}/msn.html
	sed -i -e "/uiViewIsdn/d" "$1"/${DIRI}/msn.html
    fi

    #older versions
    if `cat $1/${DIRI}/msn.html | grep -q 'Text15' ` ; then  
	echo2 "   -- Remove ISDN option from Festnetzmenue"
	sed -i -e "/Text15/d" "$1"/${DIRI}/msn.html
	sed -i -e "/uiViewIsdn/d" "$1"/${DIRI}/msn.html
    fi
fi
    #on load display Analog
if  [ -f "$1"/$DIRI/msn.js ]; then
    if `cat $1/${DIRI}/msn.html | grep -q 'uiOnArt(n)' ` ; then  
	sed -i -e "s/uiOnArt(n);/uiOnArt(1);/" "$1"/${DIRI}/msn.js
	echo2 "   ${DIRI}/msn.js"
    fi
fi
# added for W501 W701 remove ISDN from callthough page, still usable on all in one 

DIRI="usr/www/${HTML}/de/fon/durchwahl."
if  [ -f "$1"/${DIRI}htm ]; then
 if `cat $1/${DIRI}html | grep -q 'uiViewArtIsdn' ` ; then  
  sed -i -e 's|<input.*id="uiViewArtIsdn".*<br>|<input type="hidden" name="OnArt" id="uiViewArtIsdn" onload="OnChangeOnArt(0)"><br>|' "$1/${DIRI}html"
  sed -i -e 's|<label for="uiViewArtNummer">.*</p>|<input type="hidden" id="uiViewArtNummer"></p>|' "$1/${DIRI}html"
  sed -i -e 's|onclick="OnChangeOnArt(0)|onload="OnChangeOnArt(0)|' "$1/${DIRI}html"
  sed -i -e 's|OnChangeOnArt(1)|OnChangeOnArt(0)|' "$1/${DIRI}html"
  echo2 "      ${DIRI}html"
 fi
fi
if  [ -f "$1"/${DIRI}js ]; then
 if `cat $1/${DIRI}js | grep -q 'OnChangeOnArt(1)' ` ; then  
  sed -i -e 's|OnChangeOnArt(1)|OnChangeOnArt(0)|' "$1/${DIRI}js"
  echo2 "      ${DIRI}js"
 fi
fi
if  [ -f "$1"/${DIRI}inc ]; then
 if `cat $1/${DIRI}inc | grep -q 'ISDN/' ` ; then  
  sed -i -e 's|ISDN/||' "$1/${DIRI}inc"
  echo2 "      ${DIRI}inc"
 fi
fi
# older help text not in use on all in one
if  [ -f "$1"/usr/www/${HTML}/de/help/hilfe_fon_festnetz.html ]; then
    echo2 "      /usr/www/${HTML}/de/help/hilfe_fon_nebenstelle.html"
    sed -i -e "/W.hlen Sie die Art Ihres Festnetzanschlusses aus/d" "$1"/usr/www/${HTML}/de/help/hilfe_fon_festnetz.html
    sed -i -e "s/Ihre ISDN-Rufnummern oder //" "$1"/usr/www/${HTML}/de/help/hilfe_fon_festnetz.html
    sed -i -e "s/die dafür vorgesehenen Felder/das dafür vorgesehene Feld/" "$1"/usr/www/${HTML}/de/help/hilfe_fon_festnetz.html
    #all in one
    sed -i -e "s/die da.* vorgesehenen Felder/das vorgesehene Feld/" "$1"/usr/www/${HTML}/de/help/hilfe_fon_festnetz.html
fi

exit 0