| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | /** KumbiaForms - PHP Rapid Development Framework *****************************
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (C) 2005-2007 Andrés Felipe Gutiérrez (andresfelipe at vagoogle.net)
|
|---|
| 6 | *
|
|---|
| 7 | * This framework is free software; you can redistribute it and/or
|
|---|
| 8 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 9 | * License as published by the Free Software Foundation; either
|
|---|
| 10 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 11 | *
|
|---|
| 12 | * This framework is distributed in the hope that it will be useful,
|
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 15 | * Lesser General Public License for more details.
|
|---|
| 16 | *
|
|---|
| 17 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 18 | * License along with this framework; if not, write to the Free Software
|
|---|
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 20 | *
|
|---|
| 21 | * Este framework es software libre; puedes redistribuirlo y/o modificarlo
|
|---|
| 22 | * bajo los terminos de la licencia pública general GNU tal y como fue publicada
|
|---|
| 23 | * por la Fundación del Software Libre; desde la versión 2.1 o cualquier
|
|---|
| 24 | * versión superior.
|
|---|
| 25 | *
|
|---|
| 26 | * Este framework es distribuido con la esperanza de ser util pero SIN NINGUN
|
|---|
| 27 | * TIPO DE GARANTIA; sin dejar atrás su LADO MERCANTIL o PARA FAVORECER ALGUN
|
|---|
| 28 | * FIN EN PARTICULAR. Lee la licencia publica general para más detalles.
|
|---|
| 29 | *
|
|---|
| 30 | * Debes recibir una copia de la Licencia Pública General GNU junto con este
|
|---|
| 31 | * framework, si no es asi, escribe a Fundación del Software Libre Inc.,
|
|---|
| 32 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 33 | *
|
|---|
| 34 | *****************************************************************************
|
|---|
| 35 | * Functions for build Master-Detail forms
|
|---|
| 36 | *****************************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | function buildFormMasterDetail($form){
|
|---|
| 39 |
|
|---|
| 40 | if(!array_key_exists('dataRequisite', $form)) $form['dataRequisite'] = 1;
|
|---|
| 41 | if(!$form['dataRequisite']) {
|
|---|
| 42 | formsPrint("<font style='font-size:11px'><center><i><b>No hay datos en consulta</b></i></center></font>");
|
|---|
| 43 | } else {
|
|---|
| 44 | if($_REQUEST['subaction']!='browse'){
|
|---|
| 45 | formsPrint("<center>");
|
|---|
| 46 | if(!array_key_exists('permissions', $form)) {
|
|---|
| 47 | $form['permissions'] = array();
|
|---|
| 48 | }
|
|---|
| 49 | if($_REQUEST['oldsubaction']=='Modificar') {
|
|---|
| 50 | $_REQUEST['queryStatus'] = true;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | if($form['controlButtons']){
|
|---|
| 54 | foreach($form['controlButtons'] as $name => $cButton){
|
|---|
| 55 | formsPrint("<input type='button' class='controlButton' id='$name' value='".$cButton['caption']."' onclick='".$cButton['action']."'> ");
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | if(!$_REQUEST['queryStatus']){
|
|---|
| 60 | if(!$form['unableInsert']){
|
|---|
| 61 | /*foreach($form['components'] as $key => $com){
|
|---|
| 62 | $pkey = "";
|
|---|
| 63 | if($com["primary"]){
|
|---|
| 64 | $pkey $key
|
|---|
| 65 | }
|
|---|
| 66 | }*/
|
|---|
| 67 | if(array_key_exists('insert', $form['permissions'])){
|
|---|
| 68 | if(getPermission($form, 'insert'))
|
|---|
| 69 | formsPrint("<input type='button' class='controlButton' id='adiciona' value='Adicionar' onclick='enableInsertMD(this)'> ");
|
|---|
| 70 | } else formsPrint("<input type='button' class='controlButton' id='adiciona' value='Adicionar' onclick='enableInsertMD(this)'> ");
|
|---|
| 71 | }
|
|---|
| 72 | if(array_key_exists('query', $form['permissions'])){
|
|---|
| 73 | if(getPermission($form, 'query'))
|
|---|
| 74 | formsPrint("<input type='button' class='controlButton' id='consulta' value='Consultar' onclick='enableQueryMD(this)'> ");
|
|---|
| 75 | } else formsPrint("<input type='button' class='controlButton' id='consulta' value='Consultar' onclick='enableQueryMD(this)'> ");
|
|---|
| 76 | $ds = "disabled";
|
|---|
| 77 | } else {
|
|---|
| 78 | $query_string = "action=".$_REQUEST['action']."&value=".$_REQUEST['value']."&option=".$_REQUEST['option'];
|
|---|
| 79 | formsPrint("<button id='primero' class='controlButton' onclick='javascript:window.location=\"?$query_string&queryStatus=1&subaction=fetch&number=0\"'> Primero</button> ");
|
|---|
| 80 | formsPrint("<button id='anterior' class='controlButton' onclick='javascript:window.location=\"?$query_string&queryStatus=1&subaction=fetch&number=".($_REQUEST['number']-1)."\"'> Anterior</button> ");
|
|---|
| 81 | formsPrint("<button id='siguiente' class='controlButton' onclick='javascript:window.location=\"?$query_string&queryStatus=1&subaction=fetch&number=".($_REQUEST['number']+1)."\"'>Siguiente </button> ");
|
|---|
| 82 | formsPrint("<button id='ultimo' class='controlButton' onclick='javascript:window.location=\"?$query_string&queryStatus=1&subaction=fetch&number=last\"'>Ultimo </button> ");
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | //El Boton de Actualizar
|
|---|
| 86 | if($_REQUEST['queryStatus']){
|
|---|
| 87 | if(!$form['unableUpdate']){
|
|---|
| 88 | if($form['updateCondition']){
|
|---|
| 89 | if(strpos($form['updateCondition'], '@')){
|
|---|
| 90 | ereg("[\@][A-Za-z0-9_]+", $form['updateCondition'], $regs);
|
|---|
| 91 | foreach($regs as $reg){
|
|---|
| 92 | $form['updateCondition'] = str_replace($reg, $_REQUEST["fl_".str_replace("@", "", $reg)], $form['updateCondition']);
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 | $form['updateCondition'] = " \$val = (".$form['updateCondition'].");";
|
|---|
| 96 | eval($form['updateCondition']);
|
|---|
| 97 | if($val){
|
|---|
| 98 | if(array_key_exists('update', $form['permissions'])){
|
|---|
| 99 | if(getPermission($form, 'update'))
|
|---|
| 100 | formsPrint("<input type='button' class='controlButton' id='modifica' value='Modificar' $ds onclick=\"enableUpdateMD(this)\"> ");
|
|---|
| 101 | } else formsPrint("<input type='button' class='controlButton' id='modifica' value='Modificar' $ds onclick=\"enableUpdateMD(this)\"> ");
|
|---|
| 102 | }
|
|---|
| 103 | } else {
|
|---|
| 104 | if(array_key_exists('update', $form['permissions'])){
|
|---|
| 105 | if(getPermission($form, 'update'))
|
|---|
| 106 | formsPrint("<input type='button' class='controlButton' id='modifica' value='Modificar' $ds onclick=\"enableUpdateMD(this)\"> ");
|
|---|
| 107 | } else formsPrint("<input type='button' class='controlButton' id='modifica' value='Modificar' $ds onclick=\"enableUpdateMD(this)\"> ");
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | //El de Borrar
|
|---|
| 113 | if($_REQUEST['queryStatus']){
|
|---|
| 114 | if(!$form['unableDelete']){
|
|---|
| 115 | if(array_key_exists('delete', $form['permissions'])){
|
|---|
| 116 | if(getPermission($form, 'delete'))
|
|---|
| 117 | formsPrint("<input type='button' class='controlButton' id='borra' value='Borrar' $ds onclick=\"enableDeleteMD()\"> ");
|
|---|
| 118 | } else formsPrint("<input type='button' class='controlButton' id='borra' value='Borrar' $ds onclick=\"enableDeleteMD()\"> ");
|
|---|
| 119 | }
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | if(!$_REQUEST['queryStatus']) {
|
|---|
| 123 | if(array_key_exists('browse', $form['permissions'])){
|
|---|
| 124 | if(getPermission($form, 'browse'))
|
|---|
| 125 | formsPrint("<input type='button' class='controlButton' id='visualiza' value='Visualizar' onclick='enableBrowse(this)'> ");
|
|---|
| 126 | } else formsPrint("<input type='button' class='controlButton' id='visualiza' value='Visualizar' onclick='enableBrowse(this)'> ");
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | //Boton de Reporte
|
|---|
| 130 | if(!$_REQUEST['queryStatus']) {
|
|---|
| 131 | if(array_key_exists('report', $form['permissions'])){
|
|---|
| 132 | if(getPermission($form, 'report'))
|
|---|
| 133 | formsPrint("<input type='button' class='controlButton' id='reporte' value='Reporte' onclick='enableReportMD(this)'> ");
|
|---|
| 134 | } else formsPrint("<input type='button' class='controlButton' id='reporte' value='Reporte' onclick='enableReportMD(this)'> ");
|
|---|
| 135 | } else formsPrint("<br><br><button class='controlButton' id='volver' onclick='javascript:window.location=\"?$query_string&subaction=back\"'>Atras </button> ");
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | formsPrint("\r\n</center><br/><br/>");
|
|---|
| 139 |
|
|---|
| 140 | if($form['useCompactStyle']){
|
|---|
| 141 | formsPrint("<table align='center' style='position:xabsolute;left:".$form['left'].";top:".$form['top']."' cellspacing=0>
|
|---|
| 142 | <tr><td width=100%><table cellpadding=3 cellspacing=0>
|
|---|
| 143 | <td class='activeForm' id='tab1'><a href='#'
|
|---|
| 144 | onclick=\"if(document.getElementById('tab1').className=='activeForm'){ document.getElementById('tab1').className='inactiveForm'; document.getElementById('tab2').className='activeForm'; document.getElementById('tabForm2').style.visibility='visible'; document.getElementById('tabForm1').style.visibility='hidden'; } else { document.getElementById('tab1').className='activeForm'; document.getElementById('tab2').className='inactiveForm'; document.getElementById('tabForm2').style.visibility='hidden'; document.getElementById('tabForm1').style.visibility='visible';}\"
|
|---|
| 145 | >".str_replace(" ", " ", $form['caption'])."</a></td>
|
|---|
| 146 | <td id='tab2' class='inactiveForm' width='100%'
|
|---|
| 147 | ><a href='#' onclick=\"if(document.getElementById('tab2').className=='inactiveForm'){ document.getElementById('tab1').className='inactiveForm'; document.getElementById('tab2').className='activeForm'; document.getElementById('tabForm2').style.visibility='visible'; document.getElementById('tabForm1').style.visibility='hidden'; } else { document.getElementById('tab1').className='activeForm'; document.getElementById('tab2').className='inactiveForm'; document.getElementById('tabForm2').style.visibility='hidden'; document.getElementById('tabForm1').style.visibility='visible';}\">".str_replace(" ", " ", $form['detail']['caption'])."</a></td>
|
|---|
| 148 | </table></td></tr>
|
|---|
| 149 | <tr><td align='center' id='tabForm1'
|
|---|
| 150 | style='visibility:visible;'><br>");
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | formsPrint("<table align='center'><tr>");
|
|---|
| 154 | $n = 1;
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 | //La parte de los Componentes
|
|---|
| 158 | formsPrint("<td valign='top' align='right'>");
|
|---|
| 159 | foreach($form['components'] as $name => $com){
|
|---|
| 160 |
|
|---|
| 161 | //SI esa de Tipo TExt
|
|---|
| 162 | if($com['type']=='text') buildMasterTextComponent($com, $name, $form);
|
|---|
| 163 | if($com['type']=='helpText') buildHelpContext($com, $name, $form);
|
|---|
| 164 |
|
|---|
| 165 | //Tipo password
|
|---|
| 166 | if($com['type']=='password'){
|
|---|
| 167 | formsPrint("<b>".$com['caption']." : </b></td><td id='tp$i' valign='top'><input type='password' name='fl_$name' id='flid_$name' disabled ");
|
|---|
| 168 | if($_REQUEST['fl_'.$name])
|
|---|
| 169 | formsPrint("value = '".$_REQUEST['fl_'.$name]."'");
|
|---|
| 170 | foreach($com["attributes"] as $nitem => $item)
|
|---|
| 171 | formsPrint(" $nitem='$item' ");
|
|---|
| 172 | formsPrint(" onkeydown='capturePassword(tp$i, flid_$name)' onblur='nextRetype()'");
|
|---|
| 173 | formsPrint("/>\r\n");
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | //Cuando es de Tipo Combo
|
|---|
| 177 | if($com['type']=='combo') buildStandardCombo($com, $name);
|
|---|
| 178 |
|
|---|
| 179 | //Este es el Check Chulito
|
|---|
| 180 | if($com['type']=='check'){
|
|---|
| 181 | if($com['first']) formsPrint("<b>".$com['groupcaption']."</b></td><td><table cellpadding=0>");
|
|---|
| 182 | formsPrint("<tr><td>\r\n<input type='checkbox' disabled name='fl_$name' id='flid_$name' style='border:1px solid #FFFFFF'");
|
|---|
| 183 | if($_REQUEST['fl_'.$name]==$com['checkedValue'])
|
|---|
| 184 | formsPrint(" checked ");
|
|---|
| 185 | if($com["attributes"])
|
|---|
| 186 | foreach($com["attributes"] as $nitem => $item) formsPrint(" $nitem='$item' ");
|
|---|
| 187 | formsPrint(">\r\n</td><td>".$com['caption']."</td></tr>");
|
|---|
| 188 | if($com["last"]) formsPrint("</table>");
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | //Cajita Grande
|
|---|
| 192 | if($com['type']=='textarea'){
|
|---|
| 193 | formsPrint("<b>".$com['caption']." :</br></td><td><textarea disabled name='fl_$name' id='flid_$name' ");
|
|---|
| 194 | foreach($com['attributes'] as $natt => $vatt){
|
|---|
| 195 | formsPrint("$natt='$vatt' ");
|
|---|
| 196 | }
|
|---|
| 197 | formsPrint(">".$_REQUEST['fl_'.$name]."</textarea>");
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | //Oculto
|
|---|
| 201 | if($com['type']=='hidden')
|
|---|
| 202 | formsPrint("<input type='hidden' name='fl_$name' id='flid_$name' value='".$com['value']."'/>\r\n");
|
|---|
| 203 | else {
|
|---|
| 204 | formsPrint("</td>");
|
|---|
| 205 | if($com['type']=='check'){
|
|---|
| 206 | if($com['last']) {
|
|---|
| 207 | if(!($n%$form['fieldsPerRow'])) formsPrint("</tr><tr>\r\n");
|
|---|
| 208 | $n++;
|
|---|
| 209 | formsPrint("<td valign='top' align='right'>");
|
|---|
| 210 | }
|
|---|
| 211 | }
|
|---|
| 212 | else {
|
|---|
| 213 | if(!($n%$form['fieldsPerRow'])) formsPrint("</tr><tr>\r\n");
|
|---|
| 214 | $n++;
|
|---|
| 215 | formsPrint("<td valign='top' align='right'>");
|
|---|
| 216 | }
|
|---|
| 217 | }
|
|---|
| 218 | }
|
|---|
| 219 | formsPrint("</tr></table></form>\r\n");
|
|---|
| 220 |
|
|---|
| 221 | if($form['useCompactStyle']){
|
|---|
| 222 | formsPrint("</td></tr><tr>");
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | //Todos los campos
|
|---|
| 226 | formsPrint("<script> var FieldsMaster = new Array(");
|
|---|
| 227 | reset($form['components']);
|
|---|
| 228 | for($i=0;$i<=count($form['components'])-1;$i++){
|
|---|
| 229 | formsPrint("'".key($form['components'])."'");
|
|---|
| 230 | if($i!=(count($form['components'])-1)) formsPrint(",");
|
|---|
| 231 | next($form['components']);
|
|---|
| 232 | }
|
|---|
| 233 | formsPrint("); </script>\r\n");
|
|---|
| 234 |
|
|---|
| 235 | //Campos que no pueden ser nulos
|
|---|
| 236 | formsPrint("<script> var NotNullFields = new Array(");
|
|---|
| 237 | reset($form['components']);
|
|---|
| 238 | $NotNullFields = "";
|
|---|
| 239 | for($i=0;$i<=count($form['components'])-1;$i++){
|
|---|
| 240 | if($form['components'][key($form['components'])]['notNull']||$form['components'][key($form['components'])]['primary'])
|
|---|
| 241 | $NotNullFields.="'".key($form['components'])."',";
|
|---|
| 242 | next($form['components']);
|
|---|
| 243 | }
|
|---|
| 244 | $NotNullFields = substr($NotNullFields, 0, strlen($NotNullFields)-1);
|
|---|
| 245 | formsPrint("$NotNullFields); </script>\r\n");
|
|---|
| 246 |
|
|---|
| 247 | formsPrint("<script> var DateFields = new Array(");
|
|---|
| 248 | $dFields = "";
|
|---|
| 249 | foreach($form['components'] as $key => $value){
|
|---|
| 250 | if($value['valueType']=='date')
|
|---|
| 251 | $dFields.="'".$key."',";
|
|---|
| 252 | }
|
|---|
| 253 | $dFields = substr($dFields, 0, strlen($dFields)-1);
|
|---|
| 254 | formsPrint("$dFields); </script>\r\n");
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 | //Campos que no son llave
|
|---|
| 258 | formsPrint("<script> var UFields = new Array(");
|
|---|
| 259 | $uFields = "";
|
|---|
| 260 | foreach($form['components'] as $key => $value){
|
|---|
| 261 | if(!$value['primary'])
|
|---|
| 262 | $uFields.="'".$key."',";
|
|---|
| 263 | }
|
|---|
| 264 | $uFields = substr($uFields, 0, strlen($uFields)-1);
|
|---|
| 265 | formsPrint("$uFields); </script>\r\n");
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 | //Campos que son llave
|
|---|
| 269 | formsPrint("<script> var PFields = new Array(");
|
|---|
| 270 | $pFields = "";
|
|---|
| 271 | foreach($form['components'] as $key => $value){
|
|---|
| 272 | if($value['primary'])
|
|---|
| 273 | $pFields.="'".$key."',";
|
|---|
| 274 | }
|
|---|
| 275 | $pFields = substr($pFields, 0, strlen($pFields)-1);
|
|---|
| 276 | formsPrint("$pFields); </script>\r\n");
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | //Campos que son Auto Numericos
|
|---|
| 280 | formsPrint("<script> var AutoFields = new Array(");
|
|---|
| 281 | $aFields = "";
|
|---|
| 282 | foreach($form['components'] as $key => $value){
|
|---|
| 283 | if($value['auto_numeric'])
|
|---|
| 284 | $aFields.="'".$key."',";
|
|---|
| 285 | }
|
|---|
| 286 | $aFields = substr($aFields, 0, strlen($aFields)-1);
|
|---|
| 287 | formsPrint("$aFields); </script>\r\n");
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 | formsPrint("<script> var queryOnlyFields = new Array(");
|
|---|
| 291 | $rFields = "";
|
|---|
| 292 | foreach($form['components'] as $key => $value){
|
|---|
| 293 | if($value['valueType']!='date')
|
|---|
| 294 | if($value['queryOnly'])
|
|---|
| 295 | $rFields.="'".$key."',";
|
|---|
| 296 | }
|
|---|
| 297 | $rFields = substr($rFields, 0, strlen($rFields)-1);
|
|---|
| 298 | formsPrint("$rFields); </script>\r\n");
|
|---|
| 299 |
|
|---|
| 300 | formsPrint("<script> var queryOnlyDateFields = new Array(");
|
|---|
| 301 | $rdFields = "";
|
|---|
| 302 | foreach($form['components'] as $key => $value){
|
|---|
| 303 | if($value['valueType']=='date')
|
|---|
| 304 | if($value['queryOnly']){
|
|---|
| 305 | $rdFields.="'".$key."',";
|
|---|
| 306 | }
|
|---|
| 307 | }
|
|---|
| 308 | $rdFields = substr($rdFields, 0, strlen($rdFields)-1);
|
|---|
| 309 | formsPrint("$rdFields); </script>\r\n");
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 | formsPrint("<script> var AddFields = new Array(");
|
|---|
| 313 | $aFields = "";
|
|---|
| 314 | foreach($form['components'] as $key => $value){
|
|---|
| 315 | if((!$value['auto_numeric'])&&(!$value['attributes']['value']))
|
|---|
| 316 | $aFields.="'".$key."',";
|
|---|
| 317 | }
|
|---|
| 318 | $aFields = substr($aFields, 0, strlen($aFields)-1);
|
|---|
| 319 | formsPrint("$aFields); </script>\r\n");
|
|---|
| 320 |
|
|---|
| 321 | //Campos E-Mail
|
|---|
| 322 | formsPrint("<script> var emailFields = new Array(");
|
|---|
| 323 | $uFields = "";
|
|---|
| 324 | foreach($form['components'] as $key => $value){
|
|---|
| 325 | if($value['valueType']=='email')
|
|---|
| 326 | $uFields.="'".$key."',";
|
|---|
| 327 | }
|
|---|
| 328 | $uFields = substr($uFields, 0, strlen($uFields)-1);
|
|---|
| 329 | formsPrint("$uFields); </script>\r\n");
|
|---|
| 330 |
|
|---|
| 331 | //??????????
|
|---|
| 332 | formsPrint("<script> var comboQueryFields = new Array(");
|
|---|
| 333 | $uFields = "";
|
|---|
| 334 | foreach($form['components'] as $key => $value){
|
|---|
| 335 | if($value['whereConditionOnQuery'])
|
|---|
| 336 | $uFields.="'".$key."',";
|
|---|
| 337 | }
|
|---|
| 338 | $uFields = substr($uFields, 0, strlen($uFields)-1);
|
|---|
| 339 | formsPrint("$uFields); </script>\r\n");
|
|---|
| 340 |
|
|---|
| 341 | //??????????
|
|---|
| 342 | formsPrint("<script> var comboAddFields = new Array(");
|
|---|
| 343 | $uFields = "";
|
|---|
| 344 | foreach($form['components'] as $key => $value){
|
|---|
| 345 | if($value['whereConditionOnAdd'])
|
|---|
| 346 | $uFields.="'".$key."',";
|
|---|
| 347 | }
|
|---|
| 348 | $uFields = substr($uFields, 0, strlen($uFields)-1);
|
|---|
| 349 | formsPrint("$uFields); </script>\r\n");
|
|---|
| 350 |
|
|---|
| 351 | formsPrint("<script> var AutoValuesFields = new Array(");
|
|---|
| 352 | $aFields = "";
|
|---|
| 353 | foreach($form['components'] as $key => $value){
|
|---|
| 354 | if($value['auto_numeric'])
|
|---|
| 355 | $aFields.="'".$key."',";
|
|---|
| 356 | }
|
|---|
| 357 | $aFields = substr($aFields, 0, strlen($aFields)-1);
|
|---|
| 358 | formsPrint("$aFields); </script>\r\n");
|
|---|
| 359 |
|
|---|
| 360 | formsPrint("<script> var AutoValuesFFields = new Array(");
|
|---|
| 361 | $aFields = "";
|
|---|
| 362 | if(!$db) {
|
|---|
| 363 | $db = db::raw_connect();
|
|---|
| 364 | kumbia::$db = $db;
|
|---|
| 365 | }
|
|---|
| 366 | foreach($form['components'] as $key => $value){
|
|---|
| 367 | if($value['auto_numeric']){
|
|---|
| 368 | $q = $db->query("select max($key)+1 from ".$form['source']);
|
|---|
| 369 | $row = $db->fetch_array($q);
|
|---|
| 370 | $aFields.="'".($row[0] ? $row[0] : 1 )."',";
|
|---|
| 371 | }
|
|---|
| 372 | }
|
|---|
| 373 | $aFields = substr($aFields, 0, strlen($aFields)-1);
|
|---|
| 374 | formsPrint("$aFields); </script>\r\n");
|
|---|
| 375 |
|
|---|
| 376 | formsPrint("<center>");
|
|---|
| 377 | if($form['useCompactStyle']){
|
|---|
| 378 | formsPrint("<td align='center' id='tabForm2' style='visibility:hidden;position:absolute;left:".($form['left']).";top:".$form['top']."'>");
|
|---|
| 379 | }
|
|---|
| 380 | buildFormGrid($form['detail']);
|
|---|
| 381 | if($form['useCompactStyle']){
|
|---|
| 382 | formsPrint("</td><tr><td align='center'>");
|
|---|
| 383 | }
|
|---|
| 384 | formsPrint("<br><input type='button' class='controlButton' id='aceptar' value='Aceptar' disabled onclick='FormAcceptMD()'> ");
|
|---|
| 385 | formsPrint("<input type='button' class='controlButton' id='cancelar' value='Cancelar' disabled onclick='cancelFormMD()'> </center>");
|
|---|
| 386 | if($form['useCompactStyle']){
|
|---|
| 387 | formsPrint("</td></tr></table>");
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | if($_REQUEST['subaction']=='validation')
|
|---|
| 391 | if($_REQUEST['oldsubaction']=='Adicionar')
|
|---|
| 392 | formsPrint("<input type='hidden' id='actAction' value='".$_REQUEST['oldsubaction']."'><script>enableInsertMD(document.all.adiciona, 1); </script>");
|
|---|
| 393 | else formsPrint("<input type='hidden' id='actAction' value='".$_REQUEST['oldsubaction']."'><script>enableUpdateMD(document.all.modifica); </script>");
|
|---|
| 394 | else
|
|---|
| 395 | formsPrint("<input type='hidden' id='actAction' value=''>");
|
|---|
| 396 | formsPrint("<input type='hidden' id='param' value='".$_REQUEST['param']."'>");
|
|---|
| 397 | formsPrint("<input type='hidden' id='oldAction' value=''></form>
|
|---|
| 398 | <form name='saveDataForm' method='post'></form>");
|
|---|
| 399 | //print_r($form['components'][$_REQUEST['param']]);
|
|---|
| 400 | if($_REQUEST['subaction']=='validation'){
|
|---|
| 401 | if($form['components'][$_REQUEST['param']]['validation']['action']['type']=='javascript'){
|
|---|
| 402 | if($form['components'][$_REQUEST['param']]['validation']['function']($form['components'][$_REQUEST['param']]['validation']['action']['parameters']))
|
|---|
| 403 | formsPrint("<script> iBody.onload = ".$form['components'][$_REQUEST['param']]['validation']['action']['value']."</script>");
|
|---|
| 404 | } else {
|
|---|
| 405 | if($form['components'][$_REQUEST['param']]['validation']['action']['nextField']){
|
|---|
| 406 | $nextField = $form['components'][$_REQUEST['param']]['validation']['action']['nextField'];
|
|---|
| 407 | formsPrint("<script> function retField() { document.all.fl_$nextField.select(); document.all.fl_$nextField.focus(); } iBody.onload = retField; </script>");
|
|---|
| 408 | }
|
|---|
| 409 | }
|
|---|
| 410 | }
|
|---|
| 411 | if($_REQUEST['subaction']=='validation')
|
|---|
| 412 | formsPrint("<script>function returnStatus() { document.all.flid_".$_REQUEST['param'].".select(); document.all.flid_".$_REQUEST['param'].".focus(); }</script>");
|
|---|
| 413 | } else {
|
|---|
| 414 | formsBrowse($form);
|
|---|
| 415 | }
|
|---|
| 416 | }
|
|---|
| 417 | }
|
|---|
| 418 |
|
|---|
| 419 | ?> |
|---|