-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.php
More file actions
executable file
·111 lines (100 loc) · 3.17 KB
/
pdf.php
File metadata and controls
executable file
·111 lines (100 loc) · 3.17 KB
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
<?php
require_once $dPconfig['root_dir'] . '/modules/ticketsmith/config.inc.php';
require_once $AppUI->getSystemClass( 'query');
$font_dir = $dPconfig['root_dir']."/lib/ezpdf/fonts";
$temp_dir = $dPconfig['root_dir']."/files/temp";
$base_url = $dPconfig['base_url'];
require( $AppUI->getLibraryClass( 'ezpdf/class.ezpdf' ) );
$type = dPgetParam($_GET, 'type', '');
$column = dPgetParam($_GET, 'column', 'timestamp');
$direction = dPgetParam($_GET, 'direction', 'DESC');
$q =& new DBQuery;
$q->addQuery(array(
'ticket',
'author',
'subject',
'timestamp',
'type',
'assignment',
'contact_first_name',
'contact_last_name',
'activity',
'priority'
));
$q->addTable('tickets', 'a');
$q->leftJoin('users', 'b', 'a.assignment = b.user_id');
$q->leftJoin('contacts', 'c', 'b.user_id = c.contact_id');
if ($type == 'My') {
$q->addWhere("type = 'Open'");
$q->addWhere("(assignment = '$AppUI->user_id' OR assignment = '0')");
} else if ($type != 'All') {
$q->addWhere("type = '$type'");
}
$q->addWhere("parent = '0'");
$q->addOrder(urlencode($column) . " " . $direction);
$ticketlist = $q->loadHashList('ticket');
if ($err = db_error()) {
$AppUI->setMsg($err, UI_MSG_ERR);
$AppUI->redirect();
}
$df = $AppUI->getPref('SHDATEFORMAT');
$pdf =& new Cezpdf($paper='A4',$orientation='landscape');
$pdf->ezSetCmMargins( 1, 2, 1.5, 1.5 );
$pdf->selectFont( "$font_dir/Helvetica.afm" );
$pdf->ezText( dPgetConfig( 'company_name' ), 12 );
$date = new CDate();
$pdf->ezText( "\n" . $date->format( $df) , 8 );
$next_week = new CDate($date);
$next_week->addSpan(new Date_Span(array(7,0,0,0)));
$pdf->selectFont( "$font_dir/Helvetica-Bold.afm" );
$pdf->ezText( "\n" . $AppUI->_("$type Ticket Report"), 12 );
$pdf->ezText( "$pname", 15 );
$pdf->ezText( "\n" );
$pdf->selectFont( "$font_dir/Helvetica.afm" );
$title = "$type Tickets";
$options = array(
'showLines' => 2,
'showHeadings' => 1,
'fontSize' => 9,
'rowGap' => 4,
'colGap' => 5,
'xPos' => 50,
'xOrientation' => 'right',
'width'=>'750',
'shaded'=> 0,
'cols'=>array(
0=>array('justification'=>'center','width'=>250),
1=>array('justification'=>'center','width'=>250),
2=>array('justification'=>'center','width'=>45),
3=>array('justification'=>'center','width'=>45),
4=>array('justification'=>'center','width'=>45),
5=>array('justification'=>'center','width'=>45),
6=>array('justification'=>'center','width'=>45),
)
);
$pdfdata = array();
$columns = array(
'<b>' . $AppUI->_('Author') . '</b>',
'<b>' . $AppUI->_('Subject') . '</b>',
'<b>' . $AppUI->_('Date') . '</b>',
'<b>' . $AppUI->_('Followup') . '</b>',
'<b>' . $AppUI->_('Status') . '</b>',
'<b>' . $AppUI->_('Priority') . '</b>',
'<b>' . $AppUI->_('Owner') . '</b>',
);
foreach ($ticketlist as $ticket) {
$row =& $pdfdata[];
$row[] = $ticket['author'];
$row[] = $ticket['subject'];
$row[] = date($CONFIG['date_format'], $ticket['timestamp']);
if ($ticket['activity'])
$row[] = date($CONFIG['date_format'], $ticket['activity']);
else
$row[] = '-';
$row[] = $ticket['type'];
$row[] = $CONFIG['priority_names'][$ticket['priority']];
$row[] = $ticket['contact_firt_name'] . ' ' . $ticket['contact_last_name'];
}
$pdf->ezTable( $pdfdata, $columns, $title, $options );
$pdf->ezStream();
?>