projects/genea/out/phpui/select_source.php
1.
<?php
2.
 
3.
/*
4.
 
5.
        Contenu table : source.
6.
 
7.
        07/03/2021 10:45
8.
 
9.
        lvardon@laposte.net - 2021
10.
         
11.
        Licence libre
12.
 
13.
*/
14.
 
15.
?> 
16.
 
17.
<!DOCTYPE html>
18.
<html lang="fr">
19.
  <head>
20.
    <meta charset="utf-8">
21.
    <title></title>
22.
 
23.
    <link rel="stylesheet" href="css/page.css">
24.
    <link rel="stylesheet" href="css/menu.css">
25.
    <link rel="stylesheet" href="css/field.css"> 
26.
    
27.
    <script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
28.
    <script type="text/javascript" charset="utf8" src="js/DataTables/datatables.js"></script>
29.
    <link rel="stylesheet" href="js/DataTables/datatables.min.css"> 
30.
 
31.
    <link rel="stylesheet" href="https://unpkg.com/purecss@2.0.3/build/pure-min.css" integrity="sha384-cg6SkqEOCV1NbJoCu11+bm0NvBRc8IYLRGXkmNrqUBfTjmMYwNKPWBTIKyw9mHNJ" crossorigin="anonymous">
32.
 
33.
    <link rel="stylesheet" href="css/icons/css-file-icons.css" />
34.
 
35.
    <script type="text/javascript">
36.
 
37.
        $(document).keyup(function(e) {
38.
             if (e.keyCode == 27) { 
39.
                stopModal('selectplaceholder');            
40.
                $('#selectplaceholder').empty();
41.
            }
42.
        });            
43.
 
44.
        $(document).ready(function() {
45.
            
46.
            $('#datatableselect').DataTable( {
47.
                xautoWidth: false,
48.
                xcolumnDefs: [
49.
                    { "width": "10px", "targets": [0] },       
50.
                    { "width": "20px", "targets": [1] }
51.
                  ] ,             
52.
                  
53.
                "drawCallback": function( settings ) {
54.
                    
55.
                        $(".selectlistitem").on("click", function() {
56.
                            
57.
                            stopModal('selectplaceholder');            
58.
                            $('#selectplaceholder').empty();
59.
                            //alert( "2 valuebackval = [<?php echo $_REQUEST['valuebackval']; ?>]" + " lib back (valueval) = [" + $(this).attr('valueval') + "]");                            
60.
                            <?php 
61.
                                echo "$('#".$_REQUEST['valuebackfield']."').val( $(this).attr('valueid') );";
62.
                                echo "$('#".$_REQUEST['valuebackval']."').val( $(this).attr('valueval') );"
63.
                            ?>                                        
64.
                        });
65.
                        
66.
                        $("#selectclose").on("click", function() {
67.
                            stopModal('selectplaceholder');        
68.
                            $('#selectplaceholder').empty();    
69.
                        });
70.
                        
71.
                },                  
72.
                     
73.
                language: {
74.
                            "sEmptyTable":     "Aucune donnée disponible dans le tableau",
75.
                            "sInfo":           "Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments",
76.
                            "sInfoEmpty":      "Affichage de l'élément 0 à 0 sur 0 élément",
77.
                            "sInfoFiltered":   "(filtré à partir de _MAX_ éléments au total)",
78.
                            "sInfoPostFix":    "",
79.
                            "sInfoThousands":  ",",
80.
                            "sLengthMenu":     "Afficher _MENU_ éléments",
81.
                            "sLoadingRecords": "Chargement...",
82.
                            "sProcessing":     "Traitement...",
83.
                            "sSearch":         "Rechercher :",
84.
                            "sZeroRecords":    "Aucun élément correspondant trouvé",
85.
                            "oPaginate": {
86.
                                "sFirst":    "Premier",
87.
                                "sLast":     "Dernier",
88.
                                "sNext":     "Suivant",
89.
                                "sPrevious": "Précédent"
90.
                            },
91.
                            "oAria": {
92.
                                "sSortAscending":  ": activer pour trier la colonne par ordre croissant",
93.
                                "sSortDescending": ": activer pour trier la colonne par ordre décroissant"
94.
                            },
95.
                            "select": {
96.
                                    "rows": {
97.
                                        "_": "%d lignes sélectionnées",
98.
                                        "0": "Aucune ligne sélectionnée",
99.
                                        "1": "1 ligne sélectionnée"
100.
                                    } 
101.
                            }
102.
                }
103.
 
104.
            } );
105.
 
106.
            $("#menu_<?php if (isset( $_REQUEST['table'])) echo $_REQUEST['table']; else echo ''?>").addClass("nav_current");
107.
 
108.
        } );
109.
 
110.
    </script>
111.
  </head>
112.
  <body>
113.
      
114.
<?php
115.
 
116.
chdir('..');
117.
 
118.
include_once "dbconnect.php";
119.
include_once "phpdb/class_source.php";
120.
include_once "phpdb/class_source_ext.php";
121.
 
122.
// Class instance
123.
$mysource = new source$db );
124.
 
