forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Z_Upgrade_3.01-3.02.php
43 lines (31 loc) · 1.27 KB
/
Z_Upgrade_3.01-3.02.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
//$PageSecurity = 15;
include('includes/session.php');
$Title = _('Upgrade webERP 3.01 - 3.02');
include('includes/header.php');
prnMsg(_('Upgrade script to number salesorderdetails records as required by version 3.02 .... please wait'),'info');
$TestAlreadyDoneResult = DB_query('SELECT * FROM salesorderdetails WHERE orderlineno>=1');
if (DB_num_rows($TestAlreadyDoneResult)>0){
prnMsg(_('The upgrade script appears to have been run already successfully - there is no need to re-run it'),'info');
include('includes/footer.php');
exit;
}
$lineno = 1;
$orderno = 0;
$SalesOrdersResult = DB_query('SELECT orderno, stkcode FROM salesorderdetails ORDER BY orderno');
while ($SalesOrderDetails = DB_fetch_array($SalesOrdersResult)) {
if($OrderNo != $SalesOrderDetails['orderno']) {
$LineNo = 0;
} else {
$LineNo++;
}
$OrderNo = $SalesOrderDetails['orderno'];
DB_query('UPDATE salesorderdetails
SET orderlineno=' . $LineNo . '
WHERE orderno=' . $OrderNo . "
AND stkcode='" . $SalesOrderDetails['stkcode'] ."'");
}
DB_query( 'ALTER TABLE salesorderdetails ADD CONSTRAINT salesorderdetails_pk primary key(orderno, orderlineno)');
prnMsg(_('The sales orderdetails lines have been numbered appropriately for version 3.02'),'success');
include('includes/footer.php');
?>