/plugins/ -> ordering_plugin.php
1 <?php
2
3 // plugin_inc.php - skeleton file for plugin codes
4 // plugin_inc.php - author: Nico Stuurman
5
6 /*
7 Copyright 2002, Nico Stuurman
8
9 This is a skeleton file to code your own plugins.
10 To use it, rename this file to something meaningfull,
11 add the path and name to this file (relative to the phplabware root)
12 in the column 'plugin_code' of 'tableoftables', and code away.
13 And, when you make something nice, please send us a copy!
14
15 This program is free software: you can redistribute it and/ormodify it under
16 the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
17
18 */
19
20
21 function plugin_display_add_post($db,$nowfield)
22 {
23 global $title, $date, $USER, $system_settings;
24
25 $dateformat=get_cell($db,'dateformats','dateformat','id',$system_settings["dateformat"]);
26 $date=(time()); $date=date($dateformat,$date);
27 echo "<input type='hidden' name='date_requested' value='$date'>\n";
28
29 $r=$db->Execute("SELECT firstname,lastname,email FROM users WHERE id=$USER");
30 $myname=$USER["firstname"];$myname.=$USER["lastname"];
31 echo "<input type='hidden' name='ordered_by' value='$myname'>\n";
32
33
34 }
35
36
37
38 ////
39 // !Extends function display_show
40 // modified to duplicatean entry for reordering
41 function plugin_display_show ($db,$Allfields,$id)
42 {
43 global $PHP_SELF, $md, $USER, $tableinfo, $system_settings;
44
45 $dbstring=$PHP_SELF;$dbstring.="?";$dbstring.="tablename=".$tableinfo->name."&";
46 echo "<form name='order_form' method='post' id='protocolform' enctype='multipart/form-data' $j2 action='$dbstring'>\n";
47
48 echo "<input type='hidden' name='md' value='$md'>\n";
49 echo "<table border=0 align='center'>\n";
50
51 // initailize a blank array
52 $Allfields2=array();
53
54 // Define variables to be cleared from the arrays
55 $badnames=array('date_ordered','confirmed');
56
57 // variables to not be messed with, rather these are explicitly defined later or system set*/
58 $notouch=array('date','ordered_by','date_requested','ownerid','magic');
59
60 foreach ($Allfields as $nowfield2)
61 {
62 $flag=1;
63 foreach($badnames as $nolike)
64 {if ($nowfield2[label] == $nolike){$flag=0;}}
65 foreach($notouch as $nolike2)
66 {if ($nowfield2[label] == $nolike2){$flag=666;}}
67 if ($flag == 1)
68 {echo "<input type='hidden' name='$nowfield2[name]' value='$nowfield2[values]'>\n";}
69 elseif($flag == 0)
70 {echo "<input type='hidden' name='$nowfield2[name]' value=''>\n";}
71
72 }
73
74 /* set the magic variable*/
75 $magic=time(); echo "<input type='hidden' name='magic' value='$magic'>\n";
76
77 /* Put in the date requested, who requested it, etc*/
78 $dateformat=get_cell($db,'dateformats','dateformat','id',$system_settings['dateformat']);
79 $date=(time());
80 $date=date($dateformat,$date);
81 $date.='-reorder';
82 echo "<input type='hidden' name='date_requested' value='$date'>\n";
83
84
85 $r=$db->Execute("SELECT firstname,lastname,email FROM users WHERE id=$USER");
86 $myname=$USER['firstname'] .' ' . $USER['lastname'];
87 echo "<input type='hidden' name='ordered_by' value='$myname'>\n";
88
89
90 echo "<input type='hidden' name='subm' value=''>\n";
91 echo "<td colspan=7 align='center'><input type='button' name='sub' value='Re-order' onClick='document.order_form.subm.value=\"Add Record\"; document.order_form.submit(); window.opener.document.g_form.search.value=\"Search\"; window.opener.document.g_form.submit(); window.opener.focus(); '>\n";
92 //echo "<td colspan=7 align='center'><input type='button' name='sub' value='Re-order' onClick='document.order_form.subm.value=\"Add Record\"; document.order_form.submit(); window.opener.document.g_form.search.value=\"Search\"; setTimeout(\"window.opener.document.g_form.submit(); window.opener.focus(); window.close();\",300); '>\n";
93
94 echo " <input type='button' name='sub' value='Cancel' onClick='window.opener.focus(); window.close();'></td>\n";
95
96 //end of table
97 echo "</tr>\n</table>\n</form>\n";
98
99
100 }