noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
card_attr.inc.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief Manage the attributs
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 require_once('class_fiche_attr.php');
00027 
00028 
00029 
00030 $fa=new Fiche_Attr($cn);
00031 
00032 /////////////////////////////////////////////////////////////////////////////
00033 // If data are post we save them first
00034 /////////////////////////////////////////////////////////////////////////////
00035 if ( isset($_POST['save']))
00036 {
00037     $ad_id=$_POST['ad_id'];
00038     $ad_text=$_POST['desc'];
00039     $ad_type=$_POST['type'];
00040     $ad_size=$_POST['size'];
00041     $ad_extra=$_POST['extra'];
00042     try
00043     {
00044         $cn->start();
00045         for ($e=0;$e<count($ad_id);$e++)
00046         {
00047             $fa->set_parameter('id',$ad_id[$e]);
00048             $fa->set_parameter('desc',$ad_text[$e]);
00049             $fa->set_parameter('type',$ad_type[$e]);
00050             $fa->set_parameter('size',$ad_size[$e]);
00051             $fa->set_parameter('extra',$ad_extra[$e]);
00052             if ( trim($ad_text[$e])!='' && trim($ad_type[$e])!='')
00053                 $fa->save();
00054         }
00055         $cn->commit();
00056     }
00057     catch (Exception $e)
00058     {
00059       alert($e->getMessage());
00060         $cn->rollback();
00061     }
00062 
00063 }
00064 /* show list of existing */
00065 $gDossier=dossier::id();
00066 $array=$fa->seek();
00067 
00068 $select_type=new ISelect('type[]');
00069 $select_type->table=0;
00070 $desc=new IText('desc[]');
00071 $desc->size=50;
00072 $size=new INum('size[]');
00073 $size->size=5;
00074 $extra=new IText('extra[]');
00075 
00076 $select_type->value=array(
00077                         array('value'=>'text','label'=>_('Texte')),
00078                         array('value'=>'numeric','label'=>_('Nombre')),
00079                         array('value'=>'date','label'=>_('Date')),
00080                         array('value'=>'zone','label'=>_('Zone de texte')),
00081                         array('value'=>'poste','label'=>_('Poste Comptable')),
00082                         array('value'=>'card','label'=>_('Fiche')),
00083                         array('value'=>'select','label'=>_('Selection'))
00084                     );
00085 $remove=new IButton('rmfa');
00086 $remove->label=_('Effacer');
00087 echo '<div class="content">';
00088 echo '<form method="post">';
00089 
00090 echo HtmlInput::hidden('sa','fat');
00091 echo HtmlInput::hidden('p_action','divers');
00092 echo '<table id="tb_rmfa">';
00093 echo '<tr>';
00094 echo th(_("id"));
00095 echo th(_("Description"));
00096 echo th(_("Type"));
00097 echo th(_("Taille"));
00098 echo th(_("Paramètre"));
00099 echo '</tr>';
00100 for ($e=0;$e<count($array);$e++)
00101 {
00102     $row=$array[$e];
00103     $r='';
00104     $r.=td(HtmlInput::hidden('ad_id[]',$row->get_parameter('id')).$row->get_parameter('id'));
00105     $select_type->selected=$row->get_parameter('type');
00106     $desc->value=$row->get_parameter('desc');
00107     $size->value=$row->get_parameter('size');
00108     $extra->value=$row->get_parameter('extra');
00109     if ( $row->get_parameter('id')>= 9000)
00110     {
00111         $select_type->readOnly=false;
00112         $desc->readOnly=false;
00113         $size->readOnly=false;
00114         $extra->readOnly=false;
00115 
00116         $desc->style=' class="input_text" ';
00117         $r.=td($desc->input());
00118         $r.=td($select_type->input());
00119         $r.=td($size->input());
00120         $r.=td($extra->input());
00121 
00122         $remove->javascript=sprintf('if ( confirm(\'Vous  confirmez ?\')) { removeCardAttribut(%d,%d,\'tb_rmfa\',this);}',
00123                                     $row->get_parameter('id'),$gDossier);
00124         $msg='<span class="notice">'._("Attention : effacera les données qui y sont liées").' </span>';
00125         $r.=td($remove->input().$msg);
00126     }
00127     else
00128     {
00129         $select_type->readOnly=true;
00130         $desc->readOnly=true;
00131         $size->readOnly=true;
00132         $extra->readOnly=true;
00133 
00134         $r.=td($desc->input().HtmlInput::hidden('type[]',''));
00135         $r.=td($select_type->input());
00136         $r.=td($size->input());
00137         $r.=td($extra->input());
00138         $r.=td("");
00139     }
00140 
00141 
00142 
00143 
00144     echo tr($r);
00145 
00146 }
00147 $desc->readOnly=false;
00148 $select_type->readOnly=false;
00149 $size->readOnly=false;
00150 $extra->readOnly=false;
00151 $desc->value='';
00152 $select_type->selected=-1;
00153 $r=td(HtmlInput::hidden('ad_id[]','0'));
00154 $r.=td($desc->input());
00155 $r.=td($select_type->input());
00156 $r.=td($size->input());
00157 $r.=td($extra->input());
00158 echo tr($r);
00159 
00160 echo '</table>';
00161 echo HtmlInput::submit('save','Sauver');
00162 echo '</form>';
00163 echo '</div>';
 All Data Structures Namespaces Files Functions Variables Enumerations