Exemplo n.º 1
0
    /**
     * menu of project columns with a menu for each used to select that columns data type
     * 
     * @param mixed $project_id
     * @param mixed $name
     * @param mixed $id
     * 
     * @author Ryan R. Bayne
     * @package CSV 2 POST
     * @since 8.1.33
     * @version 1.0.1
     */
    public function option_column_datatypes($project_id, $name, $id, $validation = false)
    {
        if (!is_numeric($project_id)) {
            return false;
        }
        $project_columns_array = CSV2POST::get_project_columns_from_db($project_id, true);
        // get the data treatment then remove it to make the loops simple
        $treatment = $project_columns_array['arrayinfo']['datatreatment'];
        if (isset($project_columns_array['arrayinfo']['datatreatment'])) {
            unset($project_columns_array['arrayinfo']['datatreatment']);
        }
        $current_value = 'notrequired';
        $datatypes_array = array();
        $datatypes_array['notrequired'] = 'Not Required';
        $datatypes_array['alpha'] = 'Letters Only';
        $datatypes_array['alphanumeric'] = 'Letters & Numbers';
        $datatypes_array['numeric'] = 'Numbers Only';
        $datatypes_array['linkurl'] = 'Link URL';
        $datatypes_array['imageurl'] = 'Image URL';
        $datatypes_array['boolean'] = 'Boolean';
        foreach ($project_columns_array as $table_name => $columns_array) {
            if ($table_name != 'arrayinfo') {
                foreach ($columns_array as $key => $acolumn) {
                    $rules_array = CSV2POST::get_data_rules_source($project_columns_array['arrayinfo']['sources'][$table_name]);
                    if (!empty($rules_array)) {
                        if (isset($rules_array['datatypes'][$acolumn])) {
                            $current_value = $rules_array['datatypes'][$acolumn];
                        }
                    }
                    // update form from previous submission
                    if (isset($_POST["{$name}#{$table_name}#{$acolumn}"])) {
                        $current_value = $_POST["{$name}#{$table_name}#{$acolumn}"];
                    }
                    ?>
  
                
                    <?php 
                    if ($treatment == 'individual') {
                        $label = $acolumn . '<br><span style="color:grey;">' . $table_name . '</span>';
                    } else {
                        $label = $acolumn;
                    }
                    ?>
                                        
                    <tr valign="top">                    
                        <th scope="row"><?php 
                    echo $label;
                    ?>
</th>
                        <td>
                            <input type="hidden" name="sourceid_<?php 
                    echo $table_name . $acolumn;
                    ?>
" value="<?php 
                    echo $project_columns_array['arrayinfo']['sources'][$table_name];
                    ?>
">
                            <select name="<?php 
                    echo "{$name}#{$table_name}#{$acolumn}";
                    ?>
" id="<?php 
                    echo "{$name}{$table_name}{$acolumn}";
                    ?>
">
                                <?php 
                    foreach ($datatypes_array as $key => $data_type) {
                        $selected = '';
                        if ($current_value == $key) {
                            $selected = ' selected="selected"';
                        }
                        echo '<option value="' . $key . '"' . $selected . '>' . $data_type . '</option>';
                    }
                    ?>
                            </select>
                        </td>
                    </tr><?php 
                }
            }
        }
    }