- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / weberp / SuppShiptChgs.php
blobd47e906a0942d92c9d0e5cebbeeb37184d724bf0
1 <?php
4 /* $Revision: 1.7 $ */
6 /*The supplier transaction uses the SuppTrans class to hold the information about the invoice
7 the SuppTrans class contains an array of Shipts objects - containing details of all shipment charges for invoicing
8 Shipment charges are posted to the debit of GRN suspense if the Creditors - GL link is on
9 This is cleared against credits to the GRN suspense when the products are received into stock and any
10 purchase price variance calculated when the shipment is closed */
12 include('includes/DefineSuppTransClass.php');
14 $PageSecurity = 5;
16 /* Session started here for password checking and authorisation level check */
17 include('includes/session.inc');
19 $title = _('Shipment Charges or Credits');
21 include('includes/header.inc');
23 if (!isset($_SESSION['SuppTrans'])){
24 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');
25 echo "<BR><A HREF='$rootpath/SelectSupplier.php?" . SID ."'>" . _('Select A Supplier') . '</A>';
26 exit;
27 /*It all stops here if there aint no supplier selected and invoice/credit initiated ie $_SESSION['SuppTrans'] started off*/
30 /*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*/
32 if (isset($_POST['AddShiptChgToInvoice'])){
34 $InputError = False;
35 if ($_POST['ShiptRef'] == ""){
36 $_POST['ShiptRef'] = $_POST['ShiptSelection'];
38 if (!is_numeric($_POST['ShiptRef'])){
39 prnMsg(_('The shipment reference must be numeric') . '. ' . _('This shipment charge cannot be added to the invoice'),'error');
40 $InputError = True;
43 if (!is_numeric($_POST['Amount'])){
44 prnMsg(_('The amount entered is not numeric') . '. ' . _('This shipment charge cannot be added to the invoice'),'error');
45 $InputError = True;
48 if ($InputError == False){
49 $_SESSION['SuppTrans']->Add_Shipt_To_Trans($_POST['ShiptRef'], $_POST['Amount']);
50 unset($_POST['ShiptRef']);
51 unset($_POST['Amount']);
55 if (isset($_GET['Delete'])){
57 $_SESSION['SuppTrans']->Remove_Shipt_From_Trans($_GET['Delete']);
60 /*Show all the selected ShiptRefs so far from the SESSION['SuppInv']->Shipts array */
61 if ($_SESSION['SuppTrans']->InvoiceOrCredit=='Invoice'){
62 echo '<CENTER><FONT SIZE=4 COLOR=BLUE>' . _('Shipment charges on Invoice') . ' ';
63 } else {
64 echo '<CENTER><FONT SIZE=4 COLOR=BLUE>' . _('Shipment credits on Credit Note') . ' ';
67 echo $_SESSION['SuppTrans']->SuppReference . ' ' ._('From') . ' ' . $_SESSION['SuppTrans']->SupplierName;
69 echo "<TABLE CELLPADDING=2>";
70 $TableHeader = "<TR><TD CLASS='tableheader'>" . _('Shipment') . "</TD>
71 <TD CLASS='tableheader'>" . _('Amount') . '</TD></TR>';
72 echo $TableHeader;
74 $TotalShiptValue = 0;
76 foreach ($_SESSION['SuppTrans']->Shipts as $EnteredShiptRef){
78 echo '<TR><TD>' . $EnteredShiptRef->ShiptRef . '</TD>
79 <TD ALIGN=RIGHT>' . number_format($EnteredShiptRef->Amount,2) . "</TD>
80 <TD><A HREF='" . $_SERVER['PHP_SELF'] . "?" . SID . "&Delete=" . $EnteredShiptRef->Counter . "'>" . _('Delete') . '</A></TD></TR>';
82 $TotalShiptValue = $TotalShiptValue + $EnteredShiptRef->Amount;
84 $i++;
85 if ($i>15){
86 $i = 0;
87 echo $TableHeader;
91 echo '<TR>
92 <TD COLSPAN=2 ALIGN=RIGHT><FONT SIZE=4 COLOR=BLUE>' . _('Total') . ':</FONT></TD>
93 <TD ALIGN=RIGHT><FONT SIZE=4 COLOR=BLUE><U>' . number_format($TotalShiptValue,2) . '</U></FONT></TD>
94 </TR>
95 </TABLE>';
97 if ($_SESSION['SuppTrans']->InvoiceOrCredit == 'Invoice'){
98 echo "<BR><A HREF='$rootpath/SupplierInvoice.php?" . SID . "'>" . _('Back to Invoice Entry') . '</A><HR>';
99 } else {
100 echo "<BR><A HREF='$rootpath/SupplierCredit.php?" . SID . "'>" . _('Back to Credit Note Entry') . '</A><HR>';
103 /*Set up a form to allow input of new Shipment charges */
104 echo "<FORM ACTION='" . $_SERVER['PHP_SELF'] . "?" . SID . "' METHOD=POST>";
106 echo '<TABLE>';
107 echo '<TR><TD>' . _('Shipment Reference') . ":</TD>
108 <TD><INPUT TYPE='Text' NAME='ShiptRef' SIZE=12 MAXLENGTH=11 VALUE=" . $_POST['ShiptRef'] . '></TD></TR>';
109 echo '<TR><TD>' . _('Shipment Selection') . ':<BR><FONT SIZE=1>' . _('If you know the code enter it above') . '<BR>' . _('otherwise select the shipment from the list') . "</FONT></TD><TD><SELECT NAME='ShiptSelection'>";
111 $sql = "SELECT shiptref,
112 vessel,
113 eta,
114 suppname
115 FROM shipments INNER JOIN suppliers
116 ON shipments.supplierid=suppliers.supplierid
117 WHERE closed=0";
119 $result = DB_query($sql, $db);
121 while ($myrow = DB_fetch_array($result)) {
122 if ($myrow['shiptref']==$_POST['ShiptSelection']) {
123 echo '<OPTION SELECTED VALUE=';
124 } else {
125 echo '<OPTION VALUE=';
127 echo $myrow['shiptref'] . '>' . $myrow['shiptref'] . ' - ' . $myrow['vessel'] . ' ' . _('ETA') . ' ' . ConvertSQLDate($myrow['eta']) . ' ' . _('from') . ' ' . $myrow['suppname'];
130 echo '</SELECT></TD></TR>';
132 echo '<TR><TD>' . _('Amount') . ":</TD>
133 <TD><INPUT TYPE='Text' NAME='Amount' SIZE=12 MAXLENGTH=11 VALUE=" . $_POST['Amount'] . '></TD></TR>';
134 echo '</TABLE>';
136 echo "<INPUT TYPE='Submit' NAME='AddShiptChgToInvoice' VALUE='" . _('Enter Shipment Charge') . "'>";
138 echo '</FORM>';
139 include('includes/footer.inc');