forked from kivitendo/kivitendo-crm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirma3.php
148 lines (147 loc) · 5.32 KB
/
firma3.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
require_once('inc/stdLib.php');
include('inc/crmLib.php');
include('inc/template.inc');
include('inc/grafik1.php');
include('inc/FirmenLib.php');
$Q = ( isset($_GET['Q']) )?$_GET['Q']:$_POST['Q'];
$fid = $_GET['fid'];
$monat = $jahr = $re = $reM = $top = false;
$t = new Template($base);
$fa = getFirmenStamm($fid,true,$Q);
if ( isset($_GET['linlog']) ) { $linlog = '&linlog=0'; $ll = true; }
else { $linlog = '&linlog=1'; $ll = false; }
$kdnr = $fa["nummer"];;
$link1 = "firma1.php?Q=$Q&id=$fid";
$link2 = "firma2.php?Q=$Q&fid=$fid";
$link3 = "firma3.php?Q=$Q&fid=$fid".$linlog;
$link4 = "firma4.phtml?Q=$Q&kdnr=$kdnr&fid=".$fid;
$name = $fa['name'];
$plz = $fa['zipcode'];
$ort = $fa['city'];
$jahr = ( isset($_GET['jahr']) )?$_GET['jahr']:date('Y');
if ( $jahr==date('Y') ) {
$JahrV = '';
} else {
$link3 .= '&jahr='.$jahr;
$JahrV = $jahr+1;
}
$JahrZ = $jahr-1;
if ( isset($_GET['monat']) ) {
if ( substr($_GET['monat'],-4)=='Jahr' ) {
$reM = getReMonat($_GET['fid'],$jahr,'00',($Q=='V')?true:false);
} else {
$reM = getReMonat($_GET['fid'],substr($_GET['monat'],3,4),substr($_GET['monat'],0,2),($Q=='V')?true:false);
}
$t->set_file(array('fa1' => 'firma3a.tpl'));
$IMG = '';
} else {
$top = getTopParts($fid);
$re = getReJahr($fid,$jahr,($Q=='V')?true:false);
$an = getAngebJahr($fid,$jahr,($Q=='V')?true:false);
$t->set_file(array('fa1' => 'firma3.tpl'));
$IMG = getLastYearPlot($re,$an,$ll);
$monat = '';
}
doHeader($t);
$t->set_var(array(
'Q' => $Q,
'FAART' => ($Q=='C')?'.:Customer:.':'.:Vendor:.', //"Kunde":"Lieferant",
'FID' => $fid,
'kdnr' => $fa['nummer'],
'Link1' => $link1,
'Link2' => $link2,
'Link3' => $link3,
'Link4' => $link4,
'Name' => $name,
'Plz' => $plz,
'Ort' => $ort,
'IMG' => $IMG,
'JAHR' => $jahr,
'JAHRV' => $JahrV,
'JAHRZ' => $JahrZ,
'JAHRVTXT' => ($JahrV>0)?'.:later:.':'',
'Monat' => $monat
));
if ($re) {
$t->set_block('fa1','Liste','Block');
$i = 0;
$monate = array_keys($re);
for ($i=0; $i<13; $i++) {
$colr = array_shift($re);
$cola = array_shift($an);
$val = array(
'Month' => substr($monate[$i],4,2).'/'.substr($monate[$i],0,4),
'Rcount' => $colr['count'],
'RSumme' => sprintf('%01.2f',$colr['summe']),
'ASumme' => sprintf('%01.2f',$cola['summe']),
'Curr' => $colr['curr']
);
$t->set_var($val);
$t->parse('Block','Liste',true);
}
}
if ( $top ) {
$t->set_block('fa1','TopListe','BlockTP');
foreach ( $top as $row ) {
$t->set_var(array(
'transdate' => db2date($row['transdate']),
'description' => $row['description'],
'qty' => $row['qty'],
'unit' => $row['unit'],
'rabatt' => ($row['discount'])?$row['discount']*100:'',
'sellprice' => sprintf('%0.2f',$row['sellprice']),
'summe' => sprintf('%0.2f',$row['summe'])
));
$t->parse('BlockTP','TopListe',true);
}
}
if ( $reM ) {
$t->set_block('fa1','Liste','Block');
$i = 0;
if ( $reM ) foreach( $reM as $col ){
if ( array_key_exists('invnumber',$col) ){
$typ = ($Q=='C')?'R':'V';
$renr = $col['invnumber'];
$offen = ( $col['amount']==$col['paid'] )?'+':'-';
} else {
if ( $col['quotation']=='f' ) {
$typ = 'L';
$renr = $col['ordnumber'];
$offen = ($col['closes']=='t')?'c':'o';
//$offen="+";
} else {
$typ = 'A';
$renr = $col['quonumber'];
$offen = ($col['closes']=='t')?'c':'o';
}
}
$t->set_var(array(
'LineCol' => ($i%2+1),
'Datum' => db2date($col['transdate']),
'RNr' => $renr,
'RNid' => $col["id"],
'RSumme' => sprintf('%01.2f',$col['netamount']),
'RBrutto' => sprintf('%01.2f',$col['amount']),
'Curr' => $col['curr'],
'Typ' => $typ,
'offen' => $offen
));
$t->parse('Block','Liste',true);
$i++;
}
}
if ( $monat and !$reM ) {
$t->set_block('"fa1','Liste','Block');
$i = 0;
$t->set_var(array(
'LineCol' => '',
'Datum' => '',
'RNr' => 'Keine ',
'RSumme' => 'Umsätze',
'Curr' => ''
));
$t->parse('Block','Liste',true);
}
$t->Lpparse('out',array('fa1'),$_SESSION['countrycode'],'firma');
?>