X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sql%2Falter2.1.php;h=869186ac0cd4d671cea0c3dd13592474870124c7;hb=833c5906b0583f118cc1f059e257c39a7b8543cc;hp=ff9467a292f4fa1e3446f3008e5cfa7a3c3d3335;hpb=46c5f7a65a7659a44ae8254c63152074363d3987;p=fa-stable.git diff --git a/sql/alter2.1.php b/sql/alter2.1.php index ff9467a2..869186ac 100644 --- a/sql/alter2.1.php +++ b/sql/alter2.1.php @@ -21,23 +21,24 @@ class fa2_1 { // Install procedure. All additional changes // not included in sql file should go here. // - function install($pref, $force) + function install($company, $force) { global $db; + /* Statement below is allowed only for MySQL >=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"; + $sql = "SELECT id, account_code FROM ".TB_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='" + $sql = "UPDATE ".TB_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") @@ -46,7 +47,7 @@ class fa2_1 { } } // copy all item codes from stock_master into item_codes - $sql = "SELECT `stock_id`,`description`,`category_id` FROM ".$pref."stock_master"; + $sql = "SELECT `stock_id`,`description`,`category_id` FROM ".TB_PREF."stock_master"; $result = db_query($sql); if (!$result) { display_error(_("Cannot select stock identificators") @@ -55,7 +56,7 @@ class fa2_1 { } else { while ($row = db_fetch_assoc($result)) { $sql = "INSERT IGNORE " - .$pref."item_codes (`item_code`,`stock_id`,`description`,`category_id`) + .TB_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); @@ -81,11 +82,11 @@ class fa2_1 { "SELECT tr.tran_date, tr.type, tr.trans_no, dt.tax_type_id, dt.rate, dt.included_in_price, dt.amount, tr.reference as ref, tr.rate as ex_rate - FROM ".$pref."debtor_trans_tax_details dt - LEFT JOIN ".$pref."trans_tax_details tt + FROM ".TB_PREF."debtor_trans_tax_details dt + LEFT JOIN ".TB_PREF."trans_tax_details tt ON dt.debtor_trans_no=tt.trans_no AND dt.debtor_trans_type=tt.trans_type, - ".$pref."debtor_trans tr + ".TB_PREF."debtor_trans tr WHERE tt.trans_type is NULL AND dt.debtor_trans_no = tr.trans_no AND dt.debtor_trans_type = tr.type", @@ -94,8 +95,8 @@ class fa2_1 { "SELECT tr.tran_date, tr.type, tr.trans_no, st.tax_type_id, st.rate, st.included_in_price, st.amount, tr.supp_reference as ref, tr.rate as ex_rate - FROM ".$pref."supp_invoice_tax_items st - LEFT JOIN ".$pref."trans_tax_details tt + FROM ".TB_PREF."supp_invoice_tax_items st + LEFT JOIN ".TB_PREF."trans_tax_details tt ON st.supp_trans_no=tt.trans_no AND st.supp_trans_type=tt.trans_type, ".$pref."supp_trans tr @@ -104,14 +105,14 @@ class fa2_1 { AND st.supp_trans_type = tr.type"); foreach ($move_sql as $tbl => $sql) { - if (!check_table($pref, $tbl)){ + if (!check_table(TB_PREF, $tbl)){ $res = db_query($sql, "Cannot retrieve trans tax details from $tbl"); while ($row = db_fetch($res)) { $net_amount = $row['rate'] == 0 ? 0 : ($row['included_in_price'] ? ($row['amount']/$row['rate']*(100-$row['rate'])) :($row['amount']/$row['rate']*100)); - $sql2 = "INSERT INTO ".$pref."trans_tax_details + $sql2 = "INSERT INTO ".TB_PREF."trans_tax_details (trans_type,trans_no,tran_date,tax_type_id,rate,ex_rate, included_in_price, net_amount, amount, memo) VALUES ('".$row['type']."','".$row['trans_no']."','" @@ -121,7 +122,7 @@ class fa2_1 { ."','".$row['amount']."','".$row['ref']."')"; db_query($sql2, "Cannot move trans tax details from $tbl"); } - db_query("DROP TABLE ".$pref.$tbl, "cannot remove $tbl"); + db_query("DROP TABLE ".TB_PREF.$tbl, "cannot remove $tbl"); } }