Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 190
0.00% covered (danger)
0.00%
0 / 19
CRAP
n/a
0 / 0
deliverd_to_accept
0.00% covered (danger)
0.00%
0 / 29
0.00% covered (danger)
0.00%
0 / 1
132
cuentat_mov_default_record
0.00% covered (danger)
0.00%
0 / 44
0.00% covered (danger)
0.00%
0 / 1
156
banco_id_select
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
banco_options
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
banco_mov_tipo_id_select_acuenta
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
banco_mov_tipo_acuenta_options
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
42
cliente_id_select
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
cliente_options
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
moneda_id_select
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
moneda_options
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
doSelectTienda
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
20
tienda_id_select
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
tienda_options
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
tienda_puede
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
tiendas_puede_editar
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
tiendas_puede_consultar
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
deuda_puede
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
20
gasto_puede
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
20
ia_SqlOptionsData
0.00% covered (danger)
0.00%
0 / 26
0.00% covered (danger)
0.00%
0 / 1
240
1<?php
2    /**
3     * deliverd_to_accept()
4     * Hace el accept/reject de los deliveries
5     *
6     * @return
7     */
8    function deliverd_to_accept($table,$accion,$id,&$sql,&$log) {
9        $got=$accion;
10
11        $appDoc = "app_$table";
12        $documento=new $appDoc();
13        $documento->id=$id;
14        $documento->enDB=$documento->read_sql($id,'r');
15
16        //$delivered=ia_singleton("SELECT cuentaT_deliversFrom_id, FROM delivered WHERE document_type='$table' AND delivered_status='Waiting' AND document=".strit($id)." ORDER BY delivered DESC");
17        if( strcasecmp($got,'Rejected')==0 )
18        {
19            /**
20            //Rechazó un delivered que era el primero y el documento tenía cuenta T origen. Entonces, debemos poner delivered a null y regresar el dinero a la cuenta T origen.
21            if(!empty($documento->enDB['origen_cuentat_id']) && $documento->enDB['primer_delivered'] == 'Si')
22            {
23                $cuentaT_mov_id=ia_guid();
24                $cuentaT_mov_original = ia_singleton("SELECT * FROM cuentat_mov WHERE origen_mov_id = '$id' AND activo='Si' ORDER BY alta_db ASC");
25                //De volada actualizo el movimiento de cuenta t original y lo marco como que si tiene contraparte.
26                ia_query("UPDATE cuentat_mov SET contra_mov_id='$cuentaT_mov_id', activo='No' WHERE cuentaT_mov_id='$cuentaT_mov_original[cuentaT_mov_id]'");
27
28                $cuentat_mov = cuentat_mov_default_record($cuentaT_mov_id,$documento->enDB['quantity'],'Ingreso', $documento->enDB['moneda_id']);
29                $cuentat_mov["cuentaT_tipo_mov_id"]='12';
30                $cuentat_mov["remarks"]="SE DEVUELVE DINERO A CUENTA T POR QUE <strong>RECHAZÓ EL PRIMER DELIVERED</strong> DE: <strong>".$documento->label_record_summary()."</strong>";
31                $cuentat_mov["cuentaT_id"]=$cuentaT_mov_original['cuentaT_id'];//$documento->enDB['origen_cuentat_id'];
32
33                $cuentat_mov["origen_mov_id"]=$cuentaT_mov_original['cuentaT_mov_id'];
34                $cuentat_mov["contra_mov_id"]=$cuentaT_mov_original['cuentaT_mov_id'];
35                $cuentat_mov["app_origen"]=ucfirst($table).' Delivered';
36                $cuentat_mov["activo"]='No';
37                $cuentat_mov["tienda_id"]=$documento->enDB['tienda_id'];
38
39                $log.="<li>".$cuentat_mov["remarks"]." SE DEVUELVE DINERO A CUENTA T POR QUE <strong>RECHAZÓ EL PRIMER DELIVERED</strong>.";
40                $sql[]=ia_insert('cuentat_mov',$cuentat_mov,array(),'','',"/* cargaADelivered */ /** ");
41                $cuentaT_regresa='NULL';
42            }
43            else
44            {
45                $cuentaT_regresa=$documento->enDB['cuentaT_transferto_id'];
46            } **/
47
48            $cuentaT_regresa=$documento->enDB['cuentaT_deliveredto_id'];
49
50            if($cuentaT_regresa==0 || $cuentaT_regresa=='NULL')
51            {
52                $queda_en_cuenta='Ninguna, Not Delivered';
53                $accepted='Not delivered';
54            }
55            else
56            {
57                $queda_en_cuenta=ia_singleread("SELECT /* deliverd_to_accept */ usuario FROM cuentat WHERE cuentaT_id=".strit($cuentaT_regresa));
58                $accepted='Rejected';
59            }
60            $sql[]="UPDATE /* deliverd_to_accept reject */ delivered SET revisado='Por revisar', accepted=NOW(),usuario_accepts_id=".strit($_SESSION['usuario_id']).",delivered_status='Rejected' WHERE document_type='$table' AND delivered_status='Waiting' AND document=".strit($id);
61            $msg="<li>".mysqlDate2display(Date("Y-m-d G:i:s"))." ".$_SESSION['usuario'].' pone Rejected, queda delivered to '.ia_htmlentities($queda_en_cuenta);
62            $msg=strit($msg);
63            $msg="deliverd_log=IF(deliverd_log IS NULL,$msg, CONCAT($msg,deliverd_log ))";
64
65            $sql[]="UPDATE /* cargaADelivered */ $table SET cuentaT_deliveredto_id=".($cuentaT_regresa=='NULL'?'NULL':strit($cuentaT_regresa)).",delivered=".($cuentaT_regresa=='NULL'?'NULL':'NOW()')."$msg,accepted='$accepted', origen_cuentat_id=".($documento->enDB['primer_delivered']=='Si'?'NULL':strit($documento->enDB['origen_cuentat_id'])).", puede_origen_cuentat=".($documento->enDB['primer_delivered']=='Si'?strit('Si'):strit('No')).", set_origen_cuentat=".($documento->enDB['primer_delivered']=='Si'?'NOW()':strit($documento->enDB['set_origen_cuentat'])).", primer_delivered=".($cuentaT_regresa=='NULL'?strit('Si'):strit('No'))." WHERE $table"."_id=".strit($id)." LIMIT 1";
66
67            $log.="<li style='color:red'>Delivered to Rejected, queda delivered to ".ia_htmlentities($queda_en_cuenta);
68        }
69        elseif( strcasecmp($got,'Accepted')==0 )
70        {
71            $cuentaT_queda=ia_singleread("SELECT cuentaT_transferto_id FROM $table WHERE $table"."_id=".strit($id));
72            $queda_en_cuenta=ia_singleread("SELECT /* deliverd_to_accept */ usuario FROM cuentat WHERE cuentaT_id=".strit($cuentaT_queda));
73            $sql[]="UPDATE /* deliverd_to_accept accept */ delivered SET accepted=NOW(),usuario_accepts_id=".strit($_SESSION['usuario_id']).",delivered_status='Accepted' WHERE document_type='$table' AND delivered_status='Waiting' AND document=".strit($id);
74            $msg="<li>".mysqlDate2display(Date("Y-m-d G:i:s"))." ".$_SESSION['usuario'].' pone Accept, queda delivered to '.ia_htmlentities($queda_en_cuenta);
75            $msg=strit($msg);
76            $msg="deliverd_log=IF(deliverd_log IS NULL,$msg, CONCAT($msg,deliverd_log ))";
77            $sql[]="UPDATE /* cargaADelivered */ $table SET $msg,accepted='Accepted', /** puede_origen_cuentat='No', puede_borrar='No', **/ primer_delivered='No',cuentaT_deliveredto_id=".strit($cuentaT_queda)." WHERE $table"."_id=".strit($id)." LIMIT 1";
78            $log.='<li>Delivered to Accept, queda delivered to '.ia_htmlentities($queda_en_cuenta);
79        }
80        else
81            echo "<ul><li>accion invalida $accion delivered_to_accept esperaba Accpeted o Rejected";
82        return true;
83    }
84
85// cuentat_mov
86    /**
87     * cuentat_mov_default_record()
88     *
89     * @param string $id en empty genera guid
90     * @return array con cuentat_mov default values
91     */
92    function cuentat_mov_default_record($id=null,$cantidad=0,$tipo='Ingreso',$moneda=1,$tipoCampo=1,$fecha='') {
93        $mov=array();
94        if(empty($id))
95            $mov["cuentaT_mov_id"]=ia_guid();
96        else
97            $mov["cuentaT_mov_id"]=$id;
98
99        $mov["cuentaT_id"]="";
100        if(!empty($fecha))
101        {
102            if(strlen($fecha)<11)
103            {
104                $fecha = date('Y-m-d', strtotime($fecha));
105                $nowMoment = new DateTime(date('H:i:s'));
106                $fecha .= " ".$nowMoment->format('H:i:s');
107            }
108        }
109        else
110            $fecha = Date('Y-m-d H:i:s');
111        $mov["fecha"]=$fecha;
112        $mov["cuentaT_tipo_mov_id"]=0;
113        $mov["monto"]=0;
114        $mov["egreso"]=0;
115        if(!empty($cantidad) && $tipo=='Ingreso')
116            $mov["monto"]=$cantidad;
117        elseif(!empty($cantidad) && $tipo=='Egreso')
118            $mov["egreso"]=$cantidad;
119        elseif(!empty($cantidad) && $tipo=='Transfer Accepted')
120            $mov["monto"]=$cantidad;
121        elseif(!empty($cantidad) && $tipo=='Transfer Sent')
122            $mov["egreso"]=$cantidad;
123        $mov["moneda_id"]=$moneda;
124
125        $mov["tipo_cambio"]=$tipoCampo;
126        $mov["cuentaT_tipo_mov_id"]=1; //Por default efectivo.
127        $mov["banco_cuenta_id"]=0;
128        $mov["referencia"]="";
129        $mov["remarks"]="";
130        $mov["banco_cuenta_mov_link_id"]="";
131        $mov["cuentaT_deliveredto_id"]=0;
132        $mov["esta_en"]="done";
133        $mov["cuentaT_transferto_id"]=0;
134        $mov["quantity_total"]=0;
135
136        $mov["ultimo_cambio"]="NOW()";
137        $mov["ultimo_cambio_por"]=$_SESSION["usuario"];
138        $mov["alta_db"]="NOW()";
139        $mov["alta_por"]=$_SESSION["usuario"];
140        $mov['tipo']=$tipo;
141        $mov["origen_mov_id"]="";
142        $mov["contra_mov_id"]="";
143
144        $mov["saldo_corriente_mxp"]=0.00;
145        $mov["saldo_corriente_usd"]=0.00;
146
147        return $mov;
148    }
149// banco
150    function banco_id_select($name='banco_id',$dflt=null,$conTodas=false,$tag='',$text='clave') {
151        if($dflt==null)
152            $dflt=param($name);
153        if($conTodas) {
154            $todas="<option value='0'>Cual sea</option>";
155        } else
156            $todas='';
157        return "<select name='$name' id='$name$tag>$todas".banco_options($dflt,$text)."</select>";
158    }
159
160    function banco_options($dflt,$text='clave') {
161        return ia_SqlOptions( "SELECT banco_id,$text FROM banco ORDER BY 2",$dflt);
162    }
163
164// banco_mov_tipo deposit
165    function banco_mov_tipo_id_select_acuenta($name='banco_mov_tipo_id',$dflt=null,$tag='',$gasto=false,$soloLinkBancario=false,$extraCond='',$emptyOption=false,$link_vale_q=true,$deposit_only=true) {
166        if($dflt==null)
167            $dflt=param($name);
168        return "<select name='$name' id='$name$tag>".($emptyOption?'<option value="0">Cualquier Tipo</option>':'').banco_mov_tipo_acuenta_options($dflt,$gasto,$soloLinkBancario,$extraCond,$link_vale_q,$deposit_only)."</select>";
169    }
170
171
172    function banco_mov_tipo_acuenta_options($dflt,$gasto=false,$soloLinkBancario=false,$extraCond='',$link_vale_q=true,$deposit_only=true) {
173        $and = "";
174
175        if($deposit_only)
176            $and .= " AND deposit='Si' ";
177
178        if($link_vale_q)
179            $and .= " AND link_vale='Q' ";
180
181        if($gasto)
182            $and .= " AND gasto = 'Si' ";
183
184        if($soloLinkBancario)
185            $and .= " AND solicita_link_bancario = 'Si' ";
186
187        if(!empty($extraCond))
188            $and .= " $extraCond ";
189
190        $sql = "SELECT banco_mov_tipo_id,tipo,lleva_ide,cash,deposit,solicita_link_bancario,especial,comision FROM banco_mov_tipo WHERE vale='Active' $and ORDER BY orden";
191        //echo "SELECT banco_mov_tipo_id,tipo,lleva_ide,cash,deposit,solicita_link_bancario,especial,comision FROM banco_mov_tipo WHERE deposit='Si' AND link_vale='Q' $and ORDER BY orden";
192        //echo $sql;
193
194        return ia_SqlOptionsData($sql ,$dflt);
195    }
196
197// cliente
198    function cliente_id_select($dflt=null,$conTodas=false,$tag='') {
199        if($dflt==null)
200            $dflt=param('cliente_id');
201        if($conTodas) {
202            $todas="<option value='0'>Cual sea</option>";
203        } else
204            $todas='';
205        return "<select name='cliente_id' id='cliente_id' $tag>".cliente_options($dflt)."</select>";
206    }
207
208    function cliente_options($dflt) {
209        return ia_SqlOptions( "SELECT cliente_id,nombre FROM cliente WHERE vale='Active' AND cliente=1 ORDER BY orden,2",$dflt);
210    }
211
212 // moneda
213    function moneda_id_select($name='moneda_id', $dflt=null,$conTodas=false,$tag='',$soloEsta=false) {
214        if($dflt==null)
215            $dflt=param($name);
216        if($conTodas) {
217            $todas="<option value='0'>Cual sea</option>";
218        } else
219            $todas='';
220        return "<select name='$name' id='$name$tag>".moneda_options($dflt,$soloEsta)."</select>";
221    }
222
223    function moneda_options($dflt,$soloEsta=false) {
224        if($soloEsta)
225            $soloEsta = " WHERE moneda_id='$soloEsta";
226        else
227            $soloEsta = '';
228        return ia_Options_array(ia_sqlArray("SELECT moneda_id,moneda,tc FROM moneda $soloEsta ORDER BY 2",null),$dflt);
229    }
230
231    // Select tienda Function
232    function doSelectTienda($dflt=null, $tag='', $selectid='select-tienda')
233    {
234    /*    $sql="SELECT ".SQL_CACHE." t.tienda_id,t.clave, t.tienda
235            FROM tienda t
236            JOIN iac_usr u ON t.plantillatienda_id=u.plantillatienda_id
237            JOIN plantillatienda pt ON pt.plantillatienda_id = u.plantillatienda_id
238            WHERE t.vale='Active' AND u.iac_usr_id=".strit($_SESSION['usuario_id'])."
239            ORDER BY t.clave";*/
240
241        //VCA Cambié el SELECT. tenía un error cuando no era usuario rony.
242
243        $sql= "SELECT /* appRelate:sql_options_get */ t.tienda_id, t.clave, t.tienda FROM plantilla_cobranza p JOIN iac_usr u ON p.plantillatienda_id=u.plantillatienda_id JOIN tienda t ON p.tienda_id=t.tienda_id  WHERE t.vale='Active' AND u.iac_usr_id=".strit($_SESSION['usuario_id'])." ORDER BY t.clave";
244
245        if(usuarioTipoRony()){
246            $sql="SELECT ".SQL_CACHE." t.tienda_id,t.clave, t.tienda
247            FROM tienda t
248            WHERE t.vale='Active' ORDER BY 2";
249        }
250
251        $tiendas = ia_sqlArray($sql,null);
252        
253        $select="<select class='notSelectize' name='$selectid' id='$selectid'>
254                    <option value='0'>Elige</option>";
255        $selected = '';
256        foreach ($tiendas as $item => $tienda) {
257            $selected = (intval($tienda['tienda_id']) == $dflt) ? 'selected' : '';
258            $select.="<option value='$tienda[tienda_id]' title='$tienda[tienda]$selected>$tienda[clave]</option>";
259        }
260        $select.="</select>";
261
262        return $select;
263    }
264
265// tienda
266    function tienda_id_select($dflt=null,$conTodas=false,$tag='',$selectid='tienda_id') {
267        if($dflt==null)
268            $dflt=param('tienda_id');
269        if($conTodas) {
270            $todas="<option value='0'>Elige</option>";
271        } else
272            $todas='';
273
274        return "<select name='$selectid' id='$selectid$tag>$todas".tienda_options($dflt)."</select>";
275    }
276
277    function tienda_options($dflt) {
278        //Tienda Active/Inactive
279        if(usuarioTipoRony())
280            $sql="SELECT ".SQL_CACHE." t.tienda_id,t.clave,c.cuentaT_id
281            FROM tienda t
282            JOIN cuentat c ON t.tienda_id = c.tienda_id
283            WHERE t.vale='Active' ORDER BY 2"; //WHERE 1 ORDER BY 2 // // // // WHERE vale='Active' ORDER BY orden,
284        else //CAMBIAPLANTILLATIENDAS
285            $sql="SELECT ".SQL_CACHE." t.tienda_id,t.clave,c.cuentaT_id
286            FROM tienda t
287            JOIN cuentat c ON t.tienda_id = c.tienda_id
288            JOIN plantilla_cobranza pc ON t.tienda_id=pc.tienda_id
289            JOIN iac_usr u ON pc.plantillatienda_id=u.plantillatienda_id
290            WHERE t.vale='Active' AND u.iac_usr_id=".strit($_SESSION['usuario_id'])."
291            AND (pc.permiso_cheque<>'Nada' OR pc.permiso_pagare<>'Nada'
292            OR pc.permiso_cobranza<>'Nada' )
293            ORDER BY t.clave"; //t.orden, //WHERE u.iac_usr_id=".strit($_SESSION['usuario_id'])."
294          //  $sql="SELECT t.tienda_id,t.clave FROM tienda t JOIN usuario_cobranza ut ON ut.tienda_id=t.tienda_id AND ut.usuario_id=".strit($_SESSION['usuario_id'])." AND ut.permiso<>'Nada' WHERE t.vale='Active' ORDER BY t.orden,t.clave";
295
296        return ia_Options_array(ia_sqlArray($sql,null),$dflt);
297        //return ia_SqlOptions( $sql,$dflt);
298    }
299
300    function tienda_puede($tienda_id,$user_id='',$cual='cobranza') {
301        if(usuarioTipoRony())
302            return 'Editar';
303        if(empty($user_id))
304            $user_id=$_SESSION['usuario_id'];
305        //CAMBIAPLANTILLATIENDAS
306        $sql = "SELECT /* tienda_puede */ pc.permiso_$cual FROM plantilla_cobranza pc JOIN iac_usr u ON pc.plantillatienda_id=u.plantillatienda_id WHERE u.iac_usr_id=".strit($user_id)." AND pc.tienda_id=".strit($tienda_id);
307
308        //echo $sql;
309
310        return ia_singleread($sql);
311        //return ia_singleread("SELECT permiso_$cual FROM usuario_cobranza WHERE iac_usr_id=".strit($user_id)." AND tienda_id=".strit($tienda_id),'Nada');
312    }
313
314    function tiendas_puede_editar($user_id='',$cual='cobranza') {
315        if(usuarioTipoRony())
316            return true;
317        if(empty($user_id)) {
318            $user_id = $_SESSION['usuario_id'];
319        }
320
321        //$puede=ia_singleread("SELECT permiso_$cual FROM usuario_cobranza WHERE iac_usr_id=".strit($user_id)." AND permiso_$cual='Editar' LIMIT 1");
322        //CAMBIAPLANTILLATIENDAS
323        $puede=ia_singleread("SELECT pc.permiso_$cual FROM plantilla_cobranza pc JOIN iac_usr u ON pc.plantillatienda_id=u.plantillatienda_id WHERE u.iac_usr_id=".strit($user_id)." AND pc.permiso_$cual='Editar' LIMIT 1");
324        return $puede=="Editar";
325    }
326
327    function tiendas_puede_consultar($user_id='',$cual='cobranza') {
328        if(usuarioTipoRony())
329            return true;
330        if(empty($user_id)) {
331            $user_id = $_SESSION['usuario_id'];
332        }
333        //$puede=ia_singleread("SELECT COUNT(*) FROM usuario_cobranza WHERE iac_usr_id=".strit($user_id)." AND permiso_$cual IN ('Consultar','Editar') LIMIT 1");
334        //CAMBIAPLANTILLATIENDAS
335        $puede=ia_singleread("SELECT pc.permiso_$cual FROM plantilla_cobranza pc JOIN iac_usr u ON pc.plantillatienda_id=u.plantillatienda_id WHERE u.iac_usr_id=".strit($user_id)." AND pc.permiso_$cual IN ('Consultar','Editar') LIMIT 1");
336
337        return !empty($puede);
338    }
339
340    function deuda_puede($user_id='') {
341        if(usuarioTipoRony())
342            return true;
343        if(empty($user_id))
344            $user_id=$_SESSION['usuario_id'];
345        $puede=ia_singleread("SELECT puede_deuda FROM iac_usr WHERE iac_usr_id=".strit($user_id));
346
347        if($puede == 'Si')
348            $puede = true;
349        else
350            $puede = false;
351
352        return $puede;
353    }
354
355    function gasto_puede($user_id='') {
356        if(usuarioTipoRony())
357            return true;
358        if(empty($user_id))
359            $user_id=$_SESSION['usuario_id'];
360        $puede=ia_singleread("SELECT puede_gasto FROM iac_usr WHERE iac_usr_id=".strit($user_id));
361
362        if($puede == 'Si')
363            $puede = true;
364        else
365            $puede = false;
366
367        return $puede;
368    }
369
370function ia_SqlOptionsData($sql,$selected='',$extra=array(),$optionTag='') {
371
372    $ret='';
373    if($extra) foreach($extra as $k=>$v)
374        if(is_array($selected)) {
375            $ret.= "\r\n<option value='$k'".(array_key_exists($k,$selected) ? " SELECTED='selected' " : "")."$optionTag>".ia_htmlentities($v)."</option>";
376        } else {
377            $ret.= "\r\n<option value='$k'".(strcmp($selected,$k) ? "" : " SELECTED='selected' ")."$optionTag>".ia_htmlentities($v)."</option>";
378        }
379    $result = ia_sqlArrayIndx($sql);
380    foreach($result as $d) {
381        $value='';
382        $display='';
383        $data='';
384        $i=0;
385        foreach($d as $k=>$v) {
386            if($i==0)
387                $value=$v;
388            elseif($i==1)
389                $display=$v;
390            else {
391                if($k=='class')
392                    $data.=" class='$v'";
393                elseif($k=='style')
394                    $data.=" style='$v'";
395                else
396                    $data.=" data-$k='$v'";
397            }
398            $i++;
399        }
400
401        if(is_array($selected)) {
402            $ret.= "\r\n<option value='$value'".(array_key_exists($value,$selected) ? " SELECTED='selected' " : "")."$optionTag$data>".ia_htmlentities($display)."</option>";
403        } else {
404            $ret.= "\r\n<option value='$value'".(strcmp($selected,$value) ? "" : " SELECTED='selected '" )."$optionTag$data>".ia_htmlentities($display)."</option>";
405        }
406    }
407    return $ret;
408}
409
410?>