Hello, in chronoforms ver 4.0 in custom code I have this php fucntion to generate a value called "Referencia":
I try to do the same in version 6 but is not working, {data:Referencia} value is empty ¿any solution?
<?php $form->data['Referencia'] = GenReferencia($form->data['numero']); // !! copy and paste your function code here !! function GenReferencia() { $mult=2; $pref=40; $fecha = getdate(); $numero = $pref.$fecha[mday].$fecha[mon].$fecha[year].$fecha[hours].$fecha[minutes].$fecha[seconds]; $numero = trim($numero); $tam = strlen($numero); //echo "El numero es: \t\t",$numero, "\t\tEl tamaño es: \t\t",$tam, "<br>", "<br>"; $i=0; for($i=$tam ; $i>=1 ; $i--) { $dato = substr($numero, $i-1, 1); $resul = intval($dato) * $mult; if ($resul>9) { $otro = trim(strval($resul)); $aux1=substr($otro,0,1); $aux2=substr($otro,1,1); $tot = intval($aux1) + intval($aux2); //echo "\t\totro :\t\t", $otro,"\t\tAux 1:\t\t", $aux1, "\t\t Aux 2\t\t", $aux2, "\t\t Total:\t\t", $tot; } else { $tot = $resul; } //echo "La posición\t\t", $i, "\t\tEl valor de dato es: \t\t", $dato, "\t\t * \t\t", $mult, "\t\t =\t\t", $resul, "\t\tValor final:\t\t", $tot, "<br>"; $sumatot=$sumatot + $tot; $mult = $mult + 1; if ($mult>2) { $mult=1; } } // echo "La suma total es:\t\t", $sumatot; $maximo = intval(substr(trim(strval($sumatot)),0,1)) + 1; $maximo =$maximo * 10; $ref = $maximo - $sumatot; if ($maximo - $sumatot>=10) $ref=0; //echo "<br>","La Referencia es: \t\t", $ref; return $numero.$ref; } ?>
I try to do the same in version 6 but is not working, {data:Referencia} value is empty ¿any solution?