init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
101
tankrechnung.php
Normal file
101
tankrechnung.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
error_reporting(E_ALL); ini_set('display_errors', 1);
|
||||
|
||||
$kw = (int)date('W');
|
||||
$tag = (int)date('d');
|
||||
$monat = (int)date('m');
|
||||
$jahr = (int)date('Y');
|
||||
|
||||
require('lib/config.php');
|
||||
session_name(CONFIG_SESSION);
|
||||
session_start(); require('lib/mysql.class.php');
|
||||
$GLOBALS['mysql'] = new mysql(CONFIG_MYSQL_HOST,CONFIG_MYSQL_USER,CONFIG_MYSQL_PW,CONFIG_MYSQL_DB);
|
||||
// $GLOBALS['mysql']->mysql_query("SET NAMES 'utf8'");
|
||||
// $GLOBALS['mysql']->mysql_query("SET CHARACTER SET 'utf8'");
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
|
||||
$dateityp = GetImageSize($_FILES['datei']['tmp_name']);
|
||||
/*
|
||||
[name] => DE000000354187.csv
|
||||
[type] => text/csv
|
||||
[tmp_name] => /tmp/phpaavg3z
|
||||
[error] => 0
|
||||
[size] => 21104
|
||||
*/
|
||||
move_uploaded_file($_FILES['datei']['tmp_name'],'upload/'.$_FILES['datei']['name']);
|
||||
|
||||
// Info:
|
||||
// echo "<pre>"; print_r($_FILES['datei']); echo "</pre>";
|
||||
|
||||
//------------------------ Kennzeichen Leerstellen entfernen
|
||||
$car = $GLOBALS['mysql']->sql("SELECT id,kz FROM fahrzeuge ORDER by id");
|
||||
while($row = $car->fetch_assoc()) {
|
||||
$fd[$row['id']]=str_replace(' ','',$row['kz']);
|
||||
}
|
||||
// echo "<pre>"; print_r($fd); echo "</pre>";
|
||||
//------------------------ csv öffnen
|
||||
$response = []; $fid = 0;
|
||||
if(!read_csv('upload/'.$_FILES['datei']['name'], $response)){
|
||||
echo "CSV Datei konnte nicht geöffnet werden.";
|
||||
}
|
||||
$key=0;
|
||||
foreach($response as $row_number => $data) {
|
||||
if ($key!=0) {
|
||||
if (strlen($data[0])==0) {
|
||||
$fid=99;
|
||||
} else {
|
||||
$clean=str_replace(' ','',$data[0]);
|
||||
$fid=array_search($clean,$fd);
|
||||
}
|
||||
//---
|
||||
$ftest = $GLOBALS['mysql']->query_single("SELECT * FROM tankrechnung WHERE Karte='".$data[12]."' and Tankdatum='".$data[3]."' and Tankzeit='".$data[4]."' and Menge='".$data[1]."'");
|
||||
if($ftest['num_rows'] == 0) {
|
||||
|
||||
$GLOBALS['mysql']->insert("INSERT INTO tankrechnung (fid,kz_clean,Kfz,Menge,Sortenname,Tankdatum,Tankzeit,KmStand,Netto,Einzel,Brutto,MwSt,RechNr,Rechnungsdatum,Karte,Standort,Saeulenpreis,Sorte)
|
||||
VALUES(
|
||||
'".$fid."',
|
||||
'".$clean."',
|
||||
'".$data[0]."',
|
||||
'".$data[1]."',
|
||||
'".$data[2]."',
|
||||
'".$data[3]."',
|
||||
'".$data[4]."',
|
||||
'".$data[5]."',
|
||||
'".$data[6]."',
|
||||
'".$data[7]."',
|
||||
'".$data[8]."',
|
||||
'".$data[9]."',
|
||||
'".$data[10]."',
|
||||
'".$data[11]."',
|
||||
'".$data[12]."',
|
||||
'".$data[13]."',
|
||||
'".$data[17]."',
|
||||
'".$data[22]."')
|
||||
");
|
||||
|
||||
}
|
||||
}
|
||||
$key++;
|
||||
}
|
||||
//echo "<pre>"; print_r($tt); echo "</pre>";
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
header('Location: index.php?s=w_tanken&load=1');
|
||||
|
||||
function read_csv(string $path_to_csv_file, array &$result): bool{
|
||||
$handle = fopen($path_to_csv_file, 'r');
|
||||
|
||||
if(!$handle){
|
||||
return false;
|
||||
}
|
||||
|
||||
while(false !== ($data = fgetcsv($handle, null, ';'))){
|
||||
$result[] = $data;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue