Conditionnement de compta->enabled avec comptaexpert->enabled

Simplification du code pour gestion des codes compta (prparation module compta expert)
This commit is contained in:
Laurent Destailleur 2006-03-12 15:28:54 +00:00
parent 52ccd92197
commit 3d4a1ccaa5
37 changed files with 398 additions and 324 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -35,47 +35,50 @@ $langs->load("admin");
if (!$user->admin)
accessforbidden();
$codeclient_addon_var = CODECLIENT_ADDON;
/*
* Actions
*/
if ($_GET["action"] == 'setcodeclient')
{
if (dolibarr_set_const($db, "CODECLIENT_ADDON",$_GET["value"]))
{
// la constante qui a été lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage cohérent
$codeclient_addon_var = $_GET["value"];
Header("Location: societe.php");
}
if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$_GET["value"]))
{
Header("Location: ".$_SERVER["PHP_SELF"]);
}
else
{
dolibarr_print_error($db);
}
}
$codecompta_addon_var = CODECOMPTA_ADDON;
if ($_GET["action"] == 'setcodecompta')
{
if (dolibarr_set_const($db, "CODECOMPTA_ADDON",$_GET["value"]))
{
// la constante qui a été lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage cohérent
$codecompta_addon_var = $_GET["value"];
Header("Location: societe.php");
}
if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$_GET["value"]))
{
Header("Location: ".$_SERVER["PHP_SELF"]);
}
else
{
dolibarr_print_error($db);
}
}
/*
* Affichage page configuration module societe
*
*/
llxHeader();
/*
*
*
*
*/
print_titre($langs->trans("CompanySetup"));
print "<br>";
// Choix du module de gestion des codes clients / fournisseurs
print_titre($langs->trans("CustomerCodeChecker"));
print "<table class=\"noborder\" width=\"100%\">\n";
@ -107,7 +110,7 @@ if ($handle)
print $modCodeClient->info();
print "</td>\n";
if ($codeclient_addon_var == "$file")
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
{
print " <td align=\"center\">\n";
print img_tick();
@ -127,8 +130,12 @@ if ($handle)
}
print '</table>';
print "<br>";
// Choix du module de gestion des codes compta
print_titre($langs->trans("AccountCodeManager"));
print '<table class="noborder" width="100%">';
@ -161,7 +168,7 @@ if ($handle)
print $modCodeCompta->info();
print '</td>';
if ($codecompta_addon_var == "$file")
if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
{
print '<td align="center">';
print img_tick();
@ -180,7 +187,7 @@ if ($handle)
closedir($handle);
}
print "</table>\n";
$db->close();

View File

