From 43b69e1da068e6e8eb602648cc9fc3763bd68e68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Feb 2010 14:49:39 +0000 Subject: [PATCH] Qual: Clean a lot of code to prepare remove of pre.inc.php --- htdocs/ajaxbox.php | 11 +-- htdocs/compta/facture.php | 7 +- htdocs/main.inc.php | 27 +++---- htdocs/pre.inc.php | 146 -------------------------------------- htdocs/soc.php | 2 +- htdocs/societe.php | 2 +- 6 files changed, 24 insertions(+), 171 deletions(-) delete mode 100644 htdocs/pre.inc.php diff --git a/htdocs/ajaxbox.php b/htdocs/ajaxbox.php index 8f40504340c..52b92229a95 100644 --- a/htdocs/ajaxbox.php +++ b/htdocs/ajaxbox.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2009 Laurent Destailleur + * Copyright (C) 2007-2010 Laurent Destailleur * * 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 @@ -30,14 +30,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); - -// Retrieve the entity in the cookie -$entityCookieName = "DOLENTITYID_".md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); -if (isset($_COOKIE[$entityCookieName])) $_SESSION["dol_entity"] = $_COOKIE[$entityCookieName]; - -require('master.inc.php'); +require('./main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/boxes.php"); // Registering the location of boxes diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index de3325dcc01..6e3e609dde0 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -506,7 +506,6 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) { $facture = new Facture($db); $facture->socid=$_POST['socid']; - $facture->fetch_client(); $db->begin(); @@ -530,6 +529,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) { // This is a replacement invoice $result=$facture->fetch($_POST['fac_replacement']); + $facture->fetch_client(); $facture->date = $datefacture; $facture->note_public = trim($_POST['note_public']); @@ -891,6 +891,11 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $ $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
'; $result = -1 ; } + if (empty($_POST['idprod']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"])) + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; + $result = -1 ; + } if (! isset($_POST['qty']) || $_POST['qty']=='') { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b3167c87010..bab2fd5f890 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -594,25 +594,26 @@ if (! defined('NOLOGIN')) } - -if (empty($_GET["lang"])) // If language was not forced on URL +if (! defined('NOREQUIRETRAN')) { - // If user has chosen its own language - if (! empty($user->conf->MAIN_LANG_DEFAULT)) + if (empty($_GET["lang"])) // If language was not forced on URL { - // If different than current language - //print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT; - if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) + // If user has chosen its own language + if (! empty($user->conf->MAIN_LANG_DEFAULT)) { - $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + // If different than current language + //print ">>>".$langs->getDefaultLang()."-".$user->conf->MAIN_LANG_DEFAULT; + if ($langs->getDefaultLang() != $user->conf->MAIN_LANG_DEFAULT) + { + $langs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + } } } + else // If language was forced on URL + { + $langs->setDefaultLang($_GET["lang"]); + } } -else // If language was forced on URL -{ - $langs->setDefaultLang($_GET["lang"]); -} - // Case forcing style from url if (! empty($_GET["theme"])) diff --git a/htdocs/pre.inc.php b/htdocs/pre.inc.php deleted file mode 100644 index ffecc635ed6..00000000000 --- a/htdocs/pre.inc.php +++ /dev/null @@ -1,146 +0,0 @@ - - * Copyright (C) 2003 Eric Seigne - * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2004 Guillaume Delecourt - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - * \file htdocs/pre.inc.php - * \brief File to manage left menu for home page - * \version $Id$ - */ -require ("./main.inc.php"); - - -function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='') -{ - global $user, $conf, $langs; - - top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); - - $menu = new Menu(); - - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) - { - $langs->load("companies"); - $menu->add(DOL_URL_ROOT."/societe.php", $langs->trans("ThirdParties")); - - if ($user->rights->societe->creer) - { - $menu->add(DOL_URL_ROOT."/soc.php?action=create", $langs->trans("MenuNewThirdParty"),1); - } - - $menu->add(DOL_URL_ROOT."/contact/index.php",$langs->trans("Contacts"),1); - } - - if (! empty($conf->categorie->enabled)) - { - $langs->load("categories"); - $menu->add(DOL_URL_ROOT."/categories/index.php?type=0", $langs->trans("Categories")); - } - - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) - { - $langs->trans("interventions"); - $menu->add(DOL_URL_ROOT."/fichinter/index.php", $langs->trans("Interventions")); - } - - if (($conf->produit->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire)) - { - $langs->load("products"); - $chaine=""; - if ($conf->produit->enabled) { $chaine.= $langs->trans("Products"); } - if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; } - if ($conf->service->enabled) { $chaine.= $langs->trans("Services"); } - $menu->add(DOL_URL_ROOT."/product/index.php", "$chaine"); - } - - - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) - { - $langs->load("orders"); - $menu->add(DOL_URL_ROOT."/commande/index.php", $langs->trans("Orders")); - } - - if (! empty($conf->document->enabled)) - { - $menu->add(DOL_URL_ROOT."/docs/index.php", $langs->trans("DocumentsBuilder")); - } - - if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) - { - $langs->load("sendings"); - $menu->add(DOL_URL_ROOT."/expedition/index.php", $langs->trans("Sendings")); - } - - if (! empty($conf->mailing->enabled) && $user->rights->mailing->lire) - { - $langs->load("mails"); - $menu->add(DOL_URL_ROOT."/comm/mailing/index.php",$langs->trans("EMailings")); - } - - if (! empty($conf->telephonie->enabled)) - { - $menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie"); - } - - if (! empty($conf->don->enabled)) - { - $menu->add(DOL_URL_ROOT."/compta/dons/index.php", $langs->trans("Donations")); - } - - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) - { - $langs->load("suppliers"); - $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); - } - - if (! empty($conf->domaine->enabled)) - { - $menu->add(DOL_URL_ROOT."/domain/index.php", "Domaines"); - } - - if (! empty($conf->export->enabled)) - { - $langs->load("exports"); - $menu->add(DOL_URL_ROOT."/exports/index.php?leftmenu=export",$langs->trans("FormatedExport"),0,$user->rights->export->lire); - $menu->add(DOL_URL_ROOT."/exports/export.php?leftmenu=export",$langs->trans("NewExport"),1,$user->rights->export->creer); - } - - if (! empty($conf->global->MAIN_MODULE_IMPORT)) - { - $langs->load("exports"); - $menu->add(DOL_URL_ROOT."/imports/index.php?leftmenu=import",$langs->trans("FormatedImport"),0,$user->rights->import->run); - $menu->add(DOL_URL_ROOT."/imports/import.php?leftmenu=import",$langs->trans("NewImport"),1,$user->rights->import->run); - } - - if ($user->rights->user->user->lire || $user->admin) - { - $langs->load("users"); - $menu->add(DOL_URL_ROOT."/user/home.php", $langs->trans("MenuUsersAndGroups")); - } - - if ($user->admin) - { - $menu->add(DOL_URL_ROOT."/admin/index.php", $langs->trans("Setup")); - } - - left_menu($menu->liste, $help_url); -} -?> diff --git a/htdocs/soc.php b/htdocs/soc.php index 967543f4ade..42d413abfc9 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -29,7 +29,7 @@ * \version $Id$ */ -require("pre.inc.php"); +require("./main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); diff --git a/htdocs/societe.php b/htdocs/societe.php index e6657ece07c..54a9d20bc6e 100644 --- a/htdocs/societe.php +++ b/htdocs/societe.php @@ -25,7 +25,7 @@ * \version $Id$ */ -require_once("./pre.inc.php"); +require_once("./main.inc.php"); include_once(DOL_DOCUMENT_ROOT."/contact.class.php"); $langs->load("companies");