%META:TOPICINFO{author="SrikanthR" date="1215580408" format="1.1" version="1.5"}%
%META:TOPICPARENT{name="InstalledPlugins"}%
---+!! <nop>%TOPIC%

---+!! <nop>%TOPIC%

 This plugin is used for reservation of any resource using mysql database . 
          
    For example, this can be used as library reservation system, where books can be reserved by users for a particular period and it allows to delete the reservations made ( by the user only)  and retrieve the reservation list on particular date or paricular period. 

One can also retrieve the free resources on a particular date or particular period , by which  the user can make the decision of reserving the free resources according to his will. The plugin also facilitate the user to create and delete the tables ( which are used for maintaining reservations) from TWIKi only.

 The pre-requiste for accessing mysql database is that the Admin has  to create  the database named =Reservation=. 

%TOC%

---++ Syntax Rules
---++ Recognized Variables (for usage).

This is a list of all the variables available. The names should be self-explanatory. The table parameter in the following variables has to be created using  the create option in the topic ResourceAdminstator.
---+++ SHOW_ALL_RESERVATIONS
 This variable is used to show all the reservations done in the future and past. Parameters: 
   * =Table=: The table where all reservations has been stored 
---+++ RESERVE_RESOURCE
 This variable is used to reserve a resource from one date to another date.This variable takes following parameters 
   * =Table= :The table where all reservations has to be stored 
   * =resource= : The resource to be reserved 
   * =fromdate= : The starting date of reservation 
   * =todate= : The end date of reservation 
   * =username= : On whom name, the reservation has to be made..Generally <verbatim>%WIKIUSERNAME%</verbatim> is enough 
   * =comment= : Any comment to be attached to reservation The required parameters for the variable to get working is =Table,resource,fromdate,todate,username= 
---+++ SHOW_FREE_RESOURCES
 This variable is used to show free resources from a date to another date.The parameters required are given below 
   * =Table= : The table where reservations are stored 
   * =ResourceList= : The resources list 
   * =Fromdate= : The starting date 
   * =Todate= : The end date 
---+++ GET_RESOURCE_DELETE
 This variable is used to generate all the reservations done from current date. The list contains all the reservation details along with the delete option. The parameters required are given below 
   * =Table= : The table where reservations are stored 
   * =UserName= : The reservtions done by the user will be displayed. If no username is given, all the reservations will be displayed. 
   * =DeletePage= : The target topic where the reservations deletion is to be displayed.
---+++ SHOW_RESERVATION_ON_DATE
 This variable is used to show the reservations made from a particular date to another date. The parameters required are 
   * =Table= : The table where reservations are stored 
   * =date= : 
----+++ DELETE_SPECIFIED_RESOURCE
  This variable is used to delete the specified reservation.The topic where the variable is defined , has to be given as parameter in the  =GET_RESOURCE_DELETE= tag. The following code should be there inorder to work as expected.
<verbatim>
%DELETE_SPECIFIED_RESOURCE{ Table="ReservationTable" reservationid="%URLPARAM{"reservationid"}%"}%
</verbatim>
---++ Variables(For Adminstrator)
 Mysql has been used for storing the reservations. For working of plugin, =Reservation= database has to be created.After creation of Reservation database, Administrator can visit the ResourceAdministrator to create and delete the topics The username for the mysql should be =root= and the password is nil.

---++ Variables(For display)
 These variables has been defined inorder to lessen the burden of writing code, by which the  variables for reserving the resources can be directly used. How to use these variables has been given along with the variable definition
---+++ DISPLAY_FORM
 The resource reservation form will be rendered as the output of this variable. The form will have the resource,from date , to date and comment fields which are named as =Resource=,=Rdate=,=Tdate=,=comment=.An example of usage of the variable is given. <verbatim>%DISPLAYFORM{ResourceList="ResourceDetail"}%</verbatim> 
The requirement of the =ResourceList=  parameter is defined below  in the  Requirements header .
---+++ DISPLAY_FORM1
 The search form will be rendered as the output of this variable. The form will have the fromdate and todate fields which are named as =Fdate= and =Tdate=.There are no parameters required.
The usage of this variable is given in the topic CheckResource

---++ Requirements
 The requirements for the plugin to work is that Reservation database has to be created in mysql page. Then after wards tables has to be created using the <verbatim>%CREATE% </verbatim> . The =ResourceList= parameter in =SHOW_FREE_RESOURCE= should be given a topicname. The topic should be in the following format<verbatim>
%STARTINCLUDE%<option>Resource1</option><option>Resource 2</option>%STOPINCLUDE%</verbatim>

The user can has many resources which can be embedded in the INCLUDE tags as specified above.



---++ Examples
If properly installed you will see a table showing the reservations done on current date

%SHOW_RESERVATION_ON_DATE{Table="ReservationTable"  }%

---++ Plugin Settings

   * One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
      * Set SHORTDESCRIPTION = Reservation system for resources using mysql database

   * Debug plugin: (See output in =data/debug.txt=)
      * Set DEBUG = 0

---++ Plugin Installation Instructions

__Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server. 

   * Download the ZIP file from the Plugin Home (see below)
   * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content:
     | *File:* | *Description:* |
     | ==data/TWiki/%TOPIC%.txt== | Plugin topic |
     | ==data/TWiki/%TOPIC%.txt,v== | Plugin topic repository |
     | ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
     | ==data/TWiki/ResourceAdministrator== | Administrator page |
     | ==data/TWiki/CheckResources== | Sample page |
     | ==data/TWiki/ReservationOnDate== | Reservations on particular date|
   * Configure the Plugin:
      * TWiki 4.0 and up: Run the [[%SCRIPTURL%/configure%SCRIPTSUFFIX%][configure]] script to enable the Plugin
   * Using mysql, create a database named "Reservation"
   * Then go to ResourceAdministrator  and create all the tables required and reserve the resources as required.
 The plugin has been developed and tested using mysql 5.0.51.

---++ Plugin Info

|  Plugin Author: | TWiki:Main.SrikanthRevanuru |
|  Copyright: | &copy; 2007, TWiki:Main.SrikanthRevanuru |
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
|  Plugin Version: | 09 Jul 2008 (V1.000) |
|  Change History: | <!-- versions below in reverse order -->&nbsp; |
|  09 Jul 2008: | Initial version |
|  TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
|  CPAN Dependencies: | DBD-mysql-4.007 ,Time::Local |
|  Other Dependencies: | JSCalendarContrib |
|  Perl Version: | 5.005 |
|  [[TWiki:Plugins/Benchmark][Benchmarks]]: | %TWIKIWEB%.GoodStyle nn%, %TWIKIWEB%.FormattedSearch nn%, %TOPIC% 98% |
|  Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ %TWIKIWEB%.TWikiPlugins, %TWIKIWEB%.DeveloperDocumentationCategory, %TWIKIWEB%.AdminDocumentationCategory, %TWIKIWEB%.TWikiPreferences

-- TWiki:Main.SrikanthRevanuru - 09 Jul 2008






