<!--
###############################################################################
# /usr/share/doc/capi2text/capi2text-index.php
#
# Copyright (c) 2009       Rolf Bensch, rolf(at)bensch-net(dot)de
# Copyright (c) 2009-2024  Juergen Edner, juergen(at)eisfair(dot)org>
#                          Rolf Bensch, rolf(at)bensch-net(dot)de
#
# Creation:     2009-10-03  jed
# Last Update:  $Id: capi2text-index.php 44716 2017-01-22 17:17:43Z jed $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
###############################################################################
-->

<?php
	 error_reporting(0);  
    header('content-type: text/html; charset=utf-8;');
    error_reporting(E_ALL);                          // if "require" fails

    require('incl/capi2text-default-params.inc');    // load default parameters
    require('capi2text-params.inc');                 // load custom parameters
    require('incl/capi2text-functions.php');         // load functions

    if ($debug) {
        error_reporting(E_ALL);
    } else {
        // disable error handling in production mode
        error_reporting(0);
    }

    setlocale(LC_TIME, $date_locale);

    $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';

    // css: colors for specified MSN
    $arr_msn = getMsnList();
    $msnCSS = "/* default colors */";
    foreach ($arr_msn as $key => $val) {
        $trClass = ".msn$key";
        $fcolor  = $val['fcolor'];
        $bcolor  = $val['bcolor'];
        $bcolor  = "linear-gradient(to bottom, $bcolor, transparent 80%)";
        $msnCSS  .= "$trClass\t {color: $fcolor; background-image:$bcolor}\n";
        $msnCSS  .= "$trClass * *\t {color: $fcolor}\n";
    }

    $flags    = ($no_flags       == true)   ? "false" : "true";
    $fromlink = ($no_from_link   == true)   ? "false" : "true";
    $msnsort  = ($msn_sort_order == "asc")  ? "asc" : "desc";

	$dlgMsnContent="";
	foreach ($arr_msn as $key => $val) {
		$xKey = str_replace("*","_", $key);
		$dlgMsnContent .= "<div class='msn$xKey' data-sort='{$val['desc']}'><input type='checkbox' id='msn$xKey' value='$xKey' class='msn$xKey'><label for='msn$xKey'>&nbsp;{$val['desc']}</label></div>";
	 }

    $std_theme  = "base";
    if (! isset($color_ui_theme)) $color_ui_theme = $std_theme;
    if (! file_exists("./incl/jQuery/jquery-ui-themes-1.12.1/themes/$color_ui_theme/jquery-ui.min.css")) $color_ui_theme = $std_theme;
    if (! file_exists("./incl/jQuery/jquery-ui-themes-1.12.1/themes/$color_ui_theme/jquery-ui.min.css")) die("capi2text: Farbschema '$color_ui_theme' nicht vorhanden");

    // dlgEdit: language specific data
    $formdata = "data-header='$edit_frm_header'
                 data-save='$edit_frm_save'
                 data-cancel='$edit_frm_abort'";

     // display specific data
    $strNoCallDirection	= (! $no_call_direction) ? "true" : "false";
    $strNoCallDuration 	= (! $no_call_duration)  ? 'true' : "false"; 
    $default_filterdays = (! $default_filterdays)? "9999" : $default_filterdays;
    
    $bodydata   = "data-uitheme='$color_ui_theme'
                   data-flags=\"$flags\"
                   data-fromlink='$fromlink'
                   data-msnsort='$msnsort'
                   data-calldirection='$strNoCallDuration'
                   data-callduration='$strNoCallDuration' 
                   data-finout='INOUT'
                   data-fdays='$default_filterdays'
                   data-fmsn=''                  
                   ";

    $mainCSS    = "body *          { font-family      : $font_face;
                                     font-size        : $font_size;
                                   }

						 h2				  { height			  	: 1.7em;
						 						 font-weight      : bold;
                                     font-size        : 1.3em;
                                     margin           : 5px;
                                   }
                                   
						 input[type='radio'] { position:relative; top: 4px;}

                   table           { border-collapse  : collapse; }


						 tr.editable	  { cursor:pointer }

                   th, .tabFooter, .headline
                                   { text-align       : left;
                                     font-weight      : bold;
                                   }

                   td              { padding-left     : 5px;}
                   
                   .ellipsis		  { min-width		: 100%; 
 												 overflow		: hidden; 
 												 text-overflow	: ellipsis; 
 												 white-space	: nowrap;
 												 width         : 0;
											  }

                   .right          { text-align    : right }
						 .left			  { text-align    : left }
						 .center			  { text-align    : center }

                   #filter         { position      : absolute;
                                     right         : 20px;
                                     top           : 3px;
                                     /*background		: white;*/
                                   }

                   .logo           { float            : left;
                                     width            : 100px;
                                     margin-right     : 20px;
                                     position         : relative;
                                     top              : -8px;
                                   }

                   .tipp           { font-size        : 0.8em;
                                     color            : red
                                   }
                   .btnIcon        { height           : 24px;
                                     display				: inline-block;
                                   }
                   .btnInfo		  { position:relative; top:-7px; left:8px; color:#fc6262; }
                                   
                   img, .edit      { cursor           : pointer; }


                   fieldset        { border-radius    : 8px;}

                   div.table       { display          : table;
                                     border-collapse  : collapse;
                                   }
                   div.tr          { display          : table-row; }
                   div.td          { display          : table-cell;
                                     padding          : 2px;
                                   }


                   #phonelist      { border           : none;
                                     width            : 100%
                                   }

						 #phonelist tr	 	          { height:1.5em; }
                   #phonelist thead           { border-bottom   : 2px solid lightgrey }
                   #phonelist th              { font-weight     : bold;
                                                height          : 2em;
                                                padding-left    : 8px;
                                                padding-right   : 8px;
                                              }
                   #phonelist th:nth-child(1) { max-width:110px; width: 110px; min-width:29px; text-align: center }
                   #phonelist th:nth-child(2) { width:50px; text-align: center }
                   #phonelist th:nth-child(3) { width:16%;}
                   #phonelist th:nth-child(4) { width:16%;}
                   #phonelist th:nth-child(5) { }
                   #phonelist th:nth-child(6) { width: 30px; text-align: center; }
                   #phonelist th:nth-child(7) { width: 50px; text-align: center; }
               
                   #phonelist tbody td:nth-child(2)   { text-align   : center }
                   #phonelist tbody td:nth-child(6)   { text-align   : center; }
                   #phonelist tbody td:nth-child(7)   { text-align   : center; }
                   #phonelist img                     { width        : 20px;
                                                        position     : relative;
                                                        top          : 3px;
                                                      }

                   #phonelist tfoot td:nth-child(1)   { padding-left : 15px }
                   #phonelist tfoot td:nth-child(2)   { padding-right: 15px }

              		 #dlgMSNSelect div							 { white-space		 : nowrap }
              		 #dlgMSNSelect div>input[type='checkbox'] { position:relative; top: 3px;}	

                   #dlgStatistik                          { width           : 1000px;}
                   #dlgStatistik fieldset                 { background      : white }
                   #dlgStatistik table                    { border-spacing  : 0;
                                                            border-collapse : collapse;
                                                          }
                   #dlgStatistik table tr:nth-child(2n+2) { background      : #f3f3f3 }
                   #dlgStatistik table tr:nth-child(2n+3) { background      : #eeeeec }
                   #dlgStatistik th                       { padding         : 0.2em }
                   #dlgStatistik table *     { color           : black }
                   #dlgStatistik table th:nth-child(1)    { width : 20% }
                   #dlgStatistik table th:nth-child(2)    { width : 10% }
                   #dlgStatistik table th:nth-child(3)    { width : 18% }
                   #dlgStatistik table th:nth-child(4)    { width : 12% }
                   #dlgStatistik table th:nth-child(5)    { width : 30%; }

                   #dlgStatistik table td:nth-child(5)    { position:relative}
                   #dlgStatistik table td:nth-child(5) div:nth-child(1) { float    : left;
                                                                          width    : 25px;
                                                                          top      : 3px;
                                                                          position : relative
                                                                        }
                   #dlgStatistik table td:nth-child(5) div:nth-child(2) { float    : left;
                                                                          background-color: #8A91CE;
                                                                          heighti  : 22px;
                                                                          border   : 1px solid #999;
                                                                          margin   : 0 16px; }
                   #dlgStatistik table td:nth-child(5) div:nth-child(3) { position : absolute;
                                                                          right    : 3px;
                                                                          top:3px
                                                                        }

                   #dlgBtnOk                              { width   : 100px; }

                   #dlgKonfig table td:nth-child(1)       { width   : 200px }
                   #dlgKonfig table td:nth-child(2)       { width   : 150px;
                                                            padding : 0;
                                                          }
                   #dlgKonfig table td>select             { width   : 100%;
                                                            height  : 2em;
                                                          }

						 #dlgKonfigMsn									 { }
                   #dlgKonfigMsn .table                   { width   : 100%; background-color : lightgrey}
                   #dlgKonfigMsn .td:nth-child(3)         { width   : 30px; }
                   #dlgKonfigMsn .td:nth-child(4)         { width   : 30px; }
                   
                   .dlgNbrStyle *								 { font-size:10px }
                   .dlgNbrStyle th								 { padding: 2px 3px; }
                   .dlgNbrStyle button							 { width: 100%; padding: 0; }

                   .call_INOUT    	{ background : url('./pics/call_inout.png') 	left center no-repeat; padding-left:26px; }
                   .call_IN       	{ background : url('./pics/call_in.png')    		left center no-repeat; padding-left:26px; }
                   .call_OUT      	{ background : url('./pics/call_out.png')   		left center no-repeat; padding-left:26px; }
                   .call_IN_FAILED	{ background : url('./pics/call_in_failed.png')	left center no-repeat; padding-left:26px; }
                   .call_OUT_FAILED	{ background : url('./pics/call_out_failed.png')left center no-repeat; padding-left:26px; }
                   
                   .btnINOUT		{ background : url('./pics/call_inout.png') 	left top no-repeat; background-size: 24px 24px ; width:28px; }
                   .btnIN			{ background : url('./pics/call_in.png') 		left top no-repeat; background-size: 24px 24px ; width:28px; }
                   .btnOUT			{ background : url('./pics/call_out.png') 	left top no-repeat; background-size: 24px 24px ; width:28px; }
                   .btnClock		{ background : url('./pics/clock.png') 		left top no-repeat; background-size: 24px 24px ; width:28px; }
                   .btnFilter		{ background : url('./pics/filter.png') 		left top no-repeat; background-size: 24px 24px ; width:28px; }
                   .btnStatistik	{ background : url('./pics/statistic.png') 	left top no-repeat; background-size: 24px 24px ; width:28px; margin-left:5px }
                   .btnKonfig		{ background : url('./pics/config.png') 		left top no-repeat; background-size: 24px 24px ; width:28px; }
                   
                   
                   
                   .ui-selectmenu-menu li div { height: 1.2em; }
                   #sel_inout-menu .ui-state-active span {filter: invert(100%); -webkit-filter: invert(100%)};
                    ";
