menu.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of PhpCompta.
00005  *
00006  *   PhpCompta is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   PhpCompta is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with PhpCompta; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 /* $Revision$ */
00021 
00022 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00023 
00024 /* !\file
00025  *
00026  *
00027  * \brief Show the table menu and let you add your own
00028  *
00029  */
00030 require_once 'class_menu_ref.php';
00031 require_once 'class_sort_table.php';
00032 require_once 'class_extension.php';
00033 
00034 
00035 echo '<div class="content">';
00036 /**
00037  * if post save then we save a new one
00038  */
00039 if ( isset($_POST['save_plugin']))
00040 {
00041         extract($_POST);
00042         $plugin=new Extension($cn);
00043         $plugin->me_code=$me_code;
00044         $plugin->me_menu=$me_menu;
00045         $plugin->me_file=$me_file;
00046         $plugin->me_description=$me_description;
00047         $plugin->me_parameter='plugin_code='.$me_code;
00048         $plugin->insert_plugin();
00049 }
00050 /**
00051  * if post update then we update
00052  */
00053 if (isset($_POST['mod_plugin']))
00054 {
00055         extract ($_POST);
00056         $plugin=new Extension($cn);
00057         $plugin->me_code=$me_code;
00058         $plugin->me_menu=$me_menu;
00059         $plugin->me_file=$me_file;
00060         $plugin->me_description=$me_description;
00061         $plugin->me_parameter='plugin_code='.$me_code;
00062         if ( !isset ($delete_pl))
00063         {
00064                 $plugin->update_plugin();
00065         }
00066         else
00067         {
00068                 $plugin->remove_plugin();
00069         }
00070 }
00071 /**
00072  * if post save then we save a new one
00073  */
00074 if ( isset($_POST['create_menu'])|| isset($_POST['modify_menu']))
00075 {
00076         extract($_POST);
00077         $menu_ref=new Menu_Ref($cn);
00078         $menu_ref->me_code=$me_code;
00079         $menu_ref->me_menu=$me_menu;
00080         $menu_ref->me_file=$me_file;
00081         $menu_ref->me_description=$me_description;
00082         $menu_ref->me_parameter=$me_parameter;
00083         $menu_ref->me_url=$me_url;
00084         $menu_ref->me_javascript=$me_javascript;
00085         $menu_ref->me_type='ME';
00086         $check=$menu_ref->verify();
00087         if ($check == 0)
00088         {
00089                 if (isset($_POST['create_menu']))
00090                 {
00091                         $menu_ref->insert();
00092                 }
00093                 elseif (isset($_POST['modify_menu']))
00094                 {
00095                         if ($menu_ref->verify() == 0)
00096                                 $menu_ref->update();
00097                 }
00098         }
00099 }
00100 /**
00101  * if delete then delete
00102  */
00103 
00104 //////////////////////////////////////////////////////////////////////////////
00105 // Show the list of menu
00106 //////////////////////////////////////////////////////////////////////////////
00107 global $cn;
00108 
00109 $table=new Sort_Table();
00110 $url=$_SERVER['REQUEST_URI'];
00111 
00112 $table->add('Code',$url,"order by me_code asc","order by me_code desc","codea","coded");
00113 $table->add('Menu',$url,"order by me_menu asc","order by me_menu desc","menua","menud");
00114 $table->add('Description',$url,"order by me_description asc","order by me_description desc","desa","desd");
00115 $table->add('Fichier',$url,"order by me_file asc","order by me_file desc","fa","fd");
00116 $table->add('URL',$url,"order by me_url asc","order by me_url desc","urla","urld");
00117 $table->add('Paramètre',$url,"order by me_parametere asc","order by me_parameter desc","paa","pad");
00118 $table->add('Javascript',$url,"order by me_javascript asc","order by me_javascript desc","jsa","jsd");
00119 $table->add('Type',$url,"order by me_type asc","order by me_type desc","ta","td");
00120 
00121 $ord=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'codea';
00122 
00123 $order=$table->get_sql_order($ord);
00124 
00125 
00126 
00127 $iselect=new ISelect('p_type');
00128 $iselect->value=array(
00129         array("value"=>'',"label"=>"Tout"),
00130         array("value"=>'ME',"label"=>"Menu"),
00131         array("value"=>'PR',"label"=>"Impression"),
00132         array("value"=>'PL',"label"=>"Extension / Plugin"),
00133         array("value"=>'SP',"label"=>"Valeurs spéciales")
00134         );
00135 $iselect->selected=(isset($_REQUEST['p_type']))?$_REQUEST['p_type']:'';
00136 $sql="";
00137 if ( $iselect->selected != '')
00138 {
00139         $sql="where me_type='".sql_string($_REQUEST['p_type'])."'  ";
00140 }
00141 $menu=new Menu_Ref_sql($cn);
00142 $ret=$menu->seek($sql.$order);
00143 ?>
00144 <fieldset><legend>Recherche</legend>
00145 <form method="GET">
00146         <?=$iselect->input()?>
00147         <?=HtmlInput::submit("search", "Recherche")?>
00148         <?=HtmlInput::request_to_hidden(array('ac','gDossier','ord'))?>
00149 </form>
00150 </fieldset>
00151 <p class="info"> le type vaut :
00152         <ul>
00153         <li> ME pour Menu</li>
00154         <li> PR pour les impressions </li>
00155         <li> PL pour les plugins</li>
00156         <li> SP pour des valeurs spéciales</li>
00157         </ul>
00158 
00159         </p>
00160 <?
00161 $gDossier=Dossier::id();
00162 echo HtmlInput::button("Add_plugin", "Ajout d'un plugin", "onclick=add_plugin($gDossier)");
00163 echo HtmlInput::button("Add_menu", "Ajout d'un menu", "onclick=create_menu($gDossier)");
00164 echo '<table class="result">';
00165 echo '<tr>';
00166 echo '<th>'.$table->get_header(0).'</th>';
00167 echo '<th>'.$table->get_header(1).'</th>';
00168 echo '<th>'.$table->get_header(2).'</th>';
00169 echo '<th>'.$table->get_header(3).'</th>';
00170 echo '<th>'.$table->get_header(4).'</th>';
00171 echo '<th>'.$table->get_header(5).'</th>';
00172 echo '<th>'.$table->get_header(6).'</th>';
00173 echo '<th>'.$table->get_header(7).'</th>';
00174 echo '</tr>';
00175 
00176 for ($i = 0; $i < Database::num_row($ret); $i++)
00177 {
00178     $row = $menu->get_object($ret, $i);
00179     $js = $row->me_code;
00180     switch ($row->me_type)
00181     {
00182         case 'PL':
00183             $js = sprintf('<A class="line" href="javascript:void(0)"  onclick="mod_plugin(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
00184             break;
00185         case 'ME':
00186             $js = sprintf('<A class="line" href="javascript:void(0)"  onclick="modify_menu(\'%s\',\'%s\')">%s</A>', $gDossier, $row->me_code, $row->me_code);
00187             break;
00188     }
00189     $class = ( $i % 2 == 0) ? $class = ' class="odd"' : $class = ' class="even"';
00190     echo "<tr $class>";
00191     echo td($js);
00192     echo td($row->me_menu);
00193     echo td(h($row->me_description));
00194     echo td(h($row->me_file));
00195     echo td(h($row->me_url));
00196     echo td(h($row->me_parameter));
00197     echo td(h($row->me_javascript));
00198     echo td(h($row->me_type));
00199     echo '</tr>';
00200 }
00201 echo '</table>';
00202 
00203 ?>