X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sql%2Falter2.1.php;fp=sql%2Falter2.1.php;h=8e3a0d546dcf99d02b173fa38bf2f2de37910920;hb=06b2ced510cc44239e267d50b7007d98f686da55;hp=0000000000000000000000000000000000000000;hpb=90ccfadd90aa37c22f88f7bc5628f0ebeec0b29f;p=fa-stable.git
diff --git a/sql/alter2.1.php b/sql/alter2.1.php
new file mode 100644
index 00000000..8e3a0d54
--- /dev/null
+++ b/sql/alter2.1.php
@@ -0,0 +1,52 @@
+=4.0.4:
+ UPDATE `0_bank_trans`, `0_bank_accounts`
+ SET 0_bank_trans.bank_act=0_bank_accounts.id
+ WHERE 0_bank_trans.bank_act=0_bank_accounts.account_code;
+ */
+ $sql = "SELECT id, account_code FROM ".$pref."bank_accounts";
+ if(!($res = db_query($sql))) {
+ display_error(_("Cannot retrieve bank accounts codes")
+ .':
'. db_error_msg($db));
+ return false;
+ }
+ while ($acc = db_fetch($res)) {
+ $sql = "UPDATE ".$pref."bank_trans SET bank_act='"
+ .$acc['id']."' WHERE bank_act=".$acc['account_code'];
+ if (db_query($sql)==false) {
+ display_error(_("Cannot update bank transactions")
+ .':
'. db_error_msg($db));
+ return false;
+ }
+ }
+ return true;
+ }
+ //
+ // Checking before install
+ //
+ function pre_check($pref)
+ {
+ return true; // true when ok, fail otherwise
+ }
+ //
+ // Test if patch was applied before.
+ //
+ function installed($pref) {
+ return !check_table($pref, 'item_codes');
+ }
+};
+
+$install = new fa2_1;
+?>
\ No newline at end of file