diff --git a/admin/import.php b/admin/import.php index 63e7ebd6..df3e8bd5 100644 --- a/admin/import.php +++ b/admin/import.php @@ -1,187 +1,155 @@ - - * @copyright Deakin University 2007,2008 - * @package queXS - * @subpackage admin - * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include ("../config.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Sample import functions - */ -include("../functions/functions.import.php"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/font-awesome-4.3.0/css/font-awesome.css", -"../css/bootstrap-switch.min.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -"../js/bootstrap-switch.min.js" - ); -$js_foot = array( -"../js/bootstrap-filestyle.min.js", -"../js/custom.js" - ); - -if (isset($_POST['import_form'])) -{ - //form has been submitted - $subtitle = T_("Validating and uploading"); - xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); - echo " " . T_("Go back") . ""; - - - //verify each GET field is unique (except import_form) - $sfields = array(); - foreach($_POST as $getv => $val) - //clean up? - $sfields[$getv] = $val; - - $error = verify_fields($sfields); - - $description = $_POST['description']; - - if ($error == "") - { //verified so upload - if (import_file($_POST['filename'],$description,$sfields)) - { - print "

" . T_("Successfully imported sample") . " 

$description

"; - } - else - { - print -"

" . T_("Error importing file. Please try again") . "

"; - } - } - else - print "

" . T_("Error:") . " $error

" . T_("Please go back in your browser and fix the problem") . "

"; - - //verifiy that exactly one primary phone number is selected - //upload to database - - xhtml_foot($js_foot); - -} -else if (isset($_POST['import_file'])) -{ - //file has been submitted - $subtitle = T_("Select columns to import"); - xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); - echo " " . T_("Go back") . ""; - - - print "
"; - - $tmpfname = tempnam(TEMPORARY_DIRECTORY, "FOO"); - move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname); - - display_table(get_first_row($tmpfname)); - - - - ?> -

- -
- -
- -
-
- -
- - - -  " . T_("Go back") . ""; - - $ua = $_SERVER['HTTP_USER_AGENT']; - if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; - //print "ua=" . $_SERVER['HTTP_USER_AGENT']; - ?> - -
-
- - - - -
- - -
- " type="file" accept="" /> -
-
- - -
- -
- " class="form-control input-md"> -
-
- - -
- -
- -
-
- -
-
- - + " . T_("Go back") . ""; + + + //verify each GET field is unique (except import_form) + $sfields = array(); + foreach($_POST as $getv => $val) + //clean up? + $sfields[$getv] = $val; + + $error = verify_fields($sfields); + + $description = $_POST['description']; + + if ($error == "") + { //verified so upload + if (import_file($_POST['filename'],$description,$sfields)) + { + print "

" . T_("Successfully imported sample") . " 

$description

"; + } + else + { + print -"

" . T_("Error importing file. Please try again") . "

"; + } + } + else + print "

" . T_("Error:") . " $error

" . T_("Please check imported file, go back in your browser and fix the problem") . "

"; + + //verifiy that exactly one primary phone number is selected + //upload to database + + xhtml_foot($js_foot); + +} +else if (isset($_POST['import_file'])) +{ + //file has been submitted + $subtitle = T_("Select columns to import"); + xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); + echo " " . T_("Go back") . ""; + + + print "
"; + + $tmpfname = tempnam(TEMPORARY_DIRECTORY, "FOO"); + move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname); + + display_table(get_first_row($tmpfname)); + + ?> + + +
+ +
+ +
+
+ +
+ + +  " . T_("Go back") . ""; + + $ua = $_SERVER['HTTP_USER_AGENT']; + if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; + //print "ua=" . $_SERVER['HTTP_USER_AGENT']; + ?> + +
+
+ + + + +
+ + +
+ " type="file" accept="" /> +
+
+ + +
+ +
+ " class="form-control input-md"> +
+
+ + +
+ +
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/functions/functions.import.php b/functions/functions.import.php index ee7f75d3..13295f0d 100644 --- a/functions/functions.import.php +++ b/functions/functions.import.php @@ -86,7 +86,7 @@ function verify_fields($fields) { if (array_key_exists($fields["n_$val"], $names)) { - return T_("Duplicate name"); + return T_("Duplicate column name") . ": " . $fields["n_$val"] . ""; } else { @@ -141,7 +141,7 @@ function display_table($data) if (empty($val)) $val = "samp_$row"; print "$value - + "; print ""; - print " "; + print ""; print ""; $row++; }