Overview

Packages

  • Admin
  • Archive
  • Common
  • DB
  • Express
  • Form
  • Layout
  • Mailer
  • None
  • OpenHomeoDB
  • PDF
    • MC
  • Process
  • Rep
  • RevRep
  • SaveReps
  • Search
  • Session
  • SymRem
  • TreeView
  • UserDB

Functions

  • build_saved_reps_table
  • Overview
  • Package
  • Function
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * forms/saved_reps.php
  5:  *
  6:  * This file provides a form for managing your saved repertorizations from your user account.
  7:  *
  8:  * PHP version 8
  9:  *
 10:  * LICENSE: This program is free software: you can redistribute it and/or modify
 11:  * it under the terms of the GNU Affero General Public License as
 12:  * published by the Free Software Foundation, either version 3 of the
 13:  * License, or (at your option) any later version.
 14:  * This program is distributed in the hope that it will be useful,
 15:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17:  * GNU Affero General Public License for more details.
 18:  * You should have received a copy of the GNU Affero General Public License
 19:  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 20:  *
 21:  * @category  Homeopathy
 22:  * @package   SaveReps
 23:  * @author    Henri Schumacher <henri.hulski@gazeta.pl>
 24:  * @copyright 2007-2014 Henri Schumacher
 25:  * @license   http://www.gnu.org/licenses/agpl.html GNU Affero General Public License v3
 26:  * @version   1.0
 27:  * @link      https://research.openhomeo.info/download/OpenHomeopath_1.0.2.tar.gz
 28:  */
 29: 
 30: /**
 31:  * build_saved_reps_table displays the users saved repertorizations in a nicely formatted html table.
 32:  *
 33:  * @param string  $order_by   row by which the table will be ordered
 34:  * @param string  $order_type order direction: ASC | DESC
 35:  * @param string  $username   user which repertorizations will be shown
 36:  * @param string  $user_url   the url of the userinfo page
 37:  * @param integer &$num_reps  number of saved repertorizations to be shown
 38:  * @param boolean $self       true if the user is watching his own account, false otherwise
 39:  *
 40:  * @return string html table with the saved repertorizations
 41:  * @access public
 42:  */
 43: function build_saved_reps_table($order_by, $order_type, $username, $user_url, &$num_reps, $self = true){
 44:     global $db;
 45:     // build the table heading
 46:     $row_headers_ar = array (
 47:         'rep_timestamp' => _("Date"),
 48:         'rep_id' => _("RepNo"),
 49:         'patient_id' => _("Patient"),
 50:         'rep_public' => _("public")
 51:     );
 52:     $saved_reps_table = "<div class='scrollableContainer'>\n";
 53:     $saved_reps_table .= "  <div  class='scrollingArea'>\n";
 54:     $saved_reps_table .= "    <table class='saved_reps'>\n";
 55: 
 56:     // build the table heading
 57:     $saved_reps_table .= "      <thead>\n";
 58:     $saved_reps_table .= "        <tr>\n";
 59:     $saved_reps_table .= "          <th class='radio'><div>&nbsp;</div></th>\n"; // skip the first column for radiobutton
 60:     foreach ($row_headers_ar as $row => $header) {
 61:         $saved_reps_table .= "          <th class='$row'><div>";
 62:         $field_is_current_order_by = 0;
 63:         if ($order_by != $row){ // the results are not ordered by this field at the moment
 64:             $link_class="order_link_2";
 65:             if ($row == "rep_timestamp") {
 66:                 $new_order_type = "DESC";
 67:             } else {
 68:                 $new_order_type = "ASC";
 69:             }
 70:         } else {
 71:             $field_is_current_order_by = 1;
 72:             $link_class="order_link_2_selected";
 73:             if ( $order_type == "DESC") {
 74:                 $new_order_type = "ASC";
 75:             } else {
 76:                 $new_order_type = "DESC";
 77:             }
 78:         }
 79:             
 80:         $saved_reps_table .= "<a class='$link_class' href='" . $user_url . "order_by=$row&amp;order_type=$new_order_type'";
 81:         if ($self) {
 82:             $saved_reps_table .= " onclick=\"return reloadSavedRepsTable('$row', '$new_order_type')\"";
 83:         }
 84:         $saved_reps_table .= ">";
 85: 
 86:         if ($field_is_current_order_by === 1) {
 87:             if ($order_type === 'ASC') {
 88:                 $saved_reps_table .= '&uarr; ';
 89:             } else {
 90:                 $saved_reps_table .= '&darr; ';
 91:             }
 92:         }
 93:             
 94:         $saved_reps_table .= "$header</a></div></th>\n";
 95:     }
 96:     $saved_reps_table .= "        </tr>\n";
 97:     $saved_reps_table .= "      </thead>\n";
 98: 
 99:     // build the table body
100:     $i = 0;
101:     $class = "unchecked_1";
102:     $query = "SELECT rep_id, patient_id, rep_prescription, rep_note, UNIX_TIMESTAMP(rep_timestamp), rep_public FROM repertorizations WHERE username = '$username' ";
103:     if (!$self) {
104:         $query .= "AND rep_public = 1 ";
105:     }
106:     if ($order_by == 'rep_timestamp') {
107:         $query .= "ORDER BY $order_by $order_type, rep_id $order_type";
108:     } else {
109:         $query .= "ORDER BY $order_by $order_type";
110:     }
111:     $db->send_query($query);
112:     $saved_reps_table .= "      <tbody>\n";
113:     while (list($rep_id, $patient_id, $rep_prescription, $rep_note, $rep_timestamp, $rep_public) = $db->db_fetch_row()) {
114:         $i++;
115:         $date = date ("d.m.Y", $rep_timestamp);
116:         if ($rep_public == 1) {
117:             $public = _("yes");
118:         } else {
119:             $public = _("no");
120:         }
121:         if (empty($patient_id)) {
122:             $patient_id = "&nbsp;";
123:         }
124:         $saved_reps_table .= "        <tr class='$class' id='row_$i'>\n";
125:         $saved_reps_table .= "          <td class='radio'><div><input type='radio' id='radio_$i' value='$rep_id%$patient_id%$rep_prescription%$rep_note%$rep_timestamp%$rep_public' name='saved_rep' onclick=\"return colorizeRadioRow('radio','row','saved_reps_form');\" onkeyup=\"return colorizeRadioRow('radio','row','saved_reps_form');\"></div></td>\n";
126:         $saved_reps_table .= "          <td class='rep_timestamp'><div><label for='radio_$i'>$date</label></div></td>\n";
127:         $saved_reps_table .= "          <td class='rep_id'><div><label for='radio_$i'>$rep_id</label></div></td>\n";
128:         $saved_reps_table .= "          <td class='patient_id'><div><label for='radio_$i'>$patient_id</label></div></td>\n";
129:         $saved_reps_table .= "          <td class='rep_public'><div><label for='radio_$i'>$public</label></div></td>\n";
130:         $saved_reps_table .= "        </tr>\n";
131:         $class = ($class == "unchecked_1") ? "unchecked_2" : "unchecked_1";
132:     }
133:     $num_reps = $db->db_num_rows();
134:     $db->free_result();
135:     $saved_reps_table .= "      </tbody>\n";
136: 
137:     $saved_reps_table .= "    </table>\n";
138:     $saved_reps_table .= "  </div>\n";
139:     $saved_reps_table .= "</div>\n";
140: 
141:     return $saved_reps_table;
142: }
143: 
144: if (!empty($_REQUEST['ajax'])) {
145:     chdir("..");
146:     include_once ("include/classes/login/session.php");
147:     $username = $session->username;
148: }
149: if (!$tabbed && !isset($_REQUEST['tab'])) {
150:     $user_url = "userinfo.php?";
151: } else {
152:     $user_url = "index.php?tab=4&";
153: }
154: 
155: $loesch = 0;
156: $public = 0;
157: if (!empty($_REQUEST['loesch']) && !empty($_REQUEST['rep'])) {  // Repertorisierung löschen
158:     $rep_id = $_REQUEST['rep'];
159:     $query1 = "DELETE FROM rep_sym WHERE rep_id='$rep_id'";
160:     $query2 = "DELETE FROM repertorizations WHERE rep_id='$rep_id'";
161:     $loesch = 2;
162:     if ($db->send_query($query1) && $db->send_query($query2)) {
163:         $loesch = 1;
164:     }
165: } elseif (!empty($_REQUEST['public']) && !empty($_REQUEST['rep'])) {  // Öffentlich-Status ändern
166:     $rep_id = $_REQUEST['rep'];
167:     if ($_REQUEST['rep_public'] == "1"){
168:         $rep_public_new = 0;
169:     } else {
170:         $rep_public_new = 1;
171:     }
172:     $query = "SELECT rep_timestamp FROM repertorizations WHERE rep_id = $rep_id";
173:     $db->send_query($query);
174:     list($rep_timestamp) = $db->db_fetch_row();
175:     $db->free_result();
176:     $query = "UPDATE repertorizations SET rep_public = $rep_public_new, rep_timestamp = '$rep_timestamp' WHERE rep_id = $rep_id";
177:     if ($db->send_query($query)) {
178:         $public = 1;
179:     }
180: }
181: if ($loesch != 0 || $public != 0) {
182:     echo ("    <div class='alert_box'>\n");
183:     if ($loesch == 1) {
184:         printf("      " . _("Repertorization No. %d was deleted.") . "\n", $rep_id);
185:     } elseif ($loesch == 2) {
186:         printf("      <span class='red'>" . _("Repertorization No. %d couldn't be deleted totally!") . "</span>\n", $rep_id);
187:     } elseif ($public == 1) {
188:         printf("      " . _("The public status of the repertorization no. %d changed.") . "\n", $rep_id);
189:     }
190:     echo ("        </div>\n");
191: }
192: if (!$tabbed && !isset($_REQUEST['tab'])) {
193:     $tab = -1;
194: } else {
195:     $tab = 1;
196: }
197: ?>
198:     <form id="saved_reps_form" accept-charset="utf-8">
199:       <div class = 'select'>
200: <?php
201: $order_by = "rep_timestamp";
202: $order_type = "DESC";
203: if (!empty($_REQUEST['order_by'])) {
204:     $order_by = $_REQUEST['order_by'];
205: }
206: if (!empty($_REQUEST['order_type'])) {
207:     $order_type = $_REQUEST['order_type'];
208: }
209: echo build_saved_reps_table($order_by, $order_type, $username, $user_url, $num_reps);
210: printf("      <p class='label'>" . ngettext("%d saved repertorization", "%d saved repertorizations", $num_reps) . "</p>\n", $num_reps);
211: ?>
212:         <div class="button_area_2">  
213:           <input class="submit" type="button" onclick='repCall(<?php echo($tab);?>)' value=" <?php echo _("Show repertorization"); ?> ">
214:           <br>
215:           <br>
216: <?php
217: if ($tab == 1) {
218:     $tab = 0;
219: }
220: ?>
221:           <input class="submit" type="button" onclick='repContinue(<?php echo($tab);?>)' value=" <?php echo _("Add more symptoms"); ?> ">
222:           <br>
223:           <br>
224:           <input class="submit" type="button" onclick='repDelete()' value=" <?php echo _("Delete repertorization"); ?> ">
225:           <br>
226:           <br>
227:           <input class="submit" type="button" onclick='repPublic()' value=" <?php echo _("Change public-state"); ?> ">
228:         </div>
229:       </div>
230:     </form>
231: 
OpenHomeopath PHP code documentation API documentation generated by ApiGen 2.8.0