?>
<!DOCTYPE html>
<html lang="de">
    <head>
        <title>Capi2Text</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="shortcut icon" href="./favicon.ico">


        <style type="text/css"> <?php echo $mainCSS; ?> </style>
        <style type="text/css" id='msncss'> <?php echo $msnCSS; ?> </style>

		  <link rel="stylesheet" type="text/css" href="incl/jQuery/qTip/jquery.qtip.min.css" />
        <link id="ui-theme" rel="stylesheet" href="incl/jQuery/jquery-ui-themes-1.12.1/themes/<?php echo $color_ui_theme; ?>/jquery-ui.min.css">
        <link rel="stylesheet" href="incl/jQuery/jquery-minicolors/jquery.minicolors.css">

        <script type="text/javascript" src="incl/jQuery/jquery-3.6.0.min.js"></script>
        <script type="text/javascript" src="incl/jQuery/jquery-ui-1.12.1/jquery-ui.min.js"></script>
        <script type="text/javascript" src="incl/jQuery/js.cookie.js"></script>
		  <script type="text/javascript" src="incl/jQuery/jquery.json.js"></script>
        <script type="text/javascript" src="incl/jQuery/jquery-minicolors/jquery.minicolors.min.js"></script>
        <script type="text/javascript" src="incl/capi2text-functions.js"></script>
		  <script type="text/javascript" src="incl/jQuery/qTip/jquery.qtip.min.js"></script>
	     
        <style type="text/css">
            /* cosmetics */
            .ui-dialog .ui-dialog-buttonpane 	{ padding   : 0 }
            .ui-button                          { padding   : 2px 10px; }
            .ui-widget, .ui-widget .ui-widget	{ font-size : 0.9em; }
            .ui-widget-overlay                  { background: #5c5c5c none repeat scroll 0 0; opacity: 0.3;}

            .ui-dialog-buttonset {width:100%; }
            .ui-dialog-buttonset .ui-button:last-child  {float:right !important;}
            .ui-dialog-buttonset .ui-button:first-child { margin-left:10px; }
            .ui-tooltip { max-width: 400px;}
            
            .qtip-content	{padding: 5px 5px; border-radius: 8px;}

            .minicolors-theme-default .minicolors-swatch { height: 22px; width: 100%; top:2px; right: -1px}
            .minicolors-theme-default.minicolors-position-right .minicolors-swatch { right: -1px;}

            #dlgEdit table { width      : 100% }
            #dlgEdit input { width      : 95%; }
            #dlgEdit .col1 { width      : 80px; }

            #dlgKonfig select {text-align:left}
            .hidden        { display    : none }

            @media all and (max-width: 750px) {
		        	#Headline .logo 					{ display:none; }		/* Eisfair Logo */
					#phonelist th:nth-child(1) 	{ border:0px solid yellow; width: 65px; } 		/* Spalte 'Datum/Zeit' */
					#phonelist tr>*:nth-child(2) 	{ display:none }		/* Spalte 'Land' */

					#phonelist th:nth-child(7)		{ width:16px; }		/* Spalte 'Edit' */
					#phonelist .headline        	{ padding-left:0px !important}
					#phonelist .call_IN, 
					#phonelist .call_OUT,
					#phonelist .call_IN_FAILED,
					#phonelist .call_OUT_FAILED 	{ background:none; padding-left:5px; text-align:left }	
				}
				
				@media all and (orientation: portrait) and (max-width: 650px) {		
					#Headline >div:nth-child(1)	{ width: 117px; white-space:nowrap; overflow:hidden;}		
					#phonelist th:nth-child(1) 	{ border:0px solid red; width:29px } 			/* Spalte 'Datum/Zeit' (Sekunden ausblenden) */
					#phonelist tr>*:nth-child(6) 	{ display:none; }
					.ellipsis		  					{ text-overflow:clip;  }
					#filter								{ right: 0 }
            
        </style>
    </head>
    <body class='ui-widget-content' <?php echo $bodydata; ?>>
         <h2 id="Headline" style="position:relative;">
         	 <div style='font-size:1.1em;'>
                <a href="<?php echo $referer;?>" title="<?php echo "$back_to $referer";?>">
                    <img class="logo" src="pics/eisfair_logo_klein.png" alt="eisfair-Logo"/>
                </a>
             	<?php print $capi2text_title; ?>
             </div>
             <div id='filter' style="">&nbsp;&nbsp;
             		<?php 
             			if ( ! $no_call_direction) {
                 			echo "<span id='btnInout'  	class='btnIcon btnINOUT' 		title='In-Out-Filter...'>&nbsp;</span>";
                 		}                  		
                 	?>
                 	<span id='btnClock'  	class="btnIcon btnClock" 		title="Zeitraum...">&nbsp;<span class='btnInfo'>7</span></span>                 
                 	<span id='btnFilter' 	class="btnIcon btnFilter" 		title="MSN-Filter...">&nbsp;</span>
						<span id='btnStatistik' class="btnIcon btnStatistik" 	title="Statistik...">&nbsp;</span>
						<span id='btnKonfig'  	class="btnIcon btnKonfig"		title="Einstellungen...">&nbsp;</span>
             </div>
         </h2>


        <!-- the table header -->
        <table id="phonelist" style="display:none; width:100%" >
            <thead class='ui-widget-header'>
                <tr>
                    <th title="<?php print $call_date;?>"><div class='ellipsis'><?php print $call_date;?></div></th>
                    <th class='center'><?php print $call_country; ?></th>
                    <th class='center'><?php print $call_from;    ?></th>
                    <th class='center'><?php print $call_to;      ?></th>
                    <th class='center'><?php echo "<span id='callCount'></span> $call_name";   ?></th>
                    <th class='hydden'><?php echo $call_duration;?></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <!-- will be filled by AJaX -->
            </tbody>
 
        </table>
        <table id="phonelistFooter" style="display:ndone; width:100%">
           <tfoot class='ui-widget-header'>
                <tr>
                    <td colspan=4 class='tabFooter '></td>
                    <td colspan=3 class='tabFooter right'>&copy; the eisfair team</td>
                </tr>
            </tfoot>
		  </table>

       <div id='dlgKonfig' 
       	style="display:none; font-size:50%"  
       	title="<?php echo $config_title;?>"
       	data-tt-fg 			= "<?php echo $config_foreground_tt;?>"
       	data-tt-bg 			= "<?php echo $config_background_tt;?>"
       	data-tt-country	= "<?php echo $config_country_tt;?>"
       	data-tt-from 		= "<?php echo $config_from_tt;?>"
       	data-tt-direction = "<?php echo $config_direction_tt;?>"
       	data-tt-duration 	= "<?php echo $config_duration_tt;?>"
       	data-tt-msnsort	= "<?php echo $config_msnsort_tt;?>"
       	data-tt-theme		= "<?php echo $config_theme_tt;?>"
       	>
            <fieldset >
                <form id='dlgKonfigFrm' method='post'>
                    <table style="width:100%">
                        <?php
                            if (file_exists("./png/country-49.png")) {
                                echo "<tr>
                                          <td id='KonfigCountry'><div class='ellipsis'>$config_country:</div></td>
                                          <td> <input type='checkbox' id='dlgKonfigCountry' name='dlgKonfigCountry'></td>
                                     </tr>";
                                }
                        ?>
                            <tr>
                            <td id='KonfigFrom'><div class='ellipsis'><?php echo $config_from?>:</div></td>
                            <td><input type='checkbox' id='dlgKonfigFrom' name='dlgKonfigFrom'></td>
                        </tr>

                        <?php
                            if (! $no_call_direction) {
                                echo "<tr>
                                          <td id='KonfigDirection'><div class='ellipsis'>$config_direction:</div></td>
                                          <td><input type='checkbox' id='dlgKonfigDirection' name='dlgKonfigDirection'></td>
                                     </tr>";
                                }

                            if (! $no_call_duration) {
                                echo "<tr>
                                          <td id='KonfigDuration'><div class='ellipsis'>$config_duration:</div></td>
                                          <td><input type='checkbox' id='dlgKonfigDuration' name='dlgKonfigDuration'></td>
                                     </tr>";
                                }
                            ?>

                        <tr>
                            <td id='KonfigMsnSort'><div class='ellipsis'><?php echo $config_msnsort;?>:</div></td>
                            <td>
                                <select id='dlgKonfigSortMSN' name='dlgKonfigSortMSN'>
                                    <option value='desc'>absteigend</option>
                                    <option value='asc'>aufsteigend</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td id='KonfigTheme'><?php echo $config_theme;?>:</td>
                            <td>
                                <select id='dlgKonfigStyleSelect' name='dlgKonfigStyleSelect' >
                                    <?php
                                        $themePath = "incl/jQuery/jquery-ui-themes-1.12.1/themes";
                                        foreach (glob("$themePath/*", GLOB_ONLYDIR) as $folder) {
                                            $foldername = basename($folder);
                                            echo "<option >$foldername</option>";
                                            }
                                    ?>
                                </select>
                            </td>
                        </tr>
                    </table>
                    <fieldset id='dlgKonfigMsn'><legend><?php echo $config_msncolors?></legend>
                            <div class='table'></div>
                            <hr>
                            <div id="dlgKonfigTipp" class='tipp'>&nbsp;</div>
                    </fieldset>
                </form>
            </fieldset>
            </div>

            <div id='dlgStatistik' style='display:none; font-size:50%' title="<?php echo $statistic_title; ?>">
                <fieldset >
                Statistik wird geladen
              </fieldset>
           </div>
           
           <div id='dlgInout' style='display:none;'>
           	<fieldset> 
           		<input type="radio" id="rInout" name="dlgInoutVal" value="INOUT"> <label for="rInout" 	class='call_INOUT'> ein- und ausgehende Gespräche</label><br>
           		<input type="radio" id="rIn" 	  name="dlgInoutVal" value="IN"> 	<label for="rIn" 		class='call_IN'	> nur eingehende Gespräche</label><br>
           		<input type="radio" id="rOut"   name="dlgInoutVal" value="OUT"> 	<label for="rOut" 	class='call_OUT'	> nur ausgehende Gespräche</label> 
           	</fieldset>
          </div>
          
          <div id='dlgPeriod' style='display:none;'>
           	<fieldset>
           		<input type="radio" id="r1"	name="dlgPeriodVal" value="0"> 	<label for="r1" 	> <?php echo $last_day; ?></label><br> 
           		<input type="radio" id="r7"	name="dlgPeriodVal" value="7"> 	<label for="r7" 	> <?php echo $last_seven_days; ?></label><br>
           		<input type="radio" id="r14" 	name="dlgPeriodVal" value="14"> 	<label for="r14" 	> <?php echo $last_fourteen_days; ?></label><br>
           		<input type="radio" id="r30"  name="dlgPeriodVal" value="30"> 	<label for="r30" 	> <?php echo $curr_month; ?></label><br>
           		<input type="radio" id="rall" name="dlgPeriodVal" value="9999"><label for="rall" > <?php echo "- $all_data_prefix $all_data_suffix -"; ?></label> 
           	</fieldset>
          </div>
          
          <div id='dlgNbr' style="display:none;">
				<table style="width:100%">
					<tr><th></th><th class='center'>Anrufe</th><th class='center'>Dauer</th></tr>
					<tr><th>heute</th><td class='center'></td><td class='center'></td></tr>
					<tr><th>alle</th> <td class='center'></td><td class='center'></td></tr>
				</table>
				<button onClick="btnFilterClick($(this).text().substr(8).trim())">Filter diese Nr.</button>
          </div>
          
          <div id='dlgMSNSelect' style='display:none;'>
           	<fieldset> 
           		<?php echo $dlgMsnContent; ?>
           	</fieldset>
          </div>
           
          <?php
            if (! $no_editmode) {
                echo "<div id='dlgEdit' style='display:none; font-size:50%' $formdata>
                          <form>
                              <fieldset>
                                  <table>
                                      <tr><td class='col1'>$edit_frm_name:</td><td><input type='text' name='name'    /></td></tr>
                                      <tr><td>$edit_frm_street_and_nbr:   </td><td><input type='text' name='street'  /></td></tr>
                                      <tr><td>$edit_frm_zip:              </td><td><input type='text' name='zip'     /></td></tr>
                                      <tr><td>$edit_frm_city:             </td><td><input type='text' name='city'    /></td></tr>
                                      <tr><td>$edit_frm_country:          </td><td><input type='text' name='country' /></td></tr>
                                  </table>
                                  <input type='text' name='nbr' class='hidden' />
                              </fieldset>
                          </form>
                      </div>";
            }
        ?>

    </body>
</html>