phpBMS

root/trunk/phpbms/modules/base/general_import.php

Revision 703, 7.6 KB (checked in by brieb, 2 years ago)
  • Rearranged payment processing routine to be more flexible. It now needs to save the sales order first
  • Added payment processing template so developers have a guide when putting together their payment scripts
  • It seems their might be some unintentional touching of other files in this commit;
Line 
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        include("include/imports.php");
44        include("include/parsecsv.lib.php");
45
46    if(!isset($_GET["id"]))
47        exit;
48
49        if(!isset($_GET["backurl"]))
50                $backurl = NULL;
51        else{
52                $backurl = $_GET["backurl"];
53                if(isset($_GET["refid"]))
54                        $backurl .= "?refid=".$_GET["refid"];
55        }
56
57        $tabledefid = mysql_real_escape_string($_GET["id"]);
58
59        $querystatement = "
60            SELECT
61            `modules`.`name` AS `modulename`,
62            `tabledefs`.`maintable` AS `maintable`
63            FROM
64            `tabledefs` INNER JOIN `modules` ON `tabledefs`.`moduleid` = `modules`.`uuid`
65            WHERE
66            `tabledefs`.`uuid` = '".$tabledefid."'";
67
68        $queryresult = $db->query($querystatement);
69
70        $thereturn = $db->fetchArray($queryresult);
71
72        //try to include table specific functions
73        $tableFile = "../".$thereturn["modulename"]."/include/".$thereturn["maintable"].".php";
74
75        if(file_exists($tableFile))
76            include_once($tableFile);
77
78        //next, see if the table class exists
79        if(class_exists($thereturn["maintable"])){
80
81            $classname = $thereturn["maintable"];
82            $thetable = new $classname($db,$tabledefid, $backurl);
83
84        } else
85            $thetable = new phpbmsTable($db,$tabledefid, $backurl);
86
87        //finally, check to see if import class exists
88        if(class_exists($thereturn["maintable"]."Import")){
89
90            $classname = $thereturn["maintable"]."Import";
91            $import = new $classname($thetable);
92
93        } else
94                $import = new phpbmsImport($thetable);
95
96        //Next we process the form (if submitted) and
97        // return the current record as an array ($therecord)
98        // or if this is a new record, it returns the defaults
99        $therecord = $import->processImportPage();
100
101        //make sure that we set the status message id the processing returned one
102        // (e.g. "Record Updated")
103        if(isset($therecord["phpbmsStatus"]))
104            $statusmessage = $therecord["phpbmsStatus"];
105
106        $pageTitle = ($therecord["title"])?$therecord["title"]:"General Table Import";
107
108        $phpbms->cssIncludes[] = "pages/imports.css";
109
110
111                //Form Elements
112                //==============================================================
113
114                // Create the form
115                $theform = new importForm();
116                $theform->enctype = "multipart/form-data";
117
118                // lastly, use the jsMerge method to create the final Javascript formatting
119                $theform->jsMerge();
120                //==============================================================
121                //End Form Elements
122
123        include("header.php");
124
125?><div class="bodyline">
126        <!--
127                Next we start the form.  This also prints the H1 with title, and top save,cancel buttons
128                If you need to have other buttons, or need a specific top, you will need to create your form manually.
129        -->
130        <?php $theform->startForm($pageTitle, $import->pageType, count($import->transactionRecords))?>
131
132        <div id="leftSideDiv">
133                <!-- /* This next input is to store the temporary mysql table used for the confirmation insert */ -->
134                <input id="tempFileID" name="tempFileID" type="hidden" value="<?php echo $import->tempFileID?>" />
135                <!-- /* This next input is to determine the action of the cancel button (i.e. whether to redirect to backurl or not)*/ -->
136                <!-- /* This next input also determines whether the file/import fieldset will be displayed or if the preview sections will be displayed*/ -->
137                <input id="pageType" name="pageType" type="hidden" value="<?php echo $import->pageType?>" />
138
139                <?php
140                if($import->pageType == "main"){ ?>
141                <fieldset >
142                        <legend>import</legend>
143
144                        <div id="uploadlabel">
145                                <p>
146                                        <label for="import">file</label><br />
147                                        <input id="import" name="import" type="file" size="64"/><br/>
148                                </p>
149
150
151                                <div id="info0" class="info">
152                                        <p>
153                                                For any file that is a comma seperated value (csv) file:
154                                        </p>
155                                        <p>
156                                                Delimiters are commas (,) and enclosures are double-quotes (").  If you
157                                                wish to escape a double-quote character inside of an enclosure, add another
158                                                double-quote character (e.g ...,"Benny ""The Jet"" Rodriguez",...), or with
159                                                a backslash character (\) (e.g ...,"Benny \"The Jet\" Rodriguez",...).
160                                        </p>
161                                        <p>
162                                                The first row of your csv file should be the field-names of the table(s)
163                                                that you wish to import to.  Additional lines will be the actual data
164                                                that will be imported.
165                                        </p>
166                                        <p>
167                                                When entering in currency, dates, or times use the format in the bms's configuration
168                                                (e.g. use English, US style dates if that is what the bms is configured to).
169                                        </p>
170
171                                </div>
172                        </div>
173
174                </fieldset>
175                <?php
176                }//end if
177
178                if($import->error && $import->pageType != "main"){
179                        ?>
180                        <h2>Import Errors</h2>
181                        <div id="importError">
182                                <ul>
183                                <?php echo $import->error ?>
184                                </ul>
185                        </div>
186                        <?php
187                }//end if
188                $import->displayTransaction($import->transactionRecords,$import->table->fields);
189        ?>
190        </div>
191        <div id="createmodifiedby" >
192        <?php
193                //Last, we show the create/modifiy with the bottom save and cancel buttons
194                // and then close the form.
195                $theform->showButtons(2, $import->pageType, count($import->transactionRecords));
196                ?></div><?php
197                $theform->endForm();
198        ?>
199</div>
200<?php include("footer.php");?>
Note: See TracBrowser for help on using the browser.
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.