From e7bfe401f2ee27cb552174a7762097801d791821 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 21 Mar 2011 14:33:48 +0000 Subject: [PATCH] Poner checkboxes y radiobuttons en horizontal. git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_FormulariosCalidad/trunk@14 e2c41b2c-0c6f-0149-8b81-50b1a9191bb3 --- edit_form.php | 4 +- images/button_text/campos.psd | Bin 404251 -> 404953 bytes images/button_text/checkboxes.gif | Bin 787 -> 807 bytes images/button_text/multiple_choice.gif | Bin 783 -> 751 bytes includes/standard-view-functions.php | 61 ++++- js/machform.js | 22 +- manage_form.php | 360 ++++++++++++------------- 7 files changed, 247 insertions(+), 200 deletions(-) diff --git a/edit_form.php b/edit_form.php index 20f6df5..a6ea78a 100644 --- a/edit_form.php +++ b/edit_form.php @@ -254,8 +254,8 @@ Tipo de campo id}_{$option->id}\" name=\"element_{$element->id}\" class=\"element radio\" type=\"radio\" value=\"{$option->id}\" {$checked} />\n"; - $option_markup .= "\n"; + $option_input = "id}_{$option->id}\" + name=\"element_{$element->id}\" class=\"element radio\" + type=\"radio\" value=\"{$option->id}\" {$checked} />"; + $option_label = ""; + + if ($cell_col == 1) { + $option_markup .= ''; + } + + $option_markup .= '' . $option_input . ' ' . $option_label . ''; + + if ($cell_col == 5) { + $option_markup .= ''; + $cell_col = 0; + } + + $cell_col++; } + $option_markup .= ""; + $element_markup = << @@ -558,6 +572,9 @@ EOT; $option_markup = ''; + $option_markup .= ''; + $cell_col = 1; + foreach ($element->options as $option){ if(!$is_populated){ if($option->is_default){ @@ -567,19 +584,37 @@ EOT; } }else{ - if(!empty($element->populated_value['element_'.$element->id.'_'.$option->id]['default_value'])){ + if(!empty($element->populated_value['element_'.$element->id.'_' + .$option->id]['default_value'])){ $checked = 'checked="checked"'; }else{ $checked = ''; } } + $option_input = "id}_{$option->id}\" + name=\"element_{$element->id}_{$option->id}\" + class=\"element checkbox\" type=\"checkbox\" value=\"1\" {$checked} />"; + $option_label = ""; + if ($cell_col == 1) { + $option_markup .= ''; + } + + $option_markup .= ''; + + if ($cell_col == 3) { + $option_markup .= ''; + $cell_col = 0; + } + + $cell_col++; - $option_markup .= "id}_{$option->id}\" name=\"element_{$element->id}_{$option->id}\" class=\"element checkbox\" type=\"checkbox\" value=\"1\" {$checked} />\n"; - $option_markup .= "\n"; } + $option_markup .= '
' . $option_input . ' ' . $option_label . '
'; + $element_markup = << diff --git a/js/machform.js b/js/machform.js index e0b7b09..4d54ea2 100644 --- a/js/machform.js +++ b/js/machform.js @@ -3202,10 +3202,10 @@ data_source.prototype = { title = "Lista desplegable"; break; case "radio": - title = "Selección múltiple"; + title = "Botón de opciones"; break; case "checkbox": - title = "Cajas de selección"; + title = "Casillas de selección"; break; case "name": title = "Nombre"; @@ -3266,19 +3266,31 @@ data_source.prototype = { default_value: "", constraint: "", options: [{ - option: "Primera opción", + option: "Primera", is_default: 0, is_db_live: "0", id: "0" }, { - option: "Segunda opción", + option: "Segunda", is_default: 0, is_db_live: "0", id: "0" }, { - option: "Tercera opción", + option: "Tercera", + is_default: 0, + is_db_live: "0", + id: "0" + }, + { + option: "Cuarta", + is_default: 0, + is_db_live: "0", + id: "0" + }, + { + option: "Quinta", is_default: 0, is_db_live: "0", id: "0" diff --git a/manage_form.php b/manage_form.php index 1ffdcf0..59d7677 100644 --- a/manage_form.php +++ b/manage_form.php @@ -1,14 +1,14 @@ $value){ $index_key = array_search($form_id,$value,true); if($index_key !== false){ @@ -39,29 +39,29 @@ } } } - - + + //check for form delete parameter if(!empty($_GET['delete'])){ $deleted_form_id = (int) trim($_GET['delete']); delete_form($deleted_form_id); } - + //check for form duplicate parameter if(!empty($_GET['duplicate'])){ $target_form_id = (int) trim($_GET['duplicate']); $result_form_id = duplicate_form($target_form_id); - + if(!empty($result_form_id)){ $_SESSION['AP_SUCCESS']['title'] = 'Completado'; $_SESSION['AP_SUCCESS']['desc'] = 'Formulario duplicado.'; - + header("Location: manage_form.php?id={$result_form_id}"); exit; } } - - + + /****Pagination *************/ //get page number for pagination if(!empty($pageno_auto)){ @@ -71,36 +71,36 @@ }else{ $pageno = 1; } - + //identify how many database rows are available $query = "select count(*) total_row from `ap_forms`"; $result = do_query($query); $row = do_fetch_result($result); - + $numrows = $row['total_row']; - + $lastpage = ceil($numrows/$rows_per_page); - - + + //ensure that $pageno is within range //this code checks that the value of $pageno is an integer between 1 and $lastpage $pageno = (int)$pageno; - - if ($pageno < 1) { + + if ($pageno < 1) { $pageno = 1; } elseif ($pageno > $lastpage){ $pageno = $lastpage; } - + //construct the LIMIT clause for the sql SELECT statement if(!empty($numrows)){ $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; } - /*****End Pagination code *******/ - - - + /*****End Pagination code *******/ + + + //get form list $query = "select form_id,form_name,form_active,form_email from `ap_forms` order by form_id asc $limit"; $result = do_query($query); @@ -109,16 +109,16 @@ while($row = do_fetch_result($result)){ $form_list[$i]['form_id'] = $row['form_id']; $form_list[$i]['form_name'] = $row['form_name']; - $form_list[$i]['form_active'] = $row['form_active']; + $form_list[$i]['form_active'] = $row['form_active']; if(!empty($row['form_email'])){ - $form_list[$i]['form_email'] = $row['form_email']; + $form_list[$i]['form_email'] = $row['form_email']; }else{ - $form_list[$i]['form_email'] = 'nadie'; + $form_list[$i]['form_email'] = 'nadie'; } $form_id_array[] = $row['form_id']; $i++; } - + //get total entries for each form foreach ($form_id_array as $form_id){ //get all time entries @@ -126,20 +126,20 @@ $result = do_query($query); $row = do_fetch_result($result); $entries[$form_id]['total'] = $row['total_entry']; - + //get todays entries $query = "select count(*) today_entry from `ap_form_{$form_id}` where date_created >= date_format(curdate(),'%Y-%m-%d 00:00:00') "; $result = do_query($query); $row = do_fetch_result($result); $entries[$form_id]['today'] = $row['today_entry']; - + //get latest entry timing $query = "select date_created from `ap_form_{$form_id}` order by id desc limit 1"; $result = do_query($query); $row = do_fetch_result($result); $entries[$form_id]['latest_entry'] = relative_date($row['date_created']); } - + $header_data =<< @@ -158,98 +158,98 @@ } - - + new Effect.Highlight('form_status_' + response,{duration:1}); + + } + + + + + EOT; //delete a form, definition, entries and uploaded files function delete_form($form_id){ - //remove from ap_forms + //remove from ap_forms $query = "delete from `ap_forms` where form_id='$form_id'"; do_query($query); - + //remove from ap_form_elements $query = "delete from `ap_form_elements` where form_id='$form_id'"; do_query($query); - + //remove from ap_element_options $query = "delete from `ap_element_options` where form_id='$form_id'"; do_query($query); - + //remove from ap_column_preferences $query = "delete from `ap_column_preferences` where form_id='$form_id'"; do_query($query); - + //remove review table $query = "drop table if exists `ap_form_{$form_id}_review`"; do_query($query); - + //remove the actual table $query = "drop table if exists `ap_form_{$form_id}`"; do_query($query); - - //remove form folder + + //remove form folder @full_rmdir(UPLOAD_DIR."/form_{$form_id}"); if(DATA_DIR != UPLOAD_DIR){ @full_rmdir(DATA_DIR."/form_{$form_id}"); @@ -259,7 +259,7 @@ EOT; //duplicate a form function duplicate_form($form_id){ - + //set the new name $query = "select form_name,form_review from `ap_forms` where form_id='$form_id'"; $result = do_query($query); @@ -267,137 +267,137 @@ EOT; $form_review = $row['form_review']; $form_name = trim($row['form_name']); $form_name .= " Copy"; - + //get new form_id $query = "select max(form_id)+1 new_form_id from `ap_forms`"; $result = do_query($query); $row = do_fetch_result($result); $new_form_id = trim($row['new_form_id']); - + //insert into ap_forms table $query = "select * from `ap_forms` where form_id='{$form_id}'"; $result = do_query($query); - + $i = 0; $columns = array(); $fields_num = mysql_num_fields($result); while($i < $fields_num){ $meta = mysql_fetch_field($result, $i); - + if(($meta->name != 'form_id') && ($meta->name != 'form_name')){ $columns[] = $meta->name; } - + $i++; } - - + + //build the query string $columns_joined = implode(",",$columns); - $form_name = mysql_real_escape_string($form_name); - + $form_name = mysql_real_escape_string($form_name); + //insert to ap_forms - $query = "insert into - `ap_forms`(form_id,form_name,{$columns_joined}) - select - {$new_form_id},'{$form_name}',{$columns_joined} - from - `ap_forms` - where + $query = "insert into + `ap_forms`(form_id,form_name,{$columns_joined}) + select + {$new_form_id},'{$form_name}',{$columns_joined} + from + `ap_forms` + where form_id='$form_id'"; do_query($query); - + //create the new table do_query("create table `ap_form_{$new_form_id}` like `ap_form_{$form_id}`"); - - + + //copy ap_form_elements table $query = "select * from `ap_form_elements` limit 1"; $result = do_query($query); - + $i = 0; $columns = array(); $fields_num = mysql_num_fields($result); while($i < $fields_num){ $meta = mysql_fetch_field($result, $i); - + if($meta->name != 'form_id'){ $columns[] = $meta->name; } - + $i++; } $columns_joined = implode("`,`",$columns); - $query = "insert into - `ap_form_elements`(form_id,`{$columns_joined}`) - select - {$new_form_id},`{$columns_joined}` - from - `ap_form_elements` - where + $query = "insert into + `ap_form_elements`(form_id,`{$columns_joined}`) + select + {$new_form_id},`{$columns_joined}` + from + `ap_form_elements` + where form_id='$form_id'"; do_query($query); - + //copy ap_element_options table $query = "select * from `ap_element_options` limit 1"; $result = do_query($query); - + $i = 0; $columns = array(); $fields_num = mysql_num_fields($result); while($i < $fields_num){ $meta = mysql_fetch_field($result, $i); - + if(($meta->name != 'form_id') && ($meta->name != 'aeo_id')){ $columns[] = $meta->name; } - + $i++; } $columns_joined = implode("`,`",$columns); - $query = "insert into - `ap_element_options`(form_id,`{$columns_joined}`) - select - {$new_form_id},`{$columns_joined}` - from - `ap_element_options` - where + $query = "insert into + `ap_element_options`(form_id,`{$columns_joined}`) + select + {$new_form_id},`{$columns_joined}` + from + `ap_element_options` + where form_id='$form_id'"; do_query($query); - - + + //copy ap_column_preferences table $query = "select * from `ap_column_preferences` limit 1"; $result = do_query($query); - + $i = 0; $columns = array(); $fields_num = mysql_num_fields($result); while($i < $fields_num){ $meta = mysql_fetch_field($result, $i); - + if(($meta->name != 'form_id') && ($meta->name != 'acp_id')){ $columns[] = $meta->name; } - + $i++; } $columns_joined = implode("`,`",$columns); - $query = "insert into - `ap_column_preferences`(form_id,`{$columns_joined}`) - select - {$new_form_id},`{$columns_joined}` - from - `ap_column_preferences` - where + $query = "insert into + `ap_column_preferences`(form_id,`{$columns_joined}`) + select + {$new_form_id},`{$columns_joined}` + from + `ap_column_preferences` + where form_id='$form_id'"; do_query($query); - + //copy ap_form_xx_review table if exists if(!empty($form_review)){ do_query("CREATE TABLE `ap_form_{$new_form_id}_review` like `ap_form_{$form_id}_review`"); } - + //create form folder $old_mask = umask(0); mkdir(DATA_DIR."/form_{$new_form_id}",0777); @@ -407,13 +407,13 @@ EOT; } mkdir(UPLOAD_DIR."/form_{$new_form_id}/files",0777); umask($old_mask); - - //copy css file + + //copy css file copy(DATA_DIR."/form_{$form_id}/css/view.css",DATA_DIR."/form_{$new_form_id}/css/view.css"); - + return $new_form_id; } - + ?> @@ -431,29 +431,29 @@ EOT; -'; - - foreach ($form_list as $data){ - - if(!empty($data['form_active'])){ - $form_status = 'Activado'; + echo '
'; + + foreach ($form_list as $data){ + + if(!empty($data['form_active'])){ + $form_status = 'Activado'; $image_status = 'checkbox.gif'; $activation_text = 'Desactivar este formulario'; $activation_link = 'disable_form'; - }else{ - $form_status = 'Desactivado'; + }else{ + $form_status = 'Desactivado'; $image_status = 'disabled.gif'; $activation_text = 'Activar este formulario'; $activation_link = 'enable_form'; - }; - - -?> + }; + + +?>

@@ -465,7 +465,7 @@ EOT; "> "> "> - ">*/ ?> + ">     @@ -477,54 +477,54 @@ EOT; ">Editar form. ">Editar estilo ">Emails - ">Código */ ?> + ">Código   Ver formulario   ">Duplicar Borrar - +
Respuestas de hoy:
Total de respuestas:

Última respuesta:
- +
Las notificaciones se enviarán a:
- - - Estado del formulario: + + + Estado del formulario:          - - + +
-'; echo ''; + echo ''; }else{ echo "

No hay formularios.

"; } -?> - +?> + @@ -532,22 +532,22 @@ EOT;

- 19){ + + if($lastpage > 19){ echo " <<First "; } $prevpage = $pageno-1; - - - } - + + + } + //middle navigation if($pageno == 1){ $i=1; @@ -564,7 +564,7 @@ EOT; echo ' ... '; } }elseif ($pageno == $lastpage){ - + if(($lastpage - 19) > 1){ echo ' ... '; $i=1; @@ -591,18 +591,18 @@ EOT; $i++; } } - + }else{ $next_pages = false; $prev_pages = false; - + if(($lastpage - ($pageno + 9)) >= 1){ $next_pages = true; } if(($pageno - 9) > 1){ $prev_pages = true; } - + if($prev_pages){ //if there are previous pages echo ' ... '; if($next_pages){ //if there are next pages @@ -620,7 +620,7 @@ EOT; } echo ' ... '; }else{ - + $i=1; $j=$pageno - 9; while(($i<=19) && ($j <= $lastpage)){ @@ -633,9 +633,9 @@ EOT; $i++; $j++; } - } + } }else{ //if there aren't previous pages - + $i=1; while(($i<=19) && ($i <= $lastpage)){ if($i != $pageno){ @@ -645,26 +645,26 @@ EOT; } echo " $i "; $i++; - + } if($next_pages){ echo ' ... '; } - + } - - + + } - - if ($pageno != $lastpage) + + if ($pageno != $lastpage) { $nextpage = $pageno+1; if($lastpage > 19){ echo " Last>> "; } } - - + + //next we inform the user of his current position in the sequence of available pages ?>