Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
545f8b84
Commit
545f8b84
authored
15 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Fix: delete obsolete fields
parent
4e5eb408
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/install/upgrade2.php
+248
-195
248 additions, 195 deletions
htdocs/install/upgrade2.php
with
248 additions
and
195 deletions
htdocs/install/upgrade2.php
+
248
−
195
View file @
545f8b84
...
...
@@ -263,9 +263,14 @@ function migrate_paiements($db,$langs,$conf)
print
'<br>'
;
print
'<b>'
.
$langs
->
trans
(
'MigrationPaymentsUpdate'
)
.
"</b><br>
\n
"
;
$result
=
$db
->
DDLDescTable
(
MAIN_DB_PREFIX
.
"paiement"
,
"fk_facture"
);
$obj
=
$db
->
fetch_object
(
$result
);
if
(
$obj
)
{
$sql
=
"SELECT p.rowid, p.fk_facture, p.amount"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"paiement as p"
;
$sql
.
=
" WHERE p.fk_facture > 0"
;
$resql
=
$db
->
query
(
$sql
);
dolibarr_install_syslog
(
"upgrade2::migrate_paiements sql="
.
$sql
);
...
...
@@ -284,7 +289,8 @@ function migrate_paiements($db,$langs,$conf)
$i
++
;
}
}
else
{
else
{
dol_print_error
(
$db
);
}
...
...
@@ -324,6 +330,11 @@ function migrate_paiements($db,$langs,$conf)
{
print
$langs
->
trans
(
'MigrationPaymentsNothingToUpdate'
)
.
"<br>
\n
"
;
}
}
else
{
print
$langs
->
trans
(
'MigrationPaymentsNothingToUpdate'
)
.
"<br>
\n
"
;
}
print
'</td></tr>'
;
}
...
...
@@ -341,12 +352,16 @@ function migrate_paiements_orphelins_1($db,$langs,$conf)
print
'<br>'
;
print
'<b>'
.
$langs
->
trans
(
'MigrationPaymentsUpdate'
)
.
"</b><br>
\n
"
;
$result
=
$db
->
DDLDescTable
(
MAIN_DB_PREFIX
.
"paiement"
,
"fk_facture"
);
$obj
=
$db
->
fetch_object
(
$result
);
if
(
$obj
)
{
// Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
$sql
=
"SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"
;
$sql
.
=
" bu2.url_id as socid"
;
$sql
.
=
" FROM ("
.
MAIN_DB_PREFIX
.
"paiement as p, "
.
MAIN_DB_PREFIX
.
"bank_url as bu, "
.
MAIN_DB_PREFIX
.
"bank as b)"
;
$sql
.
=
"
left join
llx_paiement_facture as pf
on
pf.fk_paiement
=
p.rowid"
;
$sql
.
=
"
left join
llx_bank_url as bu2
on
(bu.fk_bank=bu2.fk_bank AND bu2.type
=
'company')"
;
$sql
.
=
"
LEFT JOIN
llx_paiement_facture as pf
ON
pf.fk_paiement
=
p.rowid"
;
$sql
.
=
"
LEFT JOIN
llx_bank_url as bu2
ON
(bu.fk_bank=bu2.fk_bank AND bu2.type
=
'company')"
;
$sql
.
=
" WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"
;
$sql
.
=
" AND b.rappro = 1"
;
$sql
.
=
" AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"
;
...
...
@@ -375,7 +390,8 @@ function migrate_paiements_orphelins_1($db,$langs,$conf)
$i
++
;
}
}
else
{
else
{
dol_print_error
(
$db
);
}
...
...
@@ -408,6 +424,7 @@ function migrate_paiements_orphelins_1($db,$langs,$conf)
$sql
=
"INSERT INTO "
.
MAIN_DB_PREFIX
.
"paiement_facture (fk_facture, fk_paiement, amount)"
;
$sql
.
=
" VALUES ("
.
$facid
.
","
.
$row
[
$i
][
'paymentid'
]
.
","
.
$row
[
$i
][
'pamount'
]
.
")"
;
$res
+=
$db
->
query
(
$sql
);
print
$langs
->
trans
(
'MigrationProcessPaymentUpdate'
,
'facid='
.
$facid
.
'-paymentid='
.
$row
[
$i
][
'paymentid'
]
.
'-amount='
.
$row
[
$i
][
'pamount'
])
.
"<br>
\n
"
;
...
...
@@ -434,6 +451,11 @@ function migrate_paiements_orphelins_1($db,$langs,$conf)
{
print
$langs
->
trans
(
'MigrationPaymentsNothingUpdatable'
)
.
"<br>
\n
"
;
}
}
else
{
print
$langs
->
trans
(
'MigrationPaymentsNothingUpdatable'
)
.
"<br>
\n
"
;
}
print
'</td></tr>'
;
}
...
...
@@ -451,14 +473,19 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
print
'<br>'
;
print
'<b>'
.
$langs
->
trans
(
'MigrationPaymentsUpdate'
)
.
"</b><br>
\n
"
;
$result
=
$db
->
DDLDescTable
(
MAIN_DB_PREFIX
.
"paiement"
,
"fk_facture"
);
$obj
=
$db
->
fetch_object
(
$result
);
if
(
$obj
)
{
// Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture
$sql
=
"SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"
;
$sql
.
=
" bu2.url_id as socid"
;
$sql
.
=
" FROM ("
.
MAIN_DB_PREFIX
.
"paiement as p, "
.
MAIN_DB_PREFIX
.
"bank_url as bu, "
.
MAIN_DB_PREFIX
.
"bank as b)"
;
$sql
.
=
"
left join
llx_paiement_facture as pf
on
pf.fk_paiement
=
p.rowid"
;
$sql
.
=
"
left join
llx_bank_url as bu2
on
(bu.fk_bank
=
bu2.fk_bank AND bu2.type
=
'company')"
;
$sql
.
=
"
LEFT JOIN
llx_paiement_facture as pf
ON
pf.fk_paiement
=
p.rowid"
;
$sql
.
=
"
LEFT JOIN
llx_bank_url as bu2
ON
(bu.fk_bank
=
bu2.fk_bank AND bu2.type
=
'company')"
;
$sql
.
=
" WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"
;
$sql
.
=
" AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"
;
$resql
=
$db
->
query
(
$sql
);
dolibarr_install_syslog
(
"upgrade2::migrate_paiements_orphelins_2 sql="
.
$sql
);
...
...
@@ -484,10 +511,13 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
$i
++
;
}
}
else
{
else
{
dol_print_error
(
$db
);
}
$nberr
=
0
;
if
(
sizeof
(
$row
))
{
print
$langs
->
trans
(
'OrphelinsPaymentsDetectedByMethod'
,
2
)
.
': '
.
sizeof
(
$row
)
.
"<br>
\n
"
;
...
...
@@ -525,6 +555,7 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
else
{
print
'ERROR'
;
$nberr
++
;
}
}
...
...
@@ -544,6 +575,27 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
print
$langs
->
trans
(
'MigrationPaymentsNothingUpdatable'
)
.
"<br>
\n
"
;
}
// Delete obsolete fields fk_facture
$db
->
begin
();
$sql
=
"ALTER TABLE "
.
MAIN_DB_PREFIX
.
"paiement DROP COLUMN fk_facture"
;
$db
->
query
(
$sql
);
if
(
!
$nberr
)
{
$db
->
commit
();
}
else
{
print
'ERROR'
;
$db
->
rollback
();
}
}
else
{
print
$langs
->
trans
(
'MigrationPaymentsNothingUpdatable'
)
.
"<br>
\n
"
;
}
print
'</td></tr>'
;
}
...
...
@@ -641,7 +693,8 @@ function migrate_contracts_det($db,$langs,$conf)
print
$langs
->
trans
(
'MigrationUpdateFailed'
)
.
'<br>'
;
}
}
else
{
else
{
print
$langs
->
trans
(
'MigrationContractsNothingToUpdate'
)
.
"<br>
\n
"
;
}
}
...
...
@@ -923,8 +976,6 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
$obj
=
$db
->
fetch_object
(
$result
);
if
(
$obj
)
{
$db
->
begin
();
$error
=
0
;
$nb
=
0
;
...
...
@@ -956,6 +1007,8 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
$check_num
=
$db
->
num_rows
(
$check_resql
);
if
(
$check_num
==
0
)
{
$db
->
begin
();
if
(
$nb
==
0
)
{
print
'<tr><td colspan="4" nowrap="nowrap"><b>'
.
$langs
->
trans
(
'SuppliersInvoices'
)
.
'</b></td></tr>'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment