2 // Copyright (C) 2007 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
13 'DEM' => xl('Demographics'),
14 'HIS' => xl('History'),
15 'REF' => xl('Referrals'),
17 if ($GLOBALS['ippf_specific']) {
18 $layouts['GCA'] = xl('Abortion Issues');
19 $layouts['CON'] = xl('Contraception Issues');
22 $layout_id = empty($_REQUEST['layout_id']) ?
'DEM' : $_REQUEST['layout_id'];
24 // Check authorization.
25 $thisauth = acl_check('admin', 'super');
26 if (!$thisauth) die("Not authorized.");
30 // Write one option line to the form.
32 function writeFieldLine($field_id, $group, $title, $seq, $uor, $length,
33 $titlecols, $datacols, $default, $desc, $data_type)
37 $bgcolor = "#" . (($fld_line_no & 1) ?
"ddddff" : "ffdddd");
38 $checked = $default ?
" checked" : "";
40 echo " <tr bgcolor='$bgcolor'>\n";
42 echo " <td align='left' class='optcell'>";
44 echo "<input type='hidden' name='fld[$fld_line_no][id]' value='" .
45 htmlspecialchars($field_id, ENT_QUOTES
) . "' size='20' />";
48 echo " <td align='center' class='optcell'>";
49 echo "<input type='text' name='fld[$fld_line_no][title]' value='" .
50 htmlspecialchars($title, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
53 echo " <td align='center' class='optcell'>";
54 echo "<input type='text' name='fld[$fld_line_no][group]' value='" .
55 htmlspecialchars($group, ENT_QUOTES
) . "' size='10' maxlength='63' class='optin' />";
58 echo " <td align='center' class='optcell'>";
59 echo "<input type='text' name='fld[$fld_line_no][seq]' value='" .
60 htmlspecialchars($seq, ENT_QUOTES
) . "' size='4' maxlength='10' class='optin' />";
63 echo " <td align='center' class='optcell'>";
64 echo "<select name='fld[$fld_line_no][uor]' class='optin'>";
65 foreach (array(0 =>xl('Unused'), 1 =>xl('Optional'), 2 =>xl('Required')) as $key => $value) {
66 echo "<option value='$key'";
67 if ($key == $uor) echo " selected";
68 echo ">$value</option>\n";
73 echo " <td align='center' class='optcell'>";
74 echo "<input type='text' name='fld[$fld_line_no][length]' value='" .
75 htmlspecialchars($length, ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
78 echo " <td align='center' class='optcell'>";
79 echo "<input type='text' name='fld[$fld_line_no][titlecols]' value='" .
80 htmlspecialchars($titlecols, ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
83 echo " <td align='center' class='optcell'>";
84 echo "<input type='text' name='fld[$fld_line_no][datacols]' value='" .
85 htmlspecialchars($datacols, ENT_QUOTES
) . "' size='3' maxlength='10' class='optin' />";
88 echo " <td align='center' class='optcell'>";
89 if ($data_type == 2) {
90 echo "<input type='text' name='fld[$fld_line_no][default]' value='" .
91 htmlspecialchars($default, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
97 echo " <td align='center' class='optcell'>";
98 echo "<input type='text' name='fld[$fld_line_no][desc]' value='" .
99 htmlspecialchars($desc, ENT_QUOTES
) . "' size='20' maxlength='63' class='optin' />";
108 <?php
html_header_show();?
>
110 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
111 <title
><?php
xl('Layout Editor','e'); ?
></title
>
114 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; }
115 tr
.detail
{ font
-size
:10pt
; }
116 td
{ font
-size
:10pt
; }
117 input
{ font
-size
:10pt
; }
118 a
, a
:visited
, a
:hover
{ color
:#0000cc; }
120 .optin
{ background
-color
:transparent
; }
123 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
125 <script language
="JavaScript">
130 <body
class="body_top">
133 // If we are saving, then save.
135 if ($_POST['form_save'] && $layout_id) {
136 $fld = $_POST['fld'];
137 for ($lino = 1; isset($fld["$lino"]['id']); ++
$lino) {
138 $iter = $fld["$lino"];
139 $field_id = trim($iter['id']);
141 sqlStatement("UPDATE layout_options SET " .
142 "title = '" . trim($iter['title']) . "', " .
143 "group_name = '" . trim($iter['group']) . "', " .
144 "seq = '" . trim($iter['seq']) . "', " .
145 "uor = '" . trim($iter['uor']) . "', " .
146 "fld_length = '" . trim($iter['length']) . "', " .
147 "titlecols = '" . trim($iter['titlecols']) . "', " .
148 "datacols = '" . trim($iter['datacols']) . "', " .
149 "default_value = '" . trim($iter['default']) . "', " .
150 "description = '" . trim($iter['desc']) . "' " .
151 "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
156 // Get the selected list's elements.
158 $res = sqlStatement("SELECT * FROM layout_options WHERE " .
159 "form_id = '$layout_id' ORDER BY group_name, seq");
163 <form method
='post' name
='theform' action
='edit_layout.php'>
165 <p
><b
>Edit layout
:</b
> 
;
166 <select name
='layout_id' onchange
='form.submit()'>
168 foreach ($layouts as $key => $value) {
169 echo "<option value='$key'";
170 if ($key == $layout_id) echo " selected";
171 echo ">$value</option>\n";
178 <table cellpadding
='2' cellspacing
='0'>
180 <td align
='left'><b
><?php
xl('ID','e'); ?
></b
></td
>
181 <td align
='center'><b
><?php
xl('Label','e'); ?
></b
></td
>
182 <td align
='center'><b
><?php
xl('Group','e'); ?
></b
></td
>
183 <td align
='center'><b
><?php
xl('Order','e'); ?
></b
></td
>
184 <td align
='center'><b
><?php
xl('UOR','e'); ?
></b
></td
>
185 <td align
='center'><b
><?php
xl('Size','e'); ?
></b
></td
>
186 <td align
='center'><b
><?php
xl('Label Columns','e'); ?
></b
></td
>
187 <td align
='center'><b
><?php
xl('Data Columns','e'); ?
></b
></td
>
188 <td align
='center'><b
><?php
xl('Default Value','e'); ?
></b
></td
>
189 <td align
='center'><b
><?php
xl('Description','e'); ?
></b
></td
>
193 while ($row = sqlFetchArray($res)) {
194 writeFieldLine($row['field_id'], $row['group_name'], $row['title'],
195 $row['seq'], $row['uor'], $row['fld_length'], $row['titlecols'],
196 $row['datacols'], $row['default_value'], $row['description'],
204 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />