From: <dai...@us...> - 2011-05-15 04:34:57
|
Revision: 4567 http://web-erp.svn.sourceforge.net/web-erp/?rev=4567&view=rev Author: daintree Date: 2011-05-15 04:34:49 +0000 (Sun, 15 May 2011) Log Message: ----------- various Modified Paths: -------------- trunk/FixedAssetCategories.php trunk/Logout.php trunk/PO_AuthorisationLevels.php trunk/PO_Header.php trunk/PcAssignCashToTab.php trunk/PcAuthorizeExpenses.php trunk/PcClaimExpensesFromTab.php trunk/PcExpenses.php trunk/PcExpensesTypeTab.php trunk/PcReportTab.php trunk/PcTabs.php trunk/PcTypeTabs.php trunk/UnitsOfMeasure.php trunk/doc/Change.log trunk/includes/Login.php Modified: trunk/FixedAssetCategories.php =================================================================== --- trunk/FixedAssetCategories.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/FixedAssetCategories.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -50,10 +50,9 @@ $InputError =1; } /*Make an array of the defined bank accounts */ - $SQL = 'SELECT bankaccounts.accountcode - FROM bankaccounts, - chartmaster - WHERE bankaccounts.accountcode=chartmaster.accountcode'; + $SQL = "SELECT bankaccounts.accountcode + FROM bankaccounts INNER JOIN chartmaster + ON bankaccounts.accountcode=chartmaster.accountcode"; $result = DB_query($SQL,$db); $BankAccounts = array(); $i=0; @@ -123,7 +122,7 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'fixedassets' - $sql= "SELECT COUNT(*) FROM fixedasset WHERE fixedassets.assetcategoryid='" . $SelectedCategory . "'"; + $sql= "SELECT COUNT(*) FROM fixedassets WHERE fixedassets.assetcategoryid='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { Modified: trunk/Logout.php =================================================================== --- trunk/Logout.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/Logout.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -23,7 +23,7 @@ <?php echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; ?> - <span><?php echo _('Thank you for using webERP'); ?></span> + <span><?php echo _('Thank you for using webERP'); ?></span> <br /> <input class="button" type="submit" value="<?php echo _('Login'); ?>" name="SubmitUser" /> </form> Modified: trunk/PO_AuthorisationLevels.php =================================================================== --- trunk/PO_AuthorisationLevels.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PO_AuthorisationLevels.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -8,18 +8,21 @@ include('includes/header.inc'); echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/group_add.png" title="' . _('Search') . '" alt="" />' . ' ' . $title.'</p><br />'; -$User=''; -$Currency=''; -$CanCreate=1; -$OffHold=1; -$AuthLevel=0; + + +/*Note: If CanCreate==0 then this means the user can create orders + * Also if OffHold==0 then the user can release purchase invocies + * This logic confused me a bit to start with + */ + + if (isset($_POST['Submit'])) { - if (isset($_POST['CanCreate']) and $_POST['CanCreate']=='on') { + if (isset($_POST['CanCreate']) AND $_POST['CanCreate']=='on') { $CanCreate=0; } else { $CanCreate=1; } - if (isset($_POST['OffHold']) and $_POST['OffHold']=='on') { + if (isset($_POST['OffHold']) AND $_POST['OffHold']=='on') { $OffHold=0; } else { $OffHold=1; @@ -48,17 +51,17 @@ $Result=DB_query($sql,$db,$ErrMsg); } else { prnMsg(_('There already exists an entry for this user/currency combination'), 'error'); - echo '<br />'; + echo '<br />'; } } if (isset($_POST['Update'])) { - if (isset($_POST['CanCreate']) and $_POST['CanCreate']=='on') { + if (isset($_POST['CanCreate']) AND $_POST['CanCreate']=='on') { $CanCreate=0; } else { $CanCreate=1; } - if (isset($_POST['OffHold']) and $_POST['OffHold']=='on') { + if (isset($_POST['OffHold']) AND $_POST['OffHold']=='on') { $OffHold=0; } else { $OffHold=1; @@ -69,7 +72,7 @@ authlevel='".$_POST['AuthLevel']."' WHERE userid='".$_POST['UserID']."' AND currabrev='".$_POST['CurrCode']."'"; - + $ErrMsg = _('The authentication details cannot be updated because'); $Result=DB_query($sql,$db,$ErrMsg); } @@ -104,6 +107,7 @@ www_users.realname, currencies.currabrev, currencies.currency, + currencies.decimalplaces, purchorderauth.cancreate, purchorderauth.offhold, purchorderauth.authlevel @@ -125,22 +129,22 @@ while ($myrow=DB_fetch_array($Result)) { if ($myrow['cancreate']==0) { - $CanCreate=_('Yes'); + $DisplayCanCreate=_('Yes'); } else { - $CanCreate=_('No'); + $DisplayCanCreate=_('No'); } if ($myrow['offhold']==0) { - $OffHold=_('Yes'); + $DisplayOffHold=_('Yes'); } else { - $OffHold=_('No'); + $DisplayOffHold=_('No'); } echo '<tr> <td>' . $myrow['userid'] . '</td> <td>' . $myrow['realname'] . '</td> <td>' . $myrow['currency'] . '</td> - <td>' . $CanCreate . '</td> - <td>' . $OffHold . '</td> - <td class="number">'.number_format($myrow['authlevel'],2).'</td> + <td>' . $DisplayCanCreate . '</td> + <td>' . $DisplayOffHold . '</td> + <td class="number">'.number_format($myrow['authlevel'],$myrow['decimalplaces']).'</td> <td><a href="'.$rootpath.'/PO_AuthorisationLevels.php?Edit=Yes&UserID=' . $myrow['userid'] . '&Currency='.$myrow['currabrev'].'">'._('Edit').'</td> <td><a href="'.$rootpath.'/PO_AuthorisationLevels.php?Delete=Yes&UserID=' . $myrow['userid'] . @@ -150,15 +154,23 @@ echo '</table><br><br>'; +if (!isset($_GET['Edit'])) { + $UserID=$_SESSION['UserID']; + $Currency=$_SESSION['CompanyRecord']['currencydefault']; + $CanCreate=0; + $OffHold=0; + $AuthLevel=0; +} + echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" name="form1">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table class=selection>'; if (isset($_GET['Edit'])) { - echo '<tr><td>'._('User ID').'</td><td>'.$UserID.'</td></tr>'; - echo '<input type=hidden name=UserID value="'.$UserID.'"'; + echo '<tr><td>'._('User ID').'</td><td>'.$_GET['UserID'].'</td></tr>'; + echo '<input type="hidden" name="UserID" value="'.$_GET['UserID'].'" />'; } else { - echo '<tr><td>'._('User ID').'</td><td><select name=UserID>'; + echo '<tr><td>'._('User ID').'</td><td><select name="UserID">'; $usersql="SELECT userid FROM www_users"; $userresult=DB_query($usersql,$db); while ($myrow=DB_fetch_array($userresult)) { @@ -172,14 +184,28 @@ } if (isset($_GET['Edit'])) { - $CurrencySQL="SELECT currency FROM currencies WHERE currabrev='".$Currency."'"; - $CurrencyResult=DB_query($CurrencySQL,$db); - $myrow=DB_fetch_array($CurrencyResult); + $sql="SELECT cancreate, + offhold, + authlevel, + currency + FROM purchorderauth INNER JOIN currencies + ON purchorderauth.currabrev=currencies.currabrev + WHERE userid='".$_GET['UserID']."' + AND purchorderauth.currabrev='".$_GET['Currency']."'"; + $ErrMsg = _('The authentication details cannot be retrieved because'); + $result=DB_query($sql,$db,$ErrMsg); + $myrow=DB_fetch_array($result); + $UserID=$_GET['UserID']; + $Currency=$_GET['Currency']; + $CanCreate=$myrow['cancreate']; + $OffHold=$myrow['offhold']; + $AuthLevel=$myrow['authlevel']; + echo '<tr> <td>'._('Currency').'</td> <td>' . $myrow['currency'] . '</td> </tr>'; - echo '<input type=hidden name="currabrev" value="'.$Currency.'"'; + echo '<input type=hidden name="CurrCode" value="'.$Currency.'"'; } else { echo '<tr><td>'._('Currency').'</td><td><select name="CurrCode">'; $currencysql="SELECT currabrev,currency FROM currencies"; Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PO_Header.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -653,7 +653,7 @@ $PurchItemRow['leadtime'], $PurchItemRow['suppliers_partno'] ); - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/PO_Items.php?identifier='.$identifier. "'>"; + echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/PO_Items.php?identifier='.$identifier. '">'; } /*Set up form for entry of order header stuff */ Modified: trunk/PcAssignCashToTab.php =================================================================== --- trunk/PcAssignCashToTab.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcAssignCashToTab.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -23,12 +23,31 @@ $Days = $_GET['Days']; } -if (isset($Errors)) { - unset($Errors); +if (isset($_POST['Cancel'])) { + unset($SelectedTabs); + unset($SelectedIndex); + unset($Days); + unset($_POST['Amount']); + unset($_POST['Notes']); + unset($_POST['Receipt']); } -$Errors = array(); +if (isset($_POST['process'])) { + if ($SelectedTabs=='') { + prnMsg(_('You Must First Select a Petty Cash Tab To Assign Cash'),'error'); + unset($SelectedTabs); + } +} +if (isset($_POST['Go'])) { + $InputError = 0; + if ($Days<=0) { + $InputError = 1; + prnMsg(_('The number of days must be a positive number'),'error'); + $Days=30; + } +} + if (isset($_POST['submit'])) { //initialise no input errors assumed initially before we test $InputError = 0; @@ -43,9 +62,7 @@ if ($_POST['Amount']==0) { $InputError = 1; - prnMsg('<br />' . _('The Amount must be inputed'),'error'); - $Errors[$i] = 'TabCode'; - $i++; + prnMsg('<br />' . _('The Amount must be input'),'error'); } $sqlLimit = "SELECT tablimit @@ -56,7 +73,7 @@ $Limit=DB_fetch_array($ResultLimit); if (($_POST['CurrentAmount']+$_POST['Amount'])>$Limit['tablimit']){ - prnMsg('<br />' . _('The balance after this assignment would be greater than the specified limit for this PC tab'),'warning'); + prnMsg(_('The balance after this assignment would be greater than the specified limit for this PC tab'),'warning'); } if ($InputError !=1 AND isset($SelectedIndex) ) { @@ -92,7 +109,7 @@ '" . $_POST['Notes'] . "', '" . $_POST['Receipt'] . "' )"; - $msg = _('Assignment of cash to PC Tab ') . ' ' . $_POST["SelectedTabs"] . ' ' . _('has been created'); + $msg = _('Assignment of cash to PC Tab ') . ' ' . $_POST['SelectedTabs'] . ' ' . _('has been created'); } if ( $InputError !=1) { @@ -103,6 +120,8 @@ unset($_POST['Amount']); unset($_POST['Notes']); unset($_POST['Receipt']); + unset($_POST['SelectedTabs']); + unset($_POST['Date']); } } elseif ( isset($_GET['delete']) ) { @@ -128,16 +147,16 @@ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<p><table class=selection>'; //Main table + echo '<p><table class="selection">'; //Main table echo '<tr><td>' . _('Petty Cash Tab To Assign Cash') . ':</td> <td><select name="SelectedTabs">'; DB_free_result($result); $SQL = "SELECT tabcode - FROM pctabs - WHERE authorizer='" . $_SESSION['UserID'] . "' - ORDER BY tabcode"; + FROM pctabs + WHERE authorizer='" . $_SESSION['UserID'] . "' + ORDER BY tabcode"; $result = DB_query($SQL,$db); @@ -179,7 +198,7 @@ } $sql = "SELECT * FROM pcashdetails WHERE tabcode='" . $SelectedTabs . "' - AND date >=DATE_SUB(CURDATE(), INTERVAL '".$Days."' DAY) + AND date >=DATE_SUB(CURDATE(), INTERVAL , '".$Days."' DAY) ORDER BY date, counterindex ASC"; @@ -188,7 +207,7 @@ echo '<table class=selection>'; echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<tr><th colspan="8">' . _('Detail Of PC Tab Movements For Last ') .': '; + echo '<tr><th colspan="8">' . _('Detail Of PC Tab Movements For Last') .': '; echo '<input type="hidden" name="SelectedTabs" value="' . $SelectedTabs . '">'; echo '<input type="text" class="number" name="Days" value="' . $Days . '" maxlength="3" size="4" /> ' . _('Days'); echo '<input type=submit name="Go" value="' . _('Go') . '">'; @@ -228,7 +247,7 @@ // only cash assignations NOT authorized can be modified or deleted echo '<td>' . ConvertSQLDate($myrow['date']) . '</td> <td>' . $Description['0'] . '</td> - <td class=number>' . number_format($myrow['amount'],2) . '</td> + <td class=number>' . number_format($myrow['amount'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td> <td>' . ConvertSQLDate($myrow['authorized']) . '</td> <td>' . $myrow['notes'] . '</td> <td>' . $myrow['receipt'] . '</td> @@ -242,7 +261,7 @@ }else{ echo '<td>' . ConvertSQLDate($myrow['date']) . '</td> <td>' . $Description['0'] . '</td> - <td class=number>' . number_format($myrow['amount'],2).'</td> + <td class=number>' . number_format($myrow['amount'],$_SESSION['CompanyRecord']['decimalplaces']).'</td> <td>' . ConvertSQLDate($myrow['authorized']) . '</td> <td>' . $myrow['notes'] . '</td> <td>' . $myrow['receipt'] . '</td> @@ -263,7 +282,7 @@ } echo '<tr><td colspan="2" style="text-align:right"><b>' . _('Current balance') . ':</b></td> - <td>' . number_format($Amount['0'],2) . '</td></tr>'; + <td>' . number_format($Amount['0'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td></tr>'; echo '</table>'; @@ -286,7 +305,7 @@ if ( isset($_GET['edit'])) { $sql = "SELECT * FROM pcashdetails - WHERE counterindex='".$SelectedIndex."'"; + WHERE counterindex='".$SelectedIndex."'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); @@ -340,13 +359,12 @@ echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=submit value="' . _('Accept') . '"><input type=submit name=Cancel value="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type=submit name=submit value="' . _('Accept') . '"> + <input type=submit name=Cancel value="' . _('Cancel') . '"></div>'; echo '</form>'; } // end if user wish to delete - } - include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/PcAuthorizeExpenses.php =================================================================== --- trunk/PcAuthorizeExpenses.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcAuthorizeExpenses.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -24,11 +24,19 @@ $Days = $_GET['Days']; } -if (isset($Errors)) { - unset($Errors); +if (isset($_POST['Process'])) { + if ($SelectedTabs=='') { + prnMsg(_('You Must First Select a Petty Cash Tab To Authorise'),'error'); + unset($SelectedTabs); + } } -$Errors = array(); +if (isset($_POST['Go'])) { + if ($Days<=0) { + prnMsg(_('The number of days must be a positive number'),'error'); + $Days=30; + } +} if (isset($SelectedTabs)) { echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Petty Cash') . @@ -37,7 +45,7 @@ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Petty Cash') . '" alt="" />' . _('Authorization Of Petty Cash Expenses ') . '</p>'; } -if (isset($_POST['submit']) or isset($_POST['update']) OR isset($SelectedTabs) OR isset ($_POST['GO'])) { +if (isset($_POST['Submit']) or isset($_POST['update']) OR isset($SelectedTabs) OR isset ($_POST['GO'])) { echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -82,7 +90,7 @@ <th>' . _('Posted') . '</th> <th>' . _('Notes') . '</th> <th>' . _('Receipt') . '</th> - <th>' . _('Authorized') . '</th> + <th>' . _('Authorised') . '</th> </tr>'; $k=0; //row colour counter @@ -92,7 +100,7 @@ while ($myrow=DB_fetch_array($result)) { //update database if update pressed - if ((isset($_POST['submit']) and $_POST['submit']=='Update') AND isset($_POST[$myrow['counterindex']])){ + if ((isset($_POST['Submit']) AND $_POST['Submit']=='Update') AND isset($_POST[$myrow['counterindex']])){ $PeriodNo = GetPeriod(ConvertSQLDate($myrow['date']), $db); @@ -225,13 +233,17 @@ echo '<tr class="OddTableRows">'; $k=1; } - + if ($myrow['posted']==0) { + $Posted=_('No'); + } else { + $Posted=_('Yes'); + } echo'<td>'.ConvertSQLDate($myrow['date']).'</td> <td>'.$myrow['codeexpense'].'</td> <td class="number">'.number_format($myrow['amount'],2).'</td> - <td>'.$myrow['posted'].'</td> - <td>'.$myrow['notes'].'</td> - <td>'.$myrow['receipt'].'</td>'; + <td>' . $Posted . '</td> + <td>' .$myrow['notes'] . '</td> + <td>' . $myrow['receipt'] . '</td>'; if (isset($_POST[$myrow['counterindex']])){ echo'<td>'.ConvertSQLDate(Date('Y-m-d')).'</td>'; @@ -263,14 +275,14 @@ $Amount['0']=0; } - echo '<tr><td colspan="4" style="text-align:right" >' . _('Current balance') . ':</td> - <td colspan="2">' . number_format($Amount['0'],2) . '</td></tr>'; + echo '<tr><td colspan=2 class="number">' . _('Current balance') . ':</td> + <td class=number>'.number_format($Amount['0'],2).'</td></tr>'; // Do the postings include ('includes/GLPostings.inc'); + echo'</table><br /><div class="centre"><input type="submit" name="Submit" value=' . _('Update') . '></div></form>'; + - echo'<tr><td style="text-align:right" colspan=4><input type="submit" name="submit" value="' . _('Update') . '"></td></tr></form>'; - } else { /*The option to submit was not hit so display form */ @@ -278,7 +290,7 @@ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<p><table class="selection">'; //Main table -echo '<tr><td>' . _('Authorize expenses to Petty Cash Tab') . ':</td> +echo '<tr><td>' . _('Authorise expenses to Petty Cash Tab') . ':</td> <td><select name="SelectedTabs">'; DB_free_result($result); @@ -292,7 +304,7 @@ if (isset($_POST['SelectTabs']) and $myrow['tabcode']==$_POST['SelectTabs']) { echo '<option selected value="'; } else { - echo '<option VALUE="'; + echo '<option value="'; } echo $myrow['tabcode'] . '">' . $myrow['tabcode'] . '</option>'; @@ -302,7 +314,8 @@ echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=process VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type=submit name="Process" value="' . _('Accept') . '"> + <input type="submit" name="Cancel" value="' . _('Cancel') . '"></div>'; echo '</form>'; } /*end of else not submit */ Modified: trunk/PcClaimExpensesFromTab.php =================================================================== --- trunk/PcClaimExpensesFromTab.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcClaimExpensesFromTab.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -25,12 +25,31 @@ $Days = $_GET['Days']; } -if (isset($Errors)) { - unset($Errors); +if (isset($_POST['Cancel'])) { + unset($SelectedTabs); + unset($SelectedIndex); + unset($Days); + unset($_POST['Amount']); + unset($_POST['Notes']); + unset($_POST['Receipt']); } -$Errors = array(); +if (isset($_POST['Process'])) { + + if ($_POST['SelectedTabs']=='') { + echo prnMsg(_('You have not selected a tab to claim the expenses on'),'error'); + unset($SelectedTabs); + } +} + +if (isset($_POST['Go'])) { + if ($Days<=0) { + prnMsg(_('The number of days must be a positive number'),'error'); + $Days=30; + } +} + if (isset($_POST['submit'])) { //initialise no input errors assumed initially before we test $InputError = 0; @@ -39,13 +58,13 @@ ie the page has called itself with some user input */ //first off validate inputs sensible - $i=1; - if ($_POST['amount']==0) { + if ($_POST['SelectedExpense']=='') { + $InputError=1; + prnMsg(_('You have not selected an expense to claim on this tab'),'error'); + } elseif ($_POST['amount']==0) { $InputError = 1; prnMsg( _('The Amount must be greater than 0'),'error'); - $Errors[$i] = 'TabCode'; - $i++; } if (isset($SelectedIndex) AND $InputError !=1) { @@ -120,7 +139,7 @@ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<p><table class="selection">'; //Main table + echo '<br /><table class="selection">'; //Main table echo '<tr><td>' . _('Petty Cash Tabs for User ') . $_SESSION['UserID'] . ':</td> <td><select name="SelectedTabs">'; @@ -131,7 +150,7 @@ WHERE usercode='" . $_SESSION['UserID'] . "'"; $result = DB_query($SQL,$db); - + echo '<option value="">' . _('Not Yet Selected') . '</option>'; while ($myrow = DB_fetch_array($result)) { if (isset($_POST['SelectTabs']) and $myrow['tabcode']==$_POST['SelectTabs']) { echo '<option selected value="'; @@ -145,21 +164,24 @@ echo '</select></td></tr>'; echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type="submit" name="process" value="' . _('Accept') . '"><input type=submit name="Cancel" value="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type="submit" name="Process" value="' . _('Accept') . '"><input type=submit name="Cancel" value="' . _('Cancel') . '"></div>'; echo '</form>'; -} +} else { // isset($SelectedTabs) -//end of ifs and buts! -if (isset($_POST['process'])OR isset($SelectedTabs)) { + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Petty Cash Claim Entry') + . '" alt="" />' . ' ' . $title . '</p>'; - echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Petty Cash Tab ') . '' .$SelectedTabs. '<a/></div><p>'; -/* RICARD */ + echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Select another tab') . '</a></div></p>'; + if (! isset($_GET['edit']) OR isset ($_POST['GO'])){ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<div class="centre"><p>' . _('Detail Of Movements For Last ') .': '; + echo '<br /><table class=selection>'; + echo '<tr><th colspan="8"><font color="navy" size="3">' . _('Petty Cash Tab') . ' ' .$SelectedTabs. '</font></th></tr>'; + echo '<tr><th colspan="8">' . _('Detail Of Movements For Last ') .': '; + if(!isset ($Days)){ $Days=30; @@ -167,7 +189,7 @@ echo '<input type="hidden" name="SelectedTabs" value="' . $SelectedTabs . '">'; echo '<input type="text" class="number" name="Days" value="' . $Days . '" maxlength="3" size="4" /> ' ._('Days'); echo '<input type="submit" name="Go" value="' . _('Go') . '" />'; - echo '<p></div></form>'; + echo '</th></div></form>'; if (isset($_POST['Cancel'])) { unset($_POST['SelectedExpense']); @@ -184,7 +206,6 @@ $result = DB_query($sql,$db); - echo '<br><table border=1>'; echo '<tr> <th>' . _('Date Of Expense') . '</th> <th>' . _('Expense Description') . '</th> @@ -215,7 +236,11 @@ if (!isset($Description['0'])){ $Description['0']='ASSIGNCASH'; } - + if ($myrow['5']=='0000-00-00') { + $AuthorisedDate=_('Unauthorised'); + } else { + $AuthorisedDate=ConvertSQLDate($myrow['5']); + } if (($myrow['5'] == '0000-00-00') and ($Description['0'] != 'ASSIGNCASH')){ // only movements NOT authorized can be modified or deleted printf('<td>%s</td> @@ -230,7 +255,7 @@ ConvertSQLDate($myrow['2']), $Description['0'], number_format($myrow['4'],2), - ConvertSQLDate($myrow['5']), + $AuthorisedDate, $myrow['7'], $myrow['8'], $_SERVER['PHP_SELF'] . '?', $myrow['0'], @@ -246,7 +271,7 @@ ConvertSQLDate($myrow['2']), $Description['0'], number_format($myrow['4'],2), - ConvertSQLDate($myrow['5']), + $AuthorisedDate, $myrow['7'], $myrow['8']); @@ -265,11 +290,11 @@ if (!isset($Amount['0'])) { $Amount['0']=0; } + + echo '<tr><td colspan="2" style="text-align:right" >' . _('Current balance') . ':</td> + <td class="number">'.number_format($Amount['0'],2) . '</td></tr>'; - echo '<tr><td colspan="4" style="text-align:right" >' . _('Current balance') . ':</td> - <td colspan=2>'.number_format($Amount['0'],2) . '</td></tr>'; - echo '</table>'; } @@ -277,8 +302,8 @@ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<p><table border=1>'; //Main table - echo '<td><table>'; // First column + + echo '<br /><table class="selection">'; //Main table if ( isset($_GET['edit'])) { @@ -320,7 +345,7 @@ ORDER BY pcexpenses.codeexpense ASC"; $result = DB_query($SQL,$db); - + echo '<option value="">' . _('Not Yet Selected') . '</option>'; while ($myrow = DB_fetch_array($result)) { if (isset($_POST['SelectedExpense']) and $myrow['codeexpense']==$_POST['SelectedExpense']) { echo '<option selected value="'; @@ -336,7 +361,7 @@ if (!isset($_POST['Amount'])) { $_POST['Amount']=0; } - + echo '<tr><td>' . _('Amount') . ':</td> <td><input type="text" class="number" name="amount" size="12" maxlength="11" value="' . $_POST['Amount'] . '"></td></tr>'; @@ -355,7 +380,7 @@ <td><input type="text" name="Receipt" size="50" maxlength="49" value="' . $_POST['Receipt'] . '"></td></tr>'; echo '<input type="hidden" name="SelectedTabs" value="' . $SelectedTabs . '">'; echo '<input type="hidden" name="Days" value="' .$Days. '">'; - echo '</table>'; // close table in first column + echo '</td></tr></table>'; // close main table echo '<p><div class="centre"><input type="submit" name="submit" value="' . _('Accept') . '"><input type=submit name="Cancel" value="' . _('Cancel') . '"></div>'; echo '</form>'; Modified: trunk/PcExpenses.php =================================================================== --- trunk/PcExpenses.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcExpenses.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -15,6 +15,14 @@ $SelectedExpense = strtoupper($_GET['SelectedExpense']); } +if (isset($_POST['Cancel'])) { + unset($SelectedExpense); + unset($_POST['CodeExpense']); + unset($_POST['Description']); + unset($_POST['GLAccount']); +} + + if (isset($Errors)) { unset($Errors); } @@ -32,39 +40,55 @@ //first off validate inputs sensible $i=1; - if ($_POST['codeexpense']=='' OR $_POST['codeexpense']==' ' OR $_POST['codeexpense']==' ') { + if ($_POST['CodeExpense']=='' OR $_POST['CodeExpense']==' ' OR $_POST['CodeExpense']==' ') { $InputError = 1; prnMsg(_('The Expense type code cannot be an empty string or spaces'),'error'); - $Errors[$i] = 'PcExpenses'; + echo '<br />'; + $Errors[$i] = 'CodeExpense'; $i++; - } elseif (strlen($_POST['codeexpense']) >20) { + } elseif (strlen($_POST['CodeExpense']) >20) { $InputError = 1; prnMsg(_('The Expense code must be twenty characters or less long'),'error'); - $Errors[$i] = 'PcExpenses'; + echo '<br />'; + $Errors[$i] = 'CodeExpense'; $i++; - }elseif (ContainsIllegalCharacters($_POST['codeexpense'])){ + }elseif (ContainsIllegalCharacters($_POST['CodeExpense'])){ $InputError = 1; prnMsg(_('The Expense code cannot contain any of the following characters " \' - &'),'error'); - $Errors[$i] = 'PcExpenses'; + echo '<br />'; + $Errors[$i] = 'CodeExpense'; $i++; - } elseif (ContainsIllegalCharacters($_POST['description'])){ + } elseif (ContainsIllegalCharacters($_POST['Description'])){ $InputError = 1; prnMsg(_('The Expense description cannot contain any of the following characters " \' - &'),'error'); - $Errors[$i] = 'TypeTabCode'; + echo '<br />'; + $Errors[$i] = 'Description'; $i++; - } elseif (strlen($_POST['description']) >50) { + } elseif (strlen($_POST['Description']) >50) { $InputError = 1; prnMsg(_('The tab code must be Fifty characters or less long'),'error'); - $Errors[$i] = 'TypeTabCode'; + echo '<br />'; + echo '<br />'; + $Errors[$i] = 'Description'; $i++; + } elseif (strlen($_POST['Description'])==0) { + $InputError = 1; + echo prnMsg(_('The tab code description must be entered'),'error'); + echo '<br />'; + $Errors[$i] = 'Description'; + $i++; + } elseif ($_POST['GLAccount']=='') { + $InputError = 1; + echo prnMsg(_('A general ledger code must be selected for this expense'),'error'); + echo '<br />'; } - + if (isset($SelectedExpense) AND $InputError !=1) { $sql = "UPDATE pcexpenses - SET description = '" . $_POST['description'] . "', - glaccount = '" . $_POST['glaccount'] . "' - WHERE codeexpense = '$SelectedExpense'"; + SET description = '" . $_POST['Description'] . "', + glaccount = '" . $_POST['GLAccount'] . "' + WHERE codeexpense = '" . $SelectedExpense . "'"; $msg = _('The Expenses type') . ' ' . $SelectedExpense . ' ' . _('has been updated'); } elseif ( $InputError !=1 ) { @@ -73,14 +97,14 @@ $checkSql = "SELECT count(*) FROM pcexpenses - WHERE codeexpense = '" . $_POST['codeexpense'] . "'"; + WHERE codeexpense = '" . $_POST['CodeExpense'] . "'"; $checkresult = DB_query($checkSql,$db); $checkrow = DB_fetch_row($checkresult); if ( $checkrow[0] > 0 ) { $InputError = 1; - prnMsg( _('The Expense type ') . $_POST['codeexpense'] . _(' already exists.'),'error'); + prnMsg( _('The Expense type ') . $_POST['CodeExpense'] . _(' already exists.'),'error'); } else { // Add new record on submit @@ -88,11 +112,11 @@ $sql = "INSERT INTO pcexpenses (codeexpense, description,glaccount) - VALUES ('" . $_POST['codeexpense'] . "', - '" . $_POST['description'] . "', - '" . $_POST['glaccount'] . "')"; + VALUES ('" . $_POST['CodeExpense'] . "', + '" . $_POST['Description'] . "', + '" . $_POST['GLAccount'] . "')"; - $msg = _('Expense ') . ' ' . $_POST['codeexpense'] . ' ' . _('has been created'); + $msg = _('Expense ') . ' ' . $_POST['CodeExpense'] . ' ' . _('has been created'); $checkSql = "SELECT count(codeexpense) FROM pcexpenses"; $result = DB_query($checkSql, $db); @@ -105,11 +129,11 @@ //run the SQL from either of the above possibilites $result = DB_query($sql,$db); prnMsg($msg,'success'); - + echo '<br />'; unset($SelectedExpense); - unset($_POST['codeexpense']); - unset($_POST['description']); - unset($_POST['glaccount']); + unset($_POST['CodeExpense']); + unset($_POST['Description']); + unset($_POST['GLAccount']); } } elseif ( isset($_GET['delete']) ) { @@ -118,7 +142,7 @@ $sql= "SELECT COUNT(*) FROM pctabexpenses - WHERE codeexpense='$SelectedExpense'"; + WHERE codeexpense='" . $SelectedExpense . "'"; $ErrMsg = _('The number of type of tabs using this expense code could not be retrieved'); $result = DB_query($sql,$db,$ErrMsg); @@ -130,14 +154,13 @@ } else { $sql="DELETE FROM pcexpenses - WHERE codeexpense='$SelectedExpense'"; + WHERE codeexpense='" . $SelectedExpense . "'"; $ErrMsg = _('The expense type record could not be deleted because'); $result = DB_query($sql,$db,$ErrMsg); prnMsg(_('Expense type') . ' ' . $SelectedExpense . ' ' . _('has been deleted') ,'success'); + echo '<br />'; unset ($SelectedExpense); unset($_GET['delete']); - - } //end if tab type used in transactions } @@ -148,17 +171,17 @@ links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ - $sql = 'SELECT * - FROM pcexpenses'; + $sql = "SELECT * + FROM pcexpenses"; $result = DB_query($sql,$db); - echo '<table class=selection>'; + echo '<table class="selection">'; echo '<tr> <th>' . _('Code Of Expense') . '</th> <th>' . _('Description') . '</th> <th>' . _('Account Code') . '</th> <th>' . _('Account Description') . '</th> - </tr>'; + </tr>'; $k=0; //row colour counter @@ -178,19 +201,19 @@ $ResultDes = DB_query($sqldesc,$db); $Description=DB_fetch_array($ResultDes); - printf("<td>%s</td> + printf('<td>%s</td> <td>%s</td> <td class=number>%s</td> <td>%s</td> - <td><a href='%sSelectedExpense=%s'>" . _('Edit') . "</td> - <td><a href='%sSelectedExpense=%s&delete=yes' onclick=\"return confirm('" . _('Are you sure you wish to delete this expense code and all the details it may have set up?') . "');\">" . _('Delete') . "</td> - </tr>", + <td><a href="%sSelectedExpense=%s">' . _('Edit') . '</td> + <td><a href="%sSelectedExpense=%s&delete=yes" onclick="return confirm(\'' . _('Are you sure you wish to delete this expense code and all the details it may have set up?') . '\');">' . _('Delete') . '</td> + </tr>', $myrow[0], $myrow[1], $myrow[2], $Description[0], $_SERVER['PHP_SELF'] . '?', $myrow[0], - $_SERVER['PHP_SELF'] . '?', $myrow[0]); + $_SERVER['PHP_SELF'] . '?', $myrow[0]); } //END WHILE LIST LOOP echo '</table>'; @@ -208,8 +231,7 @@ echo '<p><table class=selection>'; //Main table // The user wish to EDIT an existing type - if ( isset($SelectedExpense) AND $SelectedExpense!='' ) - { + if ( isset($SelectedExpense) AND $SelectedExpense!='' ){ $sql = "SELECT codeexpense, description, @@ -220,44 +242,49 @@ $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); - $_POST['codeexpense'] = $myrow['codeexpense']; - $_POST['description'] = $myrow['description']; - $_POST['glaccount'] = $myrow['glaccount']; + $_POST['CodeExpense'] = $myrow['codeexpense']; + $_POST['Description'] = $myrow['description']; + $_POST['GLAccount'] = $myrow['glaccount']; echo '<input type=hidden name="SelectedExpense" value="' . $SelectedExpense . '">'; - echo '<input type=hidden name="codeexpense" VALUE="' . $_POST['codeexpense']. '">'; - echo '<table class="selection"> <tr><td>' . _('Code Of Expense') . ':</td><td>'; - + echo '<input type=hidden name="CodeExpense" VALUE="' . $_POST['CodeExpense']. '">'; // We dont allow the user to change an existing type code + echo '<table class="selection"> + <tr> + <td>' . _('Code Of Expense') . ':</td> + <td>' . $_POST['CodeExpense'] . '</td></tr>'; - echo $_POST['codeexpense'] . '</td></tr>'; - } else { // This is a new type so the user may volunteer a type code - echo '<table class=selection> - <tr><td>' . _('Code Of Expense') . ':</td> - <td><input type="Text"' . (in_array('SalesType',$Errors) ? 'class="inputerror"' : '' ) .' name="codeexpense"></td></tr>'; + echo '<table class="selection"> + <tr> + <td>' . _('Code Of Expense') . ':</td> + <td><input type="text"' . (in_array('CodeExpense',$Errors) ? 'class="inputerror"' : '' ) .' name="CodeExpense"></td> + </tr>'; } - if (!isset($_POST['description'])) { - $_POST['description']=''; + if (!isset($_POST['Description'])) { + $_POST['Description']=''; } - echo '<tr><td>' . _('Description') . ':</td><td><input type="Text" name="description" size=50 maxlength=49 value="' . $_POST['description'] . '"></td></tr>'; + echo '<tr> + <td>' . _('Description') . ':</td> + <td><input type="text" ' . (in_array('Description',$Errors) ? 'class="inputerror"' : '' ) . ' name="Description" size=50 maxlength=49 value="' . $_POST['Description'] . '"></td> + </tr>'; - echo '<tr><td>' . _('Account Code') . ':</td><td><select name="glaccount">'; + echo '<tr><td>' . _('Account Code') . ':</td><td><select name="GLAccount">'; DB_free_result($result); - $SQL = 'SELECT accountcode, + $SQL = "SELECT accountcode, accountname FROM chartmaster - ORDER BY accountcode'; + ORDER BY accountcode"; $result = DB_query($SQL,$db); - + echo '<option value="">' . _('Not Yet Selected') . '</option>'; while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['glaccount']) and $myrow['accountcode']==$_POST['glaccount']) { + if (isset($_POST['GLAccount']) and $myrow['accountcode']==$_POST['GLAccount']) { echo '<option selected VALUE="'; } else { echo '<option VALUE="'; @@ -270,7 +297,7 @@ echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=submit VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type="submit" name=submit VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; echo '</form>'; Modified: trunk/PcExpensesTypeTab.php =================================================================== --- trunk/PcExpensesTypeTab.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcExpensesTypeTab.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -16,31 +16,51 @@ } else { $SelectedType=''; } -if (ContainsIllegalCharacters($SelectedType) OR strpos($SelectedType,' ')>0){ + +if (!isset($_GET['delete']) and (ContainsIllegalCharacters($SelectedType) OR strpos($SelectedType,' ')>0)){ $InputError = 1; prnMsg(_('The petty cash tab type contain any of the following characters " \' - & or a space'),'error'); } -if (isset($_POST['SelectedTabs'])){ - $SelectedTabs = strtoupper($_POST['SelectedTabs']); -} elseif (isset($_GET['SelectedTabs'])){ - $SelectedTabs = strtoupper($_GET['SelectedTabs']); + +if (isset($_POST['SelectedTab'])){ + $SelectedTab = strtoupper($_POST['SelectedTab']); +} elseif (isset($_GET['SelectedTab'])){ + $SelectedTab = strtoupper($_GET['SelectedTab']); } -if (isset($Errors)) { - unset($Errors); +if (isset($_POST['Cancel'])) { + unset($SelectedTab); + unset($SelectedType); } -$Errors = array(); -$InputError=0; +if (isset($_POST['Process'])) { + + if ($_POST['SelectedTab'] == '') { + echo prnMsg(_('You have not selected a tab to maintain the expenses on'),'error'); + echo '<br />'; + unset($SelectedTab); + unset($_POST['SelectedTab']); + } +} + if (isset($_POST['submit'])) { + $InputError=0; + + if ($_POST['SelectedExpense']=='') { + $InputError=1; + echo prnMsg(_('You have not selected an expense to add to this tab'),'error'); + echo '<br />'; + unset($SelectedTab); + } + if ( $InputError !=1 ) { // First check the type is not being duplicated $checkSql = "SELECT count(*) FROM pctabexpenses - WHERE typetabcode= '" . $_POST['SelectedTabs'] . "' + WHERE typetabcode= '" . $_POST['SelectedTab'] . "' AND codeexpense = '" . $_POST['SelectedExpense'] . "'"; $checkresult = DB_query($checkSql,$db); @@ -48,23 +68,19 @@ if ( $checkrow[0] >0) { $InputError = 1; - prnMsg( _('The Expense ') . $_POST['codeexpense'] . _(' already exist in this Type of Tab.'),'error'); + prnMsg( _('The Expense') . ' ' . $_POST['codeexpense'] . ' ' ._('already exists in this Type of Tab'),'error'); } else { - // Add new record on submit + $sql = "INSERT INTO pctabexpenses (typetabcode, + codeexpense) + VALUES ('" . $_POST['SelectedTab'] . "', + '" . $_POST['SelectedExpense'] . "')"; - $sql = "INSERT INTO pctabexpenses - (typetabcode, - codeexpense) - VALUES ('" . $_POST['SelectedTabs'] . "', - '" . $_POST['SelectedExpense'] . "')"; - - $msg = _('Expense code:') . ' ' . $_POST['SelectedExpense'].' '._('for Type of Tab:') .' '. $_POST['SelectedTabs'] . ' ' . _('has been created'); + $msg = _('Expense code:') . ' ' . $_POST['SelectedExpense'].' '._('for Type of Tab:') .' '. $_POST['SelectedTab'] . ' ' . _('has been created'); $checkSql = "SELECT count(typetabcode) - FROM pctypetabs"; + FROM pctypetabs"; $result = DB_query($checkSql, $db); $row = DB_fetch_row($result); - } } @@ -77,21 +93,17 @@ } } elseif ( isset($_GET['delete']) ) { - - - $sql="DELETE FROM pctabexpenses - WHERE typetabcode='".$SelectedTabs."' - AND codeexpense='".$SelectedType."'"; - $ErrMsg = _('The Tab Type record could not be deleted because'); - $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('Expense code').' '. $SelectedType .' '. _('for type of tab').' '. $SelectedTabs .' '. _('has been deleted') ,'success'); - unset ($SelectedType); - unset($_GET['delete']); - - + $sql="DELETE FROM pctabexpenses + WHERE typetabcode='".$SelectedTab."' + AND codeexpense='".$SelectedType."'"; + $ErrMsg = _('The Tab Type record could not be deleted because'); + $result = DB_query($sql,$db,$ErrMsg); + prnMsg(_('Expense code').' '. $SelectedType .' '. _('for type of tab').' '. $SelectedTab .' '. _('has been deleted') ,'success'); + unset ($SelectedType); + unset($_GET['delete']); } -if (!isset($SelectedTabs)){ +if (!isset($SelectedTab)){ /* It could still be the second time the page has been run and a record has been selected for modification - SelectedType will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters then none of the above are true and the list of sales types will be displayed with @@ -101,7 +113,7 @@ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table class=selection>'; //Main table - echo '<tr><td>' . _('Select Type of Tab') . ':</td><td><select name="SelectedTabs">'; + echo '<tr><td>' . _('Select Type of Tab') . ':</td><td><select name="SelectedTab">'; DB_free_result($result); $SQL = "SELECT typetabcode, @@ -109,12 +121,12 @@ FROM pctypetabs"; $result = DB_query($SQL,$db); - + echo '<option value="">' . _('Not Yet Selected') . '</option>'; while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['SelectedTabs']) and $myrow['typetabcode']==$_POST['SelectedTabs']) { + if (isset($SelectedTab) and $myrow['typetabcode']==$SelectedTab) { echo '<option selected value="'; } else { - echo '<option VALUE="'; + echo '<option value="'; } echo $myrow['typetabcode'] . '">' . $myrow['typetabcode'] . ' - ' . $myrow['typetabdescription'] . '</option>'; @@ -125,26 +137,30 @@ echo '</table>'; // close table in first column echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=process VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type=submit name="Process" value="' . _('Accept') . '"> + <input type=submit name="Cancel" value="' . _('Cancel') . '"></div>'; echo '</form>'; } //end of ifs and buts! -if (isset($_POST['process'])OR isset($SelectedTabs)) { +if (isset($_POST['process'])OR isset($SelectedTab)) { - echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Expense Codes for Type of Tab ') . ' ' .$SelectedTabs. '</a></div><p>'; + echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Expense Codes for Type of Tab ') . ' ' .$SelectedTab. '</a></div><p>'; - $sql = "SELECT pctabexpenses.codeexpense, pcexpenses.description - FROM pctabexpenses,pcexpenses - WHERE pctabexpenses.codeexpense=pcexpenses.codeexpense - AND pctabexpenses.typetabcode='".$SelectedTabs."' + $sql = "SELECT pctabexpenses.codeexpense, + pcexpenses.description + FROM pctabexpenses INNER JOIN pcexpenses + ON pctabexpenses.codeexpense=pcexpenses.codeexpense + WHERE pctabexpenses.typetabcode='".$SelectedTab."' ORDER BY pctabexpenses.codeexpense ASC"; $result = DB_query($sql,$db); - echo '<table class="selection">'; + echo '<br /> + <table class="selection">'; + echo '<tr><th colspan="3"><font size="2" color="navy">' . _('Expense Codes for Type of Tab ') . ' ' .$SelectedTab. '</font></th></tr>'; echo '<tr> <th>' . _('Expense Code') . '</th> <th>' . _('Description') . '</th> @@ -152,7 +168,7 @@ $k=0; //row colour counter -while ($myrow = DB_fetch_row($result)) { +while ($myrow = DB_fetch_array($result)) { if ($k==1){ echo '<tr class="EvenTableRows">'; $k=0; @@ -161,29 +177,24 @@ $k=1; } - printf("<td>%s</td> - <td>%s</td> - <td><a href='%sSelectedType=%s&delete=yes&SelectedTabs=$_POST[SelectedTabs]' onclick=\"return confirm('" . _('Are you sure you wish to delete this code and the expense it may have set up?') . "');\">" . _('Delete') . "</td> - </tr>", - $myrow[0], - $myrow[1], - $_SERVER['PHP_SELF'], $myrow[0], - $_SERVER['PHP_SELF'], $myrow[0]); + printf('<td>%s</td> + <td>%s</td> + <td><a href="%sSelectedType=%s&delete=yes&SelectedTab=' . $_POST['SelectedTab'] . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this code and the expense it may have set up?') . '\');">' . _('Delete') . '</td> + </tr>', + $myrow['codeexpense'], + $myrow['description'], + $_SERVER['PHP_SELF'], $myrow['codeexpense'], + $_SERVER['PHP_SELF'], $myrow['codeexpense']); } //END WHILE LIST LOOP echo '</table>'; - - - if (! isset($_GET['delete'])) { echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<br /><table class="selection">'; //Main table - - echo '<tr><td>' . _('Select Expense Code') . ':</td><td><select name="SelectedExpense">'; DB_free_result($result); @@ -192,9 +203,11 @@ FROM pcexpenses"; $result = DB_query($SQL,$db); - + if (!isset($_POST['SelectedExpense'])){ + echo '<option selected value="">' . _('Not Yet Selected') . '</option>'; + } while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['SelectedExpense']) and $myrow['codeexpense']==$_POST['SelectedExpense']) { + if (isset($_POST['SelectedExpense']) AND $myrow['codeexpense']==$_POST['SelectedExpense']) { echo '<option selected value="'; } else { echo '<option value="'; @@ -206,11 +219,12 @@ echo '</select></td></tr>'; - echo '<input type="hidden" name="SelectedTabs" value="' . $SelectedTabs . '">'; + echo '<input type="hidden" name="SelectedTab" value="' . $SelectedTab . '">'; echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=submit VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type=submit name=submit value="' . _('Accept') . '"> + <input type=submit name="Cancel" value="' . _('Cancel') . '"></div>'; echo '</form>'; Modified: trunk/PcReportTab.php =================================================================== --- trunk/PcReportTab.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcReportTab.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -48,7 +48,7 @@ $result = DB_query($SQL,$db); while ($myrow = DB_fetch_array($result)) { - if (isset($_POST['SelectTabs']) and $myrow['tabcode']==$_POST['SelectTabs']) { + if (isset($_POST['SelectedTabs']) and $myrow['tabcode']==$_POST['SelectedTabs']) { echo '<option selected value="'; } else { echo '<option value="'; @@ -117,11 +117,11 @@ $Tabs=DB_fetch_array($TabResult); $SqlBalance = "SELECT SUM(amount) FROM pcashdetails - WHERE tabcode='".$SelectedTabs."' - AND date<'".$SQL_FromDate."'"; + WHERE tabcode='".$SelectedTabs."' + AND date<'".$SQL_FromDate."'"; $TabBalance = DB_query($SqlBalance, - $db); + $db); $Balance=DB_fetch_array($TabBalance); @@ -177,17 +177,17 @@ while ($myrow=DB_fetch_array($TabDetail)) { - $sqldes="SELECT description - FROM pcexpenses - WHERE codeexpense='". $myrow[3] . "'"; + $sqldes="SELECT description + FROM pcexpenses + WHERE codeexpense='". $myrow[3] . "'"; + + $ResultDes = DB_query($sqldes,$db); + $Description=DB_fetch_array($ResultDes); + + if (!isset($Description[0])){ + $Description[0]='ASSIGNCASH'; + } - $ResultDes = DB_query($sqldes,$db); - $Description=DB_fetch_array($ResultDes); - - if (!isset($Description[0])){ - $Description[0]='ASSIGNCASH'; - } - // Print total for each account $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,70,$FontSize,ConvertSQLDate($myrow['date'])); $LeftOvers = $pdf->addTextWrap($Left_Margin+70,$YPos,130,$FontSize,$Description[0]); Modified: trunk/PcTabs.php =================================================================== --- trunk/PcTabs.php 2011-05-14 11:24:22 UTC (rev 4566) +++ trunk/PcTabs.php 2011-05-15 04:34:49 UTC (rev 4567) @@ -14,13 +14,26 @@ $SelectedTab = strtoupper($_GET['SelectedTab']); } +if (isset($_POST['Cancel'])) { + unset($SelectedTab); + unset($_POST['TabCode'] ); + unset($_POST['SelectUser'] ); + unset($_POST['SelectTabs']); + unset($_POST['SelectCurrency']); + unset($_POST['TabLimit']); + unset($_POST['SelectAuthorizer']); + unset($_POST['GLAccountCash']); + unset($_POST['GLAccountPcashTab']); +} + + if (isset($Errors)) { unset($Errors); } $Errors = array(); -if (isset($_POST['submit'])) { +if (isset($_POST['Submit'])) { //initialise no input errors assumed initially before we test $InputError = 0; @@ -41,18 +54,42 @@ echo prnMsg(_('The Tab code must be twenty characters or less long'),'error'); $Errors[$i] = 'TabCode'; $i++; + } elseif (($_POST['SelectUser'])=='') { + $InputError = 1; + echo prnMsg(_('You must select a User for this tab'),'error'); + $Errors[$i] = 'UserName'; + $i++; + } elseif (($_POST['SelectTabs'])=='') { + $InputError = 1; + echo prnMsg(_('You must select a type of tab from the list'),'error'); + $Errors[$i] = 'TabType'; + $i++; + } elseif (($_POST['SelectAuthorizer'])=='') { + $InputError = 1; + echo prnMsg(_('You must select a User to authorise this tab'),'error'); + $Errors[$i] = 'AuthorizerName'; + $i++; + } elseif (($_POST['GLAccountCash'])=='') { + $InputError = 1; + echo prnMsg(_('You must select a General ledger code for the cash to be assigned from'),'error'); + $Errors[$i] = 'GLCash'; + $i++; + } elseif (($_POST['GLAccountPcashTab'])=='') { + $InputError = 1; + echo prnMsg(_('You must select a General ledger code for this petty cash tab'),'error'); + $Errors[$i] = 'GLTab'; + $i++; } if (isset($SelectedTab) AND $InputError !=1) { - $sql = "UPDATE pctabs - SET usercode = '" . $_POST['SelectUser'] . "', - typetabcode = '" . $_POST['SelectTabs'] . "', - currency = '" . $_POST['SelectCurrency'] . "', - tablimit = '" . $_POST['TabLimit'] . "', - authorizer = '" . $_POST['SelectAuthorizer'] . "', - glaccountassignment = '" . $_POST['glaccountcash'] . "', - glaccountpcash = '" . $_POST['GLAccountPcashTab'] . "' + $sql = "UPDATE pctabs SET usercode = '" . $_POST['SelectUser'] . "', + typetabcode = '" . $_POST['SelectTabs'] . "', + currency = '" . $_POST['SelectCurrency'] . "', + tablimit = '" . $_POST['TabLimit'] . "', + authorizer = '" . $_POST['SelectAuthorizer'] . "', + glaccountassignment = '" . $_POST['GLAccountCash'] . "', + glaccountpcash = '" . $_POST['GLAccountPcashTab'] . "' WHERE tabcode = '".$SelectedTab."'"; $msg = _('The Tabs Of Code') . ' ' . $SelectedTab . ' ' . _('has been updated'); @@ -61,8 +98,8 @@ // First check the type is not being duplicated $checkSql = "SELECT count(*) - FROM pctabs - WHERE tabcode = '" . $_POST['TabCode'] . "'"; + FROM pctabs + WHERE tabcode = '" . $_POST['TabCode'] . "'"; $CheckResult = DB_query($checkSql,$db); $CheckRow = DB_fetch_row($CheckResult); @@ -74,24 +111,23 @@ // Add new record on submit - $sql = "INSERT INTO pctabs - (tabcode, - usercode, - typetabcode, - currency, - tablimit, - authorizer, - glaccountassignment, - glaccountpcash) - VALUES ('" . $_POST['TabCode'] . "', - '" . $_POST['SelectUser'] . "', - '" . $_POST['SelectTabs'] . "', - '" . $_POST['SelectCurrency'] . "', - '" . $_POST['TabLimit'] . "', - '" . $_POST['SelectAuthorizer'] . "', - '" . $_POST['glaccountcash'] . "', - '" . $_POST['GLAccountPcashTab'] . "')"; - + $sql = "INSERT INTO pctabs (tabcode, + usercode, + typetabcode, + currency, + tablimit, + authorizer, + glaccountassignment, + glaccountpcash) + VALUES ('" . $_POST['TabCode'] . "', + '" . $_POST['SelectUser'] . "', + '" . $_POST['SelectTabs'] . "', + '" . $_POST['SelectCurrency'] . "', + '" . $_POST['TabLimit'] . "', + '" . $_POST['SelectAuthorizer'] . "', + '" . $_POST['GLAccountCash'] . "', + '" . $_POST['GLAccountPcashTab'] . "')"; + $msg = _('Tab with Code ') . ' ' . $_POST['TabCode'] . ' ' . _('has been created'); } @@ -102,15 +138,14 @@ $result = DB_query($sql,$db); prnMsg($msg,'success'); unset($SelectedTab); - unset($_POST['SelectUser'] ); + unset($_POST['SelectUser']); + unset($_POST['TabCode']); unset($_POST['SelectTabs']); unset($_POST['SelectCurrency']); unset($_POST['TabLimit']); unset($_POST['SelectAuthorizer']); - unset($_POST['glaccountcash']); + unset($_POST['GLAccountCash']); unset($_POST['GLAccountPcashTab']); - - } } elseif ( isset($_GET['delete']) ) { @@ -130,73 +165,76 @@ links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ - $sql = 'SELECT * - FROM pctabs - ORDER BY tabcode'; + $sql = "SELECT tabcode, + usercode, + typetabdescription, + currabrev, + tablimit, + authorizer, + glaccountassignment, + glaccountpcash, + currencies.decimalplaces, + chartmaster1.accountname AS glactassigntname, + chartmaster2.accountname AS glactpcashname + FROM pctabs INNER JOIN currencies + ON pctabs.currency=currencies.currabrev + INNER JOIN pctypetabs + ON pctabs.typetabcode=pctypetabs.typetabcode + INNER JOIN chartmaster AS chartmaster1 ON + pctabs.glaccountassignment = chartmaster1.accountcode + INNER JOIN chartmaster AS chartmaster2 ON + pctabs.glaccountpcash = chartmaster2.accountcode + ORDER BY tabcode"; $result = DB_query($sql,$db); - - echo '<br><table class=selection>'; - echo '<tr> - <th>' . _('Tab Code') . '</th> - <th>' . _('User Name') . '</th> - <th>' . _('Type Of Tab') . '</th> - <th>' . _('Currency') . '</th> - <th>' . _('Limit') . '</th> - <th>' . _('Authorizer') . '</th> - <th>' . _('GL Account For Cash Assignment') . '</th> - <th>' . _('GL Account Petty Cash Tab') . '</th> - </tr>'; - -$k=0; //row colour counter - -while ($myrow = DB_fetch_row($result)) { - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - echo '<tr class="OddTableRows">'; - $k=1; - } - - $sqldes="SELECT accountname - FROM chartmaster - WHERE accountcode='". $myrow[6] . "'"; - - $ResultDes = DB_query($sqldes,$db); - $Description=DB_fetch_array($ResultDes); - - $sqlname="SELECT accountname - FROM chartmaster - WHERE accountcode='". $myrow[7] . "'"; - - $ResultName = DB_query($sqlname,$db); - $DescriptionName=DB_fetch_array($ResultName); - - - printf('<td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td><a href="%sSelectedTab=%s">' . _('Edit') . '</td> - <td><a href="%sSelectedTab=%s&delete=yes" onclick=\' return confirm("' . _('Are you sure you wish to delete this tab code?') . '");\'>' . _('Delete') . '</td> - </tr>', - $myrow[0], - $myrow[1], - $myrow[2], - $myrow[3], - number_format($myrow[4],2), - $myrow[5], - $myrow[6].' - '.$Description[0], - $myrow[7].' - '.$DescriptionName[0], - $_SERVER['PHP_SELF'] . '?', $myrow[0], - $_SERVER['PHP_SELF'] . '?', $myrow[0]); - } - //END WHILE LIST LOOP - echo '</table>'; + if (DB_num_rows($result)>0){ + echo '<br><table class=selection>'; + echo '<tr> + <th>' . _('Tab Code') . '</th> + <th>' . _('User Name') . '</th> + <th>' . _('Type Of Tab') . '</th> + <th>' . _('Currency') . '</th> + <th>' . _('Limit') . '</th> + <th>' . _('Authorizer') . '</th> + <th>' . _('GL Account For Cash Assignment') . '</th> + <th>' . _('GL Account Petty Cash Tab') . '</th> + </tr>'; + + $k=0; //row colour counter + + while ($myrow = DB_fetch_array($result)) { + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + printf('<td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class=number>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td><a href="%sSelectedTab=%s">' . _('Edit') . '</td> + <td><a href="%sSelectedTab=%s&delete=yes" onclick=\' return confirm("' . _('Are you sure you wish to delete this tab code?') . '");\'>' . _('Delete') . '</td> + </tr>', + $myrow['tabcode'], + $myrow['usercode'], + $myrow['typetabdescription'], + $myrow['currabrev'], + number_format($myrow['tablimit'],$myrow['decimalplaces']), + $myrow['authorizer'], + $myrow['glaccountassignment'].' - '. $myrow['glactassigntname'], + $myrow['glaccountpcash'].' - '.$myrow['glactpcashname'], + $_SERVER['PHP_SELF'] . '?', $myrow['tabcode'], + $_SERVER['PHP_SELF'] . '?', $myrow['tabcode']); + } + //END WHILE LIST LOOP + echo '</table>'; + } //if there are tabs to show } //end of ifs and buts! @@ -208,7 +246,7 @@ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<p><table class=selection>'; //Main table + echo '<p><table class="selection">'; //Main table if ( isset($SelectedTab) AND $SelectedTab!='' ) { @@ -225,20 +263,18 @@ $_POST['SelectCurrency'] = $myrow['currency']; $_POST['TabLimit'] = $myrow['tablimit']; $_POST['SelectAuthorizer'] = $myrow['authorizer']; - $_POST['glaccountcash'] = $myrow['glaccountassignment']; + $_POST['GLAccountCash'] = $myrow['glaccountassignment']; $_POST['GLAccountPcashTab'] = $myrow['glaccountpcash']; echo '<input type=hidden name="SelectedTab" value="' . $SelectedTab . '">'; echo '<input type=hidden name="TabCode" value="' . $_POST['TabCode']. '">'; - echo '<table class="selection"> <tr><td>' . _('Tab Code') . ':</td><td>'; - - // We dont allow the user to change an existing type code - - echo $_POST['TabCode'] . '</td></tr>'; - + echo '<table class="selection"> + <tr> + <td>' . _('Tab Code') . ':</td> + <td>' . $_POST['TabCode'] . '</td> + </tr>'; } else { - // This is a new type so the user may volunteer a type code echo '<table class="selection"> <tr><td>' . _('Tab Code') . ':</td> @@ -254,7 +290,8 @@ <td><select name="SelectUser">'; DB_free_result($result); - $SQL = "SELECT userid + $SQL = "SELECT userid, + realname FROM www_users ORDER BY userid"; $result = DB_query($SQL,$db); @@ -265,7 +302,7 @@ } else { echo '<option value="'; } - echo $myrow['userid'] . '">' . $myrow['userid'] . '</option>'; + echo $myrow['userid'] . '">' . $myrow['userid'] . ' - ' . $myrow['realname'] . '</option>'; } //end while loop get user @@ -275,7 +312,10 @@ <td><select name="SelectTabs">'; DB_free_result($result); - $SQL = "SELECT typetabcode FROM pctypetabs ORDER BY typetabcode"; + $SQL = "SELECT typetabcode, + typetabdescription + FROM pctypetabs + ORDER BY typetabcode"; $result = DB_query($SQL,$db); @@ -285,7 +325,7 @@ } else { echo '<option value="'; } - echo $myrow['typetabcode'] . '">' . $myrow['typetabcode'] . '</option>'; + echo $myrow['typetabcode'] . '">' . $myrow['typetabcode'] . ' - ' . $myrow['typetabdescription'] . '</option>'; } //end while loop get type of tab @@ -318,11 +358,12 @@ echo '<tr><td>' . _('Limit Of Tab') . ':</td> <td><input type="Text" class="number" name="TabLimit" size="12" maxlength="11" value="' . $_POST['TabLimit'] . '"></td></tr>'; - echo '<tr><td>' . _('Authorizer') . ':</td> + echo '<tr><td>' . _('Authoriser') . ':</td> <td><select name="SelectAuthorizer">'; DB_free_result($result); - $SQL = "SELECT userid + $SQL = "SELECT userid, + realname FROM www_users ORDER BY userid"; @@ -334,14 +375,14 @@ } else { echo '<option value="'; } - echo $myrow['userid'] . '">' . $myrow['userid'] . '</option>'; + echo $myrow['userid'] . '">' . $myrow['userid'] . ' - ' . $myrow['realname'] . '</option>'; } //end while loop get authorizer echo '</select></td></tr>'; echo '<tr><td>' . _('GL Account Cash Assignment') . ':</td> - <td><select name="glaccountcash">'; + <... [truncated message content] |