3 /* $Revision: 1.14 $ */
7 include('includes/session.inc');
9 $title = _('Company Preferences');
11 include('includes/header.inc');
13 if (isset($_POST['submit'])) {
15 //initialise no input errors assumed initially before we test
18 /* actions to take once the user has clicked the submit button
19 ie the page has called itself with some user input */
22 //first off validate inputs sensible
24 if (strlen($_POST['CoyName']) > 40 OR strlen($_POST['CoyName'])==0) {
26 prnMsg(_('The company name must be entered and be fifty characters or less long'), 'error');
27 } elseif (strlen($_POST['RegOffice1']) >40) {
29 prnMsg(_('The Line 1 of the address must be forty characters or less long'),'error');
30 } elseif (strlen($_POST['RegOffice2']) >40) {
32 prnMsg(_('The Line 2 of the address must be forty characters or less long'),'error');
33 } elseif (strlen($_POST['RegOffice3']) >40) {
35 prnMsg(_('The Line 3 of the address must be forty characters or less long'),'error');
36 } elseif (strlen($_POST['RegOffice4']) >40) {
38 prnMsg(_('The Line 4 of the address must be forty characters or less long'),'error');
39 } elseif (strlen($_POST['RegOffice5']) >20) {
41 prnMsg(_('The Line 5 of the address must be twenty characters or less long'),'error');
42 } elseif (strlen($_POST['RegOffice6']) >15) {
44 prnMsg(_('The Line 6 of the address must be fifteen characters or less long'),'error');
45 } elseif (strlen($_POST['Telephone']) >25) {
47 prnMsg(_('The telephone number must be 25 characters or less long'),'error');
48 } elseif (strlen($_POST['Fax']) >25) {
50 prnMsg(_('The fax number must be 25 characters or less long'),'error');
51 } elseif (strlen($_POST['Email']) >55) {
53 prnMsg(_('The email address must be 55 characters or less long'),'error');
58 $sql = "UPDATE companies SET
59 coyname='" . DB_escape_string($_POST['CoyName']) . "',
60 companynumber = '" . DB_escape_string($_POST['CompanyNumber']) . "',
61 gstno='" . DB_escape_string($_POST['GSTNo']) . "',
62 regoffice1='" . DB_escape_string($_POST['RegOffice1']) . "',
63 regoffice2='" . DB_escape_string($_POST['RegOffice2']) . "',
64 regoffice3='" . DB_escape_string($_POST['RegOffice3']) . "',
65 regoffice4='" . DB_escape_string($_POST['RegOffice4']) . "',
66 regoffice5='" . DB_escape_string($_POST['RegOffice5']) . "',
67 regoffice6='" . DB_escape_string($_POST['RegOffice6']) . "',
68 telephone='" . DB_escape_string($_POST['Telephone']) . "',
69 fax='" . DB_escape_string($_POST['Fax']) . "',
70 email='" . DB_escape_string($_POST['Email']) . "',
71 currencydefault='" . DB_escape_string($_POST['CurrencyDefault']) . "',
72 debtorsact=" . DB_escape_string($_POST['DebtorsAct']) . ",
73 pytdiscountact=" . DB_escape_string($_POST['PytDiscountAct']) . ",
74 creditorsact=" . DB_escape_string($_POST['CreditorsAct']) . ",
75 payrollact=" . DB_escape_string($_POST['PayrollAct']) . ",
76 grnact=" . DB_escape_string($_POST['GRNAct']) . ",
77 exchangediffact=" . DB_escape_string($_POST['ExchangeDiffAct']) . ",
78 purchasesexchangediffact=" . DB_escape_string($_POST['PurchasesExchangeDiffAct']) . ",
79 retainedearnings=" . DB_escape_string($_POST['RetainedEarnings']) . ",
80 gllink_debtors=" . $_POST['GLLink_Debtors'] . ",
81 gllink_creditors=" . $_POST['GLLink_Creditors'] . ",
82 gllink_stock=" . $_POST['GLLink_Stock'] .",
83 freightact=" . DB_escape_string($_POST['FreightAct']) . "
86 $ErrMsg = _('The company preferences could not be updated because');
87 $result = DB_query($sql,$db,$ErrMsg);
88 prnMsg( _('Company preferences updated'),'success');
90 $ForceConfigReload = True; // Required to force a load even if stored in the session vars
91 include('includes/GetConfig.php');
92 $ForceConfigReload = False;
95 prnMsg( _('Validation failed') . ', ' . _('no updates or deletes took place'),'warn');
98 } /* end of if submit */
102 echo '<FORM METHOD="post" action=' . $_SERVER['PHP_SELF'] . '>';
103 echo '<CENTER><TABLE>';
105 $sql = "SELECT coyname,
124 purchasesexchangediffact,
135 $ErrMsg = _('The company preferences could not be retrieved because');
136 $result = DB_query($sql, $db,$ErrMsg);
139 $myrow = DB_fetch_array($result);
141 $_POST['CoyName'] = $myrow['coyname'];
142 $_POST['GSTNo'] = $myrow['gstno'];
143 $_POST['CompanyNumber'] = $myrow['companynumber'];
144 $_POST['RegOffice1'] = $myrow['regoffice1'];
145 $_POST['RegOffice2'] = $myrow['regoffice2'];
146 $_POST['RegOffice3'] = $myrow['regoffice3'];
147 $_POST['RegOffice4'] = $myrow['regoffice4'];
148 $_POST['RegOffice5'] = $myrow['regoffice5'];
149 $_POST['RegOffice6'] = $myrow['regoffice6'];
150 $_POST['Telephone'] = $myrow['telephone'];
151 $_POST['Fax'] = $myrow['fax'];
152 $_POST['Email'] = $myrow['email'];
153 $_POST['CurrencyDefault'] = $myrow['currencydefault'];
154 $_POST['DebtorsAct'] = $myrow['debtorsact'];
155 $_POST['PytDiscountAct'] = $myrow['pytdiscountact'];
156 $_POST['CreditorsAct'] = $myrow['creditorsact'];
157 $_POST['PayrollAct'] = $myrow['payrollact'];
158 $_POST['GRNAct'] = $myrow['grnact'];
159 $_POST['ExchangeDiffAct'] = $myrow['exchangediffact'];
160 $_POST['PurchasesExchangeDiffAct'] = $myrow['purchasesexchangediffact'];
161 $_POST['RetainedEarnings'] = $myrow['retainedearnings'];
162 $_POST['GLLink_Debtors'] = $myrow['gllink_debtors'];
163 $_POST['GLLink_Creditors'] = $myrow['gllink_creditors'];
164 $_POST['GLLink_Stock'] = $myrow['gllink_stock'];
165 $_POST['FreightAct'] = $myrow['freightact'];
167 echo '<TR><TD>' . _('Name') . ' (' . _('to appear on reports') . '):</TD>
168 <TD><input type="Text" Name="CoyName" value="' . $_POST['CoyName'] . '" SIZE=52 MAXLENGTH=50></TD>
171 echo '<TR><TD>' . _('Official Company Number') . ':</TD>
172 <TD><input type="Text" Name="CompanyNumber" value="' . $_POST['CompanyNumber'] . '" SIZE=22 MAXLENGTH=20></TD>
175 echo '<TR><TD>' . _('Tax Authority Reference') . ':</TD>
176 <TD><input type="Text" Name="GSTNo" value="' . $_POST['GSTNo'] . '" SIZE=22 MAXLENGTH=20></TD>
179 echo '<TR><TD>' . _('Address Line 1') . ':</TD>
180 <TD><input type="Text" Name="RegOffice1" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice1'] . '"></TD>
183 echo '<TR><TD>' . _('Address Line 2') . ':</TD>
184 <TD><input type="Text" Name="RegOffice2" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice2'] . '"></TD>
187 echo '<TR><TD>' . _('Address Line 3') . ':</TD>
188 <TD><input type="Text" Name="RegOffice3" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice3'] . '"></TD>
191 echo '<TR><TD>' . _('Address Line 4') . ':</TD>
192 <TD><input type="Text" Name="RegOffice4" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice4'] . '"></TD>
195 echo '<TR><TD>' . _('Address Line 5') . ':</TD>
196 <TD><input type="Text" Name="RegOffice5" SIZE=22 MAXLENGTH=20 value="' . $_POST['RegOffice5'] . '"></TD>
199 echo '<TR><TD>' . _('Address Line 6') . ':</TD>
200 <TD><input type="Text" Name="RegOffice6" SIZE=17 MAXLENGTH=15 value="' . $_POST['RegOffice6'] . '"></TD>
203 echo '<TR><TD>' . _('Telephone Number') . ':</TD>
204 <TD><input type="Text" Name="Telephone" SIZE=26 MAXLENGTH=25 value="' . $_POST['Telephone'] . '"></TD>
207 echo '<TR><TD>' . _('Facsimile Number') . ':</TD>
208 <TD><input type="Text" Name="Fax" SIZE=26 MAXLENGTH=25 value="' . $_POST['Fax'] . '"></TD>
211 echo '<TR><TD>' . _('Email Address') . ':</TD>
212 <TD><input type="Text" Name="Email" SIZE=50 MAXLENGTH=55 value="' . $_POST['Email'] . '"></TD>
216 $result=DB_query("SELECT currabrev, currency FROM currencies",$db);
218 echo '<TR><TD>' . _('Home Currency') . ':</TD><TD><SELECT Name=CurrencyDefault>';
220 while ($myrow = DB_fetch_array($result)) {
221 if ($_POST['CurrencyDefault']==$myrow['currabrev']){
222 echo "<OPTION SELECTED VALUE='". $myrow['currabrev'] . "'>" . $myrow['currency'];
224 echo "<OPTION VALUE='". $myrow['currabrev'] . "'>" . $myrow['currency'];
228 DB_free_result($result);
230 echo '</SELECT></TD></TR>';
232 $result=DB_query("SELECT accountcode,
236 WHERE chartmaster.group_=accountgroups.groupname
237 AND accountgroups.pandl=0
238 ORDER BY chartmaster.accountcode",$db);
240 echo '<TR><TD>' . _('Debtors Control GL Account') . ':</TD><TD><SELECT Name=DebtorsAct>';
242 while ($myrow = DB_fetch_row($result)) {
243 if ($_POST['DebtorsAct']==$myrow[0]){
244 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
246 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
250 DB_data_seek($result,0);
252 echo '</SELECT></TD></TR>';
254 echo '<TR><TD>' . _('Creditors Control GL Account') . ':</TD><TD><SELECT Name=CreditorsAct>';
256 while ($myrow = DB_fetch_row($result)) {
257 if ($_POST['CreditorsAct']==$myrow[0]){
258 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
260 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
264 DB_data_seek($result,0);
266 echo '</SELECT></TD></TR>';
268 echo '<TR><TD>' . _('Payroll Net Pay Clearing GL Account') . ':</TD><TD><SELECT Name=PayrollAct>';
270 while ($myrow = DB_fetch_row($result)) {
271 if ($_POST['PayrollAct']==$myrow[0]){
272 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
274 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
278 DB_data_seek($result,0);
280 echo '</SELECT></TD></TR>';
282 echo '<TR><TD>' . _('Goods Received Clearing GL Account') . ':</TD><TD><SELECT Name=GRNAct>';
284 while ($myrow = DB_fetch_row($result)) {
285 if ($_POST['GRNAct']==$myrow[0]){
286 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
288 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
292 DB_data_seek($result,0);
293 echo '</SELECT></TD></TR>';
295 echo '<TR><TD>' . _('Retained Earning Clearing GL Account') . ':</TD><TD><SELECT Name=RetainedEarnings>';
297 while ($myrow = DB_fetch_row($result)) {
298 if ($_POST['RetainedEarnings']==$myrow[0]){
299 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
301 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
305 DB_free_result($result);
307 echo '</SELECT></TD></TR>';
309 echo '<TR><TD>' . _('Freight Re-charged GL Account') . ':</TD><TD><SELECT Name=FreightAct>';
311 $result=DB_query('SELECT accountcode,
315 WHERE chartmaster.group_=accountgroups.groupname
316 AND accountgroups.pandl=1
317 ORDER BY chartmaster.accountcode',$db);
319 while ($myrow = DB_fetch_row($result)) {
320 if ($_POST['FreightAct']==$myrow[0]){
321 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
323 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
327 DB_data_seek($result,0);
329 echo '</SELECT></TD></TR>';
331 echo '<TR><TD>' . _('Sales Exchange Variances GL Account') . ':</TD><TD><SELECT Name=ExchangeDiffAct>';
333 while ($myrow = DB_fetch_row($result)) {
334 if ($_POST['ExchangeDiffAct']==$myrow[0]){
335 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
337 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
341 DB_data_seek($result,0);
343 echo '</SELECT></TD></TR>';
345 echo '<TR><TD>' . _('Purchases Exchange Variances GL Account') . ':</TD><TD><SELECT Name=PurchasesExchangeDiffAct>';
347 while ($myrow = DB_fetch_row($result)) {
348 if ($_POST['PurchasesExchangeDiffAct']==$myrow[0]){
349 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
351 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
355 DB_data_seek($result,0);
357 echo '</SELECT></TD></TR>';
359 echo '<TR><TD>' . _('Payment Discount GL Account') . ':</TD><TD><SELECT Name=PytDiscountAct>';
361 while ($myrow = DB_fetch_row($result)) {
362 if ($_POST['PytDiscountAct']==$myrow[0]){
363 echo "<OPTION SELECTED VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
365 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
369 DB_data_seek($result,0);
371 echo '</SELECT></TD></TR>';
373 echo '<TR><TD>' . _('Create GL entries for accounts receivable transactions') . ':</TD><TD><SELECT Name=GLLink_Debtors>';
375 if ($_POST['GLLink_Debtors']==0){
376 echo '<OPTION SELECTED VALUE=0>' . _('No');
377 echo '<OPTION VALUE=1>' . _('Yes');
379 echo '<OPTION SELECTED VALUE=1>' . _('Yes');
380 echo '<OPTION VALUE=0>' . _('No');
383 echo '</SELECT></TD></TR>';
385 echo '<TR><TD>' . _('Create GL entries for accounts payable transactions') . ':</TD><TD><SELECT Name=GLLink_Creditors>';
387 if ($_POST['GLLink_Creditors']==0){
388 echo '<OPTION SELECTED VALUE=0>' . _('No');
389 echo '<OPTION VALUE=1>' . _('Yes');
391 echo '<OPTION SELECTED VALUE=1>' . _('Yes');
392 echo '<OPTION VALUE=0>' . _('No');
395 echo '</SELECT></TD></TR>';
397 echo '<TR><TD>' . _('Create GL entries for stock transactions') . ' (' . _('at standard cost') . '):</TD><TD><SELECT Name=GLLink_Stock>';
399 if ($_POST['GLLink_Stock']==0){
400 echo '<OPTION SELECTED VALUE=0>' . _('No');
401 echo '<OPTION VALUE=1>' . _('Yes');
403 echo '<OPTION SELECTED VALUE=1>' . _('Yes');
404 echo '<OPTION VALUE=0>' . _('No');
407 echo '</SELECT></TD></TR>';
410 echo '</TABLE><CENTER><input type="Submit" Name="submit" value="' . _('Update') . '">';
412 include('includes/footer.inc');