phpBMS

Show
Ignore:
Timestamp:
04/07/09 11:44:18 (3 years ago)
Author:
nate
Message:
  • Merged Nathan branch back into trunk.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/base/general_import.php

    r432 r485  
    1 <?php  
     1<?php 
    22/* 
    33 $Rev: 258 $ | $LastChangedBy: brieb $ 
     
    4343        include("include/imports.php"); 
    4444        include("include/parsecsv.lib.php"); 
    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 
    8882        // return the current record as an array ($therecord) 
    8983        // or if this is a new record, it returns the defaults 
     
    9690 
    9791        $pageTitle = ($therecord["title"])?$therecord["title"]:"General Table Import"; 
    98          
     92 
    9993        // Next, we set up to include any 
    10094        // additional css or javascript files we will be using 
     
    106100 
    107101        // if you need to define a body onlload function, do so with the phpbms property 
    108          
     102 
    109103        //              $phpbms->onload[] = "initializePage()"; 
    110104 
     
    112106        // Next we need to define any special fields that will be used in the form 
    113107        // A list of field objects (with documentation)is available in the /include/fields.php 
    114         // file.   
    115          
     108        // file. 
     109 
    116110        // We need to define them here in the head 
    117111        // so that any necessay javascript is loaded appropriately. 
    118          
     112 
    119113                //Form Elements 
    120114                //============================================================== 
    121                  
     115 
    122116                // Create the form 
    123117                $theform = new importForm(); 
     
    125119                //if you need to set specific form vaiables (like enctype, or extra onsubmit 
    126120                // you can set those form properties here. 
    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 
    145122 
    146123                // lastly, use the jsMerge method to create the final Javascript formatting 
    147124                $theform->jsMerge(); 
    148125                //============================================================== 
    149                 //End Form Elements      
    150  
    151         include("header.php");   
    152          
     126                //End Form Elements 
     127 
     128        include("header.php"); 
     129 
    153130?><div class="bodyline"> 
    154         <!--  
     131        <!-- 
    155132                Next we start the form.  This also prints the H1 with title, and top save,cancel buttons 
    156133                If you need to have other buttons, or need a specific top, you will need to create your form manually. 
    157134        --> 
    158         <?php $theform->startForm($pageTitle, $import->pageType)?> 
     135        <?php $theform->startForm($pageTitle, $import->pageType, count($import->transactionRecords))?> 
    159136 
    160137        <div id="leftSideDiv"> 
     
    164141                <!-- /* This next input also determines whether the file/import fieldset will be displayed or if the preview sections will be displayed*/ --> 
    165142                <input id="pageType" name="pageType" type="hidden" value="<?php echo $import->pageType?>" /> 
    166                  
     143 
    167144                <?php 
    168145                if($import->pageType == "main"){ ?> 
     
    175152                                        <input id="import" name="import" type="file" size="64"/><br/> 
    176153                                </p> 
    177                                  
     154 
    178155                                <div id="info0" class="info"> 
    179156                                        <p> 
     
    201178                <?php 
    202179                }//end if 
    203                  
     180 
    204181                if($import->error && $import->pageType != "main"){ 
    205182                        ?> 
     
    216193        </div> 
    217194        <div id="createmodifiedby" > 
    218         <?php    
     195        <?php 
    219196                //Last, we show the create/modifiy with the bottom save and cancel buttons 
    220197                // and then close the form. 
    221                 $theform->showButtons(2, $import->pageType); 
     198                $theform->showButtons(2, $import->pageType, count($import->transactionRecords)); 
    222199                ?></div><?php 
    223200                $theform->endForm(); 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.