| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | $Rev: 285 $ | $LastChangedBy: brieb $ |
|---|
| 4 | $LastChangedDate: 2007-08-27 14:05:27 -0600 (Mon, 27 Aug 2007) $ |
|---|
| 5 | +-------------------------------------------------------------------------+ |
|---|
| 6 | | Copyright (c) 2004 - 2010, Kreotek LLC | |
|---|
| 7 | | All rights reserved. | |
|---|
| 8 | +-------------------------------------------------------------------------+ |
|---|
| 9 | | | |
|---|
| 10 | | Redistribution and use in source and binary forms, with or without | |
|---|
| 11 | | modification, are permitted provided that the following conditions are | |
|---|
| 12 | | met: | |
|---|
| 13 | | | |
|---|
| 14 | | - Redistributions of source code must retain the above copyright | |
|---|
| 15 | | notice, this list of conditions and the following disclaimer. | |
|---|
| 16 | | | |
|---|
| 17 | | - Redistributions in binary form must reproduce the above copyright | |
|---|
| 18 | | notice, this list of conditions and the following disclaimer in the | |
|---|
| 19 | | documentation and/or other materials provided with the distribution. | |
|---|
| 20 | | | |
|---|
| 21 | | - Neither the name of Kreotek LLC nor the names of its contributore may | |
|---|
| 22 | | be used to endorse or promote products derived from this software | |
|---|
| 23 | | without specific prior written permission. | |
|---|
| 24 | | | |
|---|
| 25 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|---|
| 26 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|---|
| 27 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
|---|
| 28 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|---|
| 29 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|---|
| 30 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|---|
| 31 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|---|
| 32 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|---|
| 33 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|---|
| 34 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|---|
| 35 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
|---|
| 36 | | | |
|---|
| 37 | +-------------------------------------------------------------------------+ |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | include("../../include/session.php"); |
|---|
| 41 | include("include/tables.php"); |
|---|
| 42 | include("include/fields.php"); |
|---|
| 43 | include("include/addresses.php"); |
|---|
| 44 | |
|---|
| 45 | if(!isset($_GET["backurl"])){ |
|---|
| 46 | |
|---|
| 47 | $thetable = new addresses($db,"tbld:27b99bda-7bec-b152-8397-a3b09c74cb23"); |
|---|
| 48 | |
|---|
| 49 | $pageTitle="Address"; |
|---|
| 50 | |
|---|
| 51 | } else { |
|---|
| 52 | |
|---|
| 53 | include("include/addresstorecord.php"); |
|---|
| 54 | |
|---|
| 55 | $backurl = $_GET["backurl"]; |
|---|
| 56 | |
|---|
| 57 | if(isset($_GET["refid"])) |
|---|
| 58 | $backurl .= "?refid=".$_GET["refid"]; |
|---|
| 59 | |
|---|
| 60 | $thetable = new addresstorecord($db,"tbld:27b99bda-7bec-b152-8397-a3b09c74cb23",$backurl); |
|---|
| 61 | $pageTitle="Client Address"; |
|---|
| 62 | |
|---|
| 63 | }//end if |
|---|
| 64 | |
|---|
| 65 | $therecord = $thetable->processAddEditPage(); |
|---|
| 66 | |
|---|
| 67 | if(isset($therecord["phpbmsStatus"])) |
|---|
| 68 | $statusmessage = $therecord["phpbmsStatus"]; |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | $phpbms->cssIncludes[] = "pages/bms/addresses.css"; |
|---|
| 72 | $phpbms->jsIncludes[] = "modules/bms/javascript/addresstorecord.js"; |
|---|
| 73 | |
|---|
| 74 | //Form Elements |
|---|
| 75 | //============================================================== |
|---|
| 76 | $theform = new phpbmsForm(); |
|---|
| 77 | |
|---|
| 78 | $theinput = new inputField("title",$therecord["title"],NULL,false,NULL,71,128); |
|---|
| 79 | $theinput->setAttribute("class","important"); |
|---|
| 80 | $theform->addField($theinput); |
|---|
| 81 | |
|---|
| 82 | $theinput = new inputField("address1",$therecord["address1"],"address",false,NULL,71,128); |
|---|
| 83 | $theform->addField($theinput); |
|---|
| 84 | |
|---|
| 85 | $theinput = new inputField("address2",$therecord["address2"],NULL,false,NULL,71,128, false); |
|---|
| 86 | $theform->addField($theinput); |
|---|
| 87 | |
|---|
| 88 | $theinput = new inputField("city",$therecord["city"],NULL,false,NULL,35,64); |
|---|
| 89 | $theform->addField($theinput); |
|---|
| 90 | |
|---|
| 91 | $theinput = new inputField("state",$therecord["state"],"state/province",false,NULL,10,20); |
|---|
| 92 | $theform->addField($theinput); |
|---|
| 93 | |
|---|
| 94 | $theinput = new inputField("postalcode",$therecord["postalcode"],"zip/postal code",false,NULL,12,15); |
|---|
| 95 | $theform->addField($theinput); |
|---|
| 96 | |
|---|
| 97 | $theinput = new inputField("country",$therecord["country"],NULL,false,NULL,44,128); |
|---|
| 98 | $theform->addField($theinput); |
|---|
| 99 | |
|---|
| 100 | $theinput = new inputField("shiptoname",$therecord["shiptoname"],"ship to name",false,NULL,71,128); |
|---|
| 101 | $theform->addField($theinput); |
|---|
| 102 | |
|---|
| 103 | $theinput = new inputField("phone",$therecord["phone"],NULL,false,"phone",25,32); |
|---|
| 104 | $theform->addField($theinput); |
|---|
| 105 | |
|---|
| 106 | $theinput = new inputField("email",$therecord["email"],NULL,false,"email",68,128); |
|---|
| 107 | $theform->addField($theinput); |
|---|
| 108 | |
|---|
| 109 | $theinput = new inputTextarea("notes",$therecord["notes"], NULL ,false, 4,80, false); |
|---|
| 110 | $theform->addField($theinput); |
|---|
| 111 | |
|---|
| 112 | $showNewChoice = false; |
|---|
| 113 | |
|---|
| 114 | if(isset($therecord["tabledefid"])){ |
|---|
| 115 | //these are fields used only when displaying connected addresses |
|---|
| 116 | |
|---|
| 117 | if($therecord["addressid"] == ""){ |
|---|
| 118 | //this is a new record from a linked item |
|---|
| 119 | // so we need to generate the controls that |
|---|
| 120 | // allow creating a new, or linking an existing. |
|---|
| 121 | |
|---|
| 122 | $showNewChoice = true; |
|---|
| 123 | |
|---|
| 124 | $therecord["tabledefid"] = mysql_real_escape_string($_GET["tabledefid"]); |
|---|
| 125 | $querystatement = " |
|---|
| 126 | SELECT |
|---|
| 127 | `maintable` |
|---|
| 128 | FROM |
|---|
| 129 | `tabledefs` |
|---|
| 130 | WHERE |
|---|
| 131 | `uuid` = '".$therecord["tabledefid"]."' |
|---|
| 132 | "; |
|---|
| 133 | $queryresult = $thetable->db->query($querystatement); |
|---|
| 134 | if($thetable->db->numRows($queryresult)){ |
|---|
| 135 | $record = $thetable->db->fetchArray($queryresult); |
|---|
| 136 | $maintable = $record["maintable"]; |
|---|
| 137 | |
|---|
| 138 | $querystatement = " |
|---|
| 139 | SELECT |
|---|
| 140 | `uuid` |
|---|
| 141 | FROM |
|---|
| 142 | `".$maintable."` |
|---|
| 143 | WHERE |
|---|
| 144 | `id`='".(int)$_GET["refid"]."' |
|---|
| 145 | "; |
|---|
| 146 | |
|---|
| 147 | $queryresult = $thetable->db->query($querystatement); |
|---|
| 148 | |
|---|
| 149 | if($thetable->db->numRows($queryresult)){ |
|---|
| 150 | $brecord = $thetable->db->fetchArray($queryresult); |
|---|
| 151 | $therecord["recordid"] = mysql_real_escape_string($brecord["uuid"]); |
|---|
| 152 | |
|---|
| 153 | }else{ |
|---|
| 154 | $therecord["recordid"] = mysql_real_escape_string($_GET["refid"]); |
|---|
| 155 | }//endif |
|---|
| 156 | |
|---|
| 157 | }else{ |
|---|
| 158 | $therecord["recordid"] = mysql_real_escape_string($_GET["refid"]); |
|---|
| 159 | }//end if |
|---|
| 160 | |
|---|
| 161 | switch($therecord["tabledefid"]){ |
|---|
| 162 | //diferent tables will need different views |
|---|
| 163 | //and displays (will eventurally need one for vendors) |
|---|
| 164 | |
|---|
| 165 | case "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083": //clients |
|---|
| 166 | default: |
|---|
| 167 | $smartSearch = "Pick Existing Client Address"; |
|---|
| 168 | break; |
|---|
| 169 | |
|---|
| 170 | }//endswitch tabledefid |
|---|
| 171 | |
|---|
| 172 | $theinput = new inputSmartSearch($db, "existingaddressid", $smartSearch, "", "existing address", false, 71); |
|---|
| 173 | $theform->addField($theinput); |
|---|
| 174 | |
|---|
| 175 | }//endif - addressid |
|---|
| 176 | |
|---|
| 177 | $theinput = new inputDataTableList($db, "table", $therecord["tabledefid"], |
|---|
| 178 | "tabledefs", "uuid", "displayname", |
|---|
| 179 | "", "", false, "table"); |
|---|
| 180 | $theinput->setAttribute("disabled","disabled"); |
|---|
| 181 | $theinput->setAttribute("class","uneditable"); |
|---|
| 182 | $theform->addField($theinput); |
|---|
| 183 | |
|---|
| 184 | $theinput = new inputField("recordid",$therecord["recordid"],"record",false,NULL); |
|---|
| 185 | $theinput->setAttribute("readonly","readonly"); |
|---|
| 186 | $theinput->setAttribute("class","uneditable"); |
|---|
| 187 | $theform->addField($theinput); |
|---|
| 188 | |
|---|
| 189 | $theinput = new inputCheckbox("primary",$therecord["primary"]); |
|---|
| 190 | $theinput->setAttribute("disabled","disabled"); |
|---|
| 191 | $theform->addField($theinput); |
|---|
| 192 | |
|---|
| 193 | $theinput = new inputCheckbox("defaultshipto",$therecord["defaultshipto"],"default ship to"); |
|---|
| 194 | $theinput->setAttribute("disabled","disabled"); |
|---|
| 195 | $theform->addField($theinput); |
|---|
| 196 | |
|---|
| 197 | }//endif - tabledefid |
|---|
| 198 | |
|---|
| 199 | $thetable->getCustomFieldInfo(); |
|---|
| 200 | $theform->prepCustomFields($db, $thetable->customFieldsQueryResult, $therecord); |
|---|
| 201 | $theform->jsMerge(); |
|---|
| 202 | //============================================================== |
|---|
| 203 | //End Form Elements |
|---|
| 204 | |
|---|
| 205 | include("header.php"); |
|---|
| 206 | |
|---|
| 207 | ?><div class="bodyline"> |
|---|
| 208 | <?php $theform->startForm($pageTitle)?> |
|---|
| 209 | |
|---|
| 210 | <div id="rightSideDiv"> |
|---|
| 211 | <fieldset> |
|---|
| 212 | <legend>Attributes</legend> |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | <?php if(isset($therecord["addressid"])) {?> |
|---|
| 216 | |
|---|
| 217 | <p> |
|---|
| 218 | <input type="hidden" name="addressid" id="addressid" value="<?php echo $therecord["addressid"]?>" /> |
|---|
| 219 | <input type="hidden" name="tabledefid" id="tabledefid" value="<?php echo $therecord["tabledefid"]?>" /> |
|---|
| 220 | <?php $theform->showField("table")?> |
|---|
| 221 | </p> |
|---|
| 222 | |
|---|
| 223 | <p> |
|---|
| 224 | <?php $theform->showField("recordid")?> |
|---|
| 225 | </p> |
|---|
| 226 | |
|---|
| 227 | <?php }//endif - addressid ?> |
|---|
| 228 | |
|---|
| 229 | <?php if(isset($_GET["id"])){ ?> |
|---|
| 230 | <input type="hidden" name="getid" id="getid" value="<?php echo((int)$_GET["id"]); ?>" /> |
|---|
| 231 | <?php }//end if ?> |
|---|
| 232 | |
|---|
| 233 | </fieldset> |
|---|
| 234 | |
|---|
| 235 | <?php if(isset($therecord["addressid"])) {?> |
|---|
| 236 | |
|---|
| 237 | <fieldset> |
|---|
| 238 | <legend>record defaults</legend> |
|---|
| 239 | |
|---|
| 240 | <p> |
|---|
| 241 | <?php $theform->showField("primary")?> |
|---|
| 242 | </p> |
|---|
| 243 | |
|---|
| 244 | <p> |
|---|
| 245 | <?php $theform->showField("defaultshipto")?> |
|---|
| 246 | </p> |
|---|
| 247 | |
|---|
| 248 | <p class="notes"> |
|---|
| 249 | Set address defaults for record on address list screen. |
|---|
| 250 | </p> |
|---|
| 251 | |
|---|
| 252 | </fieldset> |
|---|
| 253 | |
|---|
| 254 | <?php }//endif - addressid ?> |
|---|
| 255 | </div> |
|---|
| 256 | |
|---|
| 257 | <div class="leftSideDiv" id="chooseNew"> |
|---|
| 258 | |
|---|
| 259 | <?php if($showNewChoice) { ?> |
|---|
| 260 | |
|---|
| 261 | <fieldset> |
|---|
| 262 | <legend>add address</legend> |
|---|
| 263 | |
|---|
| 264 | <p> |
|---|
| 265 | <input type="radio" name="chooseNew" class="radiochecks" checked="checked" id="newAddressRadio" value="create"/><label for="newAddressRadio">create new address</label> |
|---|
| 266 | <input type="radio" name="chooseNew" class="radiochecks" id="linkExistingRadio" value="link"/><label for="linkExistingRadio">link existing address</label> |
|---|
| 267 | </p> |
|---|
| 268 | |
|---|
| 269 | <div id="selectExistingP" class="fauxp"> |
|---|
| 270 | <?php $theform->showField("existingaddressid")?> |
|---|
| 271 | </div> |
|---|
| 272 | |
|---|
| 273 | </fieldset> |
|---|
| 274 | |
|---|
| 275 | <?php }//endif - showNewChoice ?> |
|---|
| 276 | |
|---|
| 277 | </div> |
|---|
| 278 | |
|---|
| 279 | <div class="leftSideDiv" id="newAddressDiv"> |
|---|
| 280 | |
|---|
| 281 | <fieldset> |
|---|
| 282 | <legend>address <button type="button" class="graphicButtons buttonMap" id="buttonMap" title="show map"><span>map</span></button></legend> |
|---|
| 283 | |
|---|
| 284 | <p class="big"><?php $theform->showField("title")?></p> |
|---|
| 285 | |
|---|
| 286 | <p> |
|---|
| 287 | <?php $theform->showField("address1")?><br /> |
|---|
| 288 | <?php $theform->showField("address2")?> |
|---|
| 289 | </p> |
|---|
| 290 | |
|---|
| 291 | <p class="csz"> |
|---|
| 292 | <?php $theform->showField("city")?> |
|---|
| 293 | </p> |
|---|
| 294 | |
|---|
| 295 | <p class="csz"> |
|---|
| 296 | <?php $theform->showField("state")?> |
|---|
| 297 | </p> |
|---|
| 298 | <p> |
|---|
| 299 | <?php $theform->showField("postalcode")?> |
|---|
| 300 | </p> |
|---|
| 301 | <p> |
|---|
| 302 | <?php $theform->showField("country")?> |
|---|
| 303 | </p> |
|---|
| 304 | |
|---|
| 305 | </fieldset> |
|---|
| 306 | |
|---|
| 307 | <fieldset> |
|---|
| 308 | <legend>additional information</legend> |
|---|
| 309 | |
|---|
| 310 | <p><?php $theform->showField("shiptoname")?></p> |
|---|
| 311 | |
|---|
| 312 | <p><?php $theform->showField("phone")?></p> |
|---|
| 313 | |
|---|
| 314 | <p><?php $theform->showField("email")?></p> |
|---|
| 315 | |
|---|
| 316 | </fieldset> |
|---|
| 317 | |
|---|
| 318 | <fieldset> |
|---|
| 319 | <legend><label for="notes">notes</label></legend> |
|---|
| 320 | |
|---|
| 321 | <p><?php $theform->showField("notes")?></p> |
|---|
| 322 | |
|---|
| 323 | </fieldset> |
|---|
| 324 | |
|---|
| 325 | <?php if($therecord["id"]) {?> |
|---|
| 326 | <fieldset> |
|---|
| 327 | <legend>Associations</legend> |
|---|
| 328 | |
|---|
| 329 | <div class="fauxP"> |
|---|
| 330 | <?php |
|---|
| 331 | $addressid = $therecord["addressid"]; |
|---|
| 332 | if(isset($therecord["addressuuid"])) |
|---|
| 333 | $addressid = $therecord["addressuuid"]; |
|---|
| 334 | $thetable->showAssociations($addressid); |
|---|
| 335 | ?> |
|---|
| 336 | </div> |
|---|
| 337 | </fieldset> |
|---|
| 338 | <?php } //endif record if?> |
|---|
| 339 | |
|---|
| 340 | <?php $theform->showCustomFields($db, $thetable->customFieldsQueryResult) ?> |
|---|
| 341 | </div> |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | <?php |
|---|
| 345 | $theform->showGeneralInfo($phpbms,$therecord); |
|---|
| 346 | $theform->endForm(); |
|---|
| 347 | ?> |
|---|
| 348 | </div> |
|---|
| 349 | <?php include("footer.php");?> |
|---|