Example #1
0
 function show_relations()
 {
     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     #
     #	show the table relations box
     #
     global $isFilteredData, $filters, $_TBL_DEFS, $_T_TBL_DEFS, $_FLD_DEFS, $_T_FLD_DEFS, $_FIELDS, $_T_FIELDS, $_RESERVED_FIELDS;
     //var_dump($_TBL_DEFS);echo '<hr>';
     //var_dump($_FLD_DEFS);echo '<hr>';
     //var_dump($_FIELDS);echo '<hr>';
     $html = '';
     $ajax = '';
     $_filters = array();
     $not_referenced_fields = get_not_referenced_fields();
     //echo '$_T_TBL_DEFS['.$_T_TBL_DEFS.']<br>';
     //var_dump($_TBL_DEFS);echo '<hr>';
     //echo '$_T_FLD_DEFS['.$_T_FLD_DEFS.']<br>';
     $total_referenced_on_screen = 0;
     //for($i=0;$i<$_T_FLD_DEFS;$i++)
     for ($i = 0; $i < $_T_TBL_DEFS; $i++) {
         #	list main table fields
         #
         $ii = 0;
         $referencedTable = '';
         while ($ii < $_T_FIELDS && $referencedTable == '') {
             #	let's get the field label
             #
             if ($_FIELDS[$ii]['Field'] == $_TBL_DEFS[$i]['referenceField']) {
                 if (strlen($_FIELDS[$ii]['Comment']) > 0) {
                     $label = $_FIELDS[$ii]['Comment'];
                 } else {
                     $label = $_FIELDS[$ii]['Field'];
                 }
                 $field = $_FIELDS[$ii]['Field'];
                 $type = $_FIELDS[$ii]['Type'];
                 $referencedTable = $_TBL_DEFS[$i]['referencedTable'];
                 $referencedID = $_TBL_DEFS[$i]['referencedID'];
                 $referencedDesc = $_TBL_DEFS[$i]['referencedDesc'];
             }
             $ii++;
         }
         //echo '$field['.$field.']<br>';
         //echo '$type['.$type.']<br>';
         //echo '$referencedTable['.$referencedTable.']<br>';
         //echo '$referencedID['.$referencedID.']<br>';
         //echo '$referencedDesc['.$referencedDesc.']<br>';
         //echo '$total_referenced_on_screen['.$total_referenced_on_screen.']<br>';
         if ($referencedTable != '' && $type != 'date' && $type != 'datetime' && $type != 'timestamp') {
             $total_referenced_on_screen++;
             $html .= '<tr>' . '<td valign="top" align="right">' . '<span ' . '>' . $label . '</span>' . '<div style="display:none;border:0px dotted green;">' . '<input id="__field_' . $i . '" name="__field_' . $i . '_" type="hidden" value="' . $field . '" />' . '<input id="__referencedTable_' . $i . '" name="__referencedTable_' . $i . '_" type="hidden" value="' . $referencedTable . '" />' . '<input id="__referencedID_' . $i . '" name="__referencedID_' . $i . '_" type="hidden" value="' . $referencedID . '" />' . '</div>' . '<div>' . '<input type="button" class="button-secondary" style="margin:4px -14px 0 0;" name="btn" value="&nbsp;' . __('Remove this relation', MED_LOCALE) . '&nbsp;" onclick="javascript:' . 'if(confirm(\'' . __('Are you sure that you want to remove this relation?', MED_LOCALE) . '\')==false) {' . 'return false;' . '};' . 'var t=document.getElementById(\'__total_referenced_on_screen_\');' . 't.value=t.value-1;' . 'sndReq(\'delete_reference\',\'update_references_info\',\'' . $i . AJAX_PARMS_SPLITTER . EDIT_TABLE_NAME . '\');' . '" />' . '</div>' . '</td>' . '<td valign="top">' . '&rsaquo;' . '</td>' . '<td valign="top">' . '<div id="med_' . $field . '_relation_table"><img src="' . PLUGIN_LINK . 'img/loading.gif" /></div>' . '</td>' . '<td valign="top">' . '&raquo;' . '</td>' . '<td valign="top">' . '<div id="med_' . $field . '_relation_field"><img src="' . PLUGIN_LINK . 'img/loading.gif" /></div>' . '</td>' . '</tr>';
             #
             #	build the code necessary to fill the relations top tab contents
             #
             $ajax .= 'sndReq(\'tables_list\',\'med_' . $field . '_relation_table\',\'' . MAINSITE_DB . AJAX_PARMS_SPLITTER . '' . AJAX_PARMS_SPLITTER . EDIT_TABLE_NAME . AJAX_PARMS_SPLITTER . 1 . AJAX_PARMS_SPLITTER . 'link2fields' . AJAX_PARMS_SPLITTER . $field . AJAX_PARMS_SPLITTER . $referencedTable . AJAX_PARMS_SPLITTER . $referencedID . AJAX_PARMS_SPLITTER . $i . AJAX_PARMS_SPLITTER . $referencedDesc . '\');';
         }
     }
     //var_dump($_SESSION[EDIT_TABLE_NAME.'_filters']);
     //	if(strlen($lang)==0)	{ $lang = $_SESSION['table_editor']['lang']; }
     //	if(strlen($lang)==0)	{ $lang = $_SESSION['sitelanguage']; }
     //if(strlen($html)>0)
     //{
     $html_not_referenced = '<select id="not_ref_fields" name="not_referenced_fields">' . '<option value="">' . __('Select a new field to reference and click on this button &raquo;', MED_LOCALE) . '</option>';
     foreach ($not_referenced_fields as $field) {
         $html_not_referenced .= '<option value="' . $field . '">' . $field . '</option>';
     }
     $html_not_referenced .= '</select>';
     $html = '' . '<div id="_relations_Data" class="top_tab_contents">' . '<table cellspacing="6" cellpadding="0" border="0" width="98%" align="right">' . '<tr>' . '<th align="right" colspan="2">' . 'This field is related' . '</th>' . '<th>' . '&rsaquo; to this table &raquo;' . '</th>' . '<th align="left" colspan="2">' . 'on this field' . '</th>' . '</tr>' . '<tr>' . '<td>' . $html . '</td>' . '</tr>' . '<tr>' . '<td id="_relations_add" colspan="99" align="right" style="padding:0;margin:0;background:transparent;">' . '</td>' . '</tr>' . '<tr>' . '<td id="_relations_addChildren" colspan="99" align="right" class="updated" style="border-color:#21759b;background:#298cba;">' . '</td>' . '</tr>' . '<tr>' . '<td colspan="99" width="1%" align="right">' . '<div>' . '<div style="float:right;">' . '<input type="button" class="button-secondary" style="margin-left:8px;" name="btn" value="&nbsp;' . __('Add relation', MED_LOCALE) . '&nbsp;" onclick="javascript:' . 'if(document.getElementById(\'not_ref_fields\').value==\'\'){' . 'alert(\'' . __('Please select the new field to reference!', MED_LOCALE) . '\');' . 'return false;' . '}' . 'sndReq(\'relation_add\',\'_relations_add\',\'\'+document.getElementById(\'not_ref_fields\').value+\'' . AJAX_PARMS_SPLITTER . '\'+document.getElementById(\'__total_referenced_on_screen_\').value+\'' . AJAX_PARMS_SPLITTER . EDIT_TABLE_NAME . '\');' . '" />' . '<input type="button" class="button-primary" style="margin-left:8px;" name="btn" value="&nbsp;' . __('Apply', MED_LOCALE) . '&nbsp;" onclick="javascript:' . 'sndReq(\'update_references\',\'update_references_info\',\'\'+document.getElementById(\'__total_referenced_on_screen_\').value+\'' . AJAX_PARMS_SPLITTER . EDIT_TABLE_NAME . '\');' . '" />' . '</div>' . '<div id="not_ref_fields_container" style="float:right;">' . $html_not_referenced . '</div>' . '<input id="__total_referenced_on_screen_" name="__total_referenced_on_screen_" type="hidden" value="' . $total_referenced_on_screen . '" />' . '</div>' . '</td>' . '</tr>' . '<tr>' . '<td colspan="99">' . '<div id="update_references_info"></div>' . '</td>' . '</tr>' . '</table>' . '</div>' . '<div style="float:right;margin-right:8px;background:url(' . PLUGIN_LINK . 'img/screen-options-left.gif) repeat-x;cursor:pointer;" ' . 'onclick="javascript:if(getCookie(\'myeasydb_relations_Data\')!=1){ __get_tables_relations(); };' . 'el_display_toggler(\'_relations_Data\',\'_relations_TogglerImg\');' . '">' . '<span class="vert-scrolling-tab" style="line-height:22px;">' . __('Relations', MED_LOCALE) . '' . '<img id="_relations_TogglerImg" style="float:right;margin:0;" src="' . PLUGIN_LINK . 'img/screen-options-right.gif" valign="top" />' . '</span>' . '</div>' . '<script type="text/javascript">' . 'function __get_tables_relations() {' . $ajax . '};' . 'if(getCookie(\'myeasydb_relations_Data\')==1) { ' . 'document.getElementById(\'_relations_Data\').style.display=\'block\';' . 'document.getElementById(\'_relations_TogglerImg\').src=\'' . PLUGIN_LINK . 'img/screen-options-right-up.gif\';' . 'setTimeout(\'__get_tables_relations()\',250);' . '} else {' . 'document.getElementById(\'_relations_Data\').style.display=\'none\';' . 'document.getElementById(\'_relations_TogglerImg\').src=\'' . PLUGIN_LINK . 'img/screen-options-right.gif\';' . '}' . '</script>';
     //}
     return $html;
 }
Example #2
0
     exit;
     break;
     #
     #---------------------------
 #
 #---------------------------
 case 'set_unreferenced_fields_selection':
     #---------------------------
     #
     #	0: database
     #	1: table
     #	2: field (not mandatory), if passed avoid to include it in the select
     #
     define('EDIT_TABLE_NAME', $parms[1]);
     require MED_PATH . 'inc/table_editor.inc.php';
     $not_referenced_fields = get_not_referenced_fields();
     $html_not_referenced = '<select id="not_ref_fields" name="not_referenced_fields">' . '<option value="">' . __('Select a new field to reference and click on this button &raquo;', MED_LOCALE) . '</option>';
     foreach ($not_referenced_fields as $field) {
         if ($field != $parms[2]) {
             $html_not_referenced .= '<option value="' . $field . '">' . $field . '</option>';
         }
     }
     $html_not_referenced .= '</select>';
     echo $html_not_referenced;
     //echo $splitter_block
     //	.$js;
     exit;
     break;
     #
     #---------------------------
 #