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 */
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);
18 $sql = "INSERT INTO companies (coycode, coyname) VALUES (1,'Enter company name')";
19 $Result = DB_query($sql,$db);
21 echo '<P>' . _('An existing company record is set up already. No alterations have been made');
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);
31 $sql= "INSERT INTO salesorders VALUES ( '1',
37 '1900-01-01 00:00:00',
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);
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);
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);
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);
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");