~lucian-pricop/wittenhamspottery/initial

« back to all changes in this revision

Viewing changes to editPottery.php

  • Committer: lucian-pricop
  • Date: 2009-03-23 15:38:09 UTC
  • Revision ID: lucian-pricop-20090323153809-fwp8nzu0m0vpv25c
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?
 
2
        require("header.php");
 
3
        function __autoload($class_name) {
 
4
                require_once $class_name . '.php';
 
5
        }
 
6
        function printE($id,$type,$value)
 
7
        {
 
8
                echo "\t\t\telementList.push(new element(\"".$id."\",\"".$type."\",\"".$value."\"));\n";
 
9
        }
 
10
        $debugString = "";
 
11
        $load= false;
 
12
        if(isset($_GET["refid"]) && strcmp($_GET["refid"],"")!=0)
 
13
        {
 
14
                $refid = intval($_GET["refid"]);
 
15
                $dbconn = new dbcontrol();
 
16
                $connectionStatus = $dbconn->connectdb();
 
17
                if($connectionStatus != 1)
 
18
                {
 
19
                        $debugString = "I can't connect to the DB to load data!";
 
20
                }
 
21
                else
 
22
                  $load = true;
 
23
        }
 
24
        $_SESSION["searching".KEY]= false;
 
25
?>
 
26
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 
27
        "http://www.w3.org/TR/html4/strict.dtd">
 
28
<html>
 
29
        <head>
 
30
                <title>Pottery Database</title>
 
31
                <link rel="stylesheet" type="text/css" href="style.css"/>
 
32
                <script type="text/javascript">
 
33
                        function addnew(){
 
34
                                window.location = "editPottery.php";
 
35
                        }
 
36
                </script>
 
37
                <script type="text/javascript" src="RequestQueue.js"></script>
 
38
                <script type="text/javascript" src="JavaScript.js"></script>
 
39
<?      
 
40
        if($load)
 
