Menu

[r9]: / invoicing / editinvoice.php  Maximize  Restore  History

Download this file

239 lines (194 with data), 8.7 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/*
** Application name: phpCollab
** Last Edit page: 04/12/2004
** Path by root: ../invoicing/editinvoice.php
** Authors: Ceam / Fullo
** =============================================================================
**
** phpCollab - Project Managment
**
** -----------------------------------------------------------------------------
** Please refer to license, copyright, and credits in README.TXT
**
** -----------------------------------------------------------------------------
** FILE: editinvoice.php
**
** DESC: screen: edit a invoice
**
** HISTORY:
** 04/12/2004 - added new document info
** 04/12/2004 - fixed [ 1077236 ] Calendar bug in Client's Project site
** 25/04/2006 - replaced JavaScript Calendar functions
** -----------------------------------------------------------------------------
** TO-DO:
** =============================================================================
*/
$checkSession = "true";
include_once('../includes/library.php');
$tmpquery = "WHERE inv.id = '$id'";
$detailInvoice = new request();
$detailInvoice->openInvoices($tmpquery);
$tmpquery = "WHERE pro.id = '".$detailInvoice->inv_project[0]."'";
$projectDetail = new request();
$projectDetail->openProjects($tmpquery);
if ($projectDetail->pro_owner[0] != $idSession) {
header("Location:../general/permissiondenied.php?".session_name()."=".session_id());
exit;
}
if ($id != "") {
if ($action == "update") {
if ($pub == "") {
$pub = "1";
}
if ($st == "1") {
$datesent = $date;
}
$tmpquery = "UPDATE ".$tableCollab["invoices"]." SET header_note='$header_note',footer_note='$footer_note',published='$pub',status='$st',due_date='$dd',date_sent='$datesent',total_ex_tax='$total_ex_tax',total_inc_tax='$total_inc_tax',tax_rate='$tax_rate',tax_amount='$tax_amount',modified='$dateheure' WHERE id = '$id'";
connectSql($tmpquery);
for ($i=0;$i<$comptListInvoicesItems;$i++) {
$tmpquery = "UPDATE ".$tableCollab["invoices_items"]." SET title='".$title[$i]."',position='".$position[$i]."',amount_ex_tax='".${"item".$i}."' WHERE id = '".$itemId[$i]."'";
connectSql($tmpquery);
}
headerFunction("../invoicing/viewinvoice.php?msg=update&id=$id&".session_name()."=".session_id());
}
//set value in form
$header_note = $detailInvoice->inv_header_note[0];
$footer_note = $detailInvoice->inv_footer_note[0];
$datesent = $detailInvoice->inv_date_sent[0];
$dd = $detailInvoice->inv_due_date[0];
$total_ex_tax = $detailInvoice->inv_total_ex_tax[0];
$tax_rate = $detailInvoice->inv_tax_rate[0];
$tax_amount = $detailInvoice->inv_tax_amount[0];
$total_inc_tax = $detailInvoice->inv_total_inc_tax[0];
$st = $detailInvoice->inv_status[0];
$pub = $detailInvoice->inv_published[0];
if ($pub == "0") {
$checkedPub = "checked";
}
}
$includeCalendar = true; //Include Javascript files for the pop-up calendar
include('../themes/'.THEME.'/header.php');
$blockPage = new block();
$blockPage->openBreadcrumbs();
$blockPage->itemBreadcrumbs($blockPage->buildLink("../clients/listclients.php?",$strings["clients"],in));
$blockPage->itemBreadcrumbs($blockPage->buildLink("../clients/viewclient.php?id=".$projectDetail->pro_org_id[0],$projectDetail->pro_org_name[0],in));
$blockPage->itemBreadcrumbs($blockPage->buildLink("../invoicing/listinvoices.php?client=".$projectDetail->pro_organization[0],$strings["invoices"],in));
if ($id != "") {
$blockPage->itemBreadcrumbs($blockPage->buildLink("../invoicing/viewinvoice.php?id=".$detailInvoice->inv_id[0],$detailInvoice->inv_id[0],in));
$blockPage->itemBreadcrumbs($strings["edit_invoice"]);
}
$blockPage->closeBreadcrumbs();
if ($msg != "") {
include('../includes/messages.php');
$blockPage->messagebox($msgLabel);
}
$block1 = new block();
if ($id != "") {
$block1->form = "invoice";
$block1->openForm("../invoicing/editinvoice.php?id=$id&action=update&".session_name()."=".session_id()."#".$block1->form."Anchor");
}
if ($error != "") {
$block1->headingError($strings["errors"]);
$block1->contentError($error);
}
if ($id != "") {
$block1->heading($strings["edit_invoice"]." : ".$detailInvoice->inv_id[0]);
}
$block1->openContent();
$block1->contentTitle($strings["details"]);
$block1->contentRow($strings["header_note"],"<textarea rows=\"10\" style=\"width: 400px; height: 100px;\" name=\"header_note\" cols=\"47\">$header_note</textarea>");
$block1->contentRow($strings["footer_note"],"<textarea rows=\"10\" style=\"width: 400px; height: 100px;\" name=\"footer_note\" cols=\"47\">$footer_note</textarea>");
$tmpquery = "WHERE invitem.invoice = '$id' AND invitem.active = '1' ORDER BY invitem.position ASC";
$listInvoicesItems = new request();
$listInvoicesItems->openInvoicesItems($tmpquery);
$comptListInvoicesItems = count($listInvoicesItems->invitem_id);
$selectStatus = "<select name=\"st\">";
$comptSta = count($invoiceStatus);
if ($detailInvoice->inv_status[0] == "0") {
$begin = "0";
} else {
$begin = "1";
}
for ($i=0;$i<$comptListInvoicesItems;$i++) {
if ($listInvoicesItems->invitem_completed[$i] == "0") {
$comptSta = "1";
$notCompleted = $strings["note_invoice_items_notcompleted"];
break;
}
}
for ($i=$begin;$i<$comptSta;$i++) {
if ($detailInvoice->inv_status[0] == $i) {
$selectStatus .= "<option value=\"$i\" selected>$invoiceStatus[$i]</option>";
} else {
$selectStatus .= "<option value=\"$i\">$invoiceStatus[$i]</option>";
}
}
$selectStatus .= "</select> $notCompleted";
$block1->contentRow($strings["status"],$selectStatus);
if ($dd == "") {
$dd = "--";
}
$block1->contentRow($strings["due_date"],"<input type='text' name='dd' id='due_date' size='20' value='$dd'><input type='button' value=' ... ' id='trigDueDate''>");
echo "
<script type='text/javascript'>
Calendar.setup({
inputField : 'due_date',
button : 'trigDueDate',
$calendar_common_settings
});
</script>
";
$block1->contentRow($strings["published"],"<input size=\"32\" value=\"0\" name=\"pub\" type=\"checkbox\" $checkedPub>");
$block1->contentTitle($strings["calculation"]);
echo "<tr class=\"odd\"><td valign=\"top\" class=\"leftvalue\">".$strings["items"]." :</td><td>";
echo "<table cellpadding=\"0\" cellspacing=\"0\">";
echo "<input type=\"hidden\" name=\"comptListInvoicesItems\" value=\"$comptListInvoicesItems\">";
?>
<script type="text/JavaScript">
function calc(w) {
var item = [];
var subtotal = 0;
for (var i = 0; i < <?php echo $comptListInvoicesItems; ?>; i++) {
item[i] = 1 * document.invoiceForm["item" + i].value;
if (item[i] == "") {
item[i] = 0;
} else {
subtotal += item[i];
}
}
document.invoiceForm["total_ex_tax"].value = subtotal;
var ratePercent = document.invoiceForm["tax_rate"].value;
if (subtotal != 0) {
var amount_due = subtotal + (subtotal*ratePercent)/100;
document.invoiceForm["total_inc_tax"].value = amount_due;
}
if (subtotal != 0 && ratePercent != '') {
var tax_part = (subtotal*ratePercent)/100;
document.invoiceForm["tax_amount"].value = tax_part;
}
}
</script>
<?php
if ($comptListInvoicesItems != "0") {
echo "<tr><td>".$strings["position"]."</td><td>".$strings["title"]."</td><td>".$strings["amount_ex_tax"]."</td><td>".$strings["completed"]."</td></tr>";
for ($i=0;$i<$comptListInvoicesItems;$i++) {
if ($listInvoicesItems->invitem_completed[$i] == "1") {
$completeValue = $strings["yes"];
} else {
$completeValue = $strings["no"];
}
echo "<tr><td><input type=\"hidden\" name=\"itemId[$i]\" size=\"20\" value=\"".$listInvoicesItems->invitem_id[$i]."\"><input type=\"text\" name=\"position[$i]\" size=\"3\" value=\"".$listInvoicesItems->invitem_position[$i]."\"></td><td><input type=\"text\" name=\"title[$i]\" size=\"20\" value=\"".$listInvoicesItems->invitem_title[$i]."\"></td><td><input type=\"text\" name=\"item$i\" size=\"20\" value=\"".$listInvoicesItems->invitem_amount_ex_tax[$i]."\" tabindex=\"$i\" onblur=\"calc(this)\"></td><td>$completeValue</td></tr>";
}
}
echo "</table>";
echo "</td></tr>";
$block1->contentRow($strings["total_ex_tax"],"<input type=\"text\" name=\"total_ex_tax\" size=\"20\" value=\"$total_ex_tax\">");
$block1->contentRow($strings["tax_rate"],"<input type=\"text\" name=\"tax_rate\" size=\"20\" value=\"$tax_rate\" onblur=\"calc(this)\"> %");
$block1->contentRow($strings["tax_amount"],"<input type=\"text\" name=\"tax_amount\" size=\"20\" value=\"$tax_amount\">");
$block1->contentRow($strings["total_inc_tax"],"<input type=\"text\" name=\"total_inc_tax\" size=\"20\" value=\"$total_inc_tax\">");
echo "<tr class=\"odd\"><td valign=\"top\" class=\"leftvalue\">&nbsp;</td><td><input type=\"SUBMIT\" value=\"".$strings["save"]."\"></td></tr>";
$block1->closeContent();
$block1->closeForm();
include('../themes/'.THEME.'/footer.php');
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.