phpScheduleIt
May 18, 2013, 06:42:12 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Adding a new search field to search reservations. v1.2.12  (Read 1817 times)
Azyrus
Newbie
*

Karma: 0
Posts: 28


« on: May 14, 2012, 11:20:08 PM »

Hi guys, handy little code to use if you add custom fields you most likely will want to search them at some point. The example will be adding a field to search a reservations teacher, green highlighted code/php needs to be ADDED.

There are 3 files that need to be edited:
phpscheduleit/usage.php
phpscheduleit/templates/usage.template.php
phpscheduleit/lib/db/UsageDB.class.php

First phpscheduleit/usage.php:
96 $summarysearch = $_POST['summarysearch'];
97 $summarytype = $_POST['summarytype'];
98 $teachersearch = $_POST['teachersearch'];
99 $teachertype = $_POST['teachertype'];


101 $res = $db->get_reservations($scheduleids, $memberids, $machids, $startDateMin, $startDateMax, $endDateMin, $endDateMax, $starttimeMin, $starttimeMax, $endtimeMin, $endtimeMax, $summarysearch, $summarytype, $teachersearch, $teachertype);

Secondly phpscheduleit/templates/usage.template.php:
287        <tr class="cellColor">
288         <td class="formNames"><?php echo translate('Summary')?>:</td>
289         <td>
290            <input type="radio" name="summarytype" value="anywhere" checked="checked" /><?php echo translate('Contains')?>
291            <input type="radio" name="summarytype" value="beginning" /><?php echo translate('Begins with')?>
292            <input type="text" name="summarysearch" class="textbox" />
293         </td>
294      </tr>
<Insert new code below here as a new search row>
295        <tr class="cellColor">
296         <td class="formNames">Teacher's Name:</td>
297         <td>
298            <input type="radio" name="teachertype" value="anywhere" checked="checked" /><?php echo translate('Contains')?>
299            <input type="radio" name="teachertype" value="beginning" /><?php echo translate('Begins with')?>
300            <input type="text" name="teachersearch" class="textbox" />
301         </td>
302      </tr>


Thirdly phpscheduleit/lib/db/UsageDB.class.php:
76 function get_reservations($scheduleids, $memberids, $machids, $startDateMin, $startDateMax, $endDateMin, $endDateMax, $starttimeMin, $starttimeMax, $endtimeMin, $endtimeMax, $summarysearch, $searchtype, $teachersearch, $teachertype) {

197       // Summary search clause
198      if (!empty($summarysearch)) {
199         if ($searchtype != 'beginning') {
200            $where .= ' AND res.summary LIKE "%' . $summarysearch . '%" ';
201         }
202         else {
203            $where .= ' AND res.summary LIKE "' . $summarysearch . '%" ';
204         }
205      }
<Insert new code below here as a new search row>
206      // Summary search clause
207      if (!empty($teachersearch)) {
208         if ($teachertype != 'beginning') {
209            $where .= ' AND res.teacher LIKE "%' . $teachersearch . '%" ';
210         }
211         else {
212            $where .= ' AND res.teacher LIKE "' . $teachersearch . '%" ';
213         }
214      }


Change all fields to relevant names to your actual field name, you could simply copy and paste the summary sections of code and replace summary with your field name.
Logged
tineg@94
Newbie
*

Karma: 0
Posts: 26


« Reply #1 on: May 23, 2012, 01:35:33 AM »

Hi,

Thank you.
I'd would be great to add some custom fields for reservation searching.
Would it be possible for you to adapt this code for V2.X?

Thanks in advance!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!