-
Notifications
You must be signed in to change notification settings - Fork 3
/
CustEDISetup.php
155 lines (121 loc) · 5.5 KB
/
CustEDISetup.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
<?php
/* $Revision: 1.11 $ */
/* $Id$*/
include('includes/session.inc');
$title = _('Customer EDI Set Up');
include('includes/header.inc');
echo '<a href="' . $rootpath . '/SelectCustomer.php">' . _('Back to Customers') . '</a><br />';
if (isset($Errors)) {
unset($Errors);
}
$Errors = array();
$i=0;
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/customer.png" title="' . _('Search') . '" alt="" />' . ' ' . $title.'</p><br />';
if (isset($_POST['submit'])) {
//initialise no input errors assumed initially before we test
$InputError = 0;
/* actions to take once the user has clicked the submit button
ie the page has called itself with some user input */
//first off validate inputs sensible
if (ContainsIllegalCharacters($_POST['EDIReference'])) {
$InputError = 1;
prnMsg(_('The customers EDI reference code cannot contain any of the illegal characters') ,'warn');
}
if (strlen($_POST['EDIReference'])<4 AND ($_POST['EDIInvoices']==1 OR $_POST['EDIOrders']==1)){
$InputError = 1;
prnMsg(_('The customers EDI reference code must be set when EDI Invoices or EDI orders are activated'),'warn');
$Errors[$i] = 'EDIReference';
$i++;
}
if (strlen($_POST['EDIAddress'])<4 AND $_POST['EDIInvoices']==1){
$InputError = 1;
prnMsg(_('The customers EDI email address or FTP server address must be entered if EDI Invoices are to be sent'),'warn');
$Errors[$i] = 'EDIAddress';
$i++;
}
If ($InputError==0){ //ie no input errors
if (!isset($_POST['EDIServerUser'])){
$_POST['EDIServerUser']='';
}
if (!isset($_POST['EDIServerPwd'])){
$_POST['EDIServerPwd']='';
}
$sql = "UPDATE debtorsmaster SET ediinvoices ='" . $_POST['EDIInvoices'] . "',
ediorders ='" . $_POST['EDIOrders'] . "',
edireference='" . $_POST['EDIReference'] . "',
editransport='" . $_POST['EDITransport'] . "',
ediaddress='" . $_POST['EDIAddress'] . "',
ediserveruser='" . $_POST['EDIServerUser'] . "',
ediserverpwd='" . $_POST['EDIServerPwd'] . "'
WHERE debtorno = '" . $_SESSION['CustomerID'] . "'";
$ErrMsg = _('The customer EDI setup data could not be updated because');
$result = DB_query($sql,$db,$ErrMsg);
prnMsg(_('Customer EDI configuration updated'),'success');
} else {
prnMsg(_('Customer EDI configuration failed'),'error');
}
}
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table class="selection">';
$sql = "SELECT debtorno,
name,
ediinvoices,
ediorders,
edireference,
editransport,
ediaddress,
ediserveruser,
ediserverpwd
FROM debtorsmaster
WHERE debtorno = '" . $_SESSION['CustomerID'] . "'";
$ErrMsg = _('The customer EDI configuration details could not be retrieved because');
$result = DB_query($sql, $db,$ErrMsg);
$myrow = DB_fetch_array($result);
echo '<tr><td>'._('Customer Code').':</td>
<td>' . $_SESSION['CustomerID'] . '</td></tr>';
echo '<tr><td>'._('Customer Name').':</td>
<td>' . $myrow['name'] . '</td></tr>';
echo '<tr><td>'._('Enable Sending of EDI Invoices').':</td>
<td><select tabindex="1" name="EDIInvoices">';
if ($myrow['ediinvoices']==0){
echo '<option selected="True" value="0">'._('Disabled') . '</option>';
echo '<option value="1">'._('Enabled') . '</option>';
} else {
echo '<option value="0">'._('Disabled') . '</option>';
echo '<option selected="True" value="1">'._('Enabled') . '</option>';
}
echo '</select><a href="'.$rootpath.'/EDIMessageFormat.php?MessageType=INVOIC&PartnerCode=' . $_SESSION['CustomerID'] . '">'._('Create') . '/' . _('Edit Invoice Message Format').'</a></td></tr>';
echo '<tr><td>'._('Enable Receiving of EDI Orders').':</td>
<td><select tabindex="2" name="EDIOrders">';
if ($myrow['ediorders']==0){
echo '<option selected="True" value="0">'._('Disabled') . '</option>';
echo '<option value="1">'._('Enabled') . '</option>';
} else {
echo '<option value="0">'._('Disabled') . '</option>';
echo '<option selected="True" value="1">'._('Enabled') . '</option>';
}
echo '</select></td></tr>';
echo '<tr><td>'._('Customer EDI Reference').':</td>
<td><input tabindex="3" type="text" name="EDIReference" size="20" maxlength="20" value="' . $myrow['edireference'] . '" /></td></tr>';
echo '<tr><td>'._('EDI Communication Method').':</td>
<td><select tabindex="4" name="EDITransport">';
if ($myrow['editransport']=='email'){
echo '<option selected="True" value="email">'._('Email Attachments') . '</option>';
echo '<option value="ftp">'._('File Transfer Protocol (FTP)') . '</option>';
} else {
echo '<option value="email">'._('Email Attachments') . '</option>';
echo '<option selected="True" value="ftp">'._('File Transfer Protocol (FTP)') . '</option>';
}
echo '</select></td></tr>';
echo '<tr><td>'._('FTP Server or Email Address').':</td>
<td><input tabindex="5" type="text" name="EDIAddress" size="42" maxlength="40" value="' . $myrow['ediaddress'] . '" /></td></tr>';
if ($myrow['editransport']=='ftp'){
echo '<tr><td>'._('FTP Server User Name').':</td>
<td><input tabindex="6" type="text" name="EDIServerUser" size="20" maxlength="20" value="' . $myrow['ediserveruser'] . '" /></td></tr>';
echo '<tr><td>'._('FTP Server Password').':</td>
<td><input tabindex="7" type="text" name="EDIServerPwd" size="20" maxlength="20" value="' . $myrow['ediserverpwd'] . '" /></td></tr>';
}
echo '</table><br /><div class="centre"><button tabindex="8" type="submit" name="submit">'._('Update EDI Configuration').'</button></div><br /></form>';
include('includes/footer.inc');
?>