<?php
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU Affero General Public License,
+ AGPL, as published by the Free Software Foundation, either version
+ 3 of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+***********************************************************************/
class fa2_1 {
var $version = '2.1'; // version installed
var $description = 'Version 2.1';
return false;
}
}
+ // copy all item codes from stock_master into item_codes
+ $sql = "SELECT `stock_id`,`description`,`category_id` FROM ".$pref."stock_master";
+ $result = db_query($sql);
+ if (!$result) {
+ display_error(_("Cannot select stock identificators")
+ .':<br>'. db_error_msg($db));
+ return false;
+ } else {
+ while ($row = db_fetch_assoc($result)) {
+ $sql = "INSERT IGNORE "
+ .$pref."item_codes (`item_code`,`stock_id`,`description`,`category_id`)
+ VALUES('".$row['stock_id']."','".$row['stock_id']."','"
+ .$row['description']."','".$row['category_id']."')";
+ $res2 = db_query($sql);
+ if (!$res2) {
+ display_error(_("Cannot insert stock id into item_codes")
+ .':<br>'. db_error_msg($db));
+ return false;
+ }
+ }
+ }
+ // remove obsolete bank_trans_types table
+ // (DROP queries are skipped during non-forced upgrade)
+ $sql = "DROP TABLE IF EXISTS `0_bank_trans_types`";
+ db_query($sql);
+
return true;
}
//
// Test if patch was applied before.
//
function installed($pref) {
- return !check_table($pref, 'item_codes');
+ if (check_table($pref, 'item_codes')) return false;
+ if (check_table($pref, 'company', 'foreign_codes')) return false;
+ if (check_table($pref, 'supplier', 'credit_limit') return false;
+ return true;
}
};