| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | $Rev: 258 $ | $LastChangedBy: brieb $ |
|---|
| 4 | $LastChangedDate: 2007-08-08 21:59:28 -0600 (Wed, 08 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 | |
|---|
| 44 | //if you need to ovveride the phpbmsTable class make sure to include the modules file |
|---|
| 45 | include("modules/[modulename]/include/[tablename].php"); |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | //If the addedit page will be accessd directly from a page other than the |
|---|
| 49 | // basic search results page, you may want to grab and pass the previous URL |
|---|
| 50 | //with the following code |
|---|
| 51 | |
|---|
| 52 | //=================================================== |
|---|
| 53 | if(!isset($_GET["backurl"])) |
|---|
| 54 | $backurl = NULL; |
|---|
| 55 | else{ |
|---|
| 56 | $backurl = $_GET["backurl"]; |
|---|
| 57 | if(isset($_GET["refid"])) |
|---|
| 58 | $backurl .= "?refid=".$_GET["refid"]; |
|---|
| 59 | } |
|---|
| 60 | //=================================================== |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | //Here you invoke the table class. If you are going to use the standard phpbmsTable class |
|---|
| 64 | // for updates and the such you would access it like this |
|---|
| 65 | |
|---|
| 66 | // $thetable = new phpbmsTable($db,[table definition id]); |
|---|
| 67 | |
|---|
| 68 | // if you are going to overide the class you would instantiate |
|---|
| 69 | // your overriden class like this |
|---|
| 70 | |
|---|
| 71 | // $thetable = new [tablename]($db,[table definition id]); |
|---|
| 72 | |
|---|
| 73 | //and if you are setting the backurl, make sure you pass that as well |
|---|
| 74 | // like this: |
|---|
| 75 | // $thetable = new [tablename]($db,[table definition id],$backurl); |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | // Next we process the form (if submitted) and |
|---|
| 79 | // return the current record as an array ($therecord) |
|---|
| 80 | // or if this is a new record, it returns the defaults |
|---|
| 81 | $therecord = $thetable->processAddEditPage(); |
|---|
| 82 | |
|---|
| 83 | //make sure that we set the status message id the processing returned one |
|---|
| 84 | // (e.g. "Record Updated") |
|---|
| 85 | if(isset($therecord["phpbmsStatus"])) |
|---|
| 86 | $statusmessage = $therecord["phpbmsStatus"]; |
|---|
| 87 | |
|---|
| 88 | $pageTitle = "[tablename]"; |
|---|
| 89 | |
|---|
| 90 | // Next, we set up to include any |
|---|
| 91 | // additional css or javascript files we will be using |
|---|
| 92 | // This does nto include any field-type specific js (like datepicker) |
|---|
| 93 | // as they are automatically icluded when you define the special fields you |
|---|
| 94 | // will be using below. |
|---|
| 95 | $phpbms->cssIncludes[] = "pages/[modulename]/[tablename].css"; |
|---|
| 96 | $phpbms->jsIncludes[] = "modules/[modulename]/javascript/[tablename].js"; |
|---|
| 97 | |
|---|
| 98 | // DEPRECIATED: |
|---|
| 99 | // if you need to define a body onlload function, do so with the phpbms property |
|---|
| 100 | $phpbms->onload[] = "initializePage()"; |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | // Next we need to define any special fields that will be used in the form |
|---|
| 104 | // A list of field objects (with documentation)is available in the /include/fields.php |
|---|
| 105 | // file. |
|---|
| 106 | |
|---|
| 107 | // We need to define them here in the head |
|---|
| 108 | // so that any necessay javascript is loaded appropriately. |
|---|
| 109 | |
|---|
| 110 | //Form Elements |
|---|
| 111 | //============================================================== |
|---|
| 112 | |
|---|
| 113 | // Create the form |
|---|
| 114 | $theform = new phpbmsForm(); |
|---|
| 115 | //if you need to set specific form vaiables (like enctype, or extra onsubmit |
|---|
| 116 | // you can set those form properties here. |
|---|
| 117 | |
|---|
| 118 | // for each field we will use, create the field object and add it to |
|---|
| 119 | // the forms list. |
|---|
| 120 | $theinput = new inputDatePicker("orderdate", $therecord["orderdate"], "order date"); |
|---|
| 121 | $theform->addField($theinput); |
|---|
| 122 | |
|---|
| 123 | $theinput = new inputCheckBox("weborder",$therecord["weborder"],NULL, false, false); |
|---|
| 124 | $theform->addField($theinput); |
|---|
| 125 | |
|---|
| 126 | $theinput = new inputField("accountnumber",$therecord["accountnumber"], "account number" ,false, "integer", 20, 64); |
|---|
| 127 | $theform->addField($theinput); |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | // if you neeed to add additional attributes toa field, it's easy. |
|---|
| 131 | $theinput = new inputBasicList("type",$therecord["type"],array("Quote"=>"Quote","Order"=>"Order","Invoice"=>"Invoice","VOID"=>"VOID"), $displayName = NULL, $displayLabel = true); |
|---|
| 132 | $theinput->setAttribute("onchange","checkType(this)"); |
|---|
| 133 | $theinput->setAttribute("class","important"); |
|---|
| 134 | $theform->addField($theinput); |
|---|
| 135 | |
|---|
| 136 | //If you have setup your table with the phpBMS custom fields structure |
|---|
| 137 | //make sure to prep the custom fields here. |
|---|
| 138 | $thetable->getCustomFieldInfo(); |
|---|
| 139 | $theform->prepCustomFields($db, $thetable->customFieldsQueryResult, $therecord); |
|---|
| 140 | // lastly, use the jsMerge method to create the final Javascript formatting |
|---|
| 141 | $theform->jsMerge(); |
|---|
| 142 | //============================================================== |
|---|
| 143 | //End Form Elements |
|---|
| 144 | |
|---|
| 145 | include("header.php"); |
|---|
| 146 | |
|---|
| 147 | ?><div class="bodyline"> |
|---|
| 148 | <!-- |
|---|
| 149 | Next we start the form. This also prints the H1 with title, and top save,cancel buttons |
|---|
| 150 | If you need to have other buttons, or need a specific top, you will need to create your form manually. |
|---|
| 151 | --> |
|---|
| 152 | <?php $theform->startForm($pageTitle)?> |
|---|
| 153 | |
|---|
| 154 | <fieldset id="fsAttributes"> |
|---|
| 155 | <legend>attributes</legend> |
|---|
| 156 | <p> |
|---|
| 157 | <label for="id">id</label><br /> |
|---|
| 158 | <input name="id" id="id" type="text" value="<?php echo $therecord["id"]; ?>" size="5" maxlength="5" readonly="readonly" class="uneditable" /> |
|---|
| 159 | </p> |
|---|
| 160 | <p><?php $theform->showField("inactive");?></p> |
|---|
| 161 | </fieldset> |
|---|
| 162 | |
|---|
| 163 | <div id="nameDiv"> |
|---|
| 164 | <fieldset > |
|---|
| 165 | <legend>name / percentage</legend> |
|---|
| 166 | |
|---|
| 167 | <p><?php $theform->showField("name"); ?></p> |
|---|
| 168 | |
|---|
| 169 | <p><?php $theform->showField("percentage"); ?></p> |
|---|
| 170 | |
|---|
| 171 | </fieldset> |
|---|
| 172 | |
|---|
| 173 | <?php |
|---|
| 174 | // if you are using the phpBMS custom fields format, make sure to |
|---|
| 175 | // put this in to display administratively set custom fields. |
|---|
| 176 | // If you are not, leaving this in will not affect your form |
|---|
| 177 | $theform->showCustomFields($db, $thetable->customFieldsQueryResult) |
|---|
| 178 | ?> |
|---|
| 179 | |
|---|
| 180 | </div> |
|---|
| 181 | <?php |
|---|
| 182 | //Last, we show the create/modifiy with the bottom save and cancel buttons |
|---|
| 183 | // and then close the form. |
|---|
| 184 | $theform->showGeneralInfo($phpbms,$therecord); |
|---|
| 185 | $theform->endForm(); |
|---|
| 186 | ?> |
|---|
| 187 | </div> |
|---|
| 188 | <?php include("footer.php");?> |
|---|