-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmkserdocs.php
114 lines (105 loc) · 3.99 KB
/
mkserdocs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
session_start();
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
echo "Bitte das Fenster erst nach Aufforderung schließen<br>";
ob_end_flush();
require_once("inc/stdLib.php");
require_once("inc/crmLib.php");
//Übersetzung der Platzhalter
$hli2erp["P"]=array("ANREDE"=>"cp_greeting","TITEL"=>"cp_title","NAME1"=>"cp_name","NAME2"=>"cp_givenname",
"LAND"=>"cp_country","PLZ"=>"cp_zipcode","ORT"=>"cp_city","STRASSE"=>"cp_street",
"TEL"=>"cp_phone","FAX"=>"cp_fax","EMAIL"=>"cp_email","FIRMA"=>"name","GESCHLECHT"=>"cp_gender","ID"=>"cp_id",
"DATE"=>"DATE","SUBJECT"=>"SUBJECT","BODY"=>"BODY","TMPFILE"=>"TMPFILE");
$hli2erp["F"]=array("ANREDE"=>"greeting","NAME1"=>"name","NAME2"=>"department_1",
"LAND"=>"country","PLZ"=>"zipcode","ORT"=>"city","STRASSE"=>"street",
"TEL"=>"phone","FAX"=>"fax","EMAIL"=>"email","KONTAKT"=>"contact","ID"=>"id",
"USTID"=>"ustid","STEUERNR"=>"taxnumber","LANG"=>"language","KDTYP"=>"business_id",
"KTONR"=>"account_number","BANK"=>"bank","BLZ"=>"bank_code",
"DATE"=>"DATE","SUBJECT"=>"SUBJECT","BODY"=>"BODY","TMPFILE"=>"tmpfile");
//Bibliothek nachladen
$typ=strtolower(substr($_SESSION["datei"],-3));
switch ($typ) {
case "tex" :
require('inc/phpTex.php');
$doc = new phpTex();
break;
case "swf" :
case "sxw" :
define('POO_TMP_PATH', $_SESSION["savefiledir"]);
require("inc/phpOpenOffice.php");
$doc = new phpOpenOffice();
break;
case "rtf" :
require('inc/phpRtf.php');
$doc = new phpRTF();
break;
}
$doc->loadDocument("./dokumente/".$_SESSION["dbname"]."/serbrief/".$_SESSION["datei"]);
$doc->savecontent();
$sql="select * from tempcsvdata where uid = '".$_SESSION["loginCRM"]."' AND id = -255";
$data=$GLOBALS['dbh']->getAll($sql);
$felder=str_getcsv($data[0]["csvdaten"]);
$tmpfile=substr($_SESSION["datei"],0,-4);
$i=0;
foreach($felder as $value) {
$name=strtoupper($value);
$vars[$name]="";
$pos[$name]=$i++;
};
//incCall vorbereiten
$tdata["CRMUSER"]=$_SESSION["loginCRM"];
$tdata["cause"]=$_SESSION["SUBJECT"];
$tdata["c_cause"]=$_SESSION["BODY"];
$tdata["Kontakt"]="S";
$tdata["Bezug"]=0;
$tdata["Zeit"]=date("H:i");
$tdata["Datum"]=date("d.m.Y");
$tdata["Status"]=1;
$tdata["DateiID"]=$_SESSION["dateiId"];
function decoder($txt) {
if (ini_get("default_charset")=='utf-8') {
return utf8_decode($txt);
} else {
return $txt;
}
}
//Daten holen
$sql="select * from tempcsvdata where uid = ".$_SESSION["loginCRM"]." and id >0"; //offset 1";
$data=$GLOBALS['dbh']->getAll($sql);
$cnt=1;
$_SESSION["src"]=($_GET["src"]<>"")?$_GET["src"]:"P";
if ($data) {
foreach ($data as $row) {
$tmp=str_getcsv($row["csvdaten"]);
foreach($felder as $name) {
if ($_SESSION["rub"]==1) {
//Künftig werden db-Feldnamen verwendet zZ nur RuB
$nname=$hli2erp[$_SESSION["src"]][$name];
} else {
$nname=$name;
}
$vars[$nname] = decoder($tmp[$pos[$name]]);
}
$vars["DATUM"]=$_SESSION["DATE"];
$vars["BETREFF"]=decoder($_SESSION["SUBJECT"]);
$vars["INHALT"]=decoder($_SESSION["BODY"]);
$vars["NAME"]=$vars["NAME1"];
$vars["TMPFILE"] = $tmpfile;
$tdata["CID"]=$row["id"];
insCall($tdata,false);
$doc->parse($vars);
$doc->cleanTemplate();
$doc->save($_SESSION["savefiledir"]."/".$_SESSION['src'].$row["id"]."_".$_SESSION["datei"]);
if ($cnt++ % 10 == 0) echo "."; flush();
$doc->getoriginal();
foreach ($vars as $key=>$val) { $vars[$key]=""; };
empty($tmp);
}
}
//$doc->clean();
?>
<br>
Sie können das Fensten jetzt schließen;
<br><center><a href='javascript:self.close();'>close</a></center>