phpDocumentor VFront
Administration
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file gestione_tabelle_gruppi.php

Documentation is available at gestione_tabelle_gruppi.php

  1. <?php
  2. /**
  3.  * Sono qui presenti le procedure fondamentali per la gestione del registro di VFront.
  4.  * Il file  organizzato per aree e svolge numerose funzioni
  5.  * 
  6.  * @desc File per la gestione del registro di VFront
  7.  * @package VFront
  8.  * @subpackage Administration
  9.  * @author M.Marcello Verona
  10.  * @copyright 2007 M.Marcello Verona
  11.  * @version 0.90
  12.  * @see gestione_registro.inc.php
  13.  * @license http://www.gnu.org/licenses/gpl.html GNU Public License
  14.  */
  15.  
  16.  
  17.  
  18. include("../inc/conn.php");
  19. include("../inc/layouts.php");
  20. include("../inc/func.comuni.php");
  21. include("../inc/func.tratta_campo.php");
  22. include("../inc/func.frontend.php");
  23.  
  24.  
  25. if(isset($_GET['conf_sub'])){
  26.     
  27.     include("../inc/func.tratta_campo_submask.php");
  28. }
  29.  
  30.  
  31.  
  32. if(!isset($GLOBALS['_VARIABILI'])){
  33.     
  34.     
  35.     include("../inc/func.var_frontend.php");
  36.     
  37.     var_frontend();
  38. }
  39.  
  40. ###############################################################################################
  41. #
  42. #        Da qui mostra le impostazioni della tabella
  43. #        Con richiamo di funzione esterna per ogna campo.
  44. #
  45. ###############################################################################################
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. /**
  58.  * Da qui  possibile accedere alle impostazioni delle tabelle e eseguire operazioni rapide
  59.  * sulla loro configurazione
  60.  * 
  61.  * @desc Genera il menu delle tabelle
  62.  * @param unknown_type $gid 
  63.  * @param unknown_type $order 
  64.  */
  65. function tab_menu($gid=0,$order='table_name'){
  66.     
  67.     global $link,$db1;
  68.     
  69.     
  70.     switch($order){
  71.         case 0$order "table_name"break;
  72.         case 1$order "data_modifica"break;
  73.         case 2$order "visibile"break;
  74.         case 3$order "id_table"break;
  75.         case 4$order "commento"break;
  76.         case 5$order "in_insert"break;
  77.         case 6$order "in_update"break;
  78.         case 7$order "in_delete"break;
  79.         case 8$order "n_sottomaschere"break;
  80.         default$order 'table_name'
  81.     }
  82.     
  83.     if(isset($_GET['sort'])){
  84.         
  85.         $sort ($_GET['sort']=="d"?  "DESC" "ASC";
  86.     }
  87.     else{
  88.         $sort "ASC";
  89.     }
  90.     
  91.     // Richiama tutte le tabelle dati
  92.     $sql_tab "SELECT t.table_name,  t.visibile,  t.in_insert,  t.in_update
  93.                  t.in_delete,  t.data_modifica,   t.id_table,  t.commento , t.table_type
  94.                 , (SELECT count(*) FROM {$db1['frontend']}.registro_submask s WHERE s.id_table=t.id_tableas n_sottomaschere
  95.                 FROM {$db1['frontend']}.registro_tab t
  96.                 WHERE gid=$gid
  97.                 ORDER BY t.table_type,  $order $sort ";
  98.     $q_tabvmsql_query($sql_tab,$link);
  99.     $matrice_tab vmsql_fetch_assoc_all($q_tab);
  100.  
  101.  
  102.     echo openLayout1("Amministrazione Tabelle",array("sty/admin.css","js/mostra_nascondi_id.js"));
  103.  
  104.     
  105.     
  106.     echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> &raquo; <a href=\"menu_registri.php\">menu gruppi/registri</a> &raquo; </div>";
  107.     
  108.     echo "<h1>Regole Tabelle gruppo <span class=\"var\">$gid::".gid2nome_gruppo($gid)."</span></h1>\n";
  109.     
  110.  
  111.     #############################################
  112.     #
  113.     #
  114.     #    FUNZIONI RAPIDE
  115.     #
  116.     #
  117.     
  118.     echo "<div style=\"padding:5px 0 20px 0;\"><a href=\"javascript:;\" onclick=\"mostra_nascondi('tab-menu-rapide');\">Funzioni rapide</a></div>\n";
  119.     
  120.     echo "
  121.     
  122.         <div id=\"tab-menu-rapide\"  style=\"display:none\">
  123.             <fieldset style=\"padding:10px;margin:10px;width:85%;\">
  124.                 <legend>Impostazioni rapide</legend>
  125.                 <p><strong>Visibilit&agrave; (SELECT)</strong>
  126.                     <a href=\"?gid=$gid&amp;mass=visibile_all\">Permetti a tutte le tabelle</a> | 
  127.                     <a href=\"?gid=$gid&amp;mass=visibile_none\">Nega a tutte le tabelle</a></p>
  128.                 <p><strong>Inserimento (INSERT)</strong>
  129.                 <a href=\"?gid=$gid&amp;mass=insert_all\">Permetti in tutte le tabelle</a> | 
  130.                     <a href=\"?gid=$gid&amp;mass=insert_none\">Nega in tutte le tabelle</a></p>
  131.                 <p><strong>Modifica (UPDATE)</strong>
  132.                 <a href=\"?gid=$gid&amp;mass=update_all\">Permetti in tutte le tabelle</a> | 
  133.                     <a href=\"?gid=$gid&amp;mass=update_none\">Nega in tutte le tabelle</a></p>
  134.                 <p><strong>Elimina (DELETE)</strong>
  135.                 <a href=\"?gid=$gid&amp;mass=delete_all\">Permetti in tutte le tabelle</a> | 
  136.                     <a href=\"?gid=$gid&amp;mass=delete_none\">Nega in tutte le tabelle</a>
  137.                 </p>
  138.             </fieldset>
  139.             <br/>
  140.             <br/>
  141.         </div>
  142.         ";
  143.     
  144.     
  145.     
  146.     
  147.     echo "<table summary=\"tabelle db per utenti\" id=\"tab-tabelle\" >\n";
  148.     
  149.     $c=0;
  150.     
  151.     
  152.     echo "\t<tr>\n";
  153.     
  154.     echo "\t\t<th>".table_sort('visibile',2,'Impostazione di visibili&agrave; della tabella')."</th>\n";
  155.     echo "\t\t<th>".table_sort('tabella',0,'Nome della tabella')."</th>\n";
  156.     echo "\t\t<th>".table_sort('ultimo settaggio',1,'Data dell\'ultima impostazione per questa tabella')."</th>\n";
  157.     echo "\t\t<th>".table_sort('sottomaschere',8,'numero di sottomaschere impostate per la tabella')."</th>\n";
  158.     echo "\t\t<th>".table_sort('commento',4,'Commento di tabella')."</th>\n";
  159.     echo "\t\t<th>".table_sort('insert',5,'Possibilit&agrave; di inserimento dati per questa tabella da parte di questo gruppo')."</th>\n";
  160.     echo "\t\t<th>".table_sort('update',6,'Possibilit&agrave; di modifica dei dati per questa tabella da parte di questo gruppo')."</th>\n";
  161.     echo "\t\t<th>".table_sort('delete',7,'Possibilit&agrave; di cancellazione dei dati per questa tabella da parte di questo gruppo')."</th>\n";
  162.     
  163.     
  164.     echo "\t</tr>\n";
  165.     
  166.     $inizia_vista=true;
  167.     
  168.     foreach($matrice_tab as $tab){
  169.         
  170.         $colore=(($c%2)==0"c1":"c2";
  171.         $c++;
  172.         
  173.         if($tab['data_modifica']>0{
  174.             $data_mod date("Y-m-d H:i",$tab['data_modifica']);
  175.             $color_href="";
  176.             $title_href='';
  177.         }
  178.         else{
  179.             $data_mod "-";
  180.             $color_href=" class=\"dafare\"";
  181.             $title_href='title="Questa tabella non &egrave; stata ancora configurata"';
  182.         }
  183.         
  184.          $n_sottomaschere ($tab['n_sottomaschere']>0"<strong>".$tab['n_sottomaschere']."</strong>" "<span class=\"grigio\">".$tab['n_sottomaschere']."</span>";
  185.         
  186.          
  187.          // SEPARATORE PER LE VISTE
  188.          
  189.          if($tab['table_type']=='VIEW' && $inizia_vista==true){
  190.              
  191.              echo "\t\t<tr class=\"separatore\" style=\"padding-top:50px;margin-top:10px;\">
  192.                  <td colspan=\"7\"><hr /><h2>Viste sulle tabelle</h2></td>
  193.                  </tr>\n";
  194.              
  195.              $inizia_vista=false;
  196.          }
  197.          
  198.          
  199.          
  200.         echo "\t\t<tr class=\"$colore\">
  201.                 <td>".high_si_no($tab['visibile'])."</td>
  202.                 
  203.                 <td><a $title_href $color_href href=\"".$_SERVER['PHP_SELF']."?det=".$tab['id_table']."&amp;gid=$gid\">".$tab['table_name']."</a></td>
  204.                 <td>".$data_mod."</td>
  205.                 <td>".$n_sottomaschere."</td>
  206.                 <td>".htmlentities($tab['commento'],ENT_QUOTES)."</td>
  207.                 <td>".high_si_no($tab['in_insert'])."</td>
  208.                 <td>".high_si_no($tab['in_update'])."</td>
  209.                 <td>".high_si_no($tab['in_delete'])."</td>
  210.             </tr>\n";
  211.     }
  212.     
  213.     echo "</table>\n";
  214.  
  215.     echo closeLayout1();
  216.  
  217. }
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224. /**
  225.  * Genera il menu delle sottomaschere
  226.  *
  227.  * @param int $oid 
  228.  * @param int $order 
  229.  */
  230. function submask_menu($oid=0,$order='nome_tabella'){
  231.     
  232.     global $link,$db1;
  233.     
  234.     
  235.     switch($order){
  236.         case 0$order "nome_tabella"break;
  237.         case 1$order "data_modifica"break;
  238.         case 2$order "sub_select"break;
  239.         case 3$order "sub_insert"break;
  240.         case 4$order "sub_update"break;
  241.         case 5$order "sub_delete"break;
  242.         default$order 'nome_tabella'
  243.     }
  244.     
  245.     if(isset($_GET['sort'])){
  246.         
  247.         $sort ($_GET['sort']=="d"?  "DESC" "ASC";
  248.     }
  249.     else{
  250.         $sort "ASC";
  251.     }
  252.     
  253.     // Richiama tutte le tabelle dati
  254.     $sql_tab "SELECT id_submask,sub_select,sub_insert,sub_update,sub_delete,nome_tabella,
  255.                     campo_pk_parent,campo_fk_sub,orderby_sub,orderby_sub_sort,data_modifica
  256.                 FROM {$db1['frontend']}.registro_submask
  257.                 WHERE id_table=$oid
  258.                 ORDER BY $order $sort ";
  259.     $q_tabvmsql_query($sql_tab,$link);
  260.     $matrice_tab vmsql_fetch_assoc_all($q_tab);
  261.  
  262.  
  263.         
  264.     echo "<h2>Regole sottomaschere della tabella <span class=\"var\">".oid2name($oid)."</span></h2>\n";
  265.     
  266.  
  267.     echo "<table summary=\"sottomaschere tabelle\" id=\"tab-sub-tabelle\" >\n";
  268.     
  269.     $c=0;
  270.     
  271.     
  272.     echo "\t<tr>\n";
  273.     
  274.     echo "\t\t<th height=\"20\"><span class=\"help\" title=\"Impostazione di visibili&agrave; della tabella\">visibile</span></th>\n";
  275.     echo "\t\t<th><span class=\"help\" title=\"Nome della tabella\">tabella</span></th>\n";
  276.     echo "\t\t<th><span class=\"help\" title=\"Data dell'ultima impostazione per questa sottomaschera\">ultimo settaggio</span></th>\n";
  277.     echo "\t\t<th><span class=\"help\" title=\"Possibilit&agrave; di inserimento dati da questa sottomaschera da parte di questo gruppo\">insert</span></th>\n";
  278.     echo "\t\t<th><span class=\"help\" title=\"Possibilit&agrave; di modifica dei dati da questa sottomaschera da parte di questo gruppo\">update</span></th>\n";
  279.     echo "\t\t<th><span class=\"help\" title=\"Possibilit&agrave; di cancellazione dei dati da questa sottomaschera da parte di questo gruppo\">delete</span></th>\n";
  280.     echo "\t\t<th>&nbsp;</th>\n";
  281.     
  282.     echo "\t</tr>\n";
  283.     
  284.     
  285.     foreach($matrice_tab as $tab){
  286.         
  287.         $colore=(($c%2)==0"c1":"c2";
  288.         $c++;
  289.         
  290.         if($tab['data_modifica']>0{
  291.             $data_mod date("Y-m-d H:i",$tab['data_modifica']);
  292.             $color_href="";
  293.             $title_href='';
  294.         }
  295.         else{
  296.             $data_mod "-";
  297.             $color_href=" class=\"dafare\"";
  298.             $title_href='title="Questa sottomaschera non &egrave; stata ancora configurata"';
  299.         }
  300.         
  301.         echo "\t\t<tr class=\"$colore\">
  302.                 <td>".high_si_no($tab['sub_select'])."</td>
  303.                 
  304.                 <td><a $title_href $color_href href=\"".$_SERVER['PHP_SELF']."?det=$oid&amp;conf_sub=".$tab['id_submask']."&amp;a=3&amp;gid=".$_GET['gid']."\">".$tab['nome_tabella']."</a></td>
  305.                 <td>".$data_mod."</td>
  306.                 <td>".high_si_no($tab['sub_insert'])."</td>
  307.                 <td>".high_si_no($tab['sub_update'])."</td>
  308.                 <td>".high_si_no($tab['sub_delete'])."</td>
  309.                 <td><a href=\"javascript:;\" onclick=\"if(confirm('Sei sicuro di eliminare questa sottomaschera e le sue impostazioni?\\nL\'operazione non pu� essere annullata')){document.getElementById('id_submask').value='".$tab['id_submask']."';document.forms.elimina_submask.submit();}\">Elimina</a></td>
  310.             </tr>\n";
  311.     }
  312.     
  313.     echo "</table>\n";
  314.     
  315.     echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."?elimina_submask\" id=\"elimina_submask\" name=\"elimina_submask\" style=\"display:none;\">
  316.     
  317.         <input type=\"hidden\" name=\"id_del_submask\" id=\"id_submask\" value=\"0\" />
  318.         <input type=\"hidden\" name=\"oid\" value=\"$oid\" />
  319.         <input type=\"hidden\" name=\"gid\" value=\"$gid\" />
  320.         
  321.         </form>
  322.         ";
  323.  
  324.     
  325. }
  326.  
  327.  
  328.  
  329.  
  330.  
  331. /**
  332.  * Mostra la linguetta di dettaglio dei campi per l'amministrazione delle tabelle
  333.  * 
  334.  * @desc Dettaglio per le tabelle
  335.  * @param int $oid 
  336.  * @param int $gid 
  337.  */
  338. function tab_dett($oid,$gid=0){
  339.     
  340.     global $link,$db1;
  341.     
  342.     
  343.     $oid= (int) $oid;
  344.     
  345.     $gid= (int) $gid;
  346.     
  347.     
  348.     # Vedi se  tabella o vista
  349.     $q_tipo=vmsql_query("SELECT table_type FROM {$db1['frontend']}.registro_tab WHERE id_table=$oid",$link);
  350.     list($tipo_tabvmsql_fetch_row($q_tipo);
  351.     
  352.     
  353.     # Info tabella e PK
  354.     
  355.     if($tipo_tab=='VIEW'){
  356.         
  357.         $sql_tab "SELECT rb.*, view_pk as campo_pk 
  358.                     FROM {$db1['frontend']}.registro_tab rb 
  359.                     WHERE rb.id_table=$oid
  360.                     ";
  361.         
  362.     }else{
  363.     
  364.         $sql_tab "SELECT rb.*, i.column_name as campo_pk 
  365.                     FROM {$db1['frontend']}.registro_tab rb 
  366.                     LEFT JOIN information_schema.key_column_usage i ON (i.table_name=rb.table_name AND i.table_schema='{$db1['dbname']}')
  367.                     
  368.                     WHERE rb.id_table=$oid
  369.                     ";
  370.     }
  371.     
  372.     
  373.     $q_tab=vmsql_query($sql_tab,$link);
  374.     
  375.     $info=vmsql_fetch_assoc($q_tab);
  376.     
  377.     $info['campo_pk']=str_replace(array("(",")"),"",$info['campo_pk']);
  378.     
  379.     $array_pk=explode(",",$info['campo_pk']);
  380.     foreach ($array_pk as $k=>$val){
  381.         $array_pk[$k]=trim($val);
  382.     }
  383.     
  384.  
  385.     
  386.     # Prende le FK
  387.     # Individua i campi coinvolti in una relazione esterna e tabella.campo a cui � legato
  388.  
  389.  
  390.     list($array_fk,$colref_fk)=prendi_FK($oid);
  391.     
  392.     
  393.     # Inizia a prendere i campi
  394.     
  395.     
  396.     $sql_cols "SELECT  id_reg,
  397.                         id_table,
  398.                         column_name,
  399.                         column_default,
  400.                         is_nullable,
  401.                         data_type,
  402.                         character_maximum_length,
  403.                         column_type,
  404.                         extra,
  405.                         in_tipo,
  406.                         in_default,
  407.                         in_visibile,
  408.                         in_richiesto,
  409.                         in_search,
  410.                         in_suggest,
  411.                         in_table,
  412.                         jstest,
  413.                         commento
  414.                         
  415.                         
  416.                         FROM {$db1['frontend']}.registro_col 
  417.                         WHERE id_table=$oid 
  418.                         ORDER BY ordinal_position";
  419.     
  420.     $q_cols=vmsql_query($sql_cols,$link);
  421.     
  422.     $matrice_col=vmsql_fetch_assoc_all($q_cols);
  423.     
  424.     $matrice_rev=vmsql_reverse_matrix($matrice_col);
  425.     
  426.     
  427.     // INFO GENERALI PER LA TABELLA
  428.     
  429.     $def['visibile']($info['visibile']=="1" || $info['visibile']=="t""checked=\"checked\" " "";
  430.     $def['in_insert']($info['in_insert']=="1" || $info['in_insert']=="t""checked=\"checked\" " "";
  431.     $def['in_duplica']($info['in_duplica']=="1" || $info['in_duplica']=="t""checked=\"checked\" " "";
  432.     $def['in_update']($info['in_update']=="1" || $info['in_update']=="t""checked=\"checked\" " "";
  433.     $def['in_delete']($info['in_delete']=="1" || $info['in_delete']=="t""checked=\"checked\" " "";
  434.     $def['in_export']($info['in_export']=="1" || $info['in_delete']=="t""checked=\"checked\" " "";
  435.     $def['permetti_allegati']($info['permetti_allegati']=="1" || $info['permetti_allegati']=="t" "checked=\"checked\" " "";
  436.     $def['permetti_allegati_display']($info['permetti_allegati']=="1" || $info['permetti_allegati']=="t""" "none";
  437.     
  438.     $def['permetti_link']($info['permetti_link']=="1" || $info['permetti_link']=="t""checked=\"checked\" " "";
  439.     $def['permetti_link_display']($info['permetti_link']=="1" || $info['permetti_link']=="t""" "none";
  440.     
  441.     $def['permetti_allegati_ins']($info['permetti_allegati_ins']=="1" || $info['permetti_allegati_ins']=="t""checked=\"checked\" " "";
  442.     $def['permetti_allegati_del']($info['permetti_allegati_del']=="1" || $info['permetti_allegati_del']=="t""checked=\"checked\" " "";
  443.         
  444.     $def['permetti_link_ins']($info['permetti_link_ins']=="1" || $info['permetti_link_ins']=="t""checked=\"checked\" " "";
  445.     $def['permetti_link_del']($info['permetti_link_del']=="1" || $info['permetti_link_del']=="t""checked=\"checked\" " "";
  446.     
  447.     
  448.     
  449.     
  450.     
  451.     ###############################################
  452.     #
  453.     #    Inizia a stampare
  454.     #
  455.     
  456.     $filesarray("sty/admin.css","js/mostra_hid.js","js/mostra_nascondi_id.js"
  457.                     "js/test_query.js","sty/linguette.css","js/open_window.js")//,"js/test_campi.js"); 
  458.     
  459.     $files[]="js/scriptaculous/lib/prototype.js";
  460. //    $files[]="js/prototype-1.4.0.js";
  461.     $files[]="js/scriptaculous/src/scriptaculous.js";
  462.     
  463.     echo openLayout1("Amministrazione tabella",$files);
  464.     
  465.  
  466.     
  467.     echo "<div id=\"briciole\"><a href=\"index.php\">home amministrazione</a> &raquo; <a href=\"menu_registri.php\">menu gruppi/registri</a> &raquo; <a href=\"gestione_tabelle_gruppi.php?gid=$gid\">impostazioni registro id $gid</a> &raquo; </div>";
  468.     
  469.     if($info['table_type']=='VIEW'){
  470.         echo "<h1>Impostazioni vista <span class=\"verde\">".$info['table_name']."</span> per <span class=\"verde\">".$gid."</span><span class=\"grigio\">::</span><span class=\"verde\">".gid2nome_gruppo($gid)."</span></h1>\n";
  471.     }
  472.     else{
  473.         echo "<h1>Impostazioni tabella <span class=\"var\">".$info['table_name']."</span> per <span class=\"var\">".$gid."</span><span class=\"grigio\">::</span><span class=\"var\">".gid2nome_gruppo($gid)."</span></h1>\n";
  474.     }
  475.     
  476.     
  477.     // Feedback
  478.     if(isset($_GET['feed'])){
  479.         switch($_GET['feed']){
  480.             
  481.             case 'ok_gen'$feed_str="<p class=\"feed-mod-ok\">Impostazioni generali modificate correttamente</p>\n";
  482.             break;
  483.             
  484.             case 'ok_gen_trasversale'$feed_str="<p class=\"feed-mod-ok\">Impostazioni generali per tutti i gruppi modificate correttamente</p>\n";
  485.             break;
  486.             
  487.             case 'ko_gen'$feed_str="<p class=\"feed-mod-ko\">Errore nella modifica delle impostazioni generali</p>\n";
  488.             break;            
  489.             
  490.             case 'ok_campi'$feed_str="<p class=\"feed-mod-ok\">Impostazioni dei campi modificate correttamente</p>\n";
  491.             break;
  492.             
  493.             case 'ko_campi'$feed_str="<p class=\"feed-mod-ko\">Nessuna modifica delle impostazioni dei campi</p>\n";
  494.             break;    
  495.                     
  496.             case 'ok_sub_upd'$feed_str="<p class=\"feed-mod-ok\">Impostazioni della sottomaschera modificate correttamente</p>\n";
  497.             break;
  498.             
  499.             case 'ko_sub_upd'$feed_str="<p class=\"feed-mod-ko\">Nessuna modifica delle impostazioni della sottomaschera</p>\n";
  500.             break;
  501.             
  502.             default$feed_str="";
  503.         }
  504.         
  505.         echo $feed_str;
  506.     }
  507.     
  508.     
  509.     
  510.     if(!isset($_GET['a']|| $_GET['a']=='1'){
  511.         
  512.         $attiva 'tabella-gen';
  513.         
  514.         $classe_eti['gen']='attiva';
  515.         $classe_eti['campi']='disattiva';
  516.         $classe_eti['mask']='disattiva';
  517.         $classe_eti['campisort']='disattiva';
  518.             
  519.         
  520.     }
  521.     else if($_GET['a']=='2'){
  522.         
  523.         $attiva 'tabella-campi';
  524.         
  525.         $classe_eti['gen']='disattiva';
  526.         $classe_eti['campi']='attiva';
  527.         $classe_eti['mask']='disattiva';
  528.         $classe_eti['campisort']='disattiva';
  529.         
  530.         
  531.     }else if($_GET['a']=='3'){
  532.         
  533.         $attiva 'tabella-sottomaschere';
  534.         
  535.         $classe_eti['gen']='disattiva';
  536.         $classe_eti['campi']='disattiva';
  537.         $classe_eti['mask']='attiva';
  538.         $classe_eti['campisort']='disattiva';
  539.     }
  540.     else if($_GET['a']=='4'){
  541.         
  542.         $attiva 'campi-sort';
  543.         
  544.         $classe_eti['gen']='disattiva';
  545.         $classe_eti['campi']='disattiva';
  546.         $classe_eti['mask']='disattiva';
  547.         $classe_eti['campisort']='attiva';
  548.     }
  549.     
  550.     
  551.     ?>
  552.     
  553.     
  554.     <script type="text/javascript">
  555.         // <!-- 
  556.     
  557.         var divs = new Array('tabella-gen','tabella-campi','campi-sort','tabella-sottomaschere');
  558.     
  559.         var attiva = '<?php echo $attiva;?>';
  560.         
  561.         function eti(ido){
  562.             
  563.             for (i=0;i<divs.length;i++){
  564.                 document.getElementById(divs[i]).style.display='none';
  565.                 document.getElementById('li-'+divs[i]).className='disattiva';
  566.             }
  567.             
  568.             // attiva il selezionato
  569.             document.getElementById(ido).style.display='';
  570.             document.getElementById('li-'+ido).className='attiva';
  571.             
  572.         }
  573.     
  574.         // -->
  575.     </script>
  576.     
  577.     <?php
  578.     
  579.     
  580.     
  581.     // Apre il box etichette
  582.     
  583.     // attiva disattiva
  584.     
  585.     
  586.     
  587.     echo 
  588.     "<div id=\"box-etichette\">
  589.         
  590.         <ul class=\"eti-var-gr\">
  591.             <li onclick=\"eti('tabella-gen');\" id=\"li-tabella-gen\" class=\"{$classe_eti['gen']}\" >Impostazioni generali</li>
  592.             <li onclick=\"eti('tabella-campi');\" id=\"li-tabella-campi\" class=\"{$classe_eti['campi']}\" >Impostazioni campi</li>
  593.             <li onclick=\"eti('campi-sort');\" id=\"li-campi-sort\" class=\"{$classe_eti['campisort']}\" >Ordine campi</li>
  594.             <li onclick=\"eti('tabella-sottomaschere');\" id=\"li-tabella-sottomaschere\" class=\"{$classe_eti['mask']}\" >Impostazioni sottomaschere</li>
  595.         </ul>
  596.     </div>
  597.         ";
  598.     
  599.     
  600.     
  601.     // CAMPI TABELLA:
  602.     list($campi_tabellaprendi_colonne_frontend($oid,"column_name",false);
  603.     
  604.     
  605.     ##############################################################
  606.     #
  607.     #     FORM IMPOSTAZIONI GENERALI
  608.     #
  609.     #
  610.     #
  611.     
  612.     
  613.     
  614.     $st_gen (!isset($_GET['a']|| $_GET['a']==1"" "display:none;"
  615.     
  616.     echo "
  617.     
  618.     <div class=\"tabella-gen\" id=\"tabella-gen\" style=\"$st_gen\" >
  619.     
  620.     <form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
  621.     
  622.     
  623.     
  624.         <label for=\"orderby\">Ordina per:</label>
  625.         <select name=\"orderby\" id=\"orderby\" >
  626.         ";
  627.     
  628.         while(list(,$nameeach($matrice_rev['column_name'])){
  629.             
  630.             $sel ($name==$info['orderby']"selected=\"selected\"" "";
  631.             
  632.             // se � anche chiave primaria, scrivilo
  633.             $pk ($name==$info['campo_pk'])" (chiave primaria)" "";
  634.             
  635.             echo "\t\t<option value=\"$name\" $sel >$name $pk</option>\n";        
  636.         }
  637.         
  638.     echo "
  639.         </select>
  640.         ";
  641.     
  642.     $sel_sort['ASC'($info['orderby_sort']=='ASC'"selected=\"selected\"" "";
  643.     $sel_sort['DESC'($info['orderby_sort']=='DESC'"selected=\"selected\"" "";
  644.         
  645.         echo "
  646.         <select name=\"orderby_sort\" id=\"orderby_sort\" >
  647.             <option value=\"ASC\" ".$sel_sort['ASC'].">Ascendente</option>
  648.             <option value=\"DESC\" ".$sel_sort['DESC'].">Discendente</option>
  649.         </select>
  650.         
  651.         <div class=\"info-campo\">Campo secondo il quale saranno ordinati per default i dati della tabella</div>
  652.         
  653.         <input type=\"hidden\" name=\"visibile\" id=\"visibile-hid\" value=\"0\" />
  654.         <input type=\"checkbox\" name=\"visibile\" id=\"visibile\" value=\"1\" ".$def['visibile']."/>
  655.         <label for=\"visibile\">Tabella visibile</label>
  656.         <div class=\"info-campo\">Imposta se la tabella deve essere visibile per questo gruppo</div>
  657.         
  658.         ";
  659.         
  660.         if($info['table_type']=='VIEW'){
  661.             
  662.             
  663.             /*echo "
  664.             <input type=\"hidden\" name=\"in_insert\" id=\"in_insert-hid\" value=\"0\" />
  665.             <input type=\"checkbox\" name=\"in_insert\" id=\"in_insert\" value=\"0\"  disabled=\"disabled\" />
  666.             <label for=\"in_insert\">Inserisci record (INSERT)</label>
  667.             <div class=\"info-campo\">Disabilitato in quanto vista</div>
  668.             ";*/
  669.             echo "
  670.             <input type=\"hidden\" name=\"in_insert\" id=\"in_insert-hid\" value=\"0\" />
  671.             <input type=\"checkbox\" name=\"in_insert\" id=\"in_insert\" value=\"1\"  ".$def['in_insert']." />
  672.             <label for=\"in_insert\">Inserisci record (INSERT)</label>
  673.             <div class=\"info-campo\">Permetti a questo gruppo di inserire nuovi record</div>
  674.             ";
  675.             
  676.             // IMPOSTAZIONI PER LA MODIFICABILTA' DEI DATI NELLA VISTA (prese dalla definizione della vista stessa)
  677.             $view_up=prendi_info_view($info['table_name'],'IS_UPDATABLE');
  678.             
  679.             if($view_up['IS_UPDATABLE']=='YES'){
  680.                 
  681.                 echo "
  682.             
  683.             <input type=\"hidden\" name=\"in_update\" id=\"in_update-hid\" value=\"0\" />
  684.             <input type=\"checkbox\" name=\"in_update\" id=\"in_update\"  value=\"1\" ".$def['in_update']." />
  685.             <label for=\"in_update\">Modifica i record (UPDATE)</label>
  686.             <div class=\"info-campo\">Permetti a questo gruppo di modificare record esistenti</div>
  687.             
  688.                 ";
  689.             }
  690.             else{
  691.                 echo "
  692.                 
  693.                 <input type=\"hidden\" name=\"in_update\" id=\"in_update-hid\" value=\"0\" />
  694.                 <input type=\"checkbox\" name=\"in_update\" id=\"in_update\" value=\"0\"  disabled=\"disabled\" />
  695.                 <label for=\"in_update\">Modifica i record (UPDATE)</label>
  696.                 <div class=\"info-campo\">Disabilitato in quanto vista</div>
  697.                 
  698.                 ";
  699.             }
  700.             
  701.             
  702.             // PRENDE LA DEFINIZIONE VISTA E CERACA JOIN PER IMPOSTARE IL DELETE SI|NO
  703.             if($db1['dbtype']=='mysql'){
  704.                 
  705.                 $q_join=vmsql_query("SHOW CREATE VIEW ".$info['table_name'],$link);
  706.                 list($trash,$show_create)=vmsql_fetch_row($q_join);
  707.             }
  708.             
  709.             else if ($db1['dbtype']=='postgres'){
  710.                 
  711.                 $q_join=vmsql_query("SELECT view_definition 
  712.                                     FROM information_schema.views
  713.                                     WHERE table_name='".$info['table_name']."'
  714.                                     AND table_catalog='".$db1['postgres_dbname']."'
  715.                                     AND table_schema='".$db1['dbname']."'",$link);
  716.                 list($show_create)=vmsql_fetch_row($q_join);
  717.                 
  718.             }
  719.             
  720.             $JOIN=(eregi(' JOIN ',$show_create)) true:false;
  721.                 
  722.                 
  723.             if($JOIN){
  724.                 echo "
  725.                 
  726.                 <input type=\"hidden\" name=\"in_delete\" id=\"in_delete-hid\" value=\"0\" />
  727.                 <input type=\"checkbox\" name=\"in_delete\" id=\"in_delete\" value=\"0\"  disabled=\"disabled\" />
  728.                 <label for=\"in_delete\">Elimina i record (DELETE)</label>
  729.                 <div class=\"info-campo\">Disabilitato in quanto vista con JOIN</div>
  730.                 ";
  731.             }
  732.             else{
  733.                 
  734.                 echo "
  735.                 
  736.                 <input type=\"hidden\" name=\"in_delete\" id=\"in_delete-hid\" value=\"0\" />
  737.                 <input type=\"checkbox\" name=\"in_delete\" id=\"in_delete\" value=\"1\" ".$def['in_delete']." />
  738.                 <label for=\"in_delete\">Elimina i record (DELETE)</label>
  739.                 <div class=\"info-campo\">Permetti a questo gruppo di eliminare record</div>
  740.                 ";
  741.             }
  742.         
  743.         
  744.         }
  745.         // SE invece la tabella � una normale BASE TABLE
  746.         else{
  747.             
  748.                 echo "
  749.             <input type=\"hidden\" name=\"in_insert\" id=\"in_insert-hid\" value=\"0\" />
  750.             <input type=\"checkbox\" name=\"in_insert\" id=\"in_insert\" value=\"1\" ".$def['in_insert']." onclick=\"if(this.checked){\$('cont-duplica').style.display='';} else {\$('cont-duplica').style.display='none';}\" />
  751.             <label for=\"in_insert\">Inserisci record (INSERT)</label>
  752.             <div class=\"info-campo\">Permetti a questo gruppo di inserire nuovi record</div>
  753.             ";
  754.                 
  755.             if($def['in_insert']==''$style_duplica="display:none;";
  756.                 
  757.             echo "
  758.             <div id=\"cont-duplica\" style=\"margin-left:40px;$style_duplica\">
  759.                 <input type=\"hidden\" name=\"in_duplica\" id=\"in_duplica-hid\" value=\"0\" />
  760.                 <input type=\"checkbox\" name=\"in_duplica\" id=\"in_duplica\" value=\"1\" ".$def['in_duplica']."/>
  761.                 <label for=\"in_duplica\">Duplica record (dipende da INSERT)</label>
  762.                 <div class=\"info-campo\">Permetti a questo gruppo di creare nuovi record duplicando un record esistente</div>
  763.             </div>
  764.             ";
  765.             
  766.             echo "
  767.             <input type=\"hidden\" name=\"in_update\" id=\"in_update-hid\" value=\"0\" />
  768.             <input type=\"checkbox\" name=\"in_update\" id=\"in_update\" value=\"1\" ".$def['in_update']."/>
  769.             <label for=\"in_update\">Modifica i record (UPDATE)</label>
  770.             <div class=\"info-campo\">Permetti a questo gruppo di modificare record esistenti</div>
  771.             
  772.             <input type=\"hidden\" name=\"in_delete\" id=\"in_delete-hid\" value=\"0\" />
  773.             <input type=\"checkbox\" name=\"in_delete\" id=\"in_delete\" value=\"1\" ".$def['in_delete']."/>
  774.             <label for=\"in_delete\">Elimina i record (DELETE)</label>
  775.             <div class=\"info-campo\">Permetti a questo gruppo di eliminare i record</div>
  776.             
  777.             
  778.             ";
  779.         }
  780.         
  781.         echo "
  782.         
  783.         <input type=\"hidden\" name=\"in_export\" id=\"in_export-hid\" value=\"0\" />
  784.         <input type=\"checkbox\" name=\"in_export\" id=\"in_export\" value=\"1\" ".$def['in_export']."/>
  785.         <label for=\"in_export\">Permetti esportazione</label>
  786.         <div class=\"info-campo\">Permetti a questo l'esportazione dei dati in tabella</div>
  787.         
  788.         ";
  789.         
  790.         
  791.         
  792.         // IN CASO DI VISTA IMPOSTA ESPLICITAMENTE LA CHIAVE PRIMARIA DELLA TABELLA
  793.         
  794.         if($info['table_type']=='VIEW'){
  795.             
  796.             echo "<label for=\"view_pk\">Imposta la chiave primaria</label> ";
  797.             echo "<select id=\"view_pk\" name=\"view_pk\">\n";
  798.     
  799.     
  800.             foreach($campi_tabella as $k=>$campo){
  801.                 
  802.                 $view_pk_sel ($info['view_pk']==$campo)"selected=\"selected\"""";
  803.                 
  804.                 echo "<option value=\"$campo\" $view_pk_sel>".$campo."</option>\n";
  805.                 
  806.             }
  807.             
  808.             echo "</select>
  809.             <div class=\"info-campo\">In quanto vista si rende necessario dichiarare espliticamente la chiave primaria</div>\n";
  810.         }
  811.         
  812.         
  813.         
  814.         echo "
  815.         
  816.         <fieldset style=\"width:60%;margin-bottom:20px; padding:15px;\">
  817.             <legend>Allegati e link</legend>
  818.         ";
  819.         
  820.         
  821.         // IN CASO DI VISTA IMPOSTA ESPLICITAMENTE LA FONTE PER ALLEGATI E LINK
  822.         
  823.         if($info['table_type']=='VIEW'){
  824.             
  825.             $tabelle_db=prendi_tabelle($_GET['gid']);
  826.             echo "<select id=\"fonte_al\" name=\"fonte_al\">\n";
  827.     
  828.     
  829.             foreach($tabelle_db as $k=>$tab){
  830.                 
  831.                 $view_fonte_sel ($info['fonte_al']==$tab['table_name'])"selected=\"selected\"""";
  832.                 
  833.                 echo "<option value=\"{$tab['table_name']}\" $view_fonte_sel>".$tab['table_name']."</option>\n";
  834.                 
  835.             }
  836.             
  837.             echo "</select>
  838.             <div class=\"info-campo\">In quanto vista si rende necessario dichiarare da quale tabella debbano essere letti/inseriti gli allegati e i link</div>\n";
  839.         
  840.         }
  841.         
  842.             
  843.         echo "
  844.             <input type=\"hidden\" name=\"permetti_allegati\" id=\"permetti_allegati-hid\" value=\"0\" />
  845.             <input type=\"checkbox\" name=\"permetti_allegati\" id=\"permetti_allegati\" value=\"1\" ".$def['permetti_allegati']." onclick=\";if(this.checked){document.getElementById('opzioni_allegati').style.display='';}else{document.getElementById('opzioni_allegati').style.display='none';}\" />
  846.             <label for=\"permetti_allegati\">Tabella con allegati</label>
  847.             <div class=\"info-campo\">Permette di allegare dei file (documenti o immaginiai record di questa tabella</div>
  848.             
  849.             
  850.                 <div id=\"opzioni_allegati\" style=\"display:{$def['permetti_allegati_display']}\">
  851.                     <input type=\"hidden\" name=\"permetti_allegati_ins\" id=\"permetti_allegati_ins-hid\" value=\"0\" />
  852.                     <input type=\"checkbox\" name=\"permetti_allegati_ins\" id=\"permetti_allegati_ins\" value=\"1\" ".$def['permetti_allegati_ins']."/>
  853.                     <label for=\"permetti_allegati_ins\">Permetti inserimento nuovi allegati</label>
  854.                     
  855.                     <br />
  856.                     
  857.                     
  858.                     <input type=\"hidden\" name=\"permetti_allegati_del\" id=\"permetti_allegati_del-hid\" value=\"0\" />
  859.                     <input type=\"checkbox\" name=\"permetti_allegati_del\" id=\"permetti_allegati_del\" value=\"1\" ".$def['permetti_allegati_del']."/>
  860.                     <label for=\"permetti_allegati_del\">Permetti eliminazione allegati</label>
  861.                     
  862.                 </div>
  863.             
  864.             
  865.             
  866.             <input type=\"hidden\" name=\"permetti_link\" id=\"permetti_link-hid\" value=\"0\" />
  867.             <input type=\"checkbox\" name=\"permetti_link\" id=\"permetti_link\" value=\"1\" ".$def['permetti_link']." onclick=\";if(this.checked){document.getElementById('opzioni_link').style.display='';}else{document.getElementById('opzioni_link').style.display='none';}\"  />
  868.             <label for=\"permetti_link\">Tabella con link</label>
  869.             <div class=\"info-campo\">Permette di collegare dei link ai record di questa tabella</div>
  870.             
  871.                 <div id=\"opzioni_link\" style=\"display:{$def['permetti_link_display']}\">
  872.                     <input type=\"hidden\" name=\"permetti_link_ins\" id=\"permetti_link_ins-hid\" value=\"0\" />
  873.                     <input type=\"checkbox\" name=\"permetti_link_ins\" id=\"permetti_link_ins\" value=\"1\" ".$def['permetti_link_ins']."/>
  874.                     <label for=\"permetti_link_ins\">Permetti inserimento nuovi link</label>
  875.                     
  876.                     <br />
  877.                     
  878.                     
  879.                     <input type=\"hidden\" name=\"permetti_link_del\" id=\"permetti_link_del-hid\" value=\"0\" />
  880.                     <input type=\"checkbox\" name=\"permetti_link_del\" id=\"permetti_link_del\" value=\"1\" ".$def['permetti_link_del']."/>
  881.                     <label for=\"permetti_link_del\">Permetti eliminazione link</label>
  882.                     
  883.                 </div>
  884.             
  885.         </fieldset>
  886.         <br /><br />
  887.         <input type=\"hidden\" name=\"oid\" value=\"$oid\" />
  888.         <input type=\"hidden\" name=\"gid\" value=\"$gid\" />
  889.         <input id=\"trasversale\" type=\"hidden\" name=\"trasversale_gen\" value=\"0\" />
  890.         
  891.         <input type=\"submit\" name=\"invia_gen\" value=\"Salva impostazione generale\" />
  892.         
  893.         &nbsp;&nbsp;&nbsp;
  894.         
  895.         <input type=\"button\" onclick=\"if(confirm('Attenzione!\\nSi vuole veramente modificare in questo modo le impostazioni per tutti i gruppi?')){ document.getElementById('trasversale').value='1';submit();}\" name=\"invia_gen_trasversale\" value=\"Salva impostazione generale per tutti i gruppi\" />
  896.     
  897.     </form>
  898.     
  899.     </div>\n";
  900.         
  901.     //-- fine impostazioni generali
  902.     
  903.     
  904.     
  905.     
  906.     ######################################################################################
  907.     #
  908.     #    IMPOSTAZIONI CAMPI SORT
  909.     #
  910.     #
  911.     
  912.     
  913.     $st_sub (isset($_GET['a']&& $_GET['a']==4"" "display:none;"
  914.     
  915.     echo "<div class=\"campi-sort\" id=\"campi-sort\" style=\"$st_sub\">\n";
  916.     
  917.     
  918.     echo "<h3>Ordinamento dei campi</h3>\n";
  919.     
  920.     echo "<p>Attraverso questa funzione &egrave; possibile cambiare l'ordine di presentazione dei campi della tabella
  921.      nella vista a scheda. I campi in grigio sono quelli al momento impostati come invisibili.<br />
  922.      Per modificare l'ordine dei campi prendere le etichette e trascinarle nella posizione desiderata</p>
  923.      <form name=\"ripristina\" method=\"post\" action=\"rpc.sortcampi.php?ripristina\" >
  924.      
  925.      <input type=\"hidden\" name=\"url\" value=\"".htmlentities($_SERVER['QUERY_STRING'])."\" />
  926.      <input type=\"hidden\" name=\"oid\" value=\"$oid\" />
  927.      <input type=\"button\" onclick=\"submit()\" value=\"Ripristina ordinamento di default\" name=\"ripristina1\" />
  928.      
  929.      </form>\n";
  930.     
  931.     
  932.     list($id_reg_sort,$campi_tabella_sort,$in_visibile_sortprendi_colonne_frontend($oid,"id_reg,column_name,in_visibile",false);
  933.     
  934.     
  935.     echo "<p id=\"list-info\" >&nbsp;</p>";
  936.     
  937.     echo "<div><ul id=\"firstlist\" style=\"width:200px;\">\n";
  938.     
  939.     
  940.     
  941.     foreach($campi_tabella_sort as $k=>$campo){
  942.         
  943.         $classe_sort ($in_visibile_sort[$k]=='1'"campi-float-blu":"campi-float-grigio";
  944.         
  945.         echo "<li id=\"item_{$id_reg_sort[$k]}\" class=\"$classe_sort\">".$campo."</li>\n";
  946.         
  947.     }
  948.     
  949.     echo "</ul></div>";
  950.     
  951.     
  952. //    echo "<script type=\"text/javascript\" src=\"../js/scriptaculous/scriptaculous.js?load=dragdrop\" ></script>\n";
  953.     
  954.     echo "<script type=\"text/javascript\">
  955.  // <![CDATA[
  956.             Sortable.create('firstlist', 
  957.                             {onUpdate:function()
  958.                                 {new Ajax.Updater('list-info', '".dirname($_SERVER['PHP_SELF'])."/rpc.sortcampi.php?det=$oid&gid=$gid', 
  959.                                     {onComplete:function(request){ /*new Effect.Highlight('firstlist',{}); */}
  960.                                     parameters:Sortable.serialize('firstlist'), 
  961.                                     evalScripts:true
  962.                                     asynchronous:true});
  963.                                     setTimeout(\"$('list-info').innerHTML = '&nbsp;'; \", 3000 );
  964.                                 }
  965.                             })
  966.  // ]]>
  967.     </script>";
  968.  
  969. /* echo '<script type="text/javascript">
  970.  // <![CDATA[
  971.    Sortable.create("firstlist",
  972.      {dropOnEmpty:true,containment:["firstlist","secondlist"],constraint:false});
  973.    
  974.  // ]]>
  975.  </script>';*/
  976.     
  977.     
  978.     echo "</div>\n";
  979.     
  980.     
  981.     
  982.     //-- fine campi-sort
  983.     
  984.     
  985.     ##############################################################
  986.     #
  987.     #     FORM IMPOSTAZIONI SOTTOMASCHERE
  988.     #
  989.     #
  990.     #
  991.     
  992.     
  993.     
  994.     $sottomaschere prendi_sottomaschere($oid,true);
  995.     
  996.  
  997.     
  998.     
  999.     
  1000.     $st_sub (isset($_GET['a']&& $_GET['a']==3"" "display:none;"
  1001.     
  1002.     echo "<div class=\"tabella-sottomaschere\" id=\"tabella-sottomaschere\" style=\"$st_sub\">\n";
  1003.     
  1004.     echo "<p><a href=\"javascript:;\" onclick=\"mostra_nascondi('nuova-sottomaschera');\">Nuove sottomaschere</a></p>\n";
  1005.     
  1006.         echo "<div id=\"nuova-sottomaschera\" style=\"display:none;\">\n";
  1007.         
  1008.             echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
  1009.             
  1010.             
  1011.                  <select size=\"13\" multiple=\"multiple\" name=\"new_submask[]\">
  1012.                  ";
  1013.             
  1014.             $tabelle prendi_tabelle($gid);
  1015.             
  1016.             for($i=0;$i<count($tabelle);$i++){
  1017.                 
  1018.                 // test sull'esuistanza delle sottomaschere
  1019.                 $SUB_esiste (isset($sottomaschere['nome_tabella']&& in_array($tabelle[$i]['table_name'],$sottomaschere['nome_tabella'])) true:false;
  1020.                     
  1021.                 if($tabelle[$i]['id_table']!=$oid && !$SUB_esiste)
  1022.                     echo "\t\t\t<option value=\"".$tabelle[$i]['id_table']."\">".$tabelle[$i]['table_name']."</option>\n";
  1023.                 
  1024.             }
  1025.             
  1026.             echo "
  1027.                  </select>
  1028.                 
  1029.                  <input type=\"hidden\" name=\"oid\" value=\"$oid\" />
  1030.                  
  1031.                 <br /><br />
  1032.                 <input type=\"submit\" name=\"sottomaschere\" value=\"Crea nuove sottomaschere\" />
  1033.             </form>\n";
  1034.         
  1035.  
  1036.     
  1037.         echo "</div>\n";
  1038.         
  1039.         
  1040.         ## COPIA LE SOTTOMASCHERE
  1041.         
  1042.         $mat_gruppi_sub prendi_gruppi($_GET['gid']);
  1043.     
  1044.         if(count($mat_gruppi_sub)>0){
  1045.         
  1046.             echo "<form name=\"copia_sottomaschere\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
  1047.         
  1048.             $sel_gruppi_sub="\t<select name=\"copia_sub_gid\" id=\"copia_sub_gid\" >\n";
  1049.             
  1050.             
  1051.             foreach ($mat_gruppi_sub as $k=>$ar){
  1052.                 
  1053.                 $sel_gruppi_sub.="\t\t<option value=\"".$ar['gid']."\">".$ar['gid']" - "$ar['nome_gruppo']."</option>\n";
  1054.             }
  1055.             
  1056.             $sel_gruppi_sub.="</select>";
  1057.             
  1058.             $confirm_cp_sub ="if(confirm('Se si copiano le impostazioni delle sottomaschere da un altro gruppo le attuali verranno completamente sovrascritte. \\nL\'operazione non � ripristinabile. \\nSi vuole procedere?')){submit();}";
  1059.             echo "<input type=\"hidden\" name=\"copia_sottomaschere\" value=\"1\" />\n";
  1060.             echo "<input type=\"hidden\" name=\"det\" value=\"".$_GET['det']."\" />\n";
  1061.             echo "<input type=\"hidden\" name=\"gid\" value=\"".$_GET['gid']."\" />\n";
  1062.             echo "Applica le impostazioni sottomaschere del gruppo$sel_gruppi_sub  <input type=\"button\" onclick=\"$confirm_cp_sub\" name=\"copia\" value=\" Applica \" />\n";
  1063.             
  1064.             echo "</form>\n";
  1065.             
  1066.             unset($mat_gruppi_sub);
  1067.             unset($confirm_cp_sub);
  1068.         }
  1069.         
  1070.         
  1071.     // sottomaschere esistenti:
  1072.     
  1073.     if(count($sottomaschere)==0){
  1074.         
  1075.         echo "<p><strong>Non esistono sottomaschere per questa tabella/gruppo</strong></p>\n";
  1076.         
  1077.         
  1078.         
  1079.         if($info['table_type']=='VIEW'){
  1080.         
  1081.                 
  1082.                 $tabelle_elenco=prendi_tabelle(intval($_GET['gid']));
  1083.                 
  1084.                 
  1085.                 
  1086.                 echo "<form action=\"".$_SERVER['PHP_SELF']."?det=".$_GET['det']."&amp;gid=".$_GET['gid']."\" method=\"post\" >\n";
  1087.                 
  1088.                 echo "Clona da tabella: <select name=\"id_tabella\">\n";
  1089.                 
  1090.                 for($i=0;$i<count($tabelle_elenco);$i++){
  1091.                     
  1092.                     echo "<option value=\"".$tabelle_elenco[$i]['id_table']."\">".$tabelle_elenco[$i]['table_name']."</option>\n";
  1093.                 }
  1094.                 
  1095.                 echo "</select>\n";
  1096.                 echo " <input type=\"hidden\" name=\"clona_sottomaschere_vista\" value=\"1\" />\n";
  1097.                 echo " <input type=\"hidden\" name=\"id_vista\" value=\"".$_GET['det']."\" />\n";
  1098.                 echo " <input type=\"button\" onclick=\"submit();\" name=\"clona_impostazioni\" value=\" clona impostazioni \" />\n";
  1099.                 
  1100.                 echo "</form>\n";
  1101.         }
  1102.         
  1103.         
  1104.     }
  1105.     else{
  1106.         
  1107.         submask_menu($oid);
  1108.         
  1109.     }
  1110.         
  1111.     
  1112.     // Dettagli sottomaschera
  1113.     
  1114.     if(isset($_GET['conf_sub'])){
  1115.         
  1116.         // creca l'id della submaschera nei risultati
  1117.         $k_subarray_search($_GET['conf_sub'],$sottomaschere['id_submask']);
  1118.         
  1119.         
  1120.         
  1121.         echo "<h3 style=\"margin-top:60px;border-bottom:1px solid #CCC;width:75%;\">Impostazioni generali sottomaschera <span class=\"var\">".$sottomaschere['nome_tabella'][$k_sub]."</span></h3>\n";
  1122.         
  1123.         echo "<strong>Collegamento tra le tabelle</strong>: \n";
  1124.         
  1125.         
  1126.         
  1127.         
  1128.         echo "<form name=\"sub_gen\" action=\"".$_SERVER['PHP_SELF']."?mod_sub_gen\" method=\"post\">\n";
  1129.         
  1130.         
  1131.         #######################################################################
  1132.         #
  1133.         #
  1134.         #     riferimenti e FK
  1135.         
  1136.         // prendo le FK
  1137.         $rif_sub prendi_FK($sottomaschere['nome_tabella'][$k_sub],intval($_GET['gid']));
  1138.         
  1139.         $rif_sub_k=null;
  1140.         
  1141.         // ce ne sono riferite alla tabella in oggetto?
  1142.         for($i=0;$i<count($rif_sub[1]);$i++){
  1143.             
  1144.             if(preg_match("/^{$info['table_name']}\.[\w]+/",$rif_sub[1][$i])){
  1145.                 
  1146.                 $rif_sub_k $i;
  1147.             }
  1148.         }
  1149.         
  1150.         if(!is_null($rif_sub_k)){
  1151.             
  1152.             $parent_consigliata substr$rif_sub[1][$rif_sub_k,  strpos($rif_sub[1][$rif_sub_k],".")+1  );
  1153.             $this_consigliata $rif_sub[0][$rif_sub_k];
  1154.         }
  1155.         
  1156.         
  1157.         
  1158.         echo $info['table_name'].".";
  1159.         
  1160.         echo "<select name=\"sub_gen[sub_pk_parent]\">\n";
  1161.         
  1162.         // PRENDI LE COLONNE
  1163.         
  1164.         list($colonne_parentprendi_colonne_frontend($oid,'column_name',false);
  1165.         
  1166.         list($colonne_thisprendi_colonne_frontend($sottomaschere['nome_tabella'][$k_sub],'column_name',false,0);
  1167.         
  1168.         
  1169.         
  1170.         
  1171.         // TESTA LA VISIBILITA' DEL CAMPO
  1172.         
  1173.         $campo_attuale_fk$sottomaschere['campo_pk_parent'][$k_sub];
  1174.         
  1175.         $PK_fkprendi_PK_oid($oid);
  1176.         
  1177.         /*var_dump($PK_fk);
  1178.         var_dump($sottomaschere);*/
  1179.         
  1180.         if($campo_attuale_fk!=$PK_fk[0&& $campo_attuale_fk!=''){
  1181.             
  1182.             $sql_vis_fk="SELECT in_visibile FROM {$db1['frontend']}.registro_col 
  1183.                         WHERE id_table='$oidAND column_name='$campo_attuale_fk'";
  1184.             $q_vis_fk=vmsql_query($sql_vis_fk,$link);
  1185.             
  1186.             list($in_visibile_fk)=vmsql_fetch_row($q_vis_fk);
  1187.             
  1188.             $campo_fk_visibile ($in_visibile_fktrue:false;
  1189.             
  1190.         }
  1191.         else{
  1192.             $campo_fk_visibile=true;
  1193.         }
  1194.         
  1195.         
  1196.         
  1197.  
  1198.         for($i=0;$i<count($colonne_parent);$i++){
  1199.             
  1200.             $aggiunta_sub_parent ($parent_consigliata==$colonne_parent[$i]?     " (consigliata)" "";
  1201.             
  1202.             $sel_sub_parent ($colonne_parent[$i]==$sottomaschere['campo_pk_parent'][$k_sub]"selected=\"selected\"" :"";
  1203.             
  1204.             echo "\t\t<option value=\"".$colonne_parent[$i]."\" $sel_sub_parent>".$colonne_parent[$i].$aggiunta_sub_parent."</option>\n";
  1205.         }
  1206.         
  1207.         echo "</select>\n";
  1208.         
  1209.         
  1210.         
  1211.         echo " ---<strong>&gt;</strong> ".$sottomaschere['nome_tabella'][$k_sub].".";
  1212.         
  1213.         echo "<select name=\"sub_gen[sub_fk_this]\">\n";
  1214.         
  1215.         $OPT_SUB_THIS="";
  1216.         $OPT_SUB_THIS_ORDER="";
  1217.         
  1218.         for($j=0;$j<count($colonne_this);$j++){
  1219.             
  1220.             $aggiunta_sub_this ($this_consigliata==$colonne_this[$j]?     " (consigliata)" "";
  1221.             
  1222.             $sel_sub_this ($colonne_this[$j]==$sottomaschere['campo_fk_sub'][$k_sub]"selected=\"selected\"" :"";
  1223.             
  1224.             $sel_sub_this_ord ($colonne_this[$j]==$sottomaschere['orderby_sub'][$k_sub]"selected=\"selected\"" :"";
  1225.  
  1226.             
  1227.             $OPT_SUB_THIS.= "\t\t<option value=\"".$colonne_this[$j]."\" $sel_sub_this>".$colonne_this[$j].$aggiunta_sub_this."</option>\n";
  1228.             $OPT_SUB_THIS_ORDER.= "\t\t<option value=\"".$colonne_this[$j]."\" $sel_sub_this_ord>".$colonne_this[$j]."</option>\n";
  1229.         }
  1230.         
  1231.         echo $OPT_SUB_THIS;
  1232.         
  1233.         echo "</select><div class=\"info-campo\">Imposta il collegamento tra i record della tabella e i record della sottomaschera</div>\n";
  1234.         
  1235.         
  1236.         
  1237.         
  1238.         
  1239.         // MOSTRA AVVISO IN CASO DI CAMPO NON VISIBILE
  1240.         
  1241.         if(!$campo_fk_visibile){
  1242.             
  1243.             echo "<span style=\"color:red;font-weight:bold;\">
  1244.                 ATTENZIONE! Il campo della tabella padre non &egrave; chiave primaria e non &egrave; impostato come visibile!
  1245.                  Quando si imposta un campo che non sia la chiave primaria questo deve essere visibile.
  1246.                  In questo caso il collegamento con la tabella non funzioner&agrave;<br />
  1247.                 Impostare il campo come visibile (pu&ograve essere anche un campo nascosto) dalle Impostazioni Campi</span><br /><br />\n";
  1248.         }
  1249.         //---------------------------------------------
  1250.         
  1251.         
  1252.         
  1253.         
  1254.         
  1255.         
  1256.         $sub_select_check($sottomaschere['sub_select'][$k_sub]=='1'"checked=\"checked\"" "";
  1257.         $sub_insert_check($sottomaschere['sub_insert'][$k_sub]=='1'"checked=\"checked\"" "";
  1258.         $sub_update_check($sottomaschere['sub_update'][$k_sub]=='1'"checked=\"checked\"" "";
  1259.         $sub_delete_check($sottomaschere['sub_delete'][$k_sub]=='1'"checked=\"checked\"" "";
  1260.         $tipo_vista_check1($sottomaschere['tipo_vista'][$k_sub]=='tabella'"checked=\"checked\"" "";
  1261.         $tipo_vista_check2($sottomaschere['tipo_vista'][$k_sub]=='scheda'"checked=\"checked\"" "";
  1262.         
  1263.         $sel_orderby_sub_sort_ASC ($sottomaschere['orderby_sub_sort'][$k_sub]=="ASC""selected=\"selected\"" "";
  1264.         $sel_orderby_sub_sort_DESC ($sottomaschere['orderby_sub_sort'][$k_sub]=="DESC""selected=\"selected\"" "";
  1265.         
  1266.         // imposta un default su SCHEDA
  1267.         if($tipo_vista_check1=='' && $tipo_vista_check2==''
  1268.             $tipo_vista_check2="checked=\"checked\"";
  1269.         
  1270.         
  1271.         echo "
  1272.         
  1273.         <label for=\"nome_frontend\">Nome della sottomaschera</label><br/> 
  1274.         <input type=\"text\" name=\"sub_gen[nome_frontend]\"  id=\"nome_frontend\" value=\"".$sottomaschere['nome_frontend'][$k_sub]."\" maxlength=\"240\" size=\"35\" />
  1275.         <div class=\"info-campo\">Nome della sottomaschera che apparir&agraveall'utente</div>
  1276.         
  1277.         <label for=\"tipo_vista_1\">Modalit&agravedi visualizzazione dei dati</label><br/> 
  1278.         <input type=\"radio\" name=\"sub_gen[tipo_vista]\"  id=\"tipo_vista_1\"  value=\"scheda\" $tipo_vista_check2 /> Schede
  1279.         <input type=\"radio\" name=\"sub_gen[tipo_vista]\"  id=\"tipo_vista_2\" value=\"tabella\" $tipo_vista_check1 /> Tabella
  1280.         <div class=\"info-campo\">Come mostrare i datiLa vista tabella si consiglia per sottomaschere con uno o massimo due campo di piccola dimensione</div>
  1281.         
  1282.         <input type=\"hidden\" name=\"sub_gen[sub_select]\" value=\"0\" />
  1283.         <input type=\"checkbox\" name=\"sub_gen[sub_select]\" id=\"sub_select\" value=\"1\" $sub_select_check/>
  1284.         <label for=\"sub_select\">Maschera visibile (SELECT)</label>
  1285.         <div class=\"info-campo\">Imposta se la sottomaschera deve essere visibile per questo gruppo</div>
  1286.         
  1287.         <input type=\"hidden\" name=\"sub_gen[sub_insert]\" value=\"0\" />
  1288.         <input type=\"checkbox\" name=\"sub_gen[sub_insert]\" id=\"sub_insert\" value=\"1\" $sub_insert_check/>
  1289.         <label for=\"sub_insert\">Diritti scrittura (INSERT)</label>
  1290.         <div class=\"info-campo\">Imposta se &egravepossibile inserire record attraverso la sottomaschera</div>
  1291.         
  1292.         <input type=\"hidden\" name=\"sub_gen[sub_update]\" value=\"0\" />
  1293.         <input type=\"checkbox\" name=\"sub_gen[sub_update]\" id=\"sub_update\" value=\"1\" $sub_update_check/>
  1294.         <label for=\"sub_update\">Diritti modifica (UPDATE)</label>
  1295.         <div class=\"info-campo\">Imposta se &egravepossibile modificare record attraverso la sottomaschera</div>
  1296.         
  1297.         <input type=\"hidden\" name=\"sub_gen[sub_delete]\" value=\"0\" />
  1298.         <input type=\"checkbox\" name=\"sub_gen[sub_delete]\" id=\"sub_delete\" value=\"1\" $sub_delete_check/>
  1299.         <label for=\"sub_delete\">Diritti eliminazione (DELETE)</label>
  1300.         <div class=\"info-campo\">Imposta se &egravepossibile cancellare record attraverso la sottomaschera</div>
  1301.         
  1302.         <label for=\"orderby_sub\">Ordina record sottomaschera per:</label>
  1303.         <select id=\"orderby_sub\" name=\"sub_gen[orderby_sub]\">
  1304.             $OPT_SUB_THIS_ORDER
  1305.         </select>
  1306.         
  1307.         <select id=\"orderby_sub_sort\" name=\"sub_gen[orderby_sub_sort]\">
  1308.             <option value=\"ASC\" $sel_orderby_sub_sort_ASC>Ascendente</option>
  1309.             <option value=\"DESC\" $sel_orderby_sub_sort_DESC>Discendente</option>
  1310.         </select>        
  1311.         <div class=\"info-campo\">Imposta l'ordinamento dei record della sottomaschera</div>
  1312.         
  1313.         
  1314.         
  1315.         <label for=\"max_records\">Numero di record max per la sottomaschera</label><br/> 
  1316.         <input type=\"text\" name=\"sub_gen[max_records]\"  id=\"max_records\" value=\"".$sottomaschere['max_records'][$k_sub]."\" maxlength=\"3\" size=\"5\" />
  1317.         <div class=\"info-campo\">Numero massimo di record per la sottomaschera. Si sconsiglia di tenere questo numero molto alto in quanto potrebbe causare un rallentamento nel caricamento della sottomaschera.</div>
  1318.         
  1319.         <input type=\"hidden\" name=\"sub_gen[id_submask]\" value=\"".$sottomaschere['id_submask'][$k_sub]."\" />
  1320.         <input type=\"hidden\" name=\"sub_gen[oid]\" value=\"".intval($_GET['det'])."\" />
  1321.         
  1322.         <input type=\"submit\" name=\"invia_sub_generali\" value=\"Salva impostazioni generali sottomaschera\" />
  1323.         
  1324.         ";
  1325.         
  1326.         echo "</form>\n";
  1327.         
  1328.         
  1329.         
  1330.         
  1331.         
  1332.         
  1333.         
  1334.         ###############################################################################################################
  1335.         #
  1336.         #    IMPOSTAZIONE CAMPI PER LA SOTTOMASCHERA
  1337.         #
  1338.         #
  1339.         #
  1340.         
  1341.         
  1342.         
  1343.         echo "<h3 style=\"margin-top:60px;border-bottom:1px solid #CCC;width:75%;\">Impostazioni per i campi della sottomaschera <span class=\"var\">".$sottomaschere['nome_tabella'][$k_sub]."</span></h3>\n";
  1344.         
  1345.         
  1346.             echo "\t<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."?gid=".$_GET['gid']."&amp;mod_sub_campi\">\n";
  1347.     
  1348.         
  1349.         
  1350.             # Inizia a prendere i campi
  1351.             
  1352.             
  1353.             $sql_sub_cols "SELECT  c.*
  1354.                                 
  1355.                                 FROM {$db1['frontend']}.registro_submask_col c, {$db1['frontend']}.registro_submask t
  1356.                                 WHERE t.nome_tabella='".$sottomaschere['nome_tabella'][$k_sub]."'
  1357.                                 AND t.id_table=$oid
  1358.                                 AND t.id_submask = c.id_submask
  1359.                                 ORDER BY c.ordinal_position";
  1360.             
  1361.             $q_sub_cols=vmsql_query($sql_sub_cols,$link);
  1362.             
  1363.             $matrice_sub_col=vmsql_fetch_assoc_all($q_sub_cols);
  1364.             
  1365.             $matrice_sub_rev=vmsql_reverse_matrix($matrice_sub_col);
  1366.             
  1367.             $array_sub_pk=prendi_all_PK($sottomaschere['nome_tabella'][$k_sub],0);
  1368.                        
  1369.             while(list($k,$array_sub_val)=each($matrice_sub_col)){
  1370.                 
  1371.                 
  1372.                 if($array_sub_val['column_name']==$sottomaschere['campo_fk_sub'][$k_sub]){
  1373.                     
  1374.                     
  1375.                     echo tratta_campo_submask($array_sub_val$array_sub_pk$rif_sub[0]$rif_sub[1],$sottomaschere['campo_pk_parent'][$k_sub],$oid);
  1376.                     
  1377.             /*        echo "
  1378.                     <div class=\"campo\">
  1379.                         <div class=\"campo-head\">
  1380.                             <strong class=\"var\">".$array_sub_val['column_name']."</strong> - ".$array_sub_val['data_type']." ".$array_sub_val['max_length']." ".$array_sub_val['info_fk']."
  1381.                             ".$array_sub_val['commento']."
  1382.                         
  1383.                         </div>
  1384.                         
  1385.                         <div class=\"grigio\">
  1386.                         <br />Questo campo non &egrave; soggetto ad impostazioni in quanto si &egrave; impostato come collegamento tra i record della tabella e i record della sottomaschera.
  1387.                         Pertanto il valore che assumer&agrave; sar&agrave; quello della chiave esterna relativa alla tabella genitore.
  1388.                         </div>
  1389.                     </div>
  1390.                     
  1391.                     ";*/
  1392.                 }
  1393.                 else{
  1394.                     echo tratta_campo_submask($array_sub_val$array_sub_pk$rif_sub[0]$rif_sub[1]);
  1395.                 }
  1396.             }
  1397.             
  1398.             echo "\t\t<input type=\"hidden\" name=\"oid\" value=\"".intval($_GET['det'])."\" />\n";
  1399.             
  1400.             echo "\t\t<input type=\"hidden\" name=\"id_submask\" value=\"".intval($_GET['conf_sub'])."\" />\n";
  1401.             
  1402.             echo "\t\t<input type=\"button\" name=\"invia_campi\" value=\"Salva impostazioni campi\" onclick=\"submit()\" />\n";
  1403.             
  1404.             echo "\t</form>\n";
  1405.         
  1406.         
  1407.     }
  1408.     
  1409.     
  1410.     echo "</div>\n";
  1411.     
  1412.         
  1413.     //-- fine impostazioni sottomaschere
  1414.     
  1415.     
  1416.     
  1417.     
  1418.     
  1419.     
  1420.     
  1421.     
  1422.     
  1423.     
  1424.     
  1425.     
  1426.     
  1427.     
  1428.     
  1429.     
  1430.     
  1431.     
  1432.     
  1433.     ###############################################################################
  1434.     #
  1435.     # FORM campi
  1436.     #
  1437.     
  1438.     $st_campi (isset($_GET['a']&& $_GET['a']==2"" "display:none;"
  1439.     
  1440.     echo "<div id=\"tabella-campi\" class=\"tabella-campi\" style=\"$st_campi\">\n";
  1441.     
  1442.     
  1443.     if(isset($_GET['feed']&& $_GET['feed']=='copia_ok'){
  1444.         
  1445.         echo "<p class=\"feed-mod-ok\">Impostazioni campi copiate correttamente</p>\n";
  1446.         
  1447.     }
  1448.     
  1449.     // COPIA IMPOSTAZIONI DA ALTRO GRUPPO
  1450.     
  1451.     $mat_gruppi prendi_gruppi($_GET['gid']);
  1452.     
  1453.         if(count($mat_gruppi)>0){
  1454.         
  1455.         echo "\t<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\" id=\"form_copia_campi\">\n"
  1456.         
  1457.         
  1458.         
  1459.         $sel_gruppi="\t<select name=\"copia_campi_gid\" id=\"copia_campi_gid\" >\n";
  1460.         
  1461.         
  1462.         foreach ($mat_gruppi as $k=>$ar){
  1463.             
  1464.             $sel_gruppi.="\t\t<option value=\"".$ar['gid']."\">".$ar['gid']" - "$ar['nome_gruppo']."</option>\n";
  1465.         }
  1466.         
  1467.         $sel_gruppi.="</select>";
  1468.         
  1469.         $confirm_cp ="if(confirm('Se si copiano le impostazioni da un altro gruppo le attuali verranno completamente sovrascritte. \\nL\'operazione non  ripristinabile. \\nSi vuole procedere?')){submit();}";
  1470.         echo "<input type=\"hidden\" name=\"copia_campi\" value=\"1\" />\n";
  1471.         echo "<input type=\"hidden\" name=\"det\" value=\"".$_GET['det']."\" />\n";
  1472.         echo "<input type=\"hidden\" name=\"gid\" value=\"".$_GET['gid']."\" />\n";
  1473.         echo "Applica le impostazioni campi dal gruppo$sel_gruppi  <input type=\"button\" onclick=\"$confirm_cp\" name=\"copia\" value=\" Applica \" />\n";
  1474.         
  1475.         echo "</form>\n";
  1476.         
  1477.         unset($mat_gruppi);
  1478.     }
  1479.     
  1480.     //------------------------------------
  1481.     
  1482.     
  1483.     echo "\t<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n";
  1484.     
  1485.     
  1486.                        
  1487.     while(list($k,$array_val)=each($matrice_col)){
  1488.         
  1489.         echo tratta_campo($array_val$array_pk$array_fk$colref_fk);
  1490.     }
  1491.     
  1492.     echo "\t\t<input type=\"hidden\" name=\"oid\" value=\"$oid\" />\n";
  1493.     
  1494.     echo "\t\t<input type=\"hidden\" name=\"gid\" value=\"$gid\" />\n";
  1495.     
  1496.     echo "\t\t<input id=\"trasversale_campi\" type=\"hidden\" name=\"trasversale_campi\" value=\"0\" />\n";
  1497.     
  1498.     
  1499.     echo "\t\t<input type=\"hidden\" name=\"risposta_sql_all\" id=\"risposta_sql_all\" value=\"\" />\n";
  1500.  
  1501.     
  1502.     
  1503.     echo "\t\t<input type=\"button\" name=\"invia_campi\" value=\"Salva impostazioni campi\" onclick=\"submit();\" />\n "//onclick=\"if(test_campi()=='1'){submit();}else{alert('Alcune impostazioni SQL sembrano errate, oppure si � lasciato vuoto un campo SQL. Prego verificare');}\" />
  1504.     
  1505.     
  1506.     echo "\t\t<input type=\"button\" onclick=\"if(confirm('Attenzione!\\nSi vuole veramente modificare in questo modo le impostazioni per tutti i gruppi?')){ document.getElementById('trasversale').value='1';submit();}\" name=\"invia_gen_trasversale\" value=\"Salva impostazione dei campi per tutti i gruppi\" />\n";
  1507.     
  1508.     
  1509.     
  1510.     echo "\t</form>\n";
  1511.     
  1512.     echo "</div>\n";
  1513.     
  1514.     
  1515.     echo closeLayout1();
  1516. }
  1517.  
  1518.  
  1519.  
  1520.  
  1521. // ----------------------------------  FINE FUNZIONI  -----------------------------------------
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542. // --------------------------------- AZIONI ---------------------------------------------------
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555. ###################################################################################################
  1556. #
  1557. ## INSERIMENTO INFO GENERALI DI TABELLA
  1558. #
  1559. if(isset($_POST['invia_gen']|| isset($_POST['trasversale_gen'])){
  1560.     
  1561.     
  1562.     $_dati_gen=pulisci_dom($_POST);
  1563.     
  1564.     $clausola_view_pk (isset($_dati_gen['view_pk'])) "view_pk='".$_dati_gen['view_pk']."'," "";
  1565.     $clausola_view_fonte_al (isset($_dati_gen['fonte_al'])) "fonte_al='".$_dati_gen['fonte_al']."'," "";
  1566.     
  1567.     
  1568.     $sql_gen="UPDATE {$db1['frontend']}.registro_tab 
  1569.                 SET orderby='".$_dati_gen['orderby']."', 
  1570.                     orderby_sort='".$_dati_gen['orderby_sort']."', 
  1571.                     visibile='".$_dati_gen['visibile']."',
  1572.                     in_insert='".$_dati_gen['in_insert']."',
  1573.                     in_duplica='".$_dati_gen['in_duplica']."',
  1574.                     in_update='".$_dati_gen['in_update']."',
  1575.                     in_delete='".$_dati_gen['in_delete']."',
  1576.                     in_export='".$_dati_gen['in_export']."',
  1577.                     permetti_allegati='".$_dati_gen['permetti_allegati']."',
  1578.                     permetti_allegati_ins='".$_dati_gen['permetti_allegati_ins']."',
  1579.                     permetti_allegati_del='".$_dati_gen['permetti_allegati_del']."',
  1580.                     permetti_link='".$_dati_gen['permetti_link']."',
  1581.                     permetti_link_ins='".$_dati_gen['permetti_link_ins']."',
  1582.                     permetti_link_del='".$_dati_gen['permetti_link_del']."',
  1583.                     $clausola_view_pk
  1584.                     $clausola_view_fonte_al
  1585.                     data_modifica=".time()."
  1586.                 WHERE id_table=".intval($_dati_gen['oid']);
  1587.     
  1588.     if($_dati_gen['trasversale_gen']=='1'){
  1589.         
  1590.         $q_sub_trasv=vmsql_query("SELECT table_name FROM {$db1['frontend']}.registro_tab WHERE id_table=".intval($_dati_gen['oid']),$link);
  1591.         
  1592.         list($table_name)=vmsql_fetch_row($q_sub_trasv);
  1593.         
  1594.         $sql_gen.=" OR table_name='$table_name'";
  1595.     }
  1596.     
  1597.  
  1598.     
  1599.     $q_gen=vmsql_query($sql_gen,$link);
  1600.     
  1601.     if(vmsql_affected_rows($link,$q_gen)>0){
  1602.         if($_dati_gen['trasversale_gen']=='1'){
  1603.             
  1604.             header("Location: ".$_SERVER['PHP_SELF']."?gid=".$_dati_gen['gid']."&feed=ok_gen_trasversale&det=".$_dati_gen['oid']."&a=1");
  1605.         }
  1606.         else{
  1607.             
  1608.             header("Location: ".$_SERVER['PHP_SELF']."?gid=".$_dati_gen['gid']."&feed=ok_gen&det=".$_dati_gen['oid']."&a=1");
  1609.         }
  1610.     }
  1611.     else{
  1612.         header("Location: ".$_SERVER['PHP_SELF']."?gid=".$_dati_gen['gid']."&feed=ko_gen&det=".$_dati_gen['oid']."&a=1");
  1613.     }
  1614.     
  1615.     exit;
  1616. }
  1617.  
  1618.  
  1619.  
  1620. ###################################################################################################
  1621. #
  1622. ## COPIA IMPOSTAZIONI DEI CAMPI DA UN GUPPO AD UN ALTRO
  1623. #
  1624. if(isset($_POST['copia_campi'])){
  1625.     
  1626.     require_once("./gestione_registro.inc.php");
  1627.     
  1628.     // prendi id_tabella di destinazione
  1629.     $nome_tabella_fonte oid2name($_POST['det']);
  1630.     $oid_tabella_fontename2oid($nome_tabella_fonte,$_POST['copia_campi_gid']);
  1631.     
  1632.     $esito_copiacopia_impostazione_campi($oid_tabella_fonte,$_POST['det']);
  1633.     
  1634.     if($esito_copia)
  1635.         header("Location: ".$_SERVER['PHP_SELF']."?det=".$_POST['det']."&gid=".$_POST['gid']."&a=2&feed=copia_ok");
  1636.     exit;
  1637.     
  1638. }
  1639.  
  1640.  
  1641.  
  1642.  
  1643. ###################################################################################################
  1644. #
  1645. ## COPIA IMPOSTAZIONI DELLE SOTTOMASCHERE DA UN GUPPO AD UN ALTRO
  1646. #
  1647. if(isset($_POST['copia_sottomaschere'])){
  1648.     
  1649.     require_once("./gestione_registro.inc.php");
  1650.     
  1651.     // prendi id_tabella di destinazione
  1652.     $nome_tabella_fonte oid2name($_POST['det']);
  1653.     $oid_tabella_fontename2oid($nome_tabella_fonte,$_POST['copia_sub_gid']);
  1654.     
  1655.     copia_impostazione_sottomaschere($_POST['gid'],$_POST['copia_sub_gid'],$oid_tabella_fonte,$_POST['det']);
  1656.     
  1657.     header("Location: ".$_SERVER['PHP_SELF']."?det=".$_POST['det']."&gid=".$_POST['gid']."&a=3&feed=copia_ok");
  1658.     exit;
  1659.     
  1660. }
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666. ###################################################################################################
  1667. #
  1668. ## CLONAZIONE IMPOSTAZIONI SOTTOMASCHERE DA TABELLA A VISTA AD ESSA RELATIVA
  1669. #
  1670. if(isset($_POST['clona_sottomaschere_vista'])){
  1671.     
  1672.     require_once("./gestione_registro.inc.php");
  1673.     
  1674.     $ID_TABELLA_ORIGINE= (int) $_POST['id_tabella'];
  1675.     $ID_VISTA_DESTINAZIONE= (int) $_POST['id_vista'];
  1676.     
  1677.     copia_sottomaschere_viste($ID_VISTA_DESTINAZIONE,$ID_TABELLA_ORIGINE);
  1678.     
  1679.     header("Location: ".$_SERVER['PHP_SELF']."?det=".$ID_VISTA_DESTINAZIONE."&gid=".$_GET['gid']."&a=3");
  1680.     exit;
  1681.     
  1682. }
  1683.  
  1684.  
  1685.  
  1686. ###################################################################################################
  1687. #
  1688. ## INSERIMENTO INFO SOTTOMASCHERE DI TABELLA
  1689. #
  1690. if(isset($_POST['sottomaschere'])){
  1691.     
  1692.     require_once("./gestione_registro.inc.php");
  1693.     
  1694.     
  1695.     $_dati_gen=pulisci_dom($_POST);
  1696.     
  1697.     $aff=0;
  1698.     
  1699.     for($i=0;$i<count($_dati_gen['new_submask']);$i++){
  1700.         
  1701.         $esito_inizializzazione_sub inizializza_sottomaschera($_dati_gen['oid']oid2name($_dati_gen['new_submask'][$i]));
  1702.     }
  1703.     
  1704.     
  1705.     
  1706.     if($esito_inizializzazione_sub){
  1707.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ok_new_sub&det=".$_dati_gen['oid']."&a=3");
  1708.     }
  1709.     else{
  1710.         header("Location: ".$_SERVER['PHP_SELF']."?feed=ko_new_sub&det=".$_dati_gen['oid']."&a=3");
  1711.     }
  1712.     
  1713.     
  1714.     exit;
  1715. }
  1716.  
  1717.  
  1718. ###################################################################################################
  1719. #
  1720. ## INSERIMENTO INFO CAMPI DELLA  TABELLA
  1721. #
  1722.  
  1723. if(isset($_POST['campo'])){
  1724.     
  1725.     $gid=(int) $_POST['gid'];
  1726.     
  1727.     $campo=pulisci_dom($_POST['campo']);
  1728.     
  1729.     # contatore per le righe coinvolte
  1730.     $affected=0;
  1731.     
  1732.     foreach($campo as $k=>$val){
  1733.         $sql="UPDATE {$db1['frontend']}.registro_col 
  1734.               SET in_visibile='".$val['in_visibile']."',
  1735.               in_richiesto='".$val['in_richiesto']."',
  1736.               in_search='".$val['in_search']."',
  1737.               in_suggest='".$val['in_suggest']."',
  1738.               in_tipo='".$val['in_tipo']."',
  1739.               in_table='".$val['in_table']."'
  1740.                 ";
  1741.                 
  1742.             if(isset($val['tipo_altro'])){
  1743.                 
  1744.                 // Caso selezione tra valori indicati
  1745.                 if($val['in_tipo']=="select"){
  1746.                     $val['tipo_altro']=preg_replace("'\r'","",$val['tipo_altro']);
  1747.                     $val['tipo_altro']=preg_replace("'\n'","[|]",$val['tipo_altro']);
  1748.                 }
  1749.                 
  1750.                 $altro=addslashes(stripslashes($val['tipo_altro']));
  1751.             }
  1752.             else{
  1753.                 $altro="";
  1754.             }
  1755.             
  1756.             if($altro!=""){
  1757.             $sql.=", in_default='".$altro."'
  1758.             ";
  1759.             }
  1760.             
  1761.             if(isset($val['extra']&& $val['in_tipo']=="hidden"){
  1762.                 
  1763.                 $sql.=", extra='".$val['extra']."' ";
  1764.             }
  1765.             
  1766.             
  1767.             $sql.=" WHERE id_reg=".intval($k);
  1768.         
  1769. //            echo $sql;
  1770.             
  1771.             $q_campi=vmsql_query($sql,$link,true);
  1772.             
  1773.             $affected+= vmsql_affected_rows($link,$q_campi);
  1774.             
  1775.         }
  1776.         
  1777.         
  1778.     
  1779.     
  1780.     if($affected>0){
  1781.         header("Location: ".$_SERVER['PHP_SELF']."?gid=$gid&feed=ok_campi&det=".intval($_POST['oid'])."&a=2");
  1782.     }
  1783.     else{
  1784.         header("Location: ".$_SERVER['PHP_SELF']."?gid=$gid&feed=ko_campi&det=".intval($_POST['oid'])."&a=2");
  1785.     }
  1786.         
  1787.     
  1788.     exit;
  1789. }
  1790.  
  1791. ###############################################################################################
  1792. #
  1793. #        MODIFICA IMPOSTAZIONI GENERALI DELLA SOTTOMASCHERA
  1794. #
  1795. #
  1796.  
  1797. if(isset($_GET['mod_sub_gen']&& isset($_POST['sub_gen'])){
  1798.     
  1799.     
  1800.     $dati_gen_sub =    pulisci_dom($_POST['sub_gen']);
  1801.     
  1802.     $sql_update_sub sprintf("UPDATE ".$db1['frontend'].".registro_submask 
  1803.                        SET sub_select=%d,
  1804.                         sub_insert=%d,
  1805.                         sub_update=%d,
  1806.                         sub_delete=%d,
  1807.                         nome_frontend='%s',
  1808.                         campo_pk_parent='%s',
  1809.                         campo_fk_sub='%s',
  1810.                         orderby_sub='%s',
  1811.                         orderby_sub_sort='%s',
  1812.                         max_records=%d,
  1813.                         data_modifica='%d',
  1814.                         tipo_vista='%s'
  1815.                        
  1816.                        WHERE id_submask=%d
  1817.                                            
  1818.                        ",
  1819.                         $dati_gen_sub['sub_select'],
  1820.                         $dati_gen_sub['sub_insert'],
  1821.                         $dati_gen_sub['sub_update'],
  1822.                         $dati_gen_sub['sub_delete'],
  1823.                         $dati_gen_sub['nome_frontend'],
  1824.                         $dati_gen_sub['sub_pk_parent'],
  1825.                         $dati_gen_sub['sub_fk_this'],
  1826.                         $dati_gen_sub['orderby_sub'],
  1827.                         $dati_gen_sub['orderby_sub_sort'],
  1828.                         $dati_gen_sub['max_records'],
  1829.                         time(),
  1830.                         $dati_gen_sub['tipo_vista'],
  1831.                         $dati_gen_sub['id_submask']);
  1832.                         
  1833.     $q_sub_up=vmsql_query($sql_update_sub,$link);
  1834.     
  1835.     $aff_sub_upd=vmsql_affected_rows($link,$q_sub_up);
  1836.     
  1837.     if($aff_sub_upd>0){
  1838.         header("Location: ".$_SERVER['PHP_SELF']."?gid=$gid&feed=ok_sub_upd&det=".intval($dati_gen_sub['oid'])."&conf_sub=".intval($dati_gen_sub['id_submask'])."&a=3");
  1839.     }
  1840.     else{
  1841.         header("Location: ".$_SERVER['PHP_SELF']."?gid=$gid&feed=ko_sub_upd&det=".intval($dati_gen_sub['oid'])."&conf_sub=".intval($dati_gen_sub['id_submask'])."&a=3");
  1842.     }
  1843.     
  1844.     
  1845.     
  1846.     exit;
  1847. }
  1848.  
  1849.  
  1850. #############################################################
  1851. #
  1852. #    MODIFICA CAMPI DELLA SOTTOMASCHERA
  1853. #
  1854. #
  1855.  
  1856. if(isset($_GET['mod_sub_campi'])){
  1857.     
  1858.     
  1859.     $campo_sub=pulisci_dom($_POST['campo_sub']);
  1860.     
  1861.     
  1862.     $gid=(int) $_GET['gid'];
  1863.     
  1864.     $ID_SUBMASK = (int) $_POST['id_submask'];
  1865.     
  1866.     
  1867.     
  1868.     # contatore per le righe coinvolte
  1869.     $affected=0;
  1870.     
  1871.     vmsql_begin($link);
  1872.     
  1873.     foreach($campo_sub as $k=>$val){
  1874.         $sql="UPDATE {$db1['frontend']}.registro_submask_col
  1875.               SET in_visibile='".$val['in_visibile']."',
  1876.               in_richiesto='".$val['in_richiesto']."',
  1877.               in_tipo='".$val['in_tipo']."'
  1878.                 ";
  1879.                 
  1880.             if(isset($val['tipo_altro'])){
  1881.                 
  1882.                 // Caso selezione tra valori indicati
  1883.                 if($val['in_tipo']=="select"){
  1884.                     $val['tipo_altro']=preg_replace("'\r'","",$val['tipo_altro']);
  1885.                     $val['tipo_altro']=preg_replace("'\n'","[|]",$val['tipo_altro']);
  1886.                 }
  1887.                 
  1888.                 $altro=addslashes(stripslashes($val['tipo_altro']));
  1889.             }
  1890.             elseif(isset($val['in_default'])){
  1891.                 
  1892.                 $altro=$val['in_default'];
  1893.             }
  1894.             else{
  1895.                 $altro="";
  1896.             }
  1897.             
  1898.             if($altro!="")
  1899.             $sql.=", in_default='".$altro."'
  1900.             ";
  1901.             
  1902.             $sql.=" WHERE id_reg_sub=".intval($k);
  1903.         
  1904. //            echo "\n\n$sql\n\n";
  1905.             
  1906.             $q_campi=vmsql_query($sql,$link,true);
  1907.             
  1908.             $affected+= vmsql_affected_rows($link,$q_campi);
  1909.         }
  1910.         
  1911.         
  1912.         
  1913.         
  1914.         if($affected>0){
  1915.             vmsql_commit($link);
  1916.             header("Location: ".$_SERVER['PHP_SELF']."?gid=$gid&feed=ok_sub_upd&det=".intval($_POST['oid'])."&conf_sub=".intval($_POST['id_submask'])."&a=3");
  1917.         }
  1918.         else{
  1919.             
  1920.             vmsql_rollback($link);
  1921.             header("Location: ".$_SERVER['PHP_SELF']."?gid=$gid&feed=ko_sub_upd&det=".intval($_POST['oid'])."&conf_sub=".intval($_POST['id_submask'])."&a=3");
  1922.         }
  1923.         
  1924.     
  1925.     exit;
  1926.     
  1927.     
  1928. }
  1929.  
  1930.  
  1931.  
  1932. # Funzioni di modifica di massa
  1933. if(isset($_GET['mass']&& is_numeric($_GET['gid'])){
  1934.     
  1935.     
  1936.     
  1937.     switch($_GET['mass']){
  1938.     
  1939.         case 'visibile_all'
  1940.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET visibile=1 WHERE gid=".intval($_GET['gid']),$link);
  1941.             $esito=vmsql_affected_rows($link,$q_mass);
  1942.         break;
  1943.     
  1944.         case 'visibile_none'
  1945.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET visibile=0 WHERE gid=".intval($_GET['gid']),$link);
  1946.             $esito=vmsql_affected_rows($link,$q_mass);
  1947.         break;
  1948.     
  1949.         case 'insert_all'
  1950.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET in_insert=1 WHERE gid=".intval($_GET['gid']),$link);
  1951.             $esito=vmsql_affected_rows($link,$q_mass);
  1952.         break;
  1953.     
  1954.         case 'insert_none'
  1955.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET in_insert=0 WHERE gid=".intval($_GET['gid']),$link);
  1956.             $esito=vmsql_affected_rows($link,$q_mass);
  1957.         break;
  1958.     
  1959.         case 'update_all'
  1960.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET in_update=1 WHERE gid=".intval($_GET['gid']),$link);
  1961.             $esito=vmsql_affected_rows($link,$q_mass);
  1962.         break;
  1963.     
  1964.         case 'update_none'
  1965.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET in_update=0 WHERE gid=".intval($_GET['gid']),$link);
  1966.             $esito=vmsql_affected_rows($link,$q_mass);
  1967.         break;
  1968.     
  1969.         case 'delete_all'
  1970.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET in_delete=1 WHERE gid=".intval($_GET['gid']),$link);
  1971.             $esito=vmsql_affected_rows($link,$q_mass);
  1972.         break;
  1973.     
  1974.         case 'delete_none'
  1975.             $q_mass=vmsql_query("UPDATE {$db1['frontend']}.registro_tab SET in_delete=0 WHERE gid=".intval($_GET['gid']),$link);
  1976.             $esito=vmsql_affected_rows($link,$q_mass);
  1977.         break;
  1978.     
  1979.     }
  1980.     
  1981.     if(isset($esito&& $esito>0){
  1982.         
  1983.         header("Location: ".$_SERVER['PHP_SELF']."?gid=".intval($_GET['gid'])."&feed=ok_mass");
  1984.         exit;
  1985.     }
  1986.     
  1987. }
  1988.  
  1989. // -- Fine funzioni modifica di massa
  1990.  
  1991. if(isset($_POST['id_del_submask'])){
  1992.     
  1993.     // elimina la sottomaschera
  1994.     
  1995.     $q=vmsql_query("DELETE FROM ".$db1['frontend'].".registro_submask WHERE id_submask=".intval($_POST['id_del_submask']),$link);
  1996.     
  1997.     header("Location: ".$_SERVER['PHP_SELF']."?det=".intval($_POST['oid'])."&gid=".intval($_POST['gid'])."&a=3");
  1998.     exit;
  1999. }
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005. if(isset($_GET['det']&& (int) $_GET['det']>0){
  2006.     
  2007.     // mostra i dettagli della tabella
  2008.     $oid= (int) $_GET['det'];
  2009.     tab_dett($oid,$_GET['gid']);
  2010. }
  2011. else{
  2012.     
  2013.     $gid= (int) $_GET['gid'];
  2014.     
  2015.     // se  selezionato l'ordine
  2016.     if(isset($_GET['ord'])) {
  2017.         
  2018.         tab_menu($gid,intval($_GET['ord']));  
  2019.     }
  2020.     else{
  2021.         
  2022.         tab_menu($gid);  
  2023.     }
  2024.     
  2025.     // mostra la lista tabelle
  2026.     
  2027. }
  2028.  
  2029.  
  2030. ?>

Documentation generated on Sat, 22 Sep 2007 11:50:39 +0200 by phpDocumentor 1.4.0a2