[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <? 2 //==================================================================================== 3 // OCS INVENTORY REPORTS 4 // Copyleft Pierre LEMMET 2005 5 // Web: http://ocsinventory.sourceforge.net 6 // 7 // This code is open source and may be copied and modified as long as the source 8 // code is always made freely available. 9 // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt 10 //==================================================================================== 11 //Modified on 7/7/2005 12 if(!class_exists("Req")) 13 { 14 /** 15 * \brief Classe Req 16 * 17 * Cette classe contient un objet requete pour l'application 18 */ 19 class Req 20 { 21 var $label, /// Nom et description de la requete 22 $whereId, 23 $linkId, 24 $where, /// Commande SQL de la requête 25 $select, /// Les champs à selectionner 26 $selectPrelim, /// Les champs à selectionner 27 $from, /// Les champs à selectionner 28 $fromPrelim, 29 $group, 30 $order, 31 $countId, 32 $labelChamps, /// Tableau contenant le texte de tous les paramètres de la requete 33 $sqlChamps, /// Tableau contenant toutes les requetes de préremplissage des ComboBox de choix des parametres 34 $typeChamps, /// Tableau contenant les types de champs de saisie des parametres de la requete: 35 /// COMBO: combobox préremplie par les requetes de $sqlChamps ou 36 /// FREE : champ texte libre) 37 $isNumber, /// Tableau indiquant si un nombre est attendu pour le parametre 38 $pics, //les images 39 $columnEdit, /// Indique si les colonnes sont éditables 40 $selFinal; 41 42 function Req($label,$whereId,$linkId,$where,$select,$selectPrelim,$from,$fromPrelim,$group,$order,$countId,$pics=NULL,$columnEdit=false,$labelChamps=NULL,$sqlChamps=NULL,$typeChamps=NULL,$isNumber=NULL,$selFinal="") // constructeur 43 { 44 $this->label=$label; 45 $this->whereId=$whereId; 46 $this->linkId=$linkId; 47 $this->where=$where; 48 $this->select=$select; 49 $this->selectPrelim=$selectPrelim; 50 $this->from=$from; 51 $this->fromPrelim=$fromPrelim; 52 $this->group=$group; 53 $this->order=$order; 54 $this->countId=$countId; 55 $this->pics=$pics; 56 $this->labelChamps=$labelChamps; 57 $this->sqlChamps=$sqlChamps; 58 $this->typeChamps=$typeChamps; 59 $this->isNumber=$isNumber; 60 $this->columnEdit=$columnEdit; 61 $this->selFinal=$selFinal; 62 } 63 64 function getSelect() { 65 $toRet = ""; 66 $prems = true; 67 foreach( $this->select as $key=>$val ) { 68 if( !$prems ) $toRet .= ","; 69 $toRet .= $key." AS \"".$val."\""; 70 $prems = false; 71 } 72 return $toRet; 73 } 74 75 function getFullRequest() { 76 77 $ret = "SELECT ".$this->getSelect(); 78 if( $this->from || $this->fromPrelim ) { 79 $ret .= " FROM "; 80 if( $this->from ) { 81 $ret .= $this->from; 82 $dej = 1; 83 } 84 if( $this->fromPrelim ) { 85 if( $dej ) $ret .= ","; 86 $ret .= $this->fromPrelim; 87 } 88 } 89 if( $this->where ) $ret .= " WHERE ".$this->where; 90 if( $this->group ) $ret .= " GROUP BY ".$this->group; 91 if( $this->order ) $ret .= " ORDER BY ".$this->order; 92 93 return $ret; 94 } 95 96 function getSelectPrelim() { 97 if( ! is_array($this->selectPrelim) ) 98 return; 99 $toRet = ""; 100 $prems = true; 101 foreach( $this->selectPrelim as $key=>$val ) { 102 if( !$prems ) $toRet .= ","; 103 $toRet .= $key." AS \"".$val."\""; 104 $prems = false; 105 } 106 return $toRet; 107 } 108 109 function toHtml($link) // renvoie la page html présentant la requete 110 { 111 $result=NULL; 112 $html="<br><table border=1 class= \"Fenetre\" WIDTH = '62%' ALIGN = 'Center' CELLPADDING='5'><th height=40px class=\"Fenetre\" colspan=2><b>".$this->label."</b>\n"; 113 $i=0; 114 $html.="</th><form name=\"req2\" method=\"POST\" action=\"index.php\">\n"; 115 $html.="<input type=hidden name=lareq value=\"$this->label\">"; 116 if(isset($this->labelChamps[0])) 117 foreach($this->labelChamps as $lbl) // On parcourt le tableau des parametres 118 { 119 $fond=($x == 1 ? "#FFFFFF" : "#F2F2F2"); // on alterne les couleurs de ligne 120 $x = ($x == 1 ? 0 : 1) ; 121 122 if($lbl==NULL) break; 123 124 $html.="<tr bgcolor=$fond height=40px>"; 125 if($this->typeChamps[$i]!="FREE"&&substr($this->sqlChamps[$i],0,6)=="SELECT") // Si c'est une combo 126 { 127 $result = mysql_query( $this->sqlChamps[$i], $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); // on execute la requete remplissant la combo 128 //echo $this->sqlChamps[$i]; 129 $nomColonne= mysql_fetch_field($result); 130 } 131 132 $html.="<td width=50% align=\"center\">".$lbl."</td><td width=50%>\n"; 133 134 switch($this->typeChamps[$i]) 135 { 136 case "COMBO": $html.="<p align=\"left\"><select class=\"bouton\" name=option$i>"; 137 $varr="option".$i; 138 $vall=""; 139 if(isset($_POST[$varr])) 140 { 141 $vall=$_POST[$varr]; 142 $html.="<option selected>".utf8_decode($vall)."</option>\n"; 143 $select=""; 144 } 145 else 146 { 147 $select="selected"; 148 } 149 break; 150 151 case "FREE": $html.="<p align=\"left\"><input class=bouton type=\"text\" size=\"15\" maxlength=\"256\" "; 152 $varr="option".$i; 153 $vall=isset($_POST[$varr])?$_POST[$varr]:""; 154 $html.="name=\"option$i\" value=\"".$vall."\"></p>\n";break; 155 156 } 157 158 if($this->typeChamps[$i]=="COMBO") 159 { 160 if(substr($this->sqlChamps[$i],0,6)=="SELECT") 161 while($item = mysql_fetch_object($result)) 162 { 163 // Ajouter $item dans la combo 164 $cl=$nomColonne->name; 165 if((isset($_POST[$varr])&&$item->$cl!=$vall) || !isset($_POST[$varr])) 166 $html.="<option>".$item->$cl."</option>\n"; // on met l'objet trouvé dans la combo 167 } 168 else 169 { 170 $bouts = explode(",", $this->sqlChamps[$i]); 171 foreach($bouts as $le) 172 if($le!=$vall) 173 $html.="<option>$le</option>\n"; // on met l'objet trouvé dans la combo 174 } 175 } 176 if($this->typeChamps[$i]=="COMBO") 177 $html.="</p></select>\n"; 178 $i++; 179 $html.="</td></tr>"; 180 } 181 if(isset($this->labelChamps[0])) 182 $html.="<tr bgcolor=white height=40px><td colspan=2> 183 <p align=\"right\"><input type=\"hidden\" name=\"sub\" value=\"Envoyer\"><input onmouseover=\"this.style.background='#FFFFFF';\" onmouseout=\"this.style.background='#C7D9F5'\" type=button class=\"bouton\" value=Envoyer OnClick='req2.submit()'>\n"; 184 185 $html.="</tr></FORM></table><br>\n"; 186 return $html; 187 } 188 } 189 } 190 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |