home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / daogen / fieldOptions.php < prev    next >
PHP Script  |  2004-03-08  |  3KB  |  121 lines

  1. <?php
  2. /*
  3. Copyright T & M Web Enterprises 2003
  4. Author: Mike Hostetler <mike@tm-web.com>
  5. Version: 1.0 Release date: 01 November 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. /**
  14.  *
  15.  *@NAME:        fieldOptions
  16.  *@PURPOSE:        To show the main page of the module
  17.  *@REMARKS:        This serves as the default action for the entire module
  18.  *
  19.  */
  20.  
  21. $post = $_POST;
  22.  
  23. $tabtable = new tabtable('gen_type', 'DAO Generator', '600', '400');
  24. $tabtable->add_tab('new', 'New DAO');
  25. $tabtable->add_tab('sql', 'SQL Based');
  26. $tabtable->add_tab('base', 'Base Classes');
  27. $tabtable->print_head();
  28. ?>
  29. <div align="center">
  30. <table border="0" width="80%" cellspacing=0 cellpadding=4>
  31. <form action="generateCode.php" method="POST">
  32.  
  33. <tr><td colspan="4" align="left"><br><br><font face="Verdana" size="2"><b>
  34. Database Column Names and Types:</b></font></td></tr>
  35.  
  36. <tr><td colspan="4"><font face="Verdana" size="2"><br>
  37. You must give the names for all columns in your database table. 
  38. Wrong or missing names will make the generated code malfunction. 
  39. You can also give preferred Variable Names for these columns, but 
  40. they are optional. (Column names will be used as variable names, if 
  41. no variable names are provided).</td></tr>
  42.  
  43. <?php
  44. foreach( $post as $k => $v ) {
  45.     echo '<input type="hidden" name="'.$k.'" value="'.$v.'">';
  46. }
  47.  
  48. echo <<<HEADERTEXT
  49. <tr><td colspan="4"> </td></tr>
  50. <tr><td align="center"><font face="Verdana" size="2">Type:</font></td>
  51. <td align="center"><font face="Verdana" size="2">Column Name:</font></td>
  52. <td align="center"><font face="Verdana" size="2">Variable Name:</font></td>
  53. <td align="center"><font face="Verdana" size="2">Sort:</font></td>
  54. HEADERTEXT;
  55.  
  56. // Primary Key DB columns
  57. for( $i = 0; $i < $post['pk_num']; $i++ )
  58. {
  59.     printVarForm( "varname", "colname", $i, $i, "background-color:#ff5555", $message = "(Primary Key)",'vo_label' );
  60. }
  61.  
  62. // DB columns:
  63. for( $i = $i; $i < $post['col_num']; $i++ )
  64. {
  65.     printVarForm( "varname", "colname", $i, $i, "background-color:#f0f0ff",'','vo_label');
  66. }
  67.  
  68. echo <<<FOOTERTEXT
  69.     <tr>
  70.         <td colspan="4" align="center">
  71.             <br>
  72.             <input type="submit" value="Generate Code">
  73.         </td>
  74.     </tr>
  75.  
  76. </form>
  77. </table>
  78. </div>
  79. FOOTERTEXT;
  80.  
  81. function printVarForm( $varname, $colname, $index, $radio_val, $style, $message = "",$labname ) {
  82.  
  83. $radio_checked = (($radio_val == 0)?"checked":"");
  84.  
  85. $varname = $varname . '[' . $index . ']';
  86. $colname = $colname . '[' . $index . ']';
  87. echo <<<FORM
  88.     <tr style="$style">
  89.         <td >
  90.             <select name="type_$colname">
  91.               <option value="varchar" selected>String</option>
  92.               <option value="Int">Integer</option>
  93.               <option value="Double">Double</option>
  94.               <option value="BigDecimal">Decimal</option>
  95.               <option value="DateTime">DateTime</option>
  96.               <option value="Date">Date</option>
  97.               <option value="Time">Time</option>
  98.               <option value="Timestamp">Timestamp</option>
  99.             </select>
  100.         </td>
  101.         <td>
  102. FORM;
  103.     if( $colname != "" ) {
  104.         echo '<input type="text" name="'.$colname.'" value="" size="30">';
  105.     } 
  106.  
  107. echo <<<FORM
  108.     <b>$message</b></td>
  109.  
  110.     <td><input type="text" name="$varname" value="" size="30"></td>
  111.     <td>
  112. FORM;
  113.  
  114.     if( $radio_val > -1 ) {
  115.         echo '<input type="radio" name="ordering" value="'.$radio_val.'" '.$radio_checked.'>';
  116.     }
  117.     echo '</td></tr>';
  118. }
  119. $tabtable->print_foot();
  120. ?>
  121.