3 /* $Revision: 1.12 $ */
7 include ('includes/session.inc');
8 $title = _('Recalculation of GL Balances in Chart Details Table');
9 include('includes/header.inc');
11 echo "<FORM METHOD='POST' ACTION=" . $_SERVER['PHP_SELF'] . '?' . SID
. '>';
13 if (!isset($_POST['FromPeriod'])){
15 /*Show a form to allow input of criteria for TB to show */
18 <TD>' . _('Select Period From') . ":</TD>
19 <TD><SELECT Name='FromPeriod'>";
21 $sql = 'SELECT periodno,
23 FROM periods ORDER BY periodno';
24 $Periods = DB_query($sql,$db);
26 while ($myrow=DB_fetch_array($Periods,$db)){
27 echo '<OPTION VALUE=' . $myrow['periodno'] . '>' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
34 echo "<INPUT TYPE=SUBMIT Name='recalc' Value='" . _('Do the Recalculation') . "' onclick=\"return confirm('" . _('Are you sure you wish to re-post all general ledger transactions since the selected period .... this can take some time?') . '\');"></CENTER></FORM>';
36 } else { /*OK do the updates */
38 /* Make the posted flag on all GL entries including and after the period selected = 0 */
39 $sql = 'UPDATE gltrans SET posted=0 WHERE periodno >='. $_POST['FromPeriod'];
40 $UpdGLTransPostedFlag = DB_query($sql,$db);
42 /* Now make all the actuals 0 for all periods including and after the period from */
43 $sql = 'UPDATE chartdetails SET actual =0 WHERE period >= ' . $_POST['FromPeriod'];
44 $UpdActualChartDetails = DB_query($sql,$db);
46 $ChartDetailBFwdResult = DB_query('SELECT accountcode, bfwd FROM chartdetails WHERE period=' . $_POST['FromPeriod'],$db);
47 while ($ChartRow=DB_fetch_array($ChartDetailBFwdResult)){
48 $sql = 'UPDATE chartdetails SET bfwd =' . $ChartRow['bfwd'] . ' WHERE period > ' . $_POST['FromPeriod'] . ' AND accountcode=' . $ChartRow['accountcode'];
49 $UpdActualChartDetails = DB_query($sql,$db);
52 /*Now repost the lot */
54 include('includes/GLPostings.inc');
56 prnMsg(_('All general ledger postings have been reposted from period') . ' ' . $_POST['FromPeriod'],'success');
58 include('includes/footer.inc');