diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php deleted file mode 100644 index 5c9cc16e01f..00000000000 --- a/htdocs/accountancy/admin/importaccounts.php +++ /dev/null @@ -1,188 +0,0 @@ - - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2018 Frédéric France - * - * This program 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 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/accountancy/admin/importaccounts.php - * \ingroup Advanced accountancy - * \brief Page import accounting account - * @TODO What is this page for ? Remove this ? - */ -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("compta","bills","accountancy")); - -// Security check -if (! $user->admin) - accessforbidden(); - -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - - - - -/* - * View - */ - -llxHeader('', $langs->trans("ImportAccount")); - -$to_import = GETPOST("mesCasesCochees"); - -if ($_POST["action"] == 'import') { - print '
' . $langs->trans("Processing") . '...
'; - if (is_array($to_import) && count($to_import) > 0) { - print '
' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '
'; - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - - $result = $db->query($sql); - if ($result && ($db->num_rows($result) > 0)) { - - $obj = $db->fetch_object($result); - - $cpt = 0; - foreach ($to_import as $maLigneCochee) { - - $accounting = new AccountingAccount($db); - - $monLabel = (string) GETPOST('label' . $maLigneCochee); - $monParentAccount = (string) GETPOST('AccountParent' . $maLigneCochee); - $monType = (string) GETPOST('pcgType' . $maLigneCochee); - $monSubType = (string) GETPOST('pcgSubType' . $maLigneCochee); - - $accounting->fk_pcg_version = $obj->pcg_version; - $accounting->account_number = $maLigneCochee; - $accounting->label = $monLabel; - $accounting->account_parent = $monParentAccount; - $accounting->pcg_type = $monType; - $accounting->pcg_subtype = $monSubType; - $accounting->active = 1; - - $result = $accounting->create($user); - if ($result > 0) { - setEventMessages($langs->trans("AccountingAccountAdd"), null, 'mesgs'); - } else { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - $cpt ++; - } - } else { - setEventMessages($langs->trans('AccountPlanNotFoundCheckSetting'), null, 'errors'); - } - } else { - print '
' . $langs->trans("AnyLineImport") . '
'; - } - print '
' . $langs->trans("EndProcessing") . '
'; -} - -// list accounting account from product - -$sql = "(SELECT p.rowid as product_id, p.accountancy_code_sell as accounting "; -$sql .= " FROM " . MAIN_DB_PREFIX . "product as p "; -$sql .= " WHERE p.accountancy_code_sell >=0"; -$sql .= " GROUP BY accounting "; -$sql .= ")"; -$sql .= "UNION ALL(SELECT p.rowid as product_id, p.accountancy_code_buy as accounting "; -$sql .= " FROM " . MAIN_DB_PREFIX . "product as p "; -$sql .= " WHERE p.accountancy_code_buy >=0"; -$sql .= " GROUP BY accounting "; -$sql .= ") "; -$sql .= " ORDER BY accounting DESC " . $db->plimit($limit + 1, $offset); - -dol_syslog('accountancy/admin/importaccounts.php:: $sql=' . $sql); -$result = $db->query($sql); -if ($result) { - $num_lines = $db->num_rows($result); - $i = 0; - print_barre_liste($langs->trans("ImportAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - - print '
' . "\n"; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $form = new Form($db); - $formaccounting = new FormAccounting($db); - - while ( $i < min($num_lines, $limit) ) { - $objp = $db->fetch_object($result); - print ''; - - print ''; - - print ''; - - // Colonne choix du compte - print ''; - - print ''; - - print ''; - - // Colonne choix ligne a ventiler - $checked = ('label' == 'O') ? ' checked' : ''; - - print ''; - - print ''; - $i ++; - } - - print ''; - - print '
' . $langs->trans("AccountAccouting") . '' . $langs->trans("label") . '' . $langs->trans("Accountparent") . '' . $langs->trans("Pcgtype") . '' . $langs->trans("Pcgsubtype") . '' . $langs->trans("Import") . '
'; - print $objp->accounting; - print ''; - print ''; - print ''; - print $formaccounting->select_account($accounting->account_parent, 'AccountParent'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
 
'; - print '
'; -} else { - print $db->error(); -} - -// End of page -llxFooter(); -$db->close();