- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / weberp / CompanyPreferences.php
blob44f2891f74de92efa6508c44c62fdad5751a24a7
1 <?php
3 /* $Revision: 1.14 $ */
5 $PageSecurity =10;
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
16 $InputError = 0;
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) {
25 $InputError = 1;
26 prnMsg(_('The company name must be entered and be fifty characters or less long'), 'error');
27 } elseif (strlen($_POST['RegOffice1']) >40) {
28 $InputError = 1;
29 prnMsg(_('The Line 1 of the address must be forty characters or less long'),'error');
30 } elseif (strlen($_POST['RegOffice2']) >40) {
31 $InputError = 1;
32 prnMsg(_('The Line 2 of the address must be forty characters or less long'),'error');
33 } elseif (strlen($_POST['RegOffice3']) >40) {
34 $InputError = 1;
35 prnMsg(_('The Line 3 of the address must be forty characters or less long'),'error');
36 } elseif (strlen($_POST['RegOffice4']) >40) {
37 $InputError = 1;
38 prnMsg(_('The Line 4 of the address must be forty characters or less long'),'error');
39 } elseif (strlen($_POST['RegOffice5']) >20) {
40 $InputError = 1;
41 prnMsg(_('The Line 5 of the address must be twenty characters or less long'),'error');
42 } elseif (strlen($_POST['RegOffice6']) >15) {
43 $InputError = 1;
44 prnMsg(_('The Line 6 of the address must be fifteen characters or less long'),'error');
45 } elseif (strlen($_POST['Telephone']) >25) {
46 $InputError = 1;
47 prnMsg(_('The telephone number must be 25 characters or less long'),'error');
48 } elseif (strlen($_POST['Fax']) >25) {
49 $InputError = 1;
50 prnMsg(_('The fax number must be 25 characters or less long'),'error');
51 } elseif (strlen($_POST['Email']) >55) {
52 $InputError = 1;
53 prnMsg(_('The email address must be 55 characters or less long'),'error');
56 if ($InputError !=1){
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']) . "
84 WHERE coycode=1";
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;
94 } else {
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,
106 gstno,
107 companynumber,
108 regoffice1,
109 regoffice2,
110 regoffice3,
111 regoffice4,
112 regoffice5,
113 regoffice6,
114 telephone,
115 fax,
116 email,
117 currencydefault,
118 debtorsact,
119 pytdiscountact,
120 creditorsact,
121 payrollact,
122 grnact,
123 exchangediffact,
124 purchasesexchangediffact,
125 retainedearnings,
126 gllink_debtors,
127 gllink_creditors,
128 gllink_stock,
129 freightact
130 FROM companies
131 WHERE coycode=1";
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>
169 </TR>';
171 echo '<TR><TD>' . _('Official Company Number') . ':</TD>
172 <TD><input type="Text" Name="CompanyNumber" value="' . $_POST['CompanyNumber'] . '" SIZE=22 MAXLENGTH=20></TD>
173 </TR>';
175 echo '<TR><TD>' . _('Tax Authority Reference') . ':</TD>
176 <TD><input type="Text" Name="GSTNo" value="' . $_POST['GSTNo'] . '" SIZE=22 MAXLENGTH=20></TD>
177 </TR>';
179 echo '<TR><TD>' . _('Address Line 1') . ':</TD>
180 <TD><input type="Text" Name="RegOffice1" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice1'] . '"></TD>
181 </TR>';
183 echo '<TR><TD>' . _('Address Line 2') . ':</TD>
184 <TD><input type="Text" Name="RegOffice2" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice2'] . '"></TD>
185 </TR>';
187 echo '<TR><TD>' . _('Address Line 3') . ':</TD>
188 <TD><input type="Text" Name="RegOffice3" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice3'] . '"></TD>
189 </TR>';
191 echo '<TR><TD>' . _('Address Line 4') . ':</TD>
192 <TD><input type="Text" Name="RegOffice4" SIZE=42 MAXLENGTH=40 value="' . $_POST['RegOffice4'] . '"></TD>
193 </TR>';
195 echo '<TR><TD>' . _('Address Line 5') . ':</TD>
196 <TD><input type="Text" Name="RegOffice5" SIZE=22 MAXLENGTH=20 value="' . $_POST['RegOffice5'] . '"></TD>
197 </TR>';
199 echo '<TR><TD>' . _('Address Line 6') . ':</TD>
200 <TD><input type="Text" Name="RegOffice6" SIZE=17 MAXLENGTH=15 value="' . $_POST['RegOffice6'] . '"></TD>
201 </TR>';
203 echo '<TR><TD>' . _('Telephone Number') . ':</TD>
204 <TD><input type="Text" Name="Telephone" SIZE=26 MAXLENGTH=25 value="' . $_POST['Telephone'] . '"></TD>
205 </TR>';
207 echo '<TR><TD>' . _('Facsimile Number') . ':</TD>
208 <TD><input type="Text" Name="Fax" SIZE=26 MAXLENGTH=25 value="' . $_POST['Fax'] . '"></TD>
209 </TR>';
211 echo '<TR><TD>' . _('Email Address') . ':</TD>
212 <TD><input type="Text" Name="Email" SIZE=50 MAXLENGTH=55 value="' . $_POST['Email'] . '"></TD>
213 </TR>';
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'];
223 } else {
224 echo "<OPTION VALUE='". $myrow['currabrev'] . "'>" . $myrow['currency'];
226 } //end while loop
228 DB_free_result($result);
230 echo '</SELECT></TD></TR>';
232 $result=DB_query("SELECT accountcode,
233 accountname
234 FROM chartmaster,
235 accountgroups
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].')';
245 } else {
246 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
248 } //end while loop
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].')';
259 } else {
260 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
262 } //end while loop
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].')';
273 } else {
274 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
276 } //end while loop
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].')';
287 } else {
288 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
290 } //end while loop
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].')';
300 } else {
301 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
303 } //end while loop
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,
312 accountname
313 FROM chartmaster,
314 accountgroups
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].')';
322 } else {
323 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
325 } //end while loop
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].')';
336 } else {
337 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
339 } //end while loop
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].')';
350 } else {
351 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
353 } //end while loop
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].')';
364 } else {
365 echo "<OPTION VALUE='". $myrow[0] . "'>" . $myrow[1] . ' ('.$myrow[0].')';
367 } //end while loop
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');
378 } else {
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');
390 } else {
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');
402 } else {
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');