125.
// Select all reccords :
126.
$results $mysource->selectAll();
127.
if ($results === false) {
128.
    echo "Erreur : ".$mysource->lasterror."<br>";
129.
}
130.
 
131.
echo '<div style="margin-left:1%; margin-right:1%"" >';
132.
echo '<div style="display:inline-block;" class="titleedit">Sélection: <span title="Liste des sources" class="titleedit">Source</div>';
133.
echo '<div style="float:right; display:inline-block; cursor: pointer" id="selectclose">X</div>';
134.
 
135.
?>
136.
137.
<table id="datatableselect" class="display" cellspacing="0" xwidth="85%">
138.
 
139.
    <thead>
140.
 
141.
        <tr>            
142.
             <?php echo $mysource->getTableHeaderSelect(); ?>
143.
        </tr>
144.
 
145.
    </thead>
146.
 
147.
    <tbody>
148.
 
149.
<?php
150.
 
151.
foreach($results as $row) {
152.
 
153.
    $rowkeyvalue=$row['a.id'];
154.
 
155.
    echo "\n";   
156.
    echo '<tr>';
157.
 
158.
    foreach($row as $key => $value) {
159.
 
160.
        $fieldLen $mysource->getTableFieldLenSelect$key );
161.
            if ( $fieldLen == )
162.
                continue;
163.
        
164.
        echo '<td>';
165.
 
166.
        $datafollow="";    
167.
        $dataDisplay=$value;
168.
        if ( strlen($value) > $fieldLen ) {
169.
            $datafollow="...";     
170.
            $dataDisplay=mb_substr($value0$fieldLen);
171.
        }
172.
        
173.
        if ( $mysource->getTableFieldLinkSelect$key ) == 'on' )
174.
            echo '<a title="'.$value.'" class="selectlistitem" valueid="'.$rowkeyvalue.'" valueval="'.$row['a.name'].'" href="#" >'.$dataDisplay.$datafollow.'</a>';        
175.
        else 
176.
            switch ($mysource->getMeta($key 'selectdisplay')) {
177.
              case 'color':    
178.
                echo '<span style="display:none" >'.$value.'</span>';
179.
                $iconwidth $mysource->getMeta($key 'listdisplaywidth');
180.
                $iconheight $mysource->getMeta($key 'listdisplayheight');                
181.
                echo '<div title="'.$value.'" style="height:0;width:'.$iconwidth.'%;padding-bottom:'.$iconheight.'%;background-color:'.$value.'">';
182.
                break;
183.
                                
184.
              case 'urlpic':    
185.
                $iconwidth $mysource->getMeta($key 'selectdisplaywidth');
186.
                $iconheight $mysource->getMeta($key 'selectdisplayheight');
187.
                if ( file_exists($value) )
188.
                    echo '<img alt="'.$value.'" title="'.$value.'" src="'.$value.'" width='.$iconwidth.' height='.$iconheight.'>';
189.
                else
190.
                    echo '<img alt="image inexistante" title="image inexistante" src="img/missing.png" width='.$iconwidth.' height='.$iconheight.'>';              
191.
                break;
192.
                
193.
              case 'url':
194.
                    echo '<a title="'.$value.'" href="'.$value.'" target="_blank" >'.$dataDisplay.$datafollow.'</a>';                
195.
                break;
196.
 
197.
            case 'icondoc':    
198.
                if (file_exists($value)) {
199.
                    $ext pathinfo($valuePATHINFO_EXTENSION); 
200.
                    echo '<a href="'.$value.'">';
201.
                    echo '<div class="fi fi-'.$ext.'">
202.
                        <div title="'.$value.'" class="fi-content">'.$ext.'</div>
203.
                    </div>';
204.
                    echo '</a>';
205.
                }            
206.
                break;    
207.
 
208.
                
209.
              default:
210.
                if ($mysource->getMeta($key 'sortformat') == 'date') {
211.
                    $sortData substr($value6,4) . substr($value3,2) . substr($value0,2) ; // database : dd/mm/yyyy 
212.
                    echo '<span style="display:none" >'.$sortData.'</span>'.'<div title="'.$value.'">'.$dataDisplay.$datafollow.'</div>';
213.
                }
214.
                else
215.
                    echo '<div title="'.$value.'">'.$dataDisplay.$datafollow.'</div>';
216.
 
217.
            }
218.
 
219.
        echo '</td>';
220.
        echo "\n";
221.
    }
222.
    echo '</tr>';    
223.
224.
 
225.
?>
226.
227.
    </tbody>
228.
 
229.
</table>
230.
 
231.
</div>
232.
 
233.
 
234.
<script type="text/javascript">
235.
 
236.
    function stopModal(id) {
237.
        if ($("#PopupMask") == null) return;
238.
        $("#PopupMask").remove();
239.
        $("#"+id).css( "z-index" , $("#"+id).data('saveZindex') );
240.
        $("#"+id).css( "position" , $("#"+id).data('savePosition') );
241.
    }
242.
 
243.
</script>
244.
 
245.
  </body>
246.
</html>
247.