home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 December / Chip_2000-12_cd1.bin / tema / amadea / inc / global.asi < prev    next >
Encoding:
Text File  |  2000-03-26  |  4.3 KB  |  176 lines

  1. <%
  2.   if (!Application("Started") || !Session("Started"))
  3.     {
  4. %>
  5.       <!-- #INCLUDE FILE="../global.asa" -->
  6. <%
  7.       if (!Application("Started")) Application_OnStart();
  8.       if (!Session("Started")) Session_OnStart();
  9.     };
  10. %>
  11.  
  12.  
  13. <%
  14.   function calcDeduc(price)
  15.   {
  16.   sleva = Application("sleva");
  17.   return Math.ceil(price * sleva / 100.0);
  18.   };
  19.  
  20.   function bookingKindToText(kind)
  21.   {
  22.     kindDobirka = Application("kindDobirka");
  23.     kindPrevod = Application("kindPrevod");
  24.     switch ("".concat(kind).toLowerCase())
  25.     {
  26.       case kindDobirka.toLowerCase(): return "Dobφrka";
  27.       case kindPrevod.toLowerCase(): return "Bankovnφ p°evod";
  28.       default: return "< NEZN┴M▌ >";
  29.     };
  30.   };
  31.  
  32.   function ordStav(state)
  33.   {
  34.     statZalozena = Application("statZalozena");
  35.     statAkceptovana = Application("statAkceptovana");
  36.     statVypis = Application("statVypis");
  37.     statNaCeste = Application("statNaCeste");
  38.     statVyrizena = Application("statVyrizena");
  39.  
  40.     switch ("".concat(state).toLowerCase())
  41.     {
  42.       case statZalozena.toLowerCase(): return 0
  43.       case statAkceptovana.toLowerCase(): return 1
  44.       case statVypis.toLowerCase(): return 2
  45.       case statNaCeste.toLowerCase(): return 3
  46.       case statVyrizena.toLowerCase(): return 4
  47.       default: return -1;
  48.     };
  49.   };
  50.  
  51.   function bookingStateToText(state)
  52.   {
  53.     switch (ordStav(state))
  54.     {
  55.       case 0: return "Zalo₧ena";
  56.       case 1: return "Akceptovßna";
  57.       case 2: return "╚ekß se na v²pis";
  58.       case 3: return "Odeslßno";
  59.       case 4: return "Vy°φzeno";
  60.       default: return "< NEZN┴M▌ >";
  61.     };
  62.   };
  63.  
  64.  
  65.   
  66.  
  67.  
  68.   function stavHotov(zazStav, stav)
  69.   {
  70.     return (ordStav(stav) <= ordStav(zazStav));
  71.   };
  72.  
  73.   function stavJe(zazStav, stav)
  74.   {
  75.     return (ordStav(stav) == ordStav(zazStav));
  76.   };
  77.  
  78.   function nl(num, strLen)
  79.   {
  80.     res = "".concat(num);
  81.     while (res.length < strLen) res = "0".concat(res);
  82.     return res;
  83.   };
  84.  
  85.   function EncodeDT(datetime)
  86.   {
  87.     fmtDateTime = Application("fmtDateTime");
  88.     if (!datetime) d = new Date(); else d = new Date(datetime);
  89.     return "".concat(d.getFullYear(), nl(d.getMonth()+1, 2), nl(d.getDate(), 2), nl(d.getHours(), 2), nl(d.getMinutes(), 2), nl(d.getSeconds(), 2));
  90.   };
  91.  
  92.   function en(s)
  93.   {
  94.     while ((s.length > 0) && (s.charAt(0) == "0")) s = s.substr(1, s.length-1);
  95.     return s;
  96.   };
  97.  
  98.   function DecodeDT(strDT)
  99.   {
  100.     strDT = "".concat(strDT);
  101.     return strDT.substr(6, 2)+"."+en(strDT.substr(4, 2))+"."+en(strDT.substr(0, 4))+" "+
  102.       en(strDT.substr(8, 2))+":"+en(strDT.substr(10, 2))+":"+en(strDT.substr(12, 2));
  103.   };
  104.  
  105.  
  106.   function NormNumStr(strNum)
  107.   {
  108.     var
  109.       i;
  110.  
  111.     strNum = "".concat(strNum);
  112.  
  113.     while ((strNum.length > 1) && ((strNum.charAt(0) <= ' ') || (strNum.charAt(0) == '0'))) 
  114.       strNum = strNum.substr(1, strNum.length-1);
  115.     while ((strNum.length > 1) && (strNum.charAt(strNum.length-1) <= ' ')) 
  116.       strNum = strNum.substr(0, strNum.length-1);
  117.  
  118.     p = strNum.indexOf(".");
  119.     if (p >= 0)
  120.       {
  121.       for (i = p + 4; i < (l = strNum.length); i += 4)
  122.         strNum = strNum.substr(0, i)+"."+strNum.substr(i, l - i);
  123.       strNum = strNum.substr(0, p)+","+strNum.substr(p+1, l - p - 1);
  124.       }
  125.     else
  126.       p = strNum.length;
  127.   
  128.     for (i = --p - 3; i >= 0; i -= 3)
  129.       strNum = strNum.substr(0, i+1)+"."+strNum.substr(i+1, strNum.length - i - 1);
  130.  
  131.     return strNum;
  132.   };
  133.  
  134.   function NumToHTMLImg(strNum)
  135.   {
  136.     res = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
  137.     res += " <tr>\n";
  138.     for (i = 0; i < strNum.length; i++)
  139.     {
  140.       res += "   <td>\n";
  141.       res += "   <img src=\"Images/pr_";
  142.       c = strNum.charAt(i);
  143.       if ((c >= '0') && (c <= '9'))
  144.         res += c;
  145.       else
  146.         if (c == '.')
  147.           res += "point";
  148.         else
  149.           if (c == ',')
  150.             res += "comma";
  151.           else
  152.             res += "space";
  153.       res += ".gif\" border=\"0\" hspace=\"0\" vspace=\"0\">\n";
  154.       res += "   </td>\n";
  155.     };
  156.     res += " </tr>\n";
  157.     res += "</table>\n";
  158.     return res;
  159.   };
  160.  
  161.   function countToHTMLText(count)
  162.   {
  163.     res = NormNumStr(count);
  164.     //res = NumToHTMLImg(res);
  165.     return res;
  166.   };
  167.  
  168.   function priceToHTMLText(price)
  169.   {
  170.     res = NormNumStr(price);
  171.     //res = NumToHTMLImg(res);
  172.     return res;
  173.   };
  174.  
  175. %>
  176.