From ee2375daf671616638048fdfa500aee1e5f799f1 Mon Sep 17 00:00:00 2001 From: starthomas610 Date: Wed, 12 Jun 2024 14:29:07 -0400 Subject: [PATCH] commit basic milestone1 source --- public/composer.json | 5 + public/composer.lock | 522 +++++++++++++++++ public/userarea/assets/js/common_helper.js | 11 + public/userarea/importify/columnlink.php | 540 ++++++++++++++++++ .../importify/get_columnlist_from_csv.php | 17 + .../importify/save_associate_template.php | 83 +++ .../userarea/importify/save_column_link.php | 32 ++ 7 files changed, 1210 insertions(+) create mode 100644 public/composer.json create mode 100644 public/composer.lock create mode 100644 public/userarea/assets/js/common_helper.js create mode 100644 public/userarea/importify/columnlink.php create mode 100644 public/userarea/importify/get_columnlist_from_csv.php create mode 100644 public/userarea/importify/save_associate_template.php create mode 100644 public/userarea/importify/save_column_link.php diff --git a/public/composer.json b/public/composer.json new file mode 100644 index 0000000..5216da8 --- /dev/null +++ b/public/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "phpoffice/phpspreadsheet": "^2.1" + } +} diff --git a/public/composer.lock b/public/composer.lock new file mode 100644 index 0000000..ea3a886 --- /dev/null +++ b/public/composer.lock @@ -0,0 +1,522 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b8fc76d4d2fd9a7199969838cb86a710", + "packages": [ + { + "name": "maennchen/zipstream-php", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "b8174494eda667f7d13876b4a7bfef0f62a7c0d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/b8174494eda667f7d13876b4a7bfef0f62a7c0d1", + "reference": "b8174494eda667f7d13876b4a7bfef0f62a7c0d1", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-zlib": "*", + "php-64bit": "^8.1" + }, + "require-dev": { + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.16", + "guzzlehttp/guzzle": "^7.5", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.5", + "phpunit/phpunit": "^10.0", + "vimeo/psalm": "^5.0" + }, + "suggest": { + "guzzlehttp/psr7": "^2.4", + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.0" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + }, + { + "url": "https://opencollective.com/zipstream", + "type": "open_collective" + } + ], + "time": "2023-06-21T14:59:35+00:00" + }, + { + "name": "markbaker/complex", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2" + }, + "time": "2022-12-06T16:21:08+00:00" + }, + { + "name": "markbaker/matrix", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1" + }, + "time": "2022-12-02T22:17:43+00:00" + }, + { + "name": "phpoffice/phpspreadsheet", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "dbed77bd3a0f68f96c0dd68ad4499d5674fecc3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/dbed77bd3a0f68f96c0dd68ad4499d5674fecc3e", + "reference": "dbed77bd3a0f68f96c0dd68ad4499d5674fecc3e", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "maennchen/zipstream-php": "^2.1 || ^3.0", + "markbaker/complex": "^3.0", + "markbaker/matrix": "^3.0", + "php": "^8.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "dompdf/dompdf": "^2.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.1.0" + }, + "time": "2024-05-11T04:17:56+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/public/userarea/assets/js/common_helper.js b/public/userarea/assets/js/common_helper.js new file mode 100644 index 0000000..fcaf234 --- /dev/null +++ b/public/userarea/assets/js/common_helper.js @@ -0,0 +1,11 @@ +function getLowerAndCombile(str) { + return str.toLowerCase().replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '_'); +} + +function getWithoutSpaceStr(str) { + return str.split(/[ ,]+/).join(''); +} + +function showWarningAlert(str) { + alertify.logPosition("top right").error(" " + str + ""); +} diff --git a/public/userarea/importify/columnlink.php b/public/userarea/importify/columnlink.php new file mode 100644 index 0000000..6967b48 --- /dev/null +++ b/public/userarea/importify/columnlink.php @@ -0,0 +1,540 @@ + + +setQuery("SELECT * FROM templatetable"); + $arr_template->execute(); + + //get exist data from template_associate + $arr_exist_info = new WA_MySQLi_RS("rsl", $repnew, 0); + $arr_exist_info->setQuery("SELECT * FROM template_associate where template_importify_id=$edit_id"); + $arr_exist_info->execute(); + + $arr_csv_column_name = array(); + if(count($arr_exist_info->Results) > 0) { + $arr_csv_column_name = json_decode($arr_exist_info->Results[0]['arr_csv_columns']); + } + + $arr_old_table_name = array(); + $arr_old_column_name = array(); + $arr_old_headerfile = array(); + $arr_old_db_headerfile = array(); + foreach($arr_exist_info->Results as $item) { + array_push($arr_old_table_name, $item['table_name']); + array_push($arr_old_column_name, $item['column_name']); + array_push($arr_old_headerfile, $item['headerfile']); + array_push($arr_old_db_headerfile, $item['db_headerfile']); + } +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ +
+
+
+
+
+ + +
+ + + + + +
+ +
+ + + +
+ +
+ +
+
+
+
+ +
+

Importify

+
+
+
+ + +
+
+
+
+
Importify: Associate Columns
+
+
+ + +
+
+

+ +
+
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ + +
+ atEnd()) { + ?> +
+ + +
+ moveNext(); + } + ?> +
+
+
+ +
+
+ + + + + + + + + + + +
+
+
+ +
+
+    + + +
+
+
+
+
+
+
+ + + +
+ +
+ +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/userarea/importify/get_columnlist_from_csv.php b/public/userarea/importify/get_columnlist_from_csv.php new file mode 100644 index 0000000..f5b90d8 --- /dev/null +++ b/public/userarea/importify/get_columnlist_from_csv.php @@ -0,0 +1,17 @@ +getActiveSheet(); + $arr_info = $worksheet->toArray(); + if(count($arr_info) > 0) { + die(json_encode($arr_info[0])); + } else { + die(json_encode(array())); + } +} else { + die("file_empty_error"); +} diff --git a/public/userarea/importify/save_associate_template.php b/public/userarea/importify/save_associate_template.php new file mode 100644 index 0000000..478c77e --- /dev/null +++ b/public/userarea/importify/save_associate_template.php @@ -0,0 +1,83 @@ + + +getActiveSheet(); + $arr_info = $worksheet->toArray(); + + if(count($arr_info) > 1) { + + //insert template header and description + for($i=0; $iAction = "insert"; + $InsertQuery->Table = "`templatetable`"; + $InsertQuery->bindColumn("tablename", "s", "". $tbl_name, "WA_DEFAULT"); + $InsertQuery->bindColumn("columntable", "s", "".$tbl_name."_". $arr_val[$i], "WA_DEFAULT"); + $InsertQuery->bindColumn("headerfile", "s", "".$arr_description[$i], "WA_DEFAULT"); + $InsertQuery->saveInSession(""); + $InsertQuery->execute(); + } + + //create table + $sql_create_tbl = "CREATE TABLE ".$tbl_name."( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,"; + for($i=0; $iquery($sql_create_tbl) === TRUE) { + $arr_pos = array(); + for($i=0; $iAction = "insert"; + $InsertQuery->Table = "`".$tbl_name."`"; + for($k=0; $kbindColumn("".$arr_val[$k], "s", "". $arr_result_data[$i][$k], "WA_DEFAULT"); + } + $InsertQuery->saveInSession(""); + $InsertQuery->execute(); + } + + } else { + die("error"); + } + die("success"); + } else { + die("success1"); + } +} else { + die("file_empty_error"); +} diff --git a/public/userarea/importify/save_column_link.php b/public/userarea/importify/save_column_link.php new file mode 100644 index 0000000..c150044 --- /dev/null +++ b/public/userarea/importify/save_column_link.php @@ -0,0 +1,32 @@ + + +Action = "delete"; +$deleteQuery->Table = "`template_associate`"; + +$deleteQuery->addFilter("template_importify_id", "=", "i", "" . $template_id . ""); +$deleteQuery->execute(); + +for($i=0; $iAction = "insert"; + $InsertQuery->Table = "`template_associate`"; + $InsertQuery->bindColumn("template_importify_id", "i", $template_id, "WA_DEFAULT"); + $InsertQuery->bindColumn("arr_csv_columns", "s", "".$arr_csv, "WA_DEFAULT"); + $InsertQuery->bindColumn("table_name", "s", "".$arr_selected_tbl_name[$i], "WA_DEFAULT"); + $InsertQuery->bindColumn("column_name", "s", "".$arr_selected_tbl_title[$i], "WA_DEFAULT"); + $InsertQuery->bindColumn("headerfile", "s", "".$arr_selected_csv[$i], "WA_DEFAULT"); + $InsertQuery->bindColumn("db_headerfile", "s", "".$arr_db_headerfile[$i], "WA_DEFAULT"); + $InsertQuery->saveInSession(""); + $InsertQuery->execute(); +} +die("success"); +