function plugin_financialreports_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/financialreports/inc/profile.class.php";
    $update = false;
    if (!TableExists("glpi_plugin_state_profiles") && !TableExists("glpi_plugin_financialreports_configs")) {
        $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/empty-2.1.0.sql");
    } else {
        if (TableExists("glpi_plugin_state_parameters") && !FieldExists("glpi_plugin_state_parameters", "monitor")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.5.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.6.0.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql");
        } else {
            if (TableExists("glpi_plugin_state_profiles") && FieldExists("glpi_plugin_state_profiles", "interface")) {
                $update = true;
                $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.6.0.sql");
                $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql");
            } else {
                if (!TableExists("glpi_plugin_financialreports_configs")) {
                    $update = true;
                    $DB->runFile(GLPI_ROOT . "/plugins/financialreports/sql/update-1.7.0.sql");
                }
            }
        }
    }
    if ($update) {
        //Do One time on 0.78
        $query_ = "SELECT *\n            FROM `glpi_plugin_financialreports_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_financialreports_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_financialreports_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
        Plugin::migrateItemType(array(3450 => 'PluginFinancialreportsDisposalItem'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_financialreports_disposalitems"));
    }
    //Migrate profiles to the new system
    PluginFinancialreportsProfile::initProfile();
    PluginFinancialreportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("2.0.0");
    $migration->dropTable('glpi_plugin_financialreports_profiles');
    return true;
}
Exemple #2
0
Copyright (C) 2003-2011 by the Financialreports Development Team.

https://forge.indepnet.net/projects/financialreports
-------------------------------------------------------------------------

LICENSE
		
This file is part of Financialreports.

Financialreports is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Financialreports 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
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Financialreports. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("profile", "r");
$prof = new PluginFinancialreportsProfile();
//Save profile
if (isset($_POST['update'])) {
    $prof->update($_POST);
    Html::back();
}