forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuppShiptChgs.php
159 lines (128 loc) · 6.11 KB
/
SuppShiptChgs.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
149
150
151
152
153
154
155
156
157
158
159
<?php
/*The supplier transaction uses the SuppTrans class to hold the information about the invoice
the SuppTrans class contains an array of Shipts objects - containing details of all shipment charges for invoicing
Shipment charges are posted to the debit of GRN suspense if the Creditors - GL link is on
This is cleared against credits to the GRN suspense when the products are received into stock and any
purchase price variance calculated when the shipment is closed */
include('includes/DefineSuppTransClass.php');
/* Session started here for password checking and authorisation level check */
include('includes/session.php');
$Title = _('Shipment Charges or Credits');
include('includes/header.php');
if ($_SESSION['SuppTrans']->InvoiceOrCredit == 'Invoice'){
echo '<a href="' . $RootPath . '/SupplierInvoice.php">' . _('Back to Invoice Entry') . '</a>';
} else {
echo '<a href="' . $RootPath . '/SupplierCredit.php">' . _('Back to Credit Note Entry') . '</a>';
}
if (!isset($_SESSION['SuppTrans'])){
prnMsg(_('Shipment charges or credits are entered against supplier invoices or credit notes respectively') . '. ' . _('To enter supplier transactions the supplier must first be selected from the supplier selection screen') . ', ' . _('then the link to enter a supplier invoice or credit note must be clicked on'),'info');
echo '<br /><a href="' . $RootPath . '/SelectSupplier.php">' . _('Select a supplier') . '</a>';
exit;
/*It all stops here if there aint no supplier selected and invoice/credit initiated ie $_SESSION['SuppTrans'] started off*/
}
/*If the user hit the Add to transaction button then process this first before showing all GL codes on the invoice otherwise it wouldnt show the latest addition*/
if (isset($_POST['AddShiptChgToInvoice'])){
$InputError = False;
if ($_POST['ShiptRef'] == ''){
if ($_POST['ShiptSelection']==''){
prnMsg(_('Shipment charges must reference a shipment. It appears that no shipment has been entered'),'error');
$InputError = True;
} else {
$_POST['ShiptRef'] = $_POST['ShiptSelection'];
}
} else {
$result = DB_query("SELECT shiptref FROM shipments WHERE shiptref='". $_POST['ShiptRef'] . "'");
if (DB_num_rows($result)==0) {
prnMsg(_('The shipment entered manually is not a valid shipment reference. If you do not know the shipment reference, select it from the list'),'error');
$InputError = True;
}
}
if (!is_numeric(filter_number_format($_POST['Amount']))){
prnMsg(_('The amount entered is not numeric') . '. ' . _('This shipment charge cannot be added to the invoice'),'error');
$InputError = True;
}
if ($InputError == False){
$_SESSION['SuppTrans']->Add_Shipt_To_Trans($_POST['ShiptRef'],
filter_number_format($_POST['Amount']));
unset($_POST['ShiptRef']);
unset($_POST['Amount']);
}
}
if (isset($_GET['Delete'])){
$_SESSION['SuppTrans']->Remove_Shipt_From_Trans($_GET['Delete']);
}
/*Show all the selected ShiptRefs so far from the SESSION['SuppInv']->Shipts array */
if ($_SESSION['SuppTrans']->InvoiceOrCredit=='Invoice'){
echo '<p class="page_title_text">' . _('Shipment charges on Invoice') . ' ';
} else {
echo '<p class="page_title_text">' . _('Shipment credits on Credit Note') . ' ';
}
echo $_SESSION['SuppTrans']->SuppReference . ' ' ._('From') . ' ' . $_SESSION['SuppTrans']->SupplierName;
echo '</p>';
echo '<table cellpadding="2" class="selection">';
$TableHeader = '<tr><th>' . _('Shipment') . '</th>
<th>' . _('Amount') . '</th></tr>';
echo $TableHeader;
$TotalShiptValue = 0;
foreach ($_SESSION['SuppTrans']->Shipts as $EnteredShiptRef){
echo '<tr><td>' . $EnteredShiptRef->ShiptRef . '</td>
<td class="number">' . locale_number_format($EnteredShiptRef->Amount,2) . '</td>
<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?Delete=' . $EnteredShiptRef->Counter . '">' . _('Delete') . '</a></td></tr>';
$TotalShiptValue = $TotalShiptValue + $EnteredShiptRef->Amount;
}
echo '<tr>
<td class="number">' . _('Total') . ':</td>
<td class="number">' . locale_number_format($TotalShiptValue,2) . '</td>
</tr>
</table><br />';
/*Set up a form to allow input of new Shipment charges */
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">';
echo '<div>';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if (!isset($_POST['ShiptRef'])) {
$_POST['ShiptRef']='';
}
echo '<table class="selection">';
echo '<tr>
<td>' . _('Shipment Reference') . ':</td>
<td><input class="integer" pattern="[1-9][\d]{0,10}" title="'._('The shiment Ref should be positive integer').'" placeholder="'._('positive integer').'" name="ShiptRef" size="12" maxlength="11" value="' . $_POST['ShiptRef'] . '" /></td>
</tr>';
echo '<tr>
<td>' . _('Shipment Selection') . ':
<br /> ' . _('If you know the code enter it above') . '
<br />' . _('otherwise select the shipment from the list') . '</td>
<td><select name="ShiptSelection">';
$sql = "SELECT shiptref,
vessel,
eta,
suppname
FROM shipments INNER JOIN suppliers
ON shipments.supplierid=suppliers.supplierid
WHERE closed='0'";
$result = DB_query($sql);
while ($myrow = DB_fetch_array($result)) {
if (isset($_POST['ShiptSelection']) and $myrow['shiptref']==$_POST['ShiptSelection']) {
echo '<option selected="selected" value="';
} else {
echo '<option value="';
}
echo $myrow['shiptref'] . '">' . $myrow['shiptref'] . ' - ' . $myrow['vessel'] . ' ' . _('ETA') . ' ' . ConvertSQLDate($myrow['eta']) . ' ' . _('from') . ' ' . $myrow['suppname'] . '</option>';
}
echo '</select></td>
</tr>';
if (!isset($_POST['Amount'])) {
$_POST['Amount']=0;
}
echo '<tr>
<td>' . _('Amount') . ':</td>
<td><input type="text" class="number" required="required" title="'._('The input must be non zero number').'" placeholder="'._('Non zero number').'" name="Amount" size="12" maxlength="11" value="' . locale_number_format($_POST['Amount'],$_SESSION['SuppTrans']->CurrDecimalPlaces) . '" /></td>
</tr>
</table>';
echo '<br />
<div class="centre">
<input type="submit" name="AddShiptChgToInvoice" value="' . _('Enter Shipment Charge') . '" />
</div>
</div>
</form>';
include('includes/footer.php');
?>