- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / weberp / Z_CreateCompany.php
blob025ecb42d78b509252cbca023e3be71e7396fa11
1 <?php
2 /* $Revision: 1.4 $ */
3 /*Script to insert a dummy sales order if one is not already set up - at least one order is needed for the sales order pages to work.
4 Also inserts a blank company record if one is not already set up */
6 $PageSecurity=15;
7 include ("includes/session.inc");
9 $title = _('UTILITY PAGE That sets up a new blank company record if not already existing');
11 include("includes/header.inc");
13 $sql = "SELECT COUNT(coycode) FROM companies";
14 $Result = DB_query($sql,$db);
15 $myrow = DB_fetch_row($Result);
16 if ($myrow[0]==0){
18 $sql = "INSERT INTO companies (coycode, coyname) VALUES (1,'Enter company name')";
19 $Result = DB_query($sql,$db);
20 } else {
21 echo '<P>' . _('An existing company record is set up already. No alterations have been made');
22 exit;
25 /*Need to have a sales order record set up */
27 $sql = "SELECT COUNT(orderno) FROM salesorders WHERE debtorno='NULL999' AND branchcode='NULL9'";
28 $Result = DB_query($sql,$db);
29 $myrow = DB_fetch_row($Result);
30 if ($myrow[0]==0){
31 $sql= "INSERT INTO salesorders VALUES ( '1',
32 'NULL999',
33 'NULL9',
34 '',
35 NULL,
36 NULL,
37 '1900-01-01 00:00:00',
38 '99',
39 '0',
40 '',
41 '',
42 '',
43 NULL,
44 NULL,
45 NULL,
46 '',
47 '0.00',
48 'NULL9',
49 '0000-00-00 00:00:00')";
50 $Result = DB_query($sql,$db);
53 /*The sales GL account group needs to be set up */
55 $sql = "SELECT COUNT(groupname) FROM accountgroups WHERE groupname='Sales'";
56 $Result = DB_query($sql,$db);
57 $myrow = DB_fetch_row($Result);
58 if ($myrow[0]==0){
60 $sql = "INSERT INTO accountgroups (groupname, sectioninaccounts, pandl, sequenceintb) VALUES ('Sales', 1, 1, 5)";
61 $Result = DB_query($sql,$db);
64 /*At least 1 GL acount needs to be set up for sales transactions */
66 $sql = "SELECT COUNT(accountcode) FROM chartmaster WHERE accountcode=1";
67 $Result = DB_query($sql,$db);
68 $myrow = DB_fetch_row($Result);
69 if ($myrow[0]==0){
71 $sql = "INSERT INTO chartmaster (accountcode, accountname, group_) VALUES (1,'Default Sales and Discounts', 'Sales')";
72 $Result = DB_query($sql,$db);
75 /* The default COGS GL Posting table is required */
77 $sql = "SELECT COUNT(stkcat) FROM cogsglpostings WHERE area='AN' AND stkcat='ANY'";
78 $Result = DB_query($sql,$db);
79 $myrow = DB_fetch_row($Result);
80 if ($myrow[0]==0){
82 $sql = "INSERT INTO cogsglpostings (area, stkcat, glcode) VALUES ('AN','ANY', 1)";
83 $Result = DB_query($sql,$db);
86 /* The default Sales GL Posting table is required */
88 $sql = "SELECT COUNT(stkcat) FROM salesglpostings WHERE area='AN' AND stkcat='ANY'";
89 $Result = DB_query($sql,$db);
90 $myrow = DB_fetch_row($Result);
91 if ($myrow[0]==0){
93 $sql = "INSERT INTO salesglpostings (area, stkcat, discountglcode, salesglcode) VALUES ('AN','ANY', 1, 1)";
94 $Result = DB_query($sql,$db);
98 echo '<P>' . _('Company record is now available for modification by clicking') . " <A HREF='" . $rootpath . "/CompanyPreferences.php'>" . _('this link') . "</A>";
101 include("includes/footer.inc");