@ -227,7 +227,8 @@ if ($socidp > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Accountancy");
@ -286,7 +287,7 @@ if ($socidp > 0)
if ($objsoc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode");
print '</td></tr>';
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
print '<tr>';
print '<td nowrap>'.$langs->trans("CustomerAccountancyCode").'</td><td colspan="3">'.$objsoc->code_compta.'</td>';

View File

@ -110,7 +110,8 @@ if ($_socid > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Accountancy");
$h++;

View File

@ -129,7 +129,7 @@ if ($socid > 0)
$h++;
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;

View File

@ -110,7 +110,8 @@ if ($_socid > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Accountancy");
$h++;

View File

@ -109,7 +109,8 @@ if ($_socid > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Accountancy");
$h++;

View File

@ -96,7 +96,7 @@ if ($_GET["id"] > 0) {
$h++;
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans('ComptaCard');

View File

@ -536,7 +536,7 @@ else
$h++;
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans('ComptaCard');
@ -544,11 +544,11 @@ else
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans('Info');

View File

@ -58,14 +58,14 @@ $h = 0;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard");
$h++;
}
}
if ($conf->compta->enabled)
{
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");
$h++;

View File

@ -103,7 +103,7 @@ if ($_GET["id"] > 0)
$h++;
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");

View File

@ -102,12 +102,12 @@ function llxHeader($head = "", $title="", $help_url='')
$menu->add(DOL_URL_ROOT."/compta/deplacement/", "Déplacement");
}
if ($conf->compta->enabled && $conf->compta->tva && $user->societe_id == 0)
if (($conf->compta->enabled || $conf->comptaexpert->enabled) && $conf->compta->tva && $user->societe_id == 0)
{
$menu->add(DOL_URL_ROOT."/compta/tva/index.php",$langs->trans("VAT"));
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$menu->add(DOL_URL_ROOT."/compta/charges/index.php",$langs->trans("Charges"));
}

View File

@ -176,7 +176,8 @@ if ($socid > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$hselected=$h;
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;

View File

@ -164,7 +164,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
/**
* Charges a payer
*/
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
if ($user->societe_id == 0)
{

View File

@ -99,12 +99,12 @@ function llxHeader($head = "", $title="", $help_url='')
$menu->add(DOL_URL_ROOT."/compta/deplacement/", $langs->trans("Trips"));
}
if ($conf->compta->enabled && $conf->compta->tva && $user->societe_id == 0)
if (($conf->compta->enabled || $conf->comptaexpert->enabled) && $conf->compta->tva && $user->societe_id == 0)
{
$menu->add(DOL_URL_ROOT."/compta/tva/index.php",$langs->trans("VAT"));
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$menu->add(DOL_URL_ROOT."/compta/charges/index.php",$langs->trans("Charges"));
}

View File

@ -90,7 +90,8 @@ if ($socid > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$hselected=$h;
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;

View File

@ -134,7 +134,8 @@ if ($socid > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;
$head[$h][1] = $langs->trans("Accountancy");

View File

@ -103,7 +103,7 @@ if ($_GET["id"] > 0)
$h++;
}
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");

View File

@ -104,7 +104,8 @@ if ( $societe->fetch($socid) )
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load('compta');
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid;
$head[$h][1] = $langs->trans('Accountancy');

View File

@ -354,20 +354,21 @@ class MenuLeft {
}
// Charges
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$newmenu->add(DOL_URL_ROOT."/compta/charges/index.php?leftmenu=charges&mainmenu=accountancy",$langs->trans("Charges"), 0, $user->rights->compta->charges->lire);
if ($leftmenu=="charges") $newmenu->add_submenu(DOL_URL_ROOT."/compta/sociales/index.php",$langs->trans("SocialContributions"), 1, $user->rights->compta->charges->creer);
}
if ($conf->compta->enabled && $conf->compta->tva && $user->societe_id == 0)
if (($conf->compta->enabled || $conf->comptaexpert->enabled) && $conf->compta->tva && $user->societe_id == 0)
{
$newmenu->add(DOL_URL_ROOT."/compta/tva/index.php?leftmenu=vat&mainmenu=accountancy",$langs->trans("VAT"),0,$user->rights->compta->charges->lire);
if ($leftmenu=="vat") $newmenu->add_submenu(DOL_URL_ROOT."/compta/tva/fiche.php?action=create",$langs->trans("NewPayment"),1,$user->rights->compta->charges->creer);
if ($leftmenu=="vat") $newmenu->add_submenu(DOL_URL_ROOT."/compta/tva/reglement.php",$langs->trans("Payments"),1,$user->rights->compta->charges->lire);
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
//$newmenu->add(DOL_URL_ROOT."/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Ventilations"));
//if ($leftmenu=="ventil") $newmenu->add_submenu(DOL_URL_ROOT."/compta/ventilation/liste.php",$langs->trans("A ventiler"),1);
//if ($leftmenu=="ventil") $newmenu->add_submenu(DOL_URL_ROOT."/compta/ventilation/lignes.php",$langs->trans("Ventilées"),1);
@ -407,7 +408,8 @@ class MenuLeft {
}
// Rapports
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
// Bilan, résultats
$newmenu->add(DOL_URL_ROOT."/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy",$langs->trans("Reportings"),0,$user->rights->compta->resultat->lire);

View File

@ -374,20 +374,21 @@ class MenuLeft {
// Charges
/*
if ($conf->compta->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$newmenu->add(DOL_URL_ROOT."/compta/charges/index.php?leftmenu=charges&mainmenu=accountancy",$langs->trans("Charges"), 0, $user->rights->compta->charges->lire);
if ($leftmenu=="charges") $newmenu->add_submenu(DOL_URL_ROOT."/compta/sociales/index.php",$langs->trans("SocialContributions"), 1, $user->rights->compta->charges->creer);
}
if ($conf->compta->enabled && $conf->compta->tva && $user->societe_id == 0)
if (($conf->compta->enabled || $conf->comptaexpert->enabled) && $conf->compta->tva && $user->societe_id == 0)
{
$newmenu->add(DOL_URL_ROOT."/compta/tva/index.php?leftmenu=vat&mainmenu=accountancy",$langs->trans("VAT"),0,$user->rights->compta->charges->lire);
if ($leftmenu=="vat") $newmenu->add_submenu(DOL_URL_ROOT."/compta/tva/fiche.php?action=create",$langs->trans("NewPayment"),1,$user->rights->compta->charges->creer);
if ($leftmenu=="vat") $newmenu->add_submenu(DOL_URL_ROOT."/compta/tva/reglement.php",$langs->trans("Payments"),1,$user->rights->compta->charges->lire);
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
//$newmenu->add(DOL_URL_ROOT."/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Ventilations"));
//if ($leftmenu=="ventil") $newmenu->add_submenu(DOL_URL_ROOT."/compta/ventilation/liste.php",$langs->trans("A ventiler"),1);
//if ($leftmenu=="ventil") $newmenu->add_submenu(DOL_URL_ROOT."/compta/ventilation/lignes.php",$langs->trans("Ventilées"),1);

View File

@ -144,9 +144,9 @@ class MenuTop {
}
// Entrée compta
if ($conf->compta->enabled || $conf->banque->enabled || $conf->caisse->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled || $conf->banque->enabled || $conf->caisse->enabled)
{
if ($user->rights->compta->general->lire)
if ($user->rights->compta->general->lire || $user->rights->comptaexpert->general->lire)
{
$langs->load("compta");

View File

@ -175,7 +175,7 @@ class MenuTop {
}
// Compta
if ($conf->compta->enabled || $conf->banque->enabled || $conf->caisse->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled || $conf->banque->enabled || $conf->caisse->enabled)
{
$langs->load("compta");

View File

@ -177,7 +177,7 @@ class MenuTop {
}
// Compta
if ($conf->compta->enabled || $conf->banque->enabled || $conf->caisse->enabled)
if ($conf->compta->enabled || $conf->comptaexpert->enabled || $conf->banque->enabled || $conf->caisse->enabled)
{
$langs->load("compta");

View File

@ -18,8 +18,20 @@
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/includes/modules/societe/mod_codeclient_leopard.class.php
\ingroup societe
\brief Fichier de la classe des gestion leopard des codes clients
\version $Revision$
*/
/**
\class mod_codeclient_leopard
\brief Classe permettant la gestion leopard des codes clients
*/
class mod_codeclient_leopard
{

View File

@ -18,9 +18,21 @@
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/includes/modules/societe/mod_codeclient_zebre.class.php
\ingroup societe
\brief Fichier de la classe des gestion zebre des codes clients
\version $Revision$
*/
/**
\class mod_codeclient_zebre
\brief Classe permettant la gestion zebre des codes clients
*/
class mod_codeclient_zebre
{

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -20,84 +20,98 @@
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/includes/modules/societe/mod_codecompta_aquarium.class.php
\ingroup societe
\brief Fichier de la classe des gestion aquarium des codes compta des societes clientes
\version $Revision$
*/
/**
\class mod_codecompta_aquarium
\brief Classe permettant la gestion aquarium des codes compta des societes clients
*/
class mod_codecompta_aquarium
{
var $nom;
function mod_codecompta_aquarium()
{
$this->nom = "Aquarium";
}
function info()
{
return "Renvoie un code compta composé de 401 suivit du code tiers si c'est un fournisseur, et 411 suivit du code tiers si c'est un client (compta française).";
}
/**
* \brief Renvoi code
* \param DB Handler d'accès base
* \param societe Objet societe
*/
function get_code($DB, $societe)
{
$i = 0;
$this->db = $DB;
if($societe->fournisseur == "1")
$this->code = "401".$societe->code_client;
if($societe->client == "1")
$this->code = "411".$societe->code_client;
$is_dispo = $this->verif($DB, $this->code);
while ( $is_dispo <> 0 && $i < 37)
{
$arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$this->code = $societe->prefix_comm . $societe->code_client . substr($arr, $i, 1);
$is_dispo = $this->verif($DB, $this->code);
$i++;
}
function mod_codecompta_aquarium()
{
$this->nom = "Aquarium";
}
function info()
{
return "Renvoie un code compta composé de 401 suivi du code tiers si c'est un fournisseur, et 411 suivit du code tiers si c'est un client";
}
if ($is_dispo == 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* \brief Renvoi code compta d'une societe
* \param DB Handler d'accès base
* \param societe Objet societe
* \param type Type de tiers ('customer' ou 'supplier')
* \return int >=0 ok, <0 ko
*/
function get_code($DB, $societe, $type)
{
$i = 0;
$this->db = $DB;
// Regle gestion compte compta
if ($type == 'supplier') $codetouse=$societe->code_client;
if ($type == 'customer') $codetouse=$societe->code_fournisseur;
if ($type == 'supplier') $this->code = "401".$codetouse;
if ($type == 'customer') $this->code = "411".$codetouse;
$is_dispo = $this->verif($DB, $this->code);
while ($is_dispo == 0 && $i < 37) // 40 char max
{
$arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$this->code = $societe->prefix_comm . $codetouse . substr($arr, $i, 1);
$is_dispo = $this->verif($DB, $this->code);
$i++;
}
dolibarr_debug("mod_codecompta_aquarium::get_code code=>".$this->code);
return $is_dispo;
}
/**
* \brief Renvoi si un code compta est dispo
* \return int 0 non dispo, >0 dispo, <0 erreur
*/
function verif($db, $code)
{
$sql = "SELECT code_compta FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE code_compta = '".$code."'";
if ($db->query($sql))
{
if ($db->num_rows() == 0)
{
return 1; // Dispo
}
else
{
return 0; // Non dispo
}
}
else
{
return -1; // Erreur
}
}
function verif($db, $code)
{
$sql = "SELECT code_compta FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE code_compta = '".$code."'";
if ($db->query($sql))
{
if ($db->num_rows() == 0)
{
return 0;
}
else
{
return -1;
}
}
else
{
return -2;
}
}
}
?>

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -18,11 +19,25 @@
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/includes/modules/societe/mod_codecompta_digitaria.class.php
\ingroup societe
\brief Fichier de la classe des gestion digitaria des codes compta des societes clientes
\version $Revision$
*/
/**
\class mod_codecompta_digitaria
\brief Classe permettant la gestion digitaria des codes compta des societes clients
*/
class mod_codecompta_digitaria
{
var $nom;
function mod_codecompta_digitaria()
{

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -18,11 +19,25 @@
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/includes/modules/societe/mod_codecompta_panicum.class.php
\ingroup societe
\brief Fichier de la classe des gestion panicum des codes compta des societes clientes
\version $Revision$
*/
/**
\class mod_codecompta_panicum
\brief Classe permettant la gestion panicum des codes compta des societes clients
*/
class mod_codecompta_panicum
{
var $nom;
function mod_codecompta_panicum()
{

View File

@ -219,7 +219,7 @@ if (MAIN_SHOW_WORKBOARD == 1)
//
// Nbre actions à faire (en retard)
if (($conf->commercial->enabled || $conf->compta->enabled) && $user->rights->actions->lire)
if (($conf->commercial->enabled || $conf->compta->enabled || $conf->comptaexpert->enabled) && $user->rights->actions->lire)
{
include_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
$board=new ActionComm($db);

View File

@ -339,6 +339,15 @@ $conf->export->dir_ouput=DOL_DATA_ROOT."/export";
* Modification de quelques variable de conf en fonction des Constantes
*/
// societe
if (! $conf->global->SOCIETE_CODECLIENT_ADDON) $conf->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard";
if (! $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON) $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON="mod_codeclient_leopard";
if (! $conf->global->SOCIETE_CODECOMPTA_ADDON) $conf->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum";
// Pour compatibilite ascendante:
if ($conf->global->CODECLIENT_ADDON) $conf->global->SOCIETE_CODECLIENT_ADDON=$conf->global->CODECLIENT_ADDON;
if ($conf->global->CODEFOURNISSEUR_ADDON) $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON=$conf->global->CODEFOURNISSEUR_ADDON;
// conf->use_preview_tabs
$conf->use_preview_tabs=1;
if (isset($conf->global->MAIN_USE_PREVIEW_TABS)) $conf->use_preview_tabs=$conf->global->MAIN_USE_PREVIEW_TABS;

View File

@ -71,7 +71,7 @@ function llxHeader($head = "") {
}
}
if ($conf->compta->enabled && $user->rights->general->lire)
if (($conf->compta->enabled || $conf->comptaexpert->enabled) && $user->rights->general->lire)
{
$langs->load("compta");
$menu->add(DOL_URL_ROOT."/compta/index.php", $langs->trans("Accountancy"));

View File

@ -48,7 +48,7 @@ if (! $user->rights->societe->creer)
}
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if (! $socid && ($_GET["action"] != 'create' && $_POST["action"] == 'create')) accessforbidden();
if (! $socid && ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add')) accessforbidden();
// Sécurité accés client
if ($user->societe_id > 0)
@ -116,25 +116,6 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
$soc->fournisseur = $_POST["fournisseur"];
$soc->tva_assuj = $_POST["assujtva_value"];
if ($_POST["action"] == 'update')
{
$result = $soc->update($socid,$user);
if ($result <= 0)
{
$soc->id = $socid;
// doublon sur le prefix comm
$reload = 0;
$mesg = $soc->error; //"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre";
$_GET["action"]= "edit";
}
else
{
Header("Location: soc.php?socid=".$socid);
exit;
}
}
if ($_POST["action"] == 'add')
{
$result = $soc->create($user);
@ -146,10 +127,28 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
}
else
{
$mesg=$soc->error;
$_GET["action"]='create';
//dolibarr_print_error($db);
}
}
if ($_POST["action"] == 'update')
{
$result = $soc->update($socid,$user);
if ($result > 0)
{
Header("Location: soc.php?socid=".$socid);
exit;
}
else
{
$soc->id = $socid;
$reload = 0;
$mesg = $soc->error;
$_GET["action"]= "edit";
}
}
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer)
@ -640,7 +639,8 @@ else
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id;
$head[$h][1] = $langs->trans("Accountancy");

View File

@ -87,9 +87,10 @@ class Societe {
* \param DB handler accès base de données
* \param id id societe (0 par defaut)
*/
function Societe($DB, $id=0)
{
global $conf;
$this->db = $DB;
$this->creation_bit = 0;
@ -101,21 +102,26 @@ class Societe {
$this->effectif_id = 0;
$this->forme_juridique_code = 0;
// Définit selon les modules codeclient et codefournisseur
// definit module code client
if (defined('CODECLIENT_ADDON') && strlen(CODECLIENT_ADDON) > 0) $var = CODECLIENT_ADDON;
else $var = "mod_codeclient_leopard";
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$var.'.php';
$this->mod_codeclient = new $var;
$varclient = $conf->global->SOCIETE_CODECLIENT_ADDON;
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$varclient.'.php';
$this->mod_codeclient = new $varclient;
$this->codeclient_modifiable = $this->mod_codeclient->code_modifiable;
// definit module code fournisseur
if (defined('CODEFOURNISSEUR_ADDON') && strlen(CODEFOURNISSEUR_ADDON) > 0) $var = CODEFOURNISSEUR_ADDON;
else $var = "mod_codeclient_leopard";
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$var.'.php';
$this->mod_codefournisseur = new $var;
$this->codeclient_modifiable = $this->mod_codeclient->code_modifiable;
$varfournisseur = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
if ($varfournisseur == $varclient) // Optimisation
{
$this->mod_codefournisseur = $this->mod_codeclient;
}
else
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$varfournisseur.'.php';
$this->mod_codefournisseur = new $varfournisseur;
}
$this->codefournisseur_modifiable = $this->mod_codefournisseur->code_modifiable;
return 1;
}
@ -250,6 +256,7 @@ class Societe {
dolibarr_syslog("Societe::Update");
// Nettoyage des paramètres
$this->id=$id;
$this->capital=trim($this->capital);
$this->nom=trim($this->nom);
@ -270,7 +277,8 @@ class Societe {
$this->effectif_id=trim($this->effectif_id);
$this->forme_juridique_code=trim($this->forme_juridique_code);
$this->tva_assuj=trim($this->tva_assuj);
$result = $this->verify();
$result = $this->verify(); // Verifie que nom obligatoire et code client ok et unique
if ($result >= 0)
{
@ -286,11 +294,6 @@ class Societe {
$this->fax = ereg_replace(" ","",$this->fax);
$this->fax = ereg_replace("\.","",$this->fax);
/*
* Supression des if (trim(valeur)) pour construire la requete
* sinon il est impossible de vider les champs
*/
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
$sql .= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire
$sql .= ", datea = now()";
@ -330,40 +333,34 @@ class Societe {
if ($this->creation_bit || $this->codeclient_modifiable)
{
// Attention check_codeclient peut modifier le code
// suivant le module utilis
// Attention check_codeclient peut modifier le code suivant le module utilise
$this->check_codeclient();
$sql .= ", code_client = ".($this->code_client?"'".addslashes($this->code_client)."'":"null");
// Attention check_codecompta_client peut modifier le code
// suivant le module utilis
$this->check_codecompta_client();
// Attention get_codecompta peut modifier le code suivant le module utilise
$this->get_codecompta('customer');
$sql .= ", code_compta = ".($this->code_compta?"'".addslashes($this->code_compta)."'":"null");
}
if ($this->creation_bit || $this->codefournisseur_modifiable)
{
// Attention check_codefournisseur peut modifier le code
// suivant le module utilis
// Attention check_codefournisseur peut modifier le code suivant le module utilise
$this->check_codefournisseur();
$sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".addslashes($this->code_fournisseur)."'":"null");
// Attention check_codecompta_fournisseur peut modifier le code
// suivant le module utilis
$this->check_codecompta_fournisseur();
// Attention get_codecompta peut modifier le code suivant le module utilise
$this->get_codecompta('supplier');
$sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".addslashes($this->code_compta_fournisseur)."'":"null");
}
if ($user) $sql .= ",fk_user_modif = '".$user->id."'";
$sql .= " WHERE idp = '" . $id ."'";
// Verifie que code compta défini
$resql=$this->db->query($sql);
if ($resql)
{
@ -1188,127 +1185,101 @@ function set_price_level($price_level, $user)
return $this->bank_account->verif();
}
/**
* \brief Verifie code client
* \return Renvoie 0 si ok, peut modifier le code client suivant le module utilisé
*/
function verif_codeclient()
{
if (defined('CODECLIENT_ADDON') && strlen(CODECLIENT_ADDON) > 0)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.CODECLIENT_ADDON.'.php';
$var = CODECLIENT_ADDON;
$mod = new $var;
return $mod->verif($this->db, $this->code_client, $this->id);
}
else
{
return 0;
}
}
function check_codeclient()
{
if (defined('CODECLIENT_ADDON') && strlen(CODECLIENT_ADDON) > 0)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.CODECLIENT_ADDON.'.php';
$var = CODECLIENT_ADDON;
$mod = new $var;
return $mod->verif($this->db, $this->code_client);
}
else
{
return 0;
}
}
function check_codefournisseur()
{
if (defined('CODEFOURNISSEUR_ADDON') && strlen(CODEFOURNISSEUR_ADDON) > 0)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.CODEFOURNISSEUR_ADDON.'.php';
$var = CODEFOURNISSEUR_ADDON;
$mod = new $var;
return $mod->verif($this->db, $this->code_fournisseur);
}
else
{
return 0;
}
}
/**
* \brief Renvoie un code compta, suivant le module le code compta renvoyé
* peut être identique à celui saisit ou généré automatiquement
*
* A ce jour seul la génération automatique est implémentée
*/
function check_codecompta_client()
{
if (defined('CODECOMPTA_ADDON') && strlen(CODECOMPTA_ADDON) > 0)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.CODECOMPTA_ADDON.'.php';
$var = CODECOMPTA_ADDON;
$mod = new $var;
$result = $mod->get_code($this->db, $this);
$this->code_compta = $mod->code;
return $result;
}
else
{
$this->code_compta = '';
return 0;
}
}
/**
* \brief Renvoie un code compta, suivant le module le code compta renvoyé
* peut être identique à celui saisit ou généré automatiquement
*
* A ce jour seul la génération automatique est implémentée
*/
function check_codecompta_fournisseur()
{
if (defined('CODECOMPTAFOURN_ADDON') && strlen(CODECOMPTAFOURN_ADDON) > 0)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.CODECOMPTAFOURN_ADDON.'.php';
$var = CODECOMPTAFOURN_ADDON;
$mod = new $var;
$result = $mod->get_code($this->db, $this);
$this->code_compta_fournisseur = $mod->code;
return $result;
}
else
{
$this->code_compta = '';
return 0;
}
}
/**
* \brief Verifie code client
* \return Renvoie 0 si ok, peut modifier le code client suivant le module utilis
*/
function verif_codeclient()
{
global $conf;
if ($conf->global->SOCIETE_CODECLIENT_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php';
$var = $conf->global->SOCIETE_CODECLIENT_ADDON;
$mod = new $var;
return $mod->verif($this->db, $this->code_client, $this->id);
}
else
{
return 0;
}
}
function check_codeclient()
{
if ($conf->global->SOCIETE_CODECLIENT_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php';
$var = $conf->global->SOCIETE_CODECLIENT_ADDON;
$mod = new $var;
return $mod->verif($this->db, $this->code_client);
}
else
{
return 0;
}
}
function check_codefournisseur()
{
if ($conf->global->CODEFOURNISSEUR_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->CODEFOURNISSEUR_ADDON.'.php';
$var = $conf->global->CODEFOURNISSEUR_ADDON;
$mod = new $var;
return $mod->verif($this->db, $this->code_fournisseur);
}
else
{
return 0;
}
}
/**
* \brief Renvoie un code compta, suivant le module de code compta.
* Peut être identique à celui saisit ou généré automatiquement.
* A ce jour seul la génération automatique est implémentée
* \param type Type de tiers ('customer' ou 'supplier')
*/
function get_codecompta($type)
{
global $conf;
if ($conf->global->SOCIETE_CODECOMPTA_ADDON)
{
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php';
$var = $conf->global->SOCIETE_CODECOMPTA_ADDON;
$mod = new $var;
$result = $mod->get_code($this->db, $this, $type);
if ($type == 'customer') $this->code_compta = $mod->code;
if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code;
return $result;
}
else
{
if ($type == 'customer') $this->code_compta = '';
if ($type == 'supplier') $this->code_compta_fournisseur = '';
return 0;
}
}
/**
* \brief Défini la société mère pour les filiales
* \param id id compagnie mère à positionner

View File

@ -94,7 +94,8 @@ if ($soc->fournisseur)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id;
$head[$h][1] = $langs->trans("Accountancy");

View File

@ -143,8 +143,9 @@ if ( $soc->fetch($soc->id) )
$h++;
}
if ($conf->compta->enabled) {
$langs->load("compta");
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id;
$head[$h][1] = $langs->trans("Accountancy");
$h++;

View File

@ -103,7 +103,8 @@ if ($socidp > 0)
$h++;
}
if ($conf->compta->enabled) {
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;
$head[$h][1] = $langs->trans("Accountancy");

View File

@ -315,7 +315,12 @@ if ($action == 'create')
$generated_password='';
if ($conf->global->USER_PASSWORD_GENERATED)
{
$generated_passowrd='';
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
$nomfichier=$nomclass.".class.php";
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
$genhandler=new $nomclass($db,$conf,$lang,$user);
$generated_password=$genhandler->getNewGeneratedPassword();
}
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
print '<td class="valeur"><input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'"></td></tr>';