commit basic milestone1 source

This commit is contained in:
starthomas610 2024-06-12 14:29:07 -04:00
parent 241bf5ed36
commit ee2375daf6
7 changed files with 1210 additions and 0 deletions

5
public/composer.json Normal file
View File

@ -0,0 +1,5 @@
{
"require": {
"phpoffice/phpspreadsheet": "^2.1"
}
}

522
public/composer.lock generated Normal file
View File

@ -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"
}

View File

@ -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("<i class='ion-alert-circled'><i> " + str + "");
}

View File

@ -0,0 +1,540 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");?>
<?php
$edit_id = $_GET['idimporttemplates'] != null ? $_GET['idimporttemplates'] : 0;
if($edit_id == 0) {
die("");
}
//get arr column of templatetable
$arr_template = new WA_MySQLi_RS("rsl", $repnew, 0);
$arr_template->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']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<?php include('../include/seo.php'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" href="../assets/images/favicon.ico">
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="../assets/css/icons.css" rel="stylesheet" type="text/css">
<link href="../assets/css/style.css" rel="stylesheet" type="text/css">
<script src="../assets/js/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.css">
<style>
.v-center {
align-items: center;
}
.center {
text-align: center;
}
.table-custom tr {
height: 40px;
line-height: 40px;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
#ajax_preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 9999999;
}
.ipt_tbl_name {
width: 300px;
margin-left: 20px;
}
.flex {
display: flex;
}
.column_div {
height: 400px;
overflow: auto;
border: 1px solid #ced4da;
border-radius: .25rem;
padding: 10px;
width: 100%;
text-align: left;
}
.mg_none {
margin: 0 !important;
}
.mg_auto {
margin: auto;
}
.hidden {
display: none;
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<div id="ajax_preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<div class="content">
<?php include('../include/topbar.php'); ?>
<div class="page-content-wrapper ">
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="page-title-box">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">Importify</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Importify: Associate Columns</h5>
<div class="row">
<div class="col-md-12 flex">
<button onclick="onFileUpload()" class="btn btn-primary" role="button"><i class="fa far fa-file-excel"></i> Import File</button>
<input id="f_csv" type="file" name="f_csv" style="display: none" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv">
</div>
</div>
<br><br>
<div class="row v-center">
<div class="col-md-4 center">
<label>XLS Column</label>
<div id="div_rdo_csv" class="column_div">
<?php
for($i=0; $i<count($arr_csv_column_name); $i++) {
?>
<div class="custom-control custom-radio <?=in_array($arr_csv_column_name[$i], $arr_old_headerfile) ? 'hidden' : ''?>">
<input type="radio" id="rdo_csv<?=$i?>" value="<?=$arr_csv_column_name[$i]?>" name="rdo_csv" class="custom-control-input">
<label class="custom-control-label" for="rdo_csv<?=$i?>"><?=$arr_csv_column_name[$i]?></label>
</div>
<?php
}
?>
</div>
</div>
<div class="col-md-1">
<button onclick="onAddMapping()" type="button" class="btn btn-block"><i class="ion-checkmark-circled"></i> Add </button>
</div>
<div class="col-md-4 center">
<label>Table Column</label>
<div class="column_div">
<?php
while (!$arr_template->atEnd()) {
?>
<div class="custom-control custom-radio <?=in_array($arr_template->getColumnVal('columntable'), $arr_old_column_name) ? 'hidden' : ''?>">
<input type="radio" data-headerfile="<?=$arr_template->getColumnVal('headerfile')?>" data-table="<?=$arr_template->getColumnVal('tablename')?>" id="rdo_tbl<?=$arr_template->getColumnVal('idtemplatetable')?>" value="<?=$arr_template->getColumnVal('columntable')?>" name="rdo_tbl" class="custom-control-input">
<label class="custom-control-label" for="rdo_tbl<?=$arr_template->getColumnVal('idtemplatetable')?>"><?php echo $arr_template->getColumnVal("headerfile")?></label>
</div>
<?php
$arr_template->moveNext();
}
?>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-9 center">
<table class="mg_auto">
<tbody id="tbody_result">
<?php
for($i=0; $i<count($arr_old_headerfile); $i++) {
?>
<tr>
<td><?=$arr_old_headerfile[$i]?></td>
<td><i class="ion-arrow-right-c" style="width: 30px"></i></td>
<td><?=$arr_old_db_headerfile[$i]?></td>
<td><input class="hidden" value="<?=$arr_old_table_name[$i]?>"><input class="hidden" value="<?=$arr_old_column_name[$i]?>"><a onclick="onRemoveResult(this)" style="color: red; padding: 5px; cursor:pointer; font-size: 16px"><i class="ion-close-circled"></i></a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div class="row mt-4">
<div class="col-md-9 center">
<button type="button" onclick="goBack()" class="btn btn-dark waves-effect waves-light"><i class="fa fa-backward"></i> Back</button>&nbsp;&nbsp;
<button type="button" onclick="onSave()" class="btn btn-success waves-effect waves-light"><i class="fa fa-save"></i> Save</button>
<script>
function goBack() {
window.history.back();
}
</script>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
$('#ajax_preloader').fadeOut();
});
function onFileUpload() {
$('#f_csv').trigger("click");
}
$('#f_csv').change(function(){
let formdata = new FormData();
if($(this).prop('files').length > 0)
{
formdata.append("f_csv", $(this).prop('files')[0]);
}
$.ajax({
url: 'get_columnlist_from_csv.php',
type: 'POST',
data: formdata,
processData: false,
contentType: false,
beforeSend: function() {
$('#ajax_preloader').fadeIn();
},
error: function() {
$('#ajax_preloader').fadeOut();
showWarningAlert("Server Error");
},
success: function(data) {
$('#ajax_preloader').fadeOut();
if(data == "file_empty_error") {
showWarningAlert("file_empty_error");
} else {
let arr_title = JSON.parse(data);
let str_arr_title = "";
for(let idx=0; idx<arr_title.length; idx++) {
let item = arr_title[idx];
if(item.length > 0) {
str_arr_title += `<div class="custom-control custom-radio">
<input type="radio" id="rdo_csv` + idx + `" value="` + item + `" name="rdo_csv" class="custom-control-input">
<label class="custom-control-label" for="rdo_csv` + idx + `">` + item + `</label>
</div>`;
}
}
$('#div_rdo_csv').html(str_arr_title);
}
}
})
});
function onAddMapping() {
if($('input[name=rdo_csv]:checked').length == 0) {
showWarningAlert("Please select XLS Column!");
return;
}
if($('input[name=rdo_tbl]:checked').length == 0) {
showWarningAlert("Please select Table Column!");
return;
}
let str_csv_title = $('input[name=rdo_csv]:checked').val();
let str_tbl_title = $('input[name=rdo_tbl]:checked').val();
let str_tbl_name = $('input[name=rdo_tbl]:checked').attr("data-table");
let str_tbl_headerfile = $('input[name=rdo_tbl]:checked').attr("data-headerfile");
let str_result = `<tr>
<td>` + str_csv_title + `</td>
<td><i class="ion-arrow-right-c" style="width: 30px"></i></td>
<td>` + str_tbl_headerfile + `</td>
<td><input class="hidden" value="` + str_tbl_name + `"><input class="hidden" value="` + str_tbl_title + `"><a onclick="onRemoveResult(this)" style="color: red; padding: 5px; cursor:pointer; font-size: 16px"><i class="ion-close-circled"></i></a></td>
</tr>`;
$('#tbody_result').append(str_result);
$('input[name=rdo_csv]:checked').parent("div").addClass("hidden");
$('input[name=rdo_tbl]:checked').parent("div").addClass("hidden");
$('input[name=rdo_csv]').prop("checked", false);
$('input[name=rdo_tbl]').prop("checked", false);
}
function onRemoveResult(obj) {
let csv_title = $(obj).closest('tr').find("td:eq(0)").html();
let tbl_title = $(obj).closest('tr').find("td:eq(3)").find("input:eq(1)").val();
$('input[name=rdo_csv]').each(function(e) {
if($(this).val() == csv_title) {
$(this).parent("div").removeClass("hidden");
}
})
$('input[name=rdo_tbl][value=' + tbl_title + ']').parent("div").removeClass("hidden");
$(obj).closest("tr").remove();
}
//create table and insert csv data
function onSave() {
let arr_csv = Array();
let arr_selected_csv = Array();
let arr_tbl = Array();
let arr_tbl_name = Array();
let arr_db_headerfile = Array();
$('input[name=rdo_csv]').each(function() {
arr_csv.push($(this).val());
})
$('#tbody_result').find("tr").each(function() {
arr_selected_csv.push($(this).find("td:eq(0)").html());
arr_tbl.push($(this).find("td:eq(3)").find("input:eq(1)").val());
arr_tbl_name.push($(this).find("td:eq(3)").find("input:eq(0)").val());
arr_db_headerfile.push($(this).find("td:eq(2)").html());
})
if(arr_selected_csv.length > 0) {
$.ajax({
type: 'POST',
url: 'save_column_link.php',
data: {
template_id: '<?=$edit_id?>',
arr_csv: JSON.stringify(arr_csv),
arr_selected_csv: JSON.stringify(arr_selected_csv),
arr_selected_tbl_title: JSON.stringify(arr_tbl),
arr_selected_tbl_name: JSON.stringify(arr_tbl_name),
arr_db_headerfile: JSON.stringify(arr_db_headerfile)
},
beforeSend: function() {
$('#ajax_preloader').fadeIn();
},
error: function(e) {
console.log(e);
$('#ajax_preloader').fadeOut();
showWarningAlert("Server Error");
},
success: function(data) {
$('#ajax_preloader').fadeOut();
console.log(data);
Swal.fire({
title: 'Success',
text: "Your operation successed!",
icon: 'success',
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'Confirm'
}).then((result) => {
if (result.isConfirmed) {
history.go(-1);
} else {
history.go(-1);
}
});
}
})
} else {
showWarningAlert("Please select columns!");
}
}
//
// function onSave() {
// let arr_selected_val = Array();
// let arr_selected_desc = Array();
//
// $('#multiselect_to').find("option").each((id, item) => {
// arr_selected_val.push(item.value);
// arr_selected_desc.push($(item).attr("description"));
// })
//
// let formdata = new FormData();
// formdata.append("f_csv", $('#f_csv').prop('files')[0]);
// formdata.append("tbl_name", $('#ipt_tbl_name').val());
// formdata.append("arr_selected_val", JSON.stringify(arr_selected_val));
// formdata.append("arr_selected_desc", JSON.stringify(arr_selected_desc));
//
// if(arr_selected_val.length > 0) {
// $.ajax({
// type: 'POST',
// url: 'save_associate_template.php',
// data: formdata,
// processData: false,
// contentType: false,
// beforeSend: function() {
// $('#ajax_preloader').fadeIn();
// },
// error: function(e) {
// console.log(e);
// $('#ajax_preloader').fadeOut();
// showWarningAlert("Server Error");
// },
// success: function(data) {
// $('#ajax_preloader').fadeOut();
// console.log(data);
// Swal.fire({
// title: 'Success',
// text: "Your operation successed!",
// icon: 'success',
// showCancelButton: false,
// confirmButtonColor: '#3085d6',
// confirmButtonText: 'Confirm'
// }).then((result) => {
// if (result.isConfirmed) {
// history.go(-1);
// } else {
// history.go(-1);
// }
// });
// }
// })
// } else {
// showWarningAlert("Please add table column!");
// }
// }
</script>
<!-- plugin JS -->
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<script src="../assets/js/common_helper.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
</body>
</html>

