|
From: <dai...@us...> - 2011-06-09 10:33:47
|
Revision: 4591
http://web-erp.svn.sourceforge.net/web-erp/?rev=4591&view=rev
Author: daintree
Date: 2011-06-09 10:33:38 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
various
Modified Paths:
--------------
trunk/CustomerBranches.php
trunk/PcExpensesTypeTab.php
trunk/Prices.php
trunk/SalesPeople.php
trunk/SalesTypes.php
trunk/UpgradeDatabase.php
trunk/WWW_Users.php
trunk/doc/Change.log
trunk/includes/ConnectDB.inc
trunk/includes/LanguageSetup.php
Modified: trunk/CustomerBranches.php
===================================================================
--- trunk/CustomerBranches.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/CustomerBranches.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -571,13 +571,19 @@
$_POST['BranchCode']='';
}
echo '<p Class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/customer.png" title="' . _('Customer') . '" alt="">' . ' ' . _('Add a Branch').'</p>';
- echo '<table class=selection><tr><td>'._('Branch Code'). ':</td>
- <td><input ' .(in_array('BranchCode',$Errors) ? 'class="inputerror"' : '' ) . ' tabindex=1 type="text" name="BranchCode" size=12 maxlength=10 value="' . $_POST['BranchCode'] . '"></td></tr>';
+ echo '<table class=selection>
+ <tr>
+ <td>'._('Branch Code'). ':</td>
+ <td><input ' .(in_array('BranchCode',$Errors) ? 'class="inputerror"' : '' ) . ' tabindex=1 type="text" name="BranchCode" size=12 maxlength=10 value="' . $_POST['BranchCode'] . '"></td>
+ </tr>';
$_POST['DeliverBlind'] = $_SESSION['DefaultBlindPackNote'];
}
//SQL to poulate account selection boxes
- $sql = "SELECT salesmanname, salesmancode FROM salesman";
+ $sql = "SELECT salesmanname,
+ salesmancode
+ FROM salesman
+ WHERE current = 1";
$result = DB_query($sql,$db);
@@ -592,12 +598,16 @@
echo '<input type=hidden name="DebtorNo" value="'. $DebtorNo . '" />';
- echo '<tr><td>'._('Branch Name').':</td>';
+ echo '<tr>
+ <td>'._('Branch Name').':</td>';
if (!isset($_POST['BrName'])) {$_POST['BrName']='';}
- echo '<td><input tabindex=2 type="text" name="BrName" size=41 maxlength=40 value="'. $_POST['BrName'].'"></td></tr>';
- echo '<tr><td>'._('Branch Contact').':</td>';
+ echo '<td><input tabindex=2 type="text" name="BrName" size=41 maxlength=40 value="'. $_POST['BrName'].'"></td>
+ </tr>';
+ echo '<tr>
+ <td>'._('Branch Contact').':</td>';
if (!isset($_POST['ContactName'])) {$_POST['ContactName']='';}
- echo '<td><input tabindex=3 type="text" name="ContactName" size=41 maxlength=40 value="'. $_POST['ContactName'].'"></td></tr>';
+ echo '<td><input tabindex=3 type="text" name="ContactName" size=41 maxlength=40 value="'. $_POST['ContactName'].'"></td>
+ </tr>';
echo '<tr><td>'._('Street Address 1 (Street)').':</td>';
if (!isset($_POST['BrAddress1'])) {$_POST['BrAddress1']='';}
echo '<td><input tabindex=4 type="text" name="BrAddress1" size=41 maxlength=40 value="'. $_POST['BrAddress1'].'"></td></tr>';
@@ -635,7 +645,7 @@
} else {
echo '<option value=';
}
- echo $myrow['salesmancode'] . '>' . $myrow['salesmanname'];
+ echo $myrow['salesmancode'] . '>' . $myrow['salesmanname'] . '</option>';
} //end while loop
@@ -643,7 +653,7 @@
DB_data_seek($result,0);
- $sql = 'SELECT areacode, areadescription FROM areas';
+ $sql = "SELECT areacode, areadescription FROM areas";
$result = DB_query($sql,$db);
if (DB_num_rows($result)==0){
echo '</table>';
@@ -661,7 +671,7 @@
} else {
echo '<option value="';
}
- echo $myrow['areacode'] . '">' . $myrow['areadescription'];
+ echo $myrow['areacode'] . '">' . $myrow['areadescription'] . '</option>';
} //end while loop
@@ -705,7 +715,7 @@
if (!isset($_POST['Email'])) {$_POST['Email']='';}
echo '<tr><td>'.(($_POST['Email']) ? '<a href="Mailto:'.$_POST['Email'].'">'._('Email').':</a>' : _('Email').':').'</td>';
//only display email link if there is an email address
- echo '<td><input tabindex=18 type="Text" name="Email" size=56 maxlength=55 value="'. $_POST['Email'].'"></td></tr>';
+ echo '<td><input tabindex=18 type="text" name="Email" size=56 maxlength=55 value="'. $_POST['Email'].'"></td></tr>';
echo '<tr><td>'._('Tax Group').':</td>';
echo '<td><select tabindex=19 name="TaxGroup">';
Modified: trunk/PcExpensesTypeTab.php
===================================================================
--- trunk/PcExpensesTypeTab.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/PcExpensesTypeTab.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -182,7 +182,7 @@
printf('<td>%s</td>
<td>%s</td>
- <td><a href="%s?SelectedType=%s&delete=yes&SelectedTab=' . $SelectedTab . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this code and the expense it may have set up?') . '\');">' . _('Delete') . '</td>
+ <td><a href="%s?SelectedType=%s&delete=yes&SelectedTab=' . $SelectedTab . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this expense code?') . '\');">' . _('Delete') . '</td>
</tr>',
$myrow['codeexpense'],
$myrow['description'],
Modified: trunk/Prices.php
===================================================================
--- trunk/Prices.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/Prices.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -108,7 +108,7 @@
$result = DB_query($sql, $db);
$myrow = DB_fetch_row($result);
- echo $myrow[0];
+
if ($myrow[0]!=0) {
prnMsg( _('This price has already been entered. To change it you should edit it') , 'warn');
$InputError =1;
@@ -353,6 +353,8 @@
/*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where one price falls inside another effective date range except in the case of a blank end date - ie no end date - the default price for the currency/salestype.
I first thought that we would need to update the previous default price (blank end date), when a new default price is entered, to have an end date of the startdate of this new default price less 1 day - but this is converting a default price into a special price which could result in having two special prices over the same date range - best to leave it unchanged and use logic in the GetPrice.inc to ensure the correct default price is returned
+ *
+ * After further discussion (Ricard) if the new price has a blank end date - i.e. no end then the pre-existing price with no end date should be changed to have an end date just prior to the new default (no end date) price commencing
*/
//this is just the case where debtorno='' - see the Prices_Customer.php script for customer special prices
$SQL = "SELECT price,
@@ -394,6 +396,34 @@
$EndDate = $myrow['enddate'];
$Price = $myrow['price'];
} // end of loop around all prices
+
+ //Now look for duplicate prices with no end
+ $SQL = "SELECT price,
+ startdate,
+ enddate
+ FROM prices
+ WHERE debtorno=''
+ AND stockid='" . $Item . "'
+ AND currabrev='" . $CurrAbbrev . "'
+ AND typeabbrev='" . $PriceList . "'
+ AND enddate ='0000-00-00'
+ ORDER BY startdate";
+ $result = DB_query($SQL,$db);
+ $NewEndDate = FormatDateForSQL(DateAdd(Date($_SESSION['DefaultDateFormat']),'d',-1));
+
+ for ($i=1;$i< DB_num_rows($result);$i++) {
+ $myrow = DB_fetch_array($result);
+ /*Need to make the end date the new start date less 1 day */
+ $SQL = "UPDATE prices SET enddate = '" . $NewEndDate . "'
+ WHERE stockid ='" .$Item . "'
+ AND currabrev='" . $CurrAbbrev . "'
+ AND typeabbrev='" . $PriceList . "'
+ AND startdate ='" . $myrow['startdate'] . "'
+ AND enddate = '0000-00-00'
+ AND debtorno =''";
+ $UpdateResult = DB_query($SQL,$db);
+ } // end of loop around duplicate no end date prices
+
} // end function ReSequenceEffectiveDates
?>
\ No newline at end of file
Modified: trunk/SalesPeople.php
===================================================================
--- trunk/SalesPeople.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/SalesPeople.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -1,8 +1,6 @@
<?php
/* $Id$*/
-//$PageSecurity = 3;
-
include('includes/session.inc');
$title = _('Sales People Maintenance');
include('includes/header.inc');
@@ -78,6 +76,9 @@
if (!isset($_POST['Breakpoint'])){
$_POST['Breakpoint']=0;
}
+ if (!isset($_POST['Current'])){
+ $_POST['Current']=0;
+ }
if (isset($SelectedSaleperson) AND $InputError !=1) {
@@ -88,7 +89,8 @@
smantel='" . $_POST['SManTel'] . "',
smanfax='" . $_POST['SManFax'] . "',
breakpoint='" . $_POST['Breakpoint'] . "',
- commissionrate2='" . $_POST['CommissionRate2'] . "'
+ commissionrate2='" . $_POST['CommissionRate2'] . "',
+ current='" . $_POST['Current'] . "'
WHERE salesmancode = '".$SelectedSaleperson."'";
$msg = _('Salesperson record for') . ' ' . $_POST['SalesmanName'] . ' ' . _('has been updated');
@@ -102,14 +104,16 @@
commissionrate2,
breakpoint,
smantel,
- smanfax)
+ smanfax,
+ current)
VALUES ('" . $_POST['SalesmanCode'] . "',
'" . $_POST['SalesmanName'] . "',
'" . $_POST['CommissionRate1'] . "',
'" . $_POST['CommissionRate2'] . "',
'" . $_POST['Breakpoint'] . "',
'" . $_POST['SManTel'] . "',
- '" . $_POST['SManFax'] . "'
+ '" . $_POST['SManFax'] . "',
+ '" . $_POST['Current'] . "'
)";
$msg = _('A new salesperson record has been added for') . ' ' . $_POST['SalesmanName'];
@@ -130,6 +134,7 @@
unset($_POST['Breakpoint']);
unset($_POST['SManFax']);
unset($_POST['SManTel']);
+ unset($_POST['Current']);
}
} elseif (isset($_GET['delete'])) {
@@ -176,7 +181,8 @@
smanfax,
commissionrate1,
breakpoint,
- commissionrate2
+ commissionrate2,
+ current
FROM salesman";
$result = DB_query($sql,$db);
@@ -187,7 +193,8 @@
<th>' . _('Facsimile') . '</th>
<th>' . _('Comm Rate 1') . '</th>
<th>' . _('Break') . '</th>
- <th>' . _('Comm Rate 2') . '</th></tr>';
+ <th>' . _('Comm Rate 2') . '</th>
+ <th>' . _('Current') . '</th></tr>';
$k=0;
while ($myrow=DB_fetch_row($result)) {
@@ -198,6 +205,7 @@
echo '<tr class="OddTableRows">';
$k++;
}
+ if ($myrow[7] == 1) $ActiveText = _("Yes"); else $ActiveText = _("No");
printf('
<td>%s</td>
@@ -207,6 +215,7 @@
<td class=number>%s</td>
<td class=number>%s</td>
<td class=number>%s</td>
+ <td>%s</td>
<td><a href="%sSelectedSaleperson=%s">'. _('Edit') . '</a></td>
<td><a href="%sSelectedSaleperson=%s&delete=1">' . _('Delete') . '</a></td>
</tr>',
@@ -217,6 +226,7 @@
$myrow[4],
$myrow[5],
$myrow[6],
+ $ActiveText,
$_SERVER['PHP_SELF'] . '?' . SID . '&',
$myrow[0],
$_SERVER['PHP_SELF'] . '?' . SID . '&',
@@ -244,7 +254,8 @@
smanfax,
commissionrate1,
breakpoint,
- commissionrate2
+ commissionrate2,
+ current
FROM salesman
WHERE salesmancode='".$SelectedSaleperson."'";
@@ -258,6 +269,7 @@
$_POST['CommissionRate1'] = $myrow['commissionrate1'];
$_POST['Breakpoint'] = $myrow['breakpoint'];
$_POST['CommissionRate2'] = $myrow['commissionrate2'];
+ $_POST['Current'] = $myrow['current'];
echo '<input type=hidden name="SelectedSaleperson" VALUE="' . $SelectedSaleperson . '">';
@@ -288,8 +300,10 @@
if (!isset($_POST['Breakpoint'])){
$_POST['Breakpoint']=0;
}
+ if (!isset($_POST['Current'])){
+ $_POST['Current']=0;
+ }
-
echo '<tr><td>' . _('Salesperson Name') . ':</td><td><input type="text" '. (in_array('SalesmanName',$Errors) ? 'class="inputerror"' : '' ) .' name="SalesmanName" size=30 maxlength=30 VALUE="' . $_POST['SalesmanName'] . '"></td></tr>';
echo '<tr><td>' . _('Telephone No') . ':</td><td><input type="text" name="SManTel" size=20 maxlength=20 VALUE="' . $_POST['SManTel'] . '"></td></tr>';
echo '<tr><td>' . _('Facsimile No') . ':</td><td><input type="text" name="SManFax" size=20 maxlength=20 VALUE="' . $_POST['SManFax'] . '"></td></tr>';
@@ -297,6 +311,19 @@
echo '<tr><td>' . _('Breakpoint') . ':</td><td><input type="text" class=number name="Breakpoint" size=6 maxlength=6 VALUE="' . $_POST['Breakpoint'] . '"></td></tr>';
echo '<tr><td>' . _('Commission Rate 2') . ':</td><td><input type="text" class=number name="CommissionRate2" size=5 maxlength=5 VALUE="' . $_POST['CommissionRate2']. '"></td></tr>';
+ echo '<tr><td>' . _('Current?') . ':</td><td><select name="Current">';
+ if ($_POST['Current']==1){
+ echo '<option selected value=1>' . _('Yes') . '</option>';
+ } else {
+ echo '<option value=1>' . _('Yes') . '</option>';
+ }
+ if ($_POST['Current']==0){
+ echo '<option selected value=0>' . _('No') . '</option>';
+ } else {
+ echo '<option value=0>' . _('No') . '</option>';
+ }
+ echo '</select></td></tr>';
+
echo '</table>';
echo '<br /><div class="centre"><input type="Submit" name="submit" value="' . _('Enter Information') . '"></div>';
Modified: trunk/SalesTypes.php
===================================================================
--- trunk/SalesTypes.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/SalesTypes.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -40,6 +40,11 @@
prnMsg( _('The sales type (price list) code cannot be an empty string or spaces'),'error');
$Errors[$i] = 'SalesType';
$i++;
+ } elseif( trim($_POST['Sales_Type'])==''){
+ $InputError = 1;
+ prnMsg (_('The sales type (price list) description cannot be empty'),'error');
+ $Errors[$i] = 'SalesType';
+ $i++;
} elseif (strlen($_POST['Sales_Type']) >40) {
$InputError = 1;
echo prnMsg(_('The sales type (price list) description must be forty characters or less long'),'error');
@@ -155,12 +160,12 @@
prnMsg (_('Cannot delete this sale type because customers are currently set up to use this sales type') . '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('customers with this sales type code'));
} else {
- $sql="DELETE FROM salestypes WHERE typeabbrev='".$SelectedType."'";
+ $sql="DELETE FROM salestypes WHERE typeabbrev='" . $SelectedType . "'";
$ErrMsg = _('The Sales Type record could not be deleted because');
$result = DB_query($sql,$db,$ErrMsg);
prnMsg(_('Sales type') . ' / ' . _('price list') . ' ' . $SelectedType . ' ' . _('has been deleted') ,'success');
- $sql ="DELETE FROM prices WHERE prices.typeabbrev='SelectedType'";
+ $sql ="DELETE FROM prices WHERE prices.typeabbrev='" . $SelectedType . "'";
$ErrMsg = _('The Sales Type prices could not be deleted because');
$result = DB_query($sql,$db,$ErrMsg);
Modified: trunk/UpgradeDatabase.php
===================================================================
--- trunk/UpgradeDatabase.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/UpgradeDatabase.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -1,207 +1,209 @@
-<?php
-/* $Id UpgradeDatabase.php 4183 2010-12-14 09:30:20Z daintree $ */
-
-$PageSecurity = 15; //hard coded in case database is old and PageSecurity stuff cannot be retrieved
-
-include('includes/session.inc');
-$title = _('Upgrade webERP Database');
-include('includes/header.inc');
-
-if (!isset($_POST['DoUpgrade'])){
-
- prnMsg(_('This script will perform any modifications to the database required to allow the additional functionality in later scripts'),'info');
- echo '<p><form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
- echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
-
- if (!isset($_SESSION['VersionNumber'])){
- prnMsg(_('The webERP code is version') . ' ' . $Version . ' ' . _('and the database version is not actually recorded at this version'),'info');
- echo '<table><tr><td>' . _('Select the version you are upgrading from:') . '</td>
- <td><select name="OldVersion" >';
- echo '<option selected value="Manual">' . _('Apply database changes manually') . '</option>';
- echo '<option value="3.00">' . _('Version 3.00') . '</option>';
- echo '<option value="3.01">' . _('Version 3.01') . '</option>';
- echo '<option value="3.02">' . _('Version 3.02') . '</option>';
- echo '<option value="3.03">' . _('Version 3.03') . '</option>';
- echo '<option value="3.04">' . _('Version 3.04') . '</option>';
- echo '<option value="3.05">' . _('Version 3.05') . '</option>';
- echo '<option value="3.06">' . _('Version 3.06') . '</option>';
- echo '<option value="3.07">' . _('Version 3.07') . '</option>';
- echo '<option value="3.08">' . _('Version 3.08') . '</option>';
- echo '<option value="3.09">' . _('Version 3.09') . '</option>';
- echo '<option value="3.10">' . _('Version 3.10') . '</option>';
- echo '<option value="3.11.x">' . _('Version 3.11 or 4.01 - 4.02') . '</option>';
- echo '</select></td></tr></table>';
- } else {
- if ($_SESSION['VersionNumber']=='4.00RC1'){
- $_SESSION['VersionNumber']='3.12';
- }
- prnMsg(_('The webERP code is version') . ' ' . $Version . ' ' . _('and the database version is') . ' ' . $_SESSION['VersionNumber'],'info');
- echo '<input type="hidden" name="OldVersion" value="' . $_SESSION['VersionNumber'] . '" />';
- }
-
- echo '<div class="centre"><input type="submit" name="DoUpgrade" value="' . _('Perform Database Upgrade') . '" /></div>';
- echo '</form>';
-}
-
-if (isset($_POST['DoUpgrade'])){
-
- if ($dbType=='mysql' OR $dbType =='mysqli'){
-
- /* First do a backup
- $BackupFile = $PathPrefix . './companies/' . $_SESSION['DatabaseName'] .'/' . _('Backup') . '_' . Date('Y-m-d-H-i-s') . '.sql.gz';
- $Command = 'mysqldump --opt -h' . $host . ' -u' . $dbuser . ' -p' . $dbpassword . ' ' . $_SESSION['DatabaseName'] . '| gzip > ' . $BackupFile;
- system($Command);
-
- //this could be a weighty file attachment!!
- include('includes/htmlMimeMail.php');
- $mail = new htmlMimeMail();
- $attachment = $mail->getFile( $BackupFile);
- $mail->setText(_('webERP backup file attached'));
- $mail->addAttachment($attachment, $BackupFile, 'application/gz');
- $mail->setSubject(_('Database Backup'));
- $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>');
- $result = $mail->send(array('"' . $_SESSION['UsersRealName'] . '" <' . $_SESSION['UserEmail'] . '>'));
-
- prnMsg(_('A backup of the database has been taken and emailed to you'), 'info');
- unlink($BackupFile); // would be a security issue to leave it there for all to download/see
-
- */
-
- $SQLScripts = array();
-
- if ($_POST['OldVersion']=='Manual') {
- prnMsg(_('No datbase updates have been done as you selected to apply these manually - upgrade SQL scripts are under sql/mysql/ directory in the distribution'),'info');
- } else { //we are into automatically applying database upgrades
-
- prnMsg(_('If there are any failures then please check with your system administrator. Please read all notes carefully to ensure they are expected'),'info');
- switch ($_POST['OldVersion']) {
- //since there are no "break" statements subsequent upgrade scripts will be added to the array
- case '3.00':
- $SQLScripts[] = './sql/mysql/upgrade3.00-3.01.sql';
- case '3.01':
- $SQLScripts[] = './sql/mysql/upgrade3.01-3.02.sql';
- case '3.02':
- $SQLScripts[] = './sql/mysql/upgrade3.02-3.03.sql';
- case '3.03':
- $SQLScripts[] = './sql/mysql/upgrade3.03-3.04.sql';
- case '3.04':
- $SQLScripts[] = './sql/mysql/upgrade3.04-3.05.sql';
- case '3.05':
- $SQLScripts[] = './sql/mysql/upgrade3.05-3.06.sql';
- case '3.06':
- $SQLScripts[] = './sql/mysql/upgrade3.06-3.07.sql';
- case '3.07':
- $SQLScripts[] = './sql/mysql/upgrade3.07-3.08.sql';
- case '3.08':
- case '3.09':
- $SQLScripts[] = './sql/mysql/upgrade3.09-3.10.sql';
- case '3.10':
- $SQLScripts[] = './sql/mysql/upgrade3.10-3.11.sql';
- case '3.11.x':
- case '3.11.1':
- case '3.11.2':
- case '3.11.3':
- case '3.12.32':
- case '4.0RC1':
- case '4.01':
- case '4.02':
- case '4.03RC1':
- case '4.03RC2':
- case '4.03':
- case '4.03.2':
- case '4.03.3':
- case '4.03.5':
- case '4.03.6':
- case '4.03.7':
- $SQLScripts[] = './sql/mysql/upgrade3.11.1-4.00.sql';
- case '4.03.8':
- $SQLScripts[] = './sql/mysql/upgrade4.03-4.04.sql';
- case '4.04':
- $SQLScripts[] = './sql/mysql/upgrade4.04-4.04.1.sql';
- break;
- } //end switch
- }
- } else { //dbType is not mysql or mysqli
- prnMsg(_('Only mysql upgrades are performed seamlessly at this time. Your database will need to be manually updated'),'info');
- }
-
- $result = DB_IgnoreForeignKeys($db);
-
- foreach ($SQLScripts AS $SQLScriptFile) {
-
- $SQLEntries = file($SQLScriptFile);
- $ScriptFileEntries = sizeof($SQLEntries);
- $sql ='';
- $InAFunction = false;
- echo '<br /><table>
- <tr><th colspan=2>' . _('Applying') . ' ' . $SQLScriptFile . '</th></tr>';
-
- for ($i=0; $i<=$ScriptFileEntries; $i++) {
-
- $SQLEntries[$i] = trim($SQLEntries[$i]);
-
- if (substr($SQLEntries[$i], 0, 2) != '--'
- AND substr($SQLEntries[$i], 0, 3) != 'USE'
- AND strstr($SQLEntries[$i],'/*')==FALSE
- AND strlen($SQLEntries[$i])>1){
-
- $sql .= ' ' . $SQLEntries[$i];
-
- //check if this line kicks off a function definition - pg chokes otherwise
- if (substr($SQLEntries[$i],0,15) == 'CREATE FUNCTION'){
- $InAFunction = true;
- }
- //check if this line completes a function definition - pg chokes otherwise
- if (substr($SQLEntries[$i],0,8) == 'LANGUAGE'){
- $InAFunction = false;
- }
- if (strpos($SQLEntries[$i],';')>0 AND ! $InAFunction){
- $sql = substr($sql,0,strlen($sql)-1);
- $result = DB_query($sql, $db, '','', false, false);
- echo '<tr><td>' . $sql . '</td>';
- switch (DB_error_no($db)) {
- case 0:
- echo '<td bgcolor="green">'._('Success').'</td></tr>';
- break;
- case 1050:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Table has already been created').'</td></tr>';
- break;
- case 1054:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Column has already been changed').'</td></tr>';
- break;
- case 1060:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Column has already been created').'</td></tr>';
- break;
- case 1061:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Index already exists').'</td></tr>';
- break;
- case 1062:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Entry has already been done').'</td></tr>';
- break;
- case 1064:
- echo '<td bgcolor="red">'._('Note').' - '. _('SQL syntax error. The SQL error message is'). ' ' . DB_error_msg($db) . '</td></tr>';
- break;
- case 1068:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Primary key already exists').'</td></tr>';
- break;
- case 1091:
- echo '<td bgcolor="yellow">'._('Note').' - '. _('Index already dropped previously').'</td></tr>';
- break;
- default:
- echo '<td bgcolor="red">'._('Failure').' - '. _('Error number').' - '.DB_error_no($db) .' ' . DB_error_msg($db) . '</td></tr>';
- break;
- }
- $sql='';
- }
- } //end if its a valid sql line not a comment
- } //end of for loop around the lines of the sql script
- echo '</table>';
- } //end of loop around SQLScripts apply
- $result =DB_ReinstateForeignKeys($db);
- /*Now get the modified VersionNumber and script pagesecurities */
- $ForceConfigReload=true;
- include('includes/GetConfig.php');
-} /*Dont do upgrade */
-
-include('includes/footer.inc');
+<?php
+/* $Id UpgradeDatabase.php 4183 2010-12-14 09:30:20Z daintree $ */
+
+$PageSecurity = 15; //hard coded in case database is old and PageSecurity stuff cannot be retrieved
+
+include('includes/session.inc');
+$title = _('Upgrade webERP Database');
+include('includes/header.inc');
+
+if (!isset($_POST['DoUpgrade'])){
+
+ prnMsg(_('This script will perform any modifications to the database required to allow the additional functionality in later scripts'),'info');
+ echo '<p><form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+
+ if (!isset($_SESSION['VersionNumber'])){
+ prnMsg(_('The webERP code is version') . ' ' . $Version . ' ' . _('and the database version is not actually recorded at this version'),'info');
+ echo '<table><tr><td>' . _('Select the version you are upgrading from:') . '</td>
+ <td><select name="OldVersion" >';
+ echo '<option selected value="Manual">' . _('Apply database changes manually') . '</option>';
+ echo '<option value="3.00">' . _('Version 3.00') . '</option>';
+ echo '<option value="3.01">' . _('Version 3.01') . '</option>';
+ echo '<option value="3.02">' . _('Version 3.02') . '</option>';
+ echo '<option value="3.03">' . _('Version 3.03') . '</option>';
+ echo '<option value="3.04">' . _('Version 3.04') . '</option>';
+ echo '<option value="3.05">' . _('Version 3.05') . '</option>';
+ echo '<option value="3.06">' . _('Version 3.06') . '</option>';
+ echo '<option value="3.07">' . _('Version 3.07') . '</option>';
+ echo '<option value="3.08">' . _('Version 3.08') . '</option>';
+ echo '<option value="3.09">' . _('Version 3.09') . '</option>';
+ echo '<option value="3.10">' . _('Version 3.10') . '</option>';
+ echo '<option value="3.11.x">' . _('Version 3.11 or 4.01 - 4.02') . '</option>';
+ echo '</select></td></tr></table>';
+ } else {
+ if ($_SESSION['VersionNumber']=='4.00RC1'){
+ $_SESSION['VersionNumber']='3.12';
+ }
+ prnMsg(_('The webERP code is version') . ' ' . $Version . ' ' . _('and the database version is') . ' ' . $_SESSION['VersionNumber'],'info');
+ echo '<input type="hidden" name="OldVersion" value="' . $_SESSION['VersionNumber'] . '" />';
+ }
+
+ echo '<div class="centre"><input type="submit" name="DoUpgrade" value="' . _('Perform Database Upgrade') . '" /></div>';
+ echo '</form>';
+}
+
+if (isset($_POST['DoUpgrade'])){
+
+ if ($dbType=='mysql' OR $dbType =='mysqli'){
+
+ /* First do a backup
+ $BackupFile = $PathPrefix . './companies/' . $_SESSION['DatabaseName'] .'/' . _('Backup') . '_' . Date('Y-m-d-H-i-s') . '.sql.gz';
+ $Command = 'mysqldump --opt -h' . $host . ' -u' . $dbuser . ' -p' . $dbpassword . ' ' . $_SESSION['DatabaseName'] . '| gzip > ' . $BackupFile;
+ system($Command);
+
+ //this could be a weighty file attachment!!
+ include('includes/htmlMimeMail.php');
+ $mail = new htmlMimeMail();
+ $attachment = $mail->getFile( $BackupFile);
+ $mail->setText(_('webERP backup file attached'));
+ $mail->addAttachment($attachment, $BackupFile, 'application/gz');
+ $mail->setSubject(_('Database Backup'));
+ $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>');
+ $result = $mail->send(array('"' . $_SESSION['UsersRealName'] . '" <' . $_SESSION['UserEmail'] . '>'));
+
+ prnMsg(_('A backup of the database has been taken and emailed to you'), 'info');
+ unlink($BackupFile); // would be a security issue to leave it there for all to download/see
+
+ */
+
+ $SQLScripts = array();
+
+ if ($_POST['OldVersion']=='Manual') {
+ prnMsg(_('No datbase updates have been done as you selected to apply these manually - upgrade SQL scripts are under sql/mysql/ directory in the distribution'),'info');
+ } else { //we are into automatically applying database upgrades
+
+ prnMsg(_('If there are any failures then please check with your system administrator. Please read all notes carefully to ensure they are expected'),'info');
+ switch ($_POST['OldVersion']) {
+ //since there are no "break" statements subsequent upgrade scripts will be added to the array
+ case '3.00':
+ $SQLScripts[] = './sql/mysql/upgrade3.00-3.01.sql';
+ case '3.01':
+ $SQLScripts[] = './sql/mysql/upgrade3.01-3.02.sql';
+ case '3.02':
+ $SQLScripts[] = './sql/mysql/upgrade3.02-3.03.sql';
+ case '3.03':
+ $SQLScripts[] = './sql/mysql/upgrade3.03-3.04.sql';
+ case '3.04':
+ $SQLScripts[] = './sql/mysql/upgrade3.04-3.05.sql';
+ case '3.05':
+ $SQLScripts[] = './sql/mysql/upgrade3.05-3.06.sql';
+ case '3.06':
+ $SQLScripts[] = './sql/mysql/upgrade3.06-3.07.sql';
+ case '3.07':
+ $SQLScripts[] = './sql/mysql/upgrade3.07-3.08.sql';
+ case '3.08':
+ case '3.09':
+ $SQLScripts[] = './sql/mysql/upgrade3.09-3.10.sql';
+ case '3.10':
+ $SQLScripts[] = './sql/mysql/upgrade3.10-3.11.sql';
+ case '3.11.x':
+ case '3.11.1':
+ case '3.11.2':
+ case '3.11.3':
+ case '3.12.32':
+ case '4.0RC1':
+ case '4.01':
+ case '4.02':
+ case '4.03RC1':
+ case '4.03RC2':
+ case '4.03':
+ case '4.03.2':
+ case '4.03.3':
+ case '4.03.5':
+ case '4.03.6':
+ case '4.03.7':
+ $SQLScripts[] = './sql/mysql/upgrade3.11.1-4.00.sql';
+ case '4.03.8':
+ $SQLScripts[] = './sql/mysql/upgrade4.03-4.04.sql';
+ case '4.04':
+ $SQLScripts[] = './sql/mysql/upgrade4.04-4.04.1.sql';
+ case '4.04.1':
+ $SQLScripts[] = './sql/mysql/upgrade4.04.1-4.04.4.sql';
+ break;
+ } //end switch
+ }
+ } else { //dbType is not mysql or mysqli
+ prnMsg(_('Only mysql upgrades are performed seamlessly at this time. Your database will need to be manually updated'),'info');
+ }
+
+ $result = DB_IgnoreForeignKeys($db);
+
+ foreach ($SQLScripts AS $SQLScriptFile) {
+
+ $SQLEntries = file($SQLScriptFile);
+ $ScriptFileEntries = sizeof($SQLEntries);
+ $sql ='';
+ $InAFunction = false;
+ echo '<br /><table>
+ <tr><th colspan=2>' . _('Applying') . ' ' . $SQLScriptFile . '</th></tr>';
+
+ for ($i=0; $i<=$ScriptFileEntries; $i++) {
+
+ $SQLEntries[$i] = trim($SQLEntries[$i]);
+
+ if (substr($SQLEntries[$i], 0, 2) != '--'
+ AND substr($SQLEntries[$i], 0, 3) != 'USE'
+ AND strstr($SQLEntries[$i],'/*')==FALSE
+ AND strlen($SQLEntries[$i])>1){
+
+ $sql .= ' ' . $SQLEntries[$i];
+
+ //check if this line kicks off a function definition - pg chokes otherwise
+ if (substr($SQLEntries[$i],0,15) == 'CREATE FUNCTION'){
+ $InAFunction = true;
+ }
+ //check if this line completes a function definition - pg chokes otherwise
+ if (substr($SQLEntries[$i],0,8) == 'LANGUAGE'){
+ $InAFunction = false;
+ }
+ if (strpos($SQLEntries[$i],';')>0 AND ! $InAFunction){
+ $sql = substr($sql,0,strlen($sql)-1);
+ $result = DB_query($sql, $db, '','', false, false);
+ echo '<tr><td>' . $sql . '</td>';
+ switch (DB_error_no($db)) {
+ case 0:
+ echo '<td bgcolor="green">'._('Success').'</td></tr>';
+ break;
+ case 1050:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Table has already been created').'</td></tr>';
+ break;
+ case 1054:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Column has already been changed').'</td></tr>';
+ break;
+ case 1060:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Column has already been created').'</td></tr>';
+ break;
+ case 1061:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Index already exists').'</td></tr>';
+ break;
+ case 1062:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Entry has already been done').'</td></tr>';
+ break;
+ case 1064:
+ echo '<td bgcolor="red">'._('Note').' - '. _('SQL syntax error. The SQL error message is'). ' ' . DB_error_msg($db) . '</td></tr>';
+ break;
+ case 1068:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Primary key already exists').'</td></tr>';
+ break;
+ case 1091:
+ echo '<td bgcolor="yellow">'._('Note').' - '. _('Index already dropped previously').'</td></tr>';
+ break;
+ default:
+ echo '<td bgcolor="red">'._('Failure').' - '. _('Error number').' - '.DB_error_no($db) .' ' . DB_error_msg($db) . '</td></tr>';
+ break;
+ }
+ $sql='';
+ }
+ } //end if its a valid sql line not a comment
+ } //end of for loop around the lines of the sql script
+ echo '</table>';
+ } //end of loop around SQLScripts apply
+ $result =DB_ReinstateForeignKeys($db);
+ /*Now get the modified VersionNumber and script pagesecurities */
+ $ForceConfigReload=true;
+ include('includes/GetConfig.php');
+} /*Dont do upgrade */
+
+include('includes/footer.inc');
?>
\ No newline at end of file
Modified: trunk/WWW_Users.php
===================================================================
--- trunk/WWW_Users.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/WWW_Users.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -475,7 +475,7 @@
echo '<tr><td>' . _('Restrict to Sales Person') . ':</td>
<td><select name="Salesman">';
-$sql = "SELECT salesmancode, salesmanname FROM salesman";
+$sql = "SELECT salesmancode, salesmanname FROM salesman WHERE current = 1";
$result = DB_query($sql,$db);
if ((isset($_POST['Salesman']) and $_POST['Salesman']=='') OR !isset($_POST['Salesman'])){
echo '<option selected value="">' . _('Not a salesperson only login') . '</option>';
Modified: trunk/doc/Change.log
===================================================================
--- trunk/doc/Change.log 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/doc/Change.log 2011-06-09 10:33:38 UTC (rev 4591)
@@ -1,5 +1,9 @@
webERP Change Log
+9/6/11 Phil : Prices.php now updates the end date of a price when a new default (no end date) price is added
+9/6/11 Ricard: PcExpensesTypeTab.php deletion question message fixed as does not delete any expenses set up with this expense type
+9/6/11 Daniel Richert: includes/LanguageSetup.php changed to set $Locale = setlocale (LC_MESSAGES, $_SESSION['Language']); as using LC_ALL over-rides numeric and we need decimal points as . - commas stuff things up
+9/6/11 Ricard: Added new field current to salesman table to flag if the salesman is currently still on the team or not - modified WWW_Users.php and CustomerBranches to only allow selection of current salesfolk
7/6/11 Phil: EmailCustTrans.php missing closing quote off input hidden InvOrCredit value
6/6/11 Phil: Currencies table included 2 x in SQL for getting invoice details in Credit_Invoice.php
6/6/11 Phil: AddSerialItems.php from Stock Adjustment was not picking up single entries because of error in for loop condition fixed
Modified: trunk/includes/ConnectDB.inc
===================================================================
--- trunk/includes/ConnectDB.inc 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/includes/ConnectDB.inc 2011-06-09 10:33:38 UTC (rev 4591)
@@ -4,7 +4,7 @@
* this value is saved in the $_SESSION['Versionumber'] when includes/GetConfig.php is run
* if VersionNumber is < $Version then the DB update script is run */
-$Version='4.04.1'; //must update manually every time there is a DB change
+$Version='4.04.4'; //must update manually every time there is a DB change
require_once ($PathPrefix .'includes/MiscFunctions.php');
Modified: trunk/includes/LanguageSetup.php
===================================================================
--- trunk/includes/LanguageSetup.php 2011-06-07 10:03:04 UTC (rev 4590)
+++ trunk/includes/LanguageSetup.php 2011-06-09 10:33:38 UTC (rev 4591)
@@ -24,8 +24,10 @@
if (function_exists('gettext')){
- $Locale = setlocale (LC_ALL, $_SESSION['Language']);
+ //$Locale = setlocale (LC_ALL, $_SESSION['Language']);
+ $Locale = setlocale (LC_MESSAGES, $_SESSION['Language']);
+
//Turkish seems to be a special case
if ($_SESSION['Language']=='tr_TR.utf8') {
$Locale = setlocale(LC_CTYPE, 'C');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|