| 45 | | |
| 46 | | //if you need to overide the phpbmsTable class make sure to include the modules file |
| 47 | | |
| 48 | | // include("modules/[modulename]/include/[tablename].php"); |
| 49 | | |
| 50 | | |
| 51 | | //If the addedit page will be accessd directly from a page other than the |
| 52 | | // basic search results page, you may want to grab and pass the previous URL |
| 53 | | //with the following code |
| 54 | | |
| 55 | | //=================================================== |
| 56 | | if(!isset($_GET["backurl"])) |
| 57 | | $backurl = NULL; |
| 58 | | else{ |
| 59 | | $backurl = $_GET["backurl"]; |
| 60 | | if(isset($_GET["refid"])) |
| 61 | | $backurl .= "?refid=".$_GET["refid"]; |
| 62 | | } |
| 63 | | //=================================================== |
| 64 | | |
| 65 | | if(isset($_GET["id"])) |
| 66 | | $tabledefid = ((int)$_GET["id"]); |
| 67 | | |
| 68 | | |
| 69 | | //Here you invoke the table and import classes. If you are going to use the standard phpbmsTable class |
| 70 | | // for updates and the such you would access it like this |
| 71 | | |
| 72 | | $thetable = new phpbmsTable($db,$tabledefid); |
| 73 | | $import = new phpbmsImport($thetable); |
| 74 | | |
| 75 | | //if you are going to overide the class you would instantiate |
| 76 | | // like this |
| 77 | | |
| 78 | | // $thetable = new [tablename]($db,[table definition id],$backurl); |
| 79 | | // $import = new [importname]($thetable); |
| 80 | | |
| 81 | | //and if you are setting the backurl, make sure you pass that as well |
| 82 | | // like this: |
| 83 | | |
| 84 | | // $thetable = new [tablename]($db,[table definition id],$backurl); |
| 85 | | |
| 86 | | |
| 87 | | //Next we process the form (if submitted) and |
| | 45 | |
| | 46 | |
| | 47 | $tabledefid = (int) $_GET["id"]; |
| | 48 | |
| | 49 | $querystatement = " |
| | 50 | SELECT |
| | 51 | `modules`.`name` AS `modulename`, |
| | 52 | `tabledefs`.`maintable` AS `maintable` |
| | 53 | FROM |
| | 54 | `tabledefs` INNER JOIN `modules` ON `tabledefs`.`moduleid` = `modules`.`id` |
| | 55 | WHERE |
| | 56 | `tabledefs`.`id` = '".$tabledefid."'; |
| | 57 | "; |
| | 58 | |
| | 59 | $queryresult = $db->query($querystatement); |
| | 60 | |
| | 61 | $thereturn = $db->fetchArray($queryresult); |
| | 62 | |
| | 63 | //try to include table specific functions |
| | 64 | if(file_exists("../".$thereturn["modulename"]."/include/".$thereturn["maintable"].".php")) |
| | 65 | include("../".$thereturn["modulename"]."/include/".$thereturn["maintable"].".php"); |
| | 66 | |
| | 67 | //next, see if the table class exists |
| | 68 | if(class_exists($thereturn["maintable"])){ |
| | 69 | $classname = $thereturn["maintable"]; |
| | 70 | $thetable = new $classname($db,$tabledefid); |
| | 71 | } else |
| | 72 | $thetable = new phpbmsTable($db,$tabledefid); |
| | 73 | |
| | 74 | //finally, check to see if import class exists |
| | 75 | if(class_exists($thereturn["maintable"]."Import")){ |
| | 76 | $classname = $thereturn["maintable"]."Import"; |
| | 77 | $import = new $classname($thetable); |
| | 78 | } else |
| | 79 | $import = new phpbmsImport($thetable); |
| | 80 | |
| | 81 | //Next we process the form (if submitted) and |
| 127 | | |
| 128 | | // for each field we will use, create the field object and add it to |
| 129 | | // the forms list. |
| 130 | | //$theinput = new inputDatePicker("orderdate", $therecord["orderdate"], "order date"); |
| 131 | | //$theform->addField($theinput); |
| 132 | | // |
| 133 | | //$theinput = new inputCheckBox("weborder",$therecord["weborder"],NULL, false, false); |
| 134 | | //$theform->addField($theinput); |
| 135 | | // |
| 136 | | //$theinput = new inputField("accountnumber",$therecord["accountnumber"], "account number" ,false, "integer", 20, 64); |
| 137 | | //$theform->addField($theinput); |
| 138 | | |
| 139 | | |
| 140 | | // if you neeed to add additional attributes toa field, it's easy. |
| 141 | | //$theinput = new inputBasicList("type",$therecord["type"],array("Quote"=>"Quote","Order"=>"Order","Invoice"=>"Invoice","VOID"=>"VOID"), $displayName = NULL, $displayLabel = true); |
| 142 | | //$theinput->setAttribute("onchange","checkType(this)"); |
| 143 | | //$theinput->setAttribute("class","important"); |
| 144 | | //$theform->addField($theinput); |
| | 121 | |