-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.php
More file actions
160 lines (142 loc) · 5.06 KB
/
Copy pathview.php
File metadata and controls
160 lines (142 loc) · 5.06 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
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
149
150
151
152
153
154
155
156
157
158
159
160
<?php /* INVOICES $Id: view.php,v 1.0 2004/03/24 20:25:24 mfinger Exp $ */
$invoice_id = intval( dPgetParam( $_GET, "invoice_id", 0 ) );
// check permissions for this record
$canRead = !getDenyRead( $m, $invoice_id );
$canEdit = !getDenyEdit( $m, $invoice_id );
if (!$canRead) {
$AppUI->redirect( "m=public&a=access_denied" );
}
// retrieve any state parameters
if (isset( $_GET['tab'] )) {
$AppUI->setState( 'InvVwTab', $_GET['tab'] );
}
$tab = $AppUI->getState( 'InvVwTab' ) !== NULL ? $AppUI->getState( 'InvVwTab' ) : -1;
// check if this record has dependancies to prevent deletion
$msg = '';
$obj = new CInvoice();
// load the record data
$sql = "
SELECT
company_name,
invoices.*,
SUM(t1.product_price*t1.product_qty) as invoice_grand_total
FROM invoices
LEFT JOIN companies ON company_id = invoice_company
LEFT JOIN invoice_product t1 ON invoices.invoice_id = t1.product_invoice
WHERE invoice_id = $invoice_id
GROUP BY invoice_id
";
$obj = null;
if (!db_loadObject( $sql, $obj )) {
$AppUI->setMsg( 'Invoice' );
$AppUI->setMsg( "invalidID", UI_MSG_ERROR, true );
$AppUI->redirect();
} else {
$AppUI->savePlace();
}
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
// create Date objects from the datetime fields
$invoice_date = intval( $obj->invoice_date ) ? new CDate( $obj->invoice_date ) : null;
$invoice_due = intval( $obj->invoice_due ) ? new CDate( $obj->invoice_due ) : null;
$invoice_balance = $obj->invoice_status == 0 ? $obj->invoice_grand_total : 0;
// setup the title block
$titleBlock = new CTitleBlock( 'View Invoice', 'applet3-48.png', $m, "$m.$a" );
if ($canEdit) {
$titleBlock->addCell();
/* $titleBlock->addCell(
'<input type="submit" class="button" value="'.$AppUI->_('new invoice').'">', '',
'<form action="?m=invoices&a=addedit&invoice=' . $invoice_id . '" method="post">', '</form>'
);
*/
}
$titleBlock->addCrumb( "?m=invoices", "invoices list" );
if ($canEdit) {
$obj->invoice_status == 0 ? $titleBlock->addCrumb( "?m=invoices&a=addedit&invoice_id=$invoice_id", "edit this invoice" ) : null;
if ($canEdit) {
$obj->invoice_status == 0 ? $titleBlock->addCrumbDelete( 'delete invoice', $canDelete, $msg ) : null;
}
}
$titleBlock->addCrumb( "?m=invoices&a=reports&invoice_id=$invoice_id", "reports" );
$titleBlock->show();
?>
<script language="javascript">
function updateProduct() {
var f = document.editFrm;
if (f.product_name.value.length < 1) {
alert( "<?php echo $AppUI->_('Please Enter a Description');?>" );
f.product_name.focus();
} else {
f.submit();
}
}
function delIt() {
if (confirm( "<?php echo $AppUI->_('doDelete').' '.$AppUI->_('Invoice').'?';?>" )) {
document.frmDelete.submit();
}
}
</script>
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
<form name="frmDelete" action="./index.php?m=invoices" method="post">
<input type="hidden" name="dosql" value="do_invoice_aed" />
<input type="hidden" name="del" value="1" />
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id;?>" />
</form>
<tr>
<td style="border: outset #d1d1cd 1px;" colspan="2">
<?php
echo '<strong>Invoice: ' . $obj->invoice_id .'</strong>';
?>
</td>
</tr>
<tr>
<td width="50%" valign="top">
<strong><?php echo $AppUI->_('Details');?></strong>
<table cellspacing="1" cellpadding="2" border="0" width="100%">
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Company');?>:</td>
<td class="hilite" width="100%"><?php echo $obj->company_name;?></td>
</tr>
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Total');?>:</td>
<td class="hilite">$ <?php echo @$obj->invoice_grand_total;?></td>
</tr>
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Balance');?>:</td>
<td class="hilite">$ <?php echo $invoice_balance;?></td>
</tr>
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Status');?>:</td>
<td class="hilite" width="100%"><?php echo $obj->invoice_status ? 'Paid' : 'Due';?></td>
</tr>
</table>
</td>
<td width="50%" rowspan="9" valign="top">
<strong><?php echo $AppUI->_('Summary');?></strong><br />
<table cellspacing="1" cellpadding="2" border="0" width="100%">
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Invoice Date');?>:</td>
<td class="hilite"><?php echo $invoice_date ? $invoice_date->format( $df ) : '-';?></td>
</tr>
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Invoice Due');?>:</td>
<td class="hilite"><?php echo $invoice_due ? $invoice_due->format( $df ) : '-';?></td>
</tr>
<tr>
<td align="right" nowrap><?php echo $AppUI->_('Terms');?>:</td>
<td class="hilite" width="100%"><?php echo $obj->invoice_terms; ?></td>
</tr>
</table>
</td>
</table>
<?php
$query_string = "?m=invoices&a=view&invoice_id=$invoice_id";
// tabbed information boxes
$tabBox = new CTabBox( "?m=invoices&a=view&invoice_id=$invoice_id", "", $tab );
$tabBox->add( "{$AppUI->cfg['root_dir']}/modules/invoices/vw_idx_products", 'Products' );
$obj->invoice_status == 0 ? $tabBox->add( "{$AppUI->cfg['root_dir']}/modules/invoices/vw_idx_products_update" , 'Update Products' ) : null;
// settings for tasks
$f = 'all';
$min_view = true;
$tabBox->show();
?>