forked from Wavyzz/dolibarr
Qual: Uniformize code, Declare parent class as abstract, Doxygen
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
* \file htdocs/includes/modules/societe/mod_codeclient_elephant.php
|
||||
* \ingroup societe
|
||||
* \brief File of class to manage third party code with elephant rule
|
||||
* \version $Id: mod_codeclient_elephant.php,v 1.15 2011/07/31 23:28:14 eldy Exp $
|
||||
* \version $Id: mod_codeclient_elephant.php,v 1.16 2011/08/27 13:15:38 eldy Exp $
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.php");
|
||||
@@ -34,25 +34,23 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.
|
||||
*/
|
||||
class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
{
|
||||
var $nom; // Nom du modele
|
||||
var $nom='Elephant'; // Nom du modele
|
||||
var $code_modifiable; // Code modifiable
|
||||
var $code_modifiable_invalide; // Code modifiable si il est invalide
|
||||
var $code_modifiable_null; // Code modifiables si il est null
|
||||
var $code_null; // Code facultatif
|
||||
var $version; // 'development', 'experimental', 'dolibarr'
|
||||
var $code_auto; // Numerotation automatique
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
var $code_auto; // Numerotation automatique
|
||||
|
||||
var $searchcode; // String de recherche
|
||||
var $numbitcounter; // Nombre de chiffres du compteur
|
||||
var $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre}
|
||||
|
||||
|
||||
/** \brief Constructeur classe
|
||||
/** Constructor
|
||||
*/
|
||||
function mod_codeclient_elephant()
|
||||
{
|
||||
$this->nom = "Elephant";
|
||||
$this->version = "dolibarr";
|
||||
$this->code_null = 0;
|
||||
$this->code_modifiable = 1;
|
||||
$this->code_modifiable_invalide = 1;
|
||||
@@ -62,8 +60,10 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi la description du module
|
||||
* \return string Texte descripif
|
||||
/** Return description of module
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @return string Description of module
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
@@ -107,9 +107,11 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return an example of number value
|
||||
* \param $type Client ou fournisseur (1:client, 2:fournisseur)
|
||||
* \return string Texte descripif
|
||||
/** Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @param $objsoc Object thirdparty
|
||||
* @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
*/
|
||||
function getExample($langs,$objsoc=0,$type=-1)
|
||||
{
|
||||
@@ -135,10 +137,11 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
return $examplecust.'<br>'.$examplesup;
|
||||
}
|
||||
|
||||
/** \brief Return next value
|
||||
* \param objsoc Object third party
|
||||
* \param $type Client ou fournisseur (1:client, 2:fournisseur)
|
||||
* \return string Value if OK, '' if module not configured, <0 if KO
|
||||
/** Return next value
|
||||
*
|
||||
* @param objsoc Object third party
|
||||
* @param $type Client ou fournisseur (1:client, 2:fournisseur)
|
||||
* @return string Value if OK, '' if module not configured, <0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc=0,$type=-1)
|
||||
{
|
||||
@@ -178,8 +181,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Verifie si le mask utilise le prefix
|
||||
*
|
||||
* Verifie si le mask utilise le prefix
|
||||
*/
|
||||
function verif_prefixIsUsed()
|
||||
{
|
||||
@@ -196,12 +198,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Check validity of code according to its rules
|
||||
* \param $db Database handler
|
||||
* \param $code Code to check/correct
|
||||
* \param $soc Object third party
|
||||
* \param $type 0 = customer/prospect , 1 = supplier
|
||||
* \return int 0 if OK
|
||||
* Check validity of code according to its rules
|
||||
*
|
||||
* @param $db Database handler
|
||||
* @param $code Code to check/correct
|
||||
* @param $soc Object third party
|
||||
* @param $type 0 = customer/prospect , 1 = supplier
|
||||
* @return int 0 if OK
|
||||
* -1 ErrorBadCustomerCodeSyntax
|
||||
* -2 ErrorCustomerCodeRequired
|
||||
* -3 ErrorCustomerCodeAlreadyUsed
|
||||
@@ -245,11 +248,12 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code est pris ou non (par autre tiers)
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a verifier
|
||||
* \param $soc Objet societe
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
* Renvoi si un code est pris ou non (par autre tiers)
|
||||
*
|
||||
* @param $db Handler acces base
|
||||
* @param $code Code a verifier
|
||||
* @param $soc Objet societe
|
||||
* @return int 0 si dispo, <0 si erreur
|
||||
*/
|
||||
function verif_dispo($db, $code, $soc)
|
||||
{
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
* \file htdocs/includes/modules/societe/mod_codeclient_leopard.php
|
||||
* \ingroup societe
|
||||
* \brief Fichier de la classe des gestion leopard des codes clients
|
||||
* \version $Id: mod_codeclient_leopard.php,v 1.17 2011/07/31 23:28:14 eldy Exp $
|
||||
* \version $Id: mod_codeclient_leopard.php,v 1.18 2011/08/27 13:15:37 eldy Exp $
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class mod_codeclient_leopard
|
||||
\brief Classe permettant la gestion leopard des codes tiers
|
||||
* \class mod_codeclient_leopard
|
||||
* \brief Classe permettant la gestion leopard des codes tiers
|
||||
*/
|
||||
class mod_codeclient_leopard extends ModeleThirdPartyCode
|
||||
{
|
||||
@@ -37,24 +37,22 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode
|
||||
* Attention ce module est utilise par defaut si aucun module n'a
|
||||
* ete definit dans la configuration
|
||||
*
|
||||
* Le fonctionnement de celui-ci doit dont rester le plus ouvert possible
|
||||
* Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
|
||||
*/
|
||||
|
||||
var $nom; // Nom du modele
|
||||
var $nom='Leopard'; // Nom du modele
|
||||
var $code_modifiable; // Code modifiable
|
||||
var $code_modifiable_invalide; // Code modifiable si il est invalide
|
||||
var $code_modifiable_null; // Code modifiables si il est null
|
||||
var $code_null; // Code facultatif
|
||||
var $version; // 'development', 'experimental', 'dolibarr'
|
||||
var $code_auto; // Numerotation automatique
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
var $code_auto; // Numerotation automatique
|
||||
|
||||
|
||||
/** \brief Constructeur classe
|
||||
/** Constructor
|
||||
*/
|
||||
function mod_codeclient_leopard()
|
||||
{
|
||||
$this->nom = "Leopard";
|
||||
$this->version = "dolibarr";
|
||||
$this->code_null = 1;
|
||||
$this->code_modifiable = 1;
|
||||
$this->code_modifiable_invalide = 1;
|
||||
@@ -63,9 +61,10 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoie la description du module
|
||||
* \return string Texte descripif
|
||||
/** Return description of module
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @return string Description of module
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
@@ -73,8 +72,11 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return next value available
|
||||
* \return string Value
|
||||
/** Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @param $objsoc Object thirdparty
|
||||
* @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
*/
|
||||
function getNextValue($objsoc=0,$type=-1)
|
||||
{
|
||||
@@ -84,12 +86,13 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Check validity of code according to its rules
|
||||
* \param $db Database handler
|
||||
* \param $code Code to check/correct
|
||||
* \param $soc Object third party
|
||||
* \param $type 0 = customer/prospect , 1 = supplier
|
||||
* \return int 0 if OK
|
||||
* Check validity of code according to its rules
|
||||
*
|
||||
* @param $db Database handler
|
||||
* @param $code Code to check/correct
|
||||
* @param $soc Object third party
|
||||
* @param $type 0 = customer/prospect , 1 = supplier
|
||||
* @return int 0 if OK
|
||||
* -1 ErrorBadCustomerCodeSyntax
|
||||
* -2 ErrorCustomerCodeRequired
|
||||
* -3 ErrorCustomerCodeAlreadyUsed
|
||||
|
||||
@@ -21,30 +21,31 @@
|
||||
* \file htdocs/includes/modules/societe/mod_codeclient_monkey.php
|
||||
* \ingroup societe
|
||||
* \brief Fichier de la classe des gestion lion des codes clients
|
||||
* \version $Id: mod_codeclient_monkey.php,v 1.11 2011/07/31 23:28:14 eldy Exp $
|
||||
* \version $Id: mod_codeclient_monkey.php,v 1.12 2011/08/27 13:15:38 eldy Exp $
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class mod_codeclient_monkey
|
||||
\brief Classe permettant la gestion monkey des codes tiers
|
||||
* \class mod_codeclient_monkey
|
||||
* \brief Classe permettant la gestion monkey des codes tiers
|
||||
*/
|
||||
class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
{
|
||||
var $nom; // Nom du modele
|
||||
var $nom='Monkey'; // Nom du modele
|
||||
var $code_modifiable; // Code modifiable
|
||||
var $code_modifiable_invalide; // Code modifiable si il est invalide
|
||||
var $code_modifiable_null; // Code modifiables si il est null
|
||||
var $code_null; // Code facultatif
|
||||
var $version; // 'development', 'experimental', 'dolibarr'
|
||||
var $code_auto; // Numerotation automatique
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
var $code_auto; // Numerotation automatique
|
||||
|
||||
var $prefixcustomer='CU';
|
||||
var $prefixsupplier='SU';
|
||||
|
||||
/** \brief Constructeur classe
|
||||
|
||||
/** Constructor classe
|
||||
*/
|
||||
function mod_codeclient_monkey()
|
||||
{
|
||||
@@ -58,8 +59,10 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi la description du module
|
||||
* \return string Texte descripif
|
||||
/** Return description of module
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @return string Description of module
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
@@ -67,8 +70,11 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi la description du module
|
||||
* \return string Texte descripif
|
||||
/** Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @param $objsoc Object thirdparty
|
||||
* @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
*/
|
||||
function getExample($langs,$objsoc=0,$type=-1)
|
||||
{
|
||||
@@ -76,10 +82,11 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return next value
|
||||
* \param objsoc Object third party
|
||||
* \param $type Client ou fournisseur (1:client, 2:fournisseur)
|
||||
* \return string Value if OK, '' if module not configured, <0 if KO
|
||||
/** Return next value
|
||||
*
|
||||
* @param objsoc Object third party
|
||||
* @param type Client ou fournisseur (1:client, 2:fournisseur)
|
||||
* @return string Value if OK, '' if module not configured, <0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc=0,$type=-1)
|
||||
{
|
||||
@@ -134,12 +141,13 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Check validity of code according to its rules
|
||||
* \param $db Database handler
|
||||
* \param $code Code to check/correct
|
||||
* \param $soc Object third party
|
||||
* \param $type 0 = customer/prospect , 1 = supplier
|
||||
* \return int 0 if OK
|
||||
* Check validity of code according to its rules
|
||||
*
|
||||
* @param $db Database handler
|
||||
* @param $code Code to check/correct
|
||||
* @param $soc Object third party
|
||||
* @param $type 0 = customer/prospect , 1 = supplier
|
||||
* @return int 0 if OK
|
||||
* -1 ErrorBadCustomerCodeSyntax
|
||||
* -2 ErrorCustomerCodeRequired
|
||||
* -3 ErrorCustomerCodeAlreadyUsed
|
||||
@@ -193,11 +201,12 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code est pris ou non (par autre tiers)
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a verifier
|
||||
* \param $soc Objet societe
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
* Renvoi si un code est pris ou non (par autre tiers)
|
||||
*
|
||||
* @param $db Handler acces base
|
||||
* @param $code Code a verifier
|
||||
* @param $soc Objet societe
|
||||
* @return int 0 si dispo, <0 si erreur
|
||||
*/
|
||||
function verif_dispo($db, $code, $soc)
|
||||
{
|
||||
@@ -226,9 +235,10 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code respecte la syntaxe
|
||||
* \param $code Code a verifier
|
||||
* \return int 0 si OK, <0 si KO
|
||||
* Renvoi si un code respecte la syntaxe
|
||||
*
|
||||
* @param $code Code a verifier
|
||||
* * @return int 0 si OK, <0 si KO
|
||||
*/
|
||||
function verif_syntax($code)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2006-2011 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
|
||||
@@ -19,85 +19,83 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/modules/societe/mod_codecompta_aquarium.php
|
||||
\ingroup societe
|
||||
\brief Fichier de la classe des gestion aquarium des codes compta des societes clientes
|
||||
\version $Id: mod_codecompta_aquarium.php,v 1.17 2011/07/31 23:28:14 eldy Exp $
|
||||
* \file htdocs/includes/modules/societe/mod_codecompta_aquarium.php
|
||||
* \ingroup societe
|
||||
* \brief File of class to manage accountancy code of thirdparties with Panicum rules
|
||||
* \version $Id: mod_codecompta_aquarium.php,v 1.18 2011/08/27 13:15:38 eldy Exp $
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class mod_codecompta_aquarium
|
||||
\brief Classe permettant la gestion aquarium des codes compta des societes clients
|
||||
* \class mod_codecompta_aquarium
|
||||
* \brief Class to manage accountancy code of thirdparties with Aquarium rules
|
||||
*/
|
||||
class mod_codecompta_aquarium extends ModeleAccountancyCode
|
||||
{
|
||||
var $nom;
|
||||
var $nom='Aquarium';
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
var $prefixcodecomptacustomer='411';
|
||||
var $prefixcodecomptasupplier='401';
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructor
|
||||
* Constructor
|
||||
*/
|
||||
function mod_codecompta_aquarium()
|
||||
{
|
||||
$this->nom = "Aquarium";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return description of module
|
||||
* \param $langs Object langs
|
||||
* \return string Description
|
||||
/** Return description of module
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @return string Description of module
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
return $langs->trans("ModuleCompanyCode".$this->nom);
|
||||
}
|
||||
|
||||
/** Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @param $objsoc Object thirdparty
|
||||
* @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
*/
|
||||
function getExample($langs,$objsoc=0,$type=-1)
|
||||
{
|
||||
return $this->prefixcodecomptacustomer.'MYTHIRDPARTY';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return accountancy account code for a third party
|
||||
* \param DB Database handler
|
||||
* \param societe Third party object
|
||||
* \param type 'customer' or 'supplier'
|
||||
* \return int >=0 if OK, <0 if KO
|
||||
* Set accountancy account code for a third party into this->code
|
||||
*
|
||||
* @param db Database handler
|
||||
* @param societe Third party object
|
||||
* @param type 'customer' or 'supplier'
|
||||
* @return int >=0 if OK, <0 if KO
|
||||
*/
|
||||
function get_code($DB, $societe, $type)
|
||||
function get_code($db, $societe, $type)
|
||||
{
|
||||
$prefixcodecomptacustomer='411';
|
||||
$prefixcodecomptasupplier='401';
|
||||
|
||||
$i = 0;
|
||||
$this->db = $DB;
|
||||
$this->db = $db;
|
||||
|
||||
dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".$societe->nom);
|
||||
|
||||
// Regle gestion compte compta
|
||||
$codetouse='';
|
||||
if ($type == 'customer') $codetouse = $prefixcodecomptacustomer;
|
||||
if ($type == 'supplier') $codetouse = $prefixcodecomptasupplier;
|
||||
if ($type == 'customer') $codetouse.=$societe->code_client;
|
||||
if ($type == 'supplier') $codetouse.=$societe->code_fournisseur;
|
||||
if ($type == 'customer') $codetouse = $this->prefixcodecomptacustomer;
|
||||
if ($type == 'supplier') $codetouse = $this->prefixcodecomptasupplier;
|
||||
if ($type == 'customer') $codetouse.= ($societe->code_client?$societe->code_client:'CustomerCode');
|
||||
if ($type == 'supplier') $codetouse.= ($societe->code_fournisseur?$societe->code_fournisseur:'SupplierCode');
|
||||
$codetouse=strtoupper(preg_replace('/([^a-z0-9])/i','',$codetouse));
|
||||
|
||||
$is_dispo = $this->verif($DB, $codetouse, $societe, $type);
|
||||
$is_dispo = $this->verif($db, $codetouse, $societe, $type);
|
||||
if (! $is_dispo)
|
||||
{
|
||||
/*
|
||||
// On tente ajout suffix
|
||||
while ($is_dispo == 0 && $i < 37)
|
||||
{
|
||||
$arr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$altcodetouse = $codetouse . substr($arr, $i, 1);
|
||||
|
||||
$is_dispo = $this->verif($DB, $altcodetouse, $societe, $type);
|
||||
|
||||
$i++;
|
||||
}
|
||||
*/
|
||||
// Pour retour
|
||||
// $this->code=$altcodetouse;
|
||||
$this->code=$codetouse;
|
||||
}
|
||||
else
|
||||
@@ -111,12 +109,13 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return if a code is available
|
||||
* \param db Database handler
|
||||
* \param code Code of third party
|
||||
* \param societe Object third party
|
||||
* \param type 'supplier' or 'customer'
|
||||
* \return int 0 if OK but not available, >0 if OK and available, <0 if KO
|
||||
* Return if a code is available
|
||||
*
|
||||
* @param db Database handler
|
||||
* @param code Code of third party
|
||||
* @param societe Object third party
|
||||
* @param type 'supplier' or 'customer'
|
||||
* @return int 0 if OK but not available, >0 if OK and available, <0 if KO
|
||||
*/
|
||||
function verif($db, $code, $societe, $type)
|
||||
{
|
||||
|
||||
@@ -20,46 +20,60 @@
|
||||
/**
|
||||
* \file htdocs/includes/modules/societe/mod_codecompta_panicum.php
|
||||
* \ingroup societe
|
||||
* \brief Fichier de la classe des gestion panicum des codes compta des societes clientes
|
||||
* \version $Id: mod_codecompta_panicum.php,v 1.8 2011/07/31 23:28:14 eldy Exp $
|
||||
* \brief File of class to manage accountancy code of thirdparties with Panicum rules
|
||||
* \version $Id: mod_codecompta_panicum.php,v 1.9 2011/08/27 13:15:38 eldy Exp $
|
||||
*/
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.php");
|
||||
|
||||
|
||||
/**
|
||||
* \class mod_codecompta_panicum
|
||||
* \brief Classe permettant la gestion panicum des codes compta des societes clients
|
||||
* \brief Class to manage accountancy code of thirdparties with Panicum rules
|
||||
*/
|
||||
class mod_codecompta_panicum extends ModeleAccountancyCode
|
||||
{
|
||||
var $nom;
|
||||
var $nom='Panicum';
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function mod_codecompta_panicum()
|
||||
{
|
||||
$this->nom = "Panicum";
|
||||
}
|
||||
|
||||
|
||||
/** Return description of module
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @return string Description of module
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
return $langs->trans("ModuleCompanyCode".$this->nom);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return example
|
||||
/** Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @param $objsoc Object thirdparty
|
||||
* @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
*/
|
||||
function getExample()
|
||||
function getExample($langs,$objsoc=0,$type=-1)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi code
|
||||
* \param DB Handler d'acc<63>s base
|
||||
* \param societe Objet societe
|
||||
* Set accountancy account code for a third party into this->code
|
||||
*
|
||||
* @param db Database handler
|
||||
* @param societe Third party object
|
||||
* @param type 'customer' or 'supplier'
|
||||
* @return int >=0 if OK, <0 if KO
|
||||
*/
|
||||
function get_code($DB, $societe)
|
||||
function get_code($db, $societe, $type='')
|
||||
{
|
||||
// Renvoie toujours ok
|
||||
$this->code = $societe->code_compta;
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
/**
|
||||
* \file htdocs/includes/modules/societe/modules_societe.class.php
|
||||
* \ingroup societe
|
||||
* \brief Fichier contenant la classe mere de module de generation societes
|
||||
* \version $Id: modules_societe.class.php,v 1.28 2011/07/31 23:28:14 eldy Exp $
|
||||
* \brief File with parent class of submodules to manage numbering and document generation
|
||||
*/
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commondocgenerator.class.php");
|
||||
|
||||
@@ -32,40 +31,41 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/commondocgenerator.class.php");
|
||||
* \class ModeleThirdPartyDoc
|
||||
* \brief Parent class for third parties models of doc generators
|
||||
*/
|
||||
class ModeleThirdPartyDoc extends CommonDocGenerator
|
||||
abstract class ModeleThirdPartyDoc extends CommonDocGenerator
|
||||
{
|
||||
var $error='';
|
||||
var $error='';
|
||||
|
||||
/**
|
||||
* Return list of active generation modules
|
||||
* @param $db Database handler
|
||||
* @param $maxfilenamelength Max length of value to show
|
||||
*/
|
||||
function liste_modeles($db,$maxfilenamelength=0)
|
||||
{
|
||||
global $conf;
|
||||
/**
|
||||
* Return list of active generation modules
|
||||
* @param $db Database handler
|
||||
* @param $maxfilenamelength Max length of value to show
|
||||
*/
|
||||
function liste_modeles($db,$maxfilenamelength=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$type='company';
|
||||
$liste=array();
|
||||
$type='company';
|
||||
$liste=array();
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
|
||||
$liste=getListOfModels($db,$type,$maxfilenamelength);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
|
||||
$liste=getListOfModels($db,$type,$maxfilenamelength);
|
||||
|
||||
return $liste;
|
||||
}
|
||||
return $liste;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \class ModeleThirdPartyCode
|
||||
* \brief Classe mere des modeles de numerotation des codes tiers
|
||||
* \brief Parent class for third parties code generators
|
||||
*/
|
||||
class ModeleThirdPartyCode
|
||||
abstract class ModeleThirdPartyCode
|
||||
{
|
||||
var $error='';
|
||||
|
||||
/** \brief Renvoi la description par defaut du modele de numerotation
|
||||
* \return string Texte descripif
|
||||
/** Renvoi la description par defaut du modele de numerotation
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
@@ -73,8 +73,9 @@ class ModeleThirdPartyCode
|
||||
return $langs->trans("NoDescription");
|
||||
}
|
||||
|
||||
/** \brief Renvoi nom module
|
||||
* \return string Nom du module
|
||||
/** Renvoi nom module
|
||||
*
|
||||
* @return string Nom du module
|
||||
*/
|
||||
function getNom($langs)
|
||||
{
|
||||
@@ -82,8 +83,9 @@ class ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi un exemple de numerotation
|
||||
* \return string Example
|
||||
/** Renvoi un exemple de numerotation
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
function getExample($langs)
|
||||
{
|
||||
@@ -91,42 +93,46 @@ class ModeleThirdPartyCode
|
||||
return $langs->trans("NoExample");
|
||||
}
|
||||
|
||||
/** \brief Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
* \return boolean false si conflit, true si ok
|
||||
/** Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
*
|
||||
* @return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \brief Return next value available
|
||||
* \return string Value
|
||||
/** Return next value available
|
||||
*
|
||||
* @return string Value
|
||||
*/
|
||||
function getNextValue($objsoc=0,$type=-1)
|
||||
{
|
||||
global $langs;
|
||||
global $langs;
|
||||
return $langs->trans("Function_getNextValue_InModuleNotWorking");
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi version du module numerotation
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
/** Return version of module
|
||||
*
|
||||
* @return string Version
|
||||
*/
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
||||
if ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
||||
if ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi la liste des modeles de numéroation
|
||||
* \param db Handler de base
|
||||
/**
|
||||
* Renvoi la liste des modeles de numéroation
|
||||
*
|
||||
* @param db Handler de base
|
||||
*/
|
||||
function liste_modeles($db)
|
||||
{
|
||||
@@ -153,89 +159,93 @@ class ModeleThirdPartyCode
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return description of module parameters
|
||||
* \param langs Output language
|
||||
* \param soc Third party object
|
||||
* \param type -1=Nothing, 0=Customer, 1=Supplier
|
||||
* \return string HTML translated description
|
||||
* Return description of module parameters
|
||||
*
|
||||
* @param langs Output language
|
||||
* @param soc Third party object
|
||||
* @param type -1=Nothing, 0=Customer, 1=Supplier
|
||||
* @return string HTML translated description
|
||||
*/
|
||||
function getToolTip($langs,$soc,$type)
|
||||
{
|
||||
global $conf;
|
||||
global $conf;
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("admin");
|
||||
|
||||
$s='';
|
||||
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>';
|
||||
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
|
||||
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
|
||||
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
||||
$s.='<br>';
|
||||
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||
if ($type == 0)
|
||||
{
|
||||
$s.=$langs->trans("RequiredIfCustomer").': ';
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='<strike>';
|
||||
$s.=yn(!$this->code_null,1,2);
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
|
||||
$s.='<br>';
|
||||
}
|
||||
if ($type == 1)
|
||||
{
|
||||
$s.=$langs->trans("RequiredIfSupplier").': ';
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='<strike>';
|
||||
$s.=yn(!$this->code_null,1,2);
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
|
||||
$s.='<br>';
|
||||
}
|
||||
if ($type == -1)
|
||||
{
|
||||
$s.=$langs->trans("Required").': ';
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='<strike>';
|
||||
$s.=yn(!$this->code_null,1,2);
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
|
||||
$s.='<br>';
|
||||
}
|
||||
$s.=$langs->trans("CanBeModifiedIfOk").': ';
|
||||
$s.=yn($this->code_modifiable,1,2);
|
||||
$s.='<br>';
|
||||
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
|
||||
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
|
||||
$s.='<br>';
|
||||
if ($type == 0 || $type == -1)
|
||||
{
|
||||
$nextval=$this->getNextValue($soc,0);
|
||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
||||
}
|
||||
if ($type == 1 || $type == -1)
|
||||
{
|
||||
$nextval=$this->getNextValue($soc,1);
|
||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
$s='';
|
||||
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>';
|
||||
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
|
||||
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
|
||||
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
||||
$s.='<br>';
|
||||
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||
if ($type == 0)
|
||||
{
|
||||
$s.=$langs->trans("RequiredIfCustomer").': ';
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='<strike>';
|
||||
$s.=yn(!$this->code_null,1,2);
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
|
||||
$s.='<br>';
|
||||
}
|
||||
if ($type == 1)
|
||||
{
|
||||
$s.=$langs->trans("RequiredIfSupplier").': ';
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='<strike>';
|
||||
$s.=yn(!$this->code_null,1,2);
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
|
||||
$s.='<br>';
|
||||
}
|
||||
if ($type == -1)
|
||||
{
|
||||
$s.=$langs->trans("Required").': ';
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='<strike>';
|
||||
$s.=yn(!$this->code_null,1,2);
|
||||
if ($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED && !empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
|
||||
$s.='<br>';
|
||||
}
|
||||
$s.=$langs->trans("CanBeModifiedIfOk").': ';
|
||||
$s.=yn($this->code_modifiable,1,2);
|
||||
$s.='<br>';
|
||||
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
|
||||
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
|
||||
$s.='<br>';
|
||||
if ($type == 0 || $type == -1)
|
||||
{
|
||||
$nextval=$this->getNextValue($soc,0);
|
||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
||||
}
|
||||
if ($type == 1 || $type == -1)
|
||||
{
|
||||
$nextval=$this->getNextValue($soc,1);
|
||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
function verif_prefixIsUsed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
function verif_prefixIsUsed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \class ModeleAccountancyCode
|
||||
* \brief Classe mere des modeles de numerotation des codes compta
|
||||
* \brief Parent class for third parties accountancy code generators
|
||||
*/
|
||||
class ModeleAccountancyCode
|
||||
abstract class ModeleAccountancyCode
|
||||
{
|
||||
var $error='';
|
||||
|
||||
/** \brief Renvoi la description par defaut du modele de numerotation
|
||||
* \return string Texte descripif
|
||||
|
||||
/** Return description of module
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @return string Description of module
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
@@ -243,28 +253,89 @@ class ModeleAccountancyCode
|
||||
return $langs->trans("NoDescription");
|
||||
}
|
||||
|
||||
/** \brief Renvoi un exemple de numerotation
|
||||
* \return string Example
|
||||
/** Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param $langs Object langs
|
||||
* @param $objsoc Object thirdparty
|
||||
* @param $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
*/
|
||||
function getExample($langs)
|
||||
function getExample($langs,$objsoc=0,$type=-1)
|
||||
{
|
||||
$langs->load("bills");
|
||||
return $langs->trans("NoExample");
|
||||
}
|
||||
|
||||
/** \brief Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
* \return boolean false si conflit, true si ok
|
||||
/** Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
*
|
||||
* @return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribuee
|
||||
* \return string Valeur
|
||||
/** Return version of module
|
||||
*
|
||||
* @return string Version
|
||||
*/
|
||||
function getNextValue($langs)
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
||||
if ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return description of module parameters
|
||||
*
|
||||
* @param langs Output language
|
||||
* @param soc Third party object
|
||||
* @param type -1=Nothing, 0=Customer, 1=Supplier
|
||||
* @return string HTML translated description
|
||||
*/
|
||||
function getToolTip($langs,$soc,$type)
|
||||
{
|
||||
global $conf,$db;
|
||||
|
||||
$langs->load("admin");
|
||||
|
||||
$s='';
|
||||
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->nom.'</b><br>';
|
||||
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||
//$s.='<br>';
|
||||
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||
$s.='<br>';
|
||||
if ($type == 0 || $type == -1)
|
||||
{
|
||||
$result=$this->get_code($db,$soc,'customer');
|
||||
$nextval=$this->code;
|
||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
|
||||
}
|
||||
if ($type == 1 || $type == -1)
|
||||
{
|
||||
$result=$this->get_code($db,$soc,'supplier');
|
||||
$nextval=$this->code;
|
||||
if (empty($nextval)) $nextval=$langs->trans("Undefined");
|
||||
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set accountancy account code for a third party into this->code
|
||||
*
|
||||
* @param db Database handler
|
||||
* @param societe Third party object
|
||||
* @param type 'customer' or 'supplier'
|
||||
* @return int >=0 if OK, <0 if KO
|
||||
*/
|
||||
function get_code($db, $societe, $type='')
|
||||
{
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
@@ -274,75 +345,76 @@ class ModeleAccountancyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Create a document for third party
|
||||
* \param db Database handler
|
||||
* \param id Id of third party to use
|
||||
* \param message Message
|
||||
* \param modele Force model to use ('' to not force). model can be a model name or a template file.
|
||||
* \param outputlangs Objet lang to use for translation
|
||||
* \return int <0 if KO, >0 if OK
|
||||
* Create a document for third party
|
||||
*
|
||||
* @param db Database handler
|
||||
* @param id Id of third party to use
|
||||
* @param message Message
|
||||
* @param modele Force model to use ('' to not force). model can be a model name or a template file.
|
||||
* @param outputlangs Objet lang to use for translation
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function thirdparty_doc_create($db, $id, $message, $modele, $outputlangs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$langs->load("bills");
|
||||
global $conf,$langs;
|
||||
$langs->load("bills");
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/societe/doc";
|
||||
$srctemplatepath='';
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/societe/doc";
|
||||
$srctemplatepath='';
|
||||
|
||||
// Positionne modele sur le nom du modele a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if ($conf->global->COMPANY_ADDON_PDF)
|
||||
{
|
||||
$modele = $conf->global->COMPANY_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// Positionne modele sur le nom du modele a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if ($conf->global->COMPANY_ADDON_PDF)
|
||||
{
|
||||
$modele = $conf->global->COMPANY_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp=explode(':',$modele,2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp=explode(':',$modele,2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template
|
||||
$file = "doc_".$modele.".modules.php";
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$classname = "doc_".$modele;
|
||||
require_once($dir.'/'.$file);
|
||||
// Search template
|
||||
$file = "doc_".$modele.".modules.php";
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$classname = "doc_".$modele;
|
||||
require_once($dir.'/'.$file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
$obj->message = $message;
|
||||
$obj = new $classname($db);
|
||||
$obj->message = $message;
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
if ($obj->write_file($id, $outputlangs, $srctemplatepath) > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($db,"thirdparty_doc_create Error: ".$obj->error);
|
||||
return -1;
|
||||
}
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
if ($obj->write_file($id, $outputlangs, $srctemplatepath) > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($db,"thirdparty_doc_create Error: ".$obj->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.'/'.$file));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.'/'.$file));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user