View File

@ -0,0 +1,17 @@
<?php
require '../../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
if(isset($_FILES['f_csv'])) {
$file = $_FILES['f_csv']['tmp_name'];
$spreadsheet = IOFactory::load($file);
$worksheet = $spreadsheet->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");
}

View File

@ -0,0 +1,83 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php"); ?>
<?php
require '../../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
if(isset($_FILES['f_csv'])) {
$tbl_name = $_POST['tbl_name'];
$arr_val = json_decode($_POST['arr_selected_val']);
$arr_description = json_decode($_POST['arr_selected_desc']);
$file = $_FILES['f_csv']['tmp_name'];
$spreadsheet = IOFactory::load($file);
$worksheet = $spreadsheet->getActiveSheet();
$arr_info = $worksheet->toArray();
if(count($arr_info) > 1) {
//insert template header and description
for($i=0; $i<count($arr_val); $i++) {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "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; $i<count($arr_val); $i++) {
if($i == (count($arr_val) - 1)) {
$sql_create_tbl .= $arr_val[$i]." TEXT NOT NULL";
} else {
$sql_create_tbl .= $arr_val[$i]." TEXT NOT NULL,";
}
}
$sql_create_tbl .= ")";
if ($repnew->query($sql_create_tbl) === TRUE) {
$arr_pos = array();
for($i=0; $i<count($arr_info[0]); $i++) {
for($j=0; $j<count($arr_description); $j++) {
if($arr_info[0][$i] == $arr_description[$j]) {
array_push($arr_pos, $i);
}
}
}
$arr_result_data = array(); //insert data list
for($i=1; $i<count($arr_info); $i++) {
$item_info = array();
for($pos=0; $pos<count($arr_pos); $pos++) {
array_push($item_info, $arr_info[$i][$arr_pos[$pos]]);
}
array_push($arr_result_data, $item_info);
}
//insert item to target table
for($i=0; $i<count($arr_result_data); $i++) {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "`".$tbl_name."`";
for($k=0; $k<count($arr_val); $k++) {
$InsertQuery->bindColumn("".$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");
}

View File

@ -0,0 +1,32 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php"); ?>
<?php
$template_id = $_POST['template_id'];
$arr_csv = $_POST['arr_csv'];
$arr_selected_csv = json_decode($_POST['arr_selected_csv']);
$arr_selected_tbl_title = json_decode($_POST['arr_selected_tbl_title']);
$arr_selected_tbl_name = json_decode($_POST['arr_selected_tbl_name']);
$arr_db_headerfile = json_decode($_POST['arr_db_headerfile']);
$deleteQuery = new WA_MySQLi_Query($repnew);
$deleteQuery->Action = "delete";
$deleteQuery->Table = "`template_associate`";
$deleteQuery->addFilter("template_importify_id", "=", "i", "" . $template_id . "");
$deleteQuery->execute();
for($i=0; $i<count($arr_selected_csv); $i++) {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "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");