41
        {       
 
42
                $queryString = "select * from tbl_pottery where refid=".$refid;
 
43
                $queryResult = $dbconn->sendquery2($queryString);
 
44
                $rowNr = $dbconn->numberofrows();
 
45
                if($rowNr ==1)
 
46
                {
 
47
                        echo "\t\t<script type=\"text/javascript\">\n";
 
48
                        echo "\t\t\tisLoading = true;\n";
 
49
                        echo "\t\t\telementList = new Array();\n";
 
50
                        //pottery related elements
 
51
                        $rowArray = pg_fetch_array($queryResult,null,PGSQL_ASSOC);
 
52
                    printE("potteryNumber","input",$rowArray["potterynumber"]);
 
53
                        printE("contextNumber","input",$rowArray["contextnumber"]);
 
54
                        printE("siteNumber","input",$rowArray["sitenumber"]);
 
55
                        printE("dateArea","input",$rowArray["datearea"]);
 
56
                        printE("descriptionCode","input",$rowArray["descriptioncode"]);
 
57
                        printE("colour","input",$rowArray["colour"]);
 
58
                        printE("surface_treatment","input",$rowArray["surface_treatment"]);
 
59
                        printE("fabric","input",$rowArray["fabric"]);
 
60
                        printE("form","input",$rowArray["form"]);
 
61
                        //getting the pot list
 
62
                        $queryString = "select * from tbl_entry_location where tbl_pottery_refid=".$refid." order by refid";
 
63
                        $potQueryResult = $dbconn->sendquery2($queryString);
 
64
                        $potRowNr = $dbconn->numberofrows();
 
65
                        if($potRowNr >0)
 
66
                        {
 
67
                                for($potNo=0;$potNo<$potRowNr;++$potNo)
 
68
                                {
 
69
                                        $rowarray = pg_fetch_array($potQueryResult,null,PGSQL_ASSOC);
 
70
                                        printE("pot:".$potNo."-0-0-0","select",$rowarray["potzone"]);
 
71
                                        //getting the location list
 
72
                                        $queryString = "select * from tbl_entry_type where tbl_entry_type_refid=".$rowarray["refid"]." order by refid";
 
73
                                        $locationQueryResult = $dbconn->sendquery2($queryString);
 
74
                                        $locationRowNr = $dbconn->numberofrows();
 
75
                                        if($locationRowNr >0)
 
76
                                        {
 
77
                                                for($locationNo=0;$locationNo<$locationRowNr;++$locationNo)
 
78
                                                {
 
79
                                                        $rowarray = pg_fetch_array($locationQueryResult,null,PGSQL_ASSOC);
 
80
                                                        printE("location:".$potNo."-".$locationNo."-0-0","select",$rowarray["entrytype"]);
 
81
                                                        $locationValue = $rowarray["entrytype"];
 
82
                                                        printE("method:".$potNo."-".$locationNo."-0-0","input",$rowarray["method"]);
 
83
                                                        printE("inlay:".$potNo."-".$locationNo."-0-0","input",$rowarray["inlay"]);
 
84
                                                        printE("design:".$potNo."-".$locationNo."-0-0","input",$rowarray["design"]);
 
85
                                                        printE("comments:".$potNo."-".$locationNo."-0-0","input",$rowarray["comments"]);
 
86
                                                        //getting the entry list
 
87
                                                        $queryString = "select * from tbl_entry_type_detail where entrytyperefid=".$rowarray["refid"]." order by refid";
 
88
                                                        $entryQueryResult = $dbconn->sendquery2($queryString);
 
89
                                                        $entryRowNr = $dbconn->numberofrows();
 
90
                                                        if($entryRowNr >0)
 
91
                                                        {
 
92
                                                                for($entryNo=0;$entryNo<$entryRowNr;++$entryNo)
 
93
                                                                {
 
94
                                                                        $rowarray = pg_fetch_array($entryQueryResult,null,PGSQL_ASSOC);
 
95
                                                                        if(strcmp($locationValue,"all over")!=0)
 
96
                                                                        {
 
97
                                                                                if(strcmp($locationValue,"zoned")==0 && strcmp($rowarray["entrydetail"],"geometric")==0 )
 
98
                                                                                {
 
99
                                                                                        printE("entryType:".$potNo."-".$locationNo."-".$entryNo."-0","select",$rowarray["entrydetail"]."2");
 
100
                                                                                    $entryValue = $rowarray["entrydetail"]."2";
 
101
                                                                                }
 
102
                                                                                else
 
103
                                                                                {
 
104
                                                                                        printE("entryType:".$potNo."-".$locationNo."-".$entryNo."-0","select",$rowarray["entrydetail"]);
 
105
                                                                                        $entryValue = $rowarray["entrydetail"];
 
106
                                                                                }
 
107
                                                                        }
 
108
                                                                        else
 
109
                                                                                $entryValue = $rowarray["entrydetail"];
 
110
                                                                        $entryRefid = $rowarray["refid"];
 
111
                                                                        //for quirk fix
 
112
                                                                        $isPatternInfill = false;
 
113
                                                                        //getting the component list
 
114
                                                                        $queryString = "select * from tbl_entry_type_components where typedetailrefid=".$entryRefid." order by refid";
 
115
                                                                        $componentQueryResult = $dbconn->sendquery2($queryString);
 
116
                                                                        $componentRowNr = $dbconn->numberofrows();
 
117
                                                                        if($componentRowNr >0)
 
118
                                                                        {
 
119
                                                                                for($componentNo=0;$componentNo<$componentRowNr;++$componentNo)
 
120
                                                                                {
 
121
                                                                                        $rowarray = pg_fetch_array($componentQueryResult,null,PGSQL_ASSOC);
 
122
                                                                                        if( (strcmp($locationValue,"zoned")==0 && strcmp($rowarray["entrytype"],"infill")==0) || 
 
123
                                                                                                (strcmp($entryValue,"linear")==0 && strcmp($rowarray["entrytype"],"elements")==0) ||
 
124
                                                                                                (strcmp($entryValue,"swag")==0 && strcmp($rowarray["entrytype"],"elements")==0) ||
 
125
                                                                                                (strcmp($entryValue,"running scroll")==0 && strcmp($rowarray["entrytype"],"infill")==0) ||
 
126
                                                                                                (strcmp($entryValue,"geometric")==0 && strcmp($rowarray["entrytype"],"type")==0)
 
127
                                                                                          )
 
128
                                                                                                printE($rowarray["entrytype"].":".$potNo."-".$locationNo."-".$entryNo."-0","simpleSelect",$rowarray["entryvalue"]);
 
129
                                                                                        elseif((strcmp($entryValue,"curvilinear")==0 && strcmp($rowarray["entrytype"],"type")==0))
 
130
                                                                                                printE($rowarray["entrytype"].":".$potNo."-".$locationNo."-".$entryNo."-0","specialInput",$rowarray["entryvalue"]);
 
131
                                                                                        else
 
132
                                                                                                printE($rowarray["entrytype"].":".$potNo."-".$locationNo."-".$entryNo."-0","input",$rowarray["entryvalue"]);
 
133
                                                                                        if(strcmp($rowarray["entrytype"],"infill")==0 && strcmp($rowarray["entryvalue"],"pattern")==0)
 
134
                                                                                                $isPatternInfill = true;
 
135
                                                                                }
 
136
                                                                        }
 
137
                                                                        //getting the border list
 
138
                                                                        $queryString = "select * from tbl_component_borders where typedetailrefid=".$entryRefid." order by refid";
 
139
                                                                        $componentQueryResult = $dbconn->sendquery2($queryString);
 
140
                                                                        $componentRowNr = $dbconn->numberofrows();
 
141
                                                                        if($componentRowNr >0)
 
142
                                                                        {
 
143
                                                                                $surplus = 0;
 
144
                                                                                for($componentNo=0;$componentNo<$componentRowNr;++$componentNo)
 
145
                                                                                {
 
146
                                                                                        $rowarray = pg_fetch_array($componentQueryResult,null,PGSQL_ASSOC);
 
147
                                                                                        
 
148
                                                                                        if($isPatternInfill && strcmp($rowarray["borderorshape"],"border")==0)
 
149
                                                                                                $surplus = 2;
 
150
                                                                                        if(strcmp($rowarray["borderorshape"],"border")==0)
 
151
                                                                                                printE("border:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"simpleSelect",$rowarray["value"]);
 
152
                                                                                        else
 
153
                                                                                                printE("shape:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"simpleSelect",$rowarray["value"]);
 
154
                                                                                        if(strcmp($rowarray["type"],"")!=0)
 
155
                                                                                                printE("borderType:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"input",$rowarray["type"]);
 
156
                                                                                        if(strcmp($rowarray["orientation"],"")!=0)
 
157
                                                                                                printE("borderOrientation:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"input",$rowarray["orientation"]);
 
158
                                                                                        printE("borderMethod:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"input",$rowarray["method"]);
 
159
                                                                                        printE("borderContinuity:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"input",$rowarray["continuity"]);
 
160
                                                                                        printE("borderElements:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"input",$rowarray["elements"]);
 
161
                                                                                        printE("borderNoRows:".$potNo."-".$locationNo."-".$entryNo."-".($componentNo+$surplus),"input",$rowarray["numberofrows"]);
 
162
                                                                                }
 
163
                                                                        }
 
164
                                                                        //getting the bandElements list
 
165
                                                                        $queryString = "select * from tbl_component_elements where typedetailrefid=".$entryRefid." order by refid";
 
166
                                                                        $componentQueryResult = $dbconn->sendquery2($queryString);
 
167
                                                                        $componentRowNr = $dbconn->numberofrows();
 
168
                                                                        if($componentRowNr >0)
 
169
                                                                        {
 
170
                                                                                for($componentNo=0;$componentNo<$componentRowNr;++$componentNo)
 
171
                                                                                {
 
172
                                                                                        $rowarray = pg_fetch_array($componentQueryResult,null,PGSQL_ASSOC);
 
173
                                                                                        printE("bandelements:".$potNo."-".$locationNo."-".$entryNo."-".$componentNo,"simpleSelect",$rowarray["value"]);
 
174
                                                                                        printE("bandorientation:".$potNo."-".$locationNo."-".$entryNo."-".$componentNo,"input",$rowarray["orientation"]);
 
175
                                                                                        printE("bandmethod:".$potNo."-".$locationNo."-".$entryNo."-".$componentNo,"input",$rowarray["method"]);
 
176
                                                                                        printE("bandnoRows:".$potNo."-".$locationNo."-".$entryNo."-".$componentNo,"input",$rowarray["numberofrows"]);
 
177
                                                                                        printE("bandContinuity:".$potNo."-".$locationNo."-".$entryNo."-".$componentNo,"input",$rowarray["continuity"]);
 
178
                                                                                }
 
179
                                                                        }
 
180
                                                                }
 
181
                                                        }
 
182
                                                }
 
183
                                        }
 
184
                                }
 
185
                        }       
 
186
                        echo "\t\t\telementList.reverse();\n";
 
187
                        echo "\t\t</script>\n";
 
188
                }
 
189
        }
 
190
?>
 
191
        </head>
 
192
        <body onload="initialize()">
 
193
                <h1>Pottery Database</h1>
 
194
                <div id="welcomeSection">
 
195
                        <div id="logout">
 
196
                                <form name="logout" action="logonAuthentication.php" method="POST">
 
197
                                        <input name="action" value="logout" type="hidden"/>
 
198
                                        <a class="inlineLink" href="#" onclick="document.forms['logout'].submit();"> Logout <?echo $_SESSION["fname".KEY]." ".$_SESSION["lname".KEY];?></a>
 
199
                                </form>
 
200
                        </div>
 
201
                        <?
 
202
                        if($load)
 
203
                        {
 
204
                                echo "Edit";
 
205
                                echo "&nbsp;| <a class=\"inlineLink\" href=\"javascript:addnew()\">New</a>";
 
206
                        }
 
207
                        else
 
208
                                echo "New";
 
209
                        ?>&nbsp;| 
 
210
                        <a class="inlineLink" href="index2.php">pot list</a>
 
211
                        &nbsp;| <a class="inlineLink" href="searchPottery.php">Search Pottery</a>
 
212
                </div>
 
213
                <?
 
214
                if(isset($_GET["status"]) && strcmp($_GET["status"],"succes")==0)
 
215
                        echo "<h3>Previous data has been succesfully added to the database...</h3>\n";
 
216
                else
 
217
                        echo "<h3>".$debugString."</h3>";
 
218
                ?>
 
219
                <div id="content">
 
220
                <form name="entry" method="post" action="nextStep.php">
 
221
                        <div id="entryDetail">
 
222
                                <p class="details">Pot details:</p>
 
223
                                <div class="inline">
 
224
                                        <p>pottery #</p>
 
225
                                        <input type="text" name="pottery number" maxlength="20" id="potteryNumber" length="10"/>
 
226
                                </div> 
 
227
                                <div class="inline">
 
228
                                        <p>context #</p>
 
229
                                        <input type="text" name="context number" maxlength="20" id="contextNumber" length="10"/>
 
230
                                </div>
 
231
                                <div class="inline">
 
232
                                        <p>site #</p>
 
233
                                        <input type="text" name="site number" maxlength="20" id="siteNumber" length="10" onkeypress="onDigitInputsChange(event)"/>
 
234
                                </div>
 
235
                                <div class="inline">
 
236
                                        <p>date area</p>
 
237
                                        <input type="text" name="date area" maxlength="20" id="dateArea" length="10"/>
 
238
                                </div>
 
239
                                <div class="inline">
 
240
                                        <p>description code</p>
 
241
                                        <input type="text" name="description code" maxlength="20" id="descriptionCode" length="10"/>
 
242
                                </div>
 
243
                                <div class="inline">
 
244
                                        <p>fabric</p>
 
245
                                        <input type="text" name="fabric" maxlength="20" id="fabric" length="10"/>
 
246
                                </div>
 
247
                                <div class="inline">
 
248
                                        <p>colour</p>
 
249
                                        <input type="text" name="colour" maxlength="30" id="colour" length="10"/>
 
250
                                </div>
 
251
                                <div class="inline">
 
252
                                        <p>surface treatment</p>
 
253
                                        <input type="text" name="surface_treatment" maxlength="30" id="surface_treatment" length="10"/>
 
254
                                </div>
 
255
                                <div class="inline">
 
256
                                        <p>form</p>
 
257
                                        <input type="text" name="form" maxlength="20" id="form" length="10"/>
 
258
                                </div>
 
259
                                <div class="clear"></div>
 
260
                                <br/><hr/><br/>
 
261
                        </div>
 
262
                        
 
263
                        <div id="potteryForm" class="inline">
 
264
                                <div id="0-0-0-0" class="block" lastLocationNumber="1">
 
265
                                </div>
 
266
                        </div>
 
267
                        <div class="submit">
 
268
                                <input type="submit" value="Save" title="press this button to save data"/>
 
269
                        </div>
 
270
                        <div id="WindowCover" class="invisible">
 
271
                                Loading...
 
272
                                <br/>Please wait
 
273
                                <br/>Loaded<p id="WindowCoverLoaded"></p>%
 
274
                        </div>  
 
275
                </form>
 
276
                </div>
 
277
                <div id="ft">
 
278
                        Developed by Oxford Archaeology, Maturo Cito, Adnitor Alternus Alicubi Clavis
 
279
                </div>
 
280
        </body>
 
281
</html>
 
 
b'\\ No newline at end of file'