Skip to content

Commit

Permalink
Merge pull request #25759 from frederic34/partnership
Browse files Browse the repository at this point in the history
clean numbering module
  • Loading branch information
eldy committed Sep 1, 2023
2 parents 6633908 + 9132529 commit 6f0bd65
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2023 Frédéric France <frederic.france@netlogic.fr>
*
* 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
Expand All @@ -26,7 +26,7 @@
* \brief File containing class for advanced numbering model of Partnership
*/

dol_include_once('/partnership/core/modules/partnership/modules_partnership.php');
require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php';


/**
Expand Down Expand Up @@ -54,22 +54,23 @@ class mod_partnership_advanced extends ModeleNumRefPartnership
/**
* Returns the description of the numbering model
*
* @param Translate $langs Lang object to use for output
* @return string Descriptive text
*/
public function info()
public function info($langs)
{
global $conf, $langs, $db;
global $db;

$langs->load("bills");

$form = new Form($db);

$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconst" value="PARTNERSHIP_ADVANCED_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$text = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$text .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$text .= '<input type="hidden" name="token" value="'.newToken().'">';
$text .= '<input type="hidden" name="action" value="updateMask">';
$text .= '<input type="hidden" name="maskconst" value="PARTNERSHIP_ADVANCED_MASK">';
$text .= '<table class="nobordernopadding" width="100%">';

$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Partnership"), $langs->transnoentities("Partnership"));
$tooltip .= $langs->trans("GenericMaskCodes2");
Expand All @@ -78,17 +79,17 @@ public function info()
$tooltip .= $langs->trans("GenericMaskCodes5");

// Parametrage du prefix
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskPartnership" value="'.getDolGlobalString('PARTNERSHIP_ADVANCED_MASK').'">', $tooltip, 1, 1).'</td>';
$text .= '<tr><td>'.$langs->trans("Mask").':</td>';
$text .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskPartnership" value="'.getDolGlobalString('PARTNERSHIP_ADVANCED_MASK').'">', $tooltip, 1, 1).'</td>';

$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
$text .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';

$texte .= '</tr>';
$text .= '</tr>';

$texte .= '</table>';
$texte .= '</form>';
$text .= '</table>';
$text .= '</form>';

return $texte;
return $text;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* \ingroup partnership
* \brief File of class to manage Partnership numbering rules standard
*/
dol_include_once('/partnership/core/modules/partnership/modules_partnership.php');
require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php';


/**
Expand Down Expand Up @@ -52,11 +52,11 @@ class mod_partnership_standard extends ModeleNumRefPartnership
/**
* Return description of numbering module
*
* @return string Text with description
* @param Translate $langs Lang object to use for output
* @return string Text with description
*/
public function info()
public function info($langs)
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit


Expand Down Expand Up @@ -66,93 +67,7 @@ public static function liste_modeles($db, $maxfilenamelength = 0)
/**
* Parent class to manage numbering of Partnership
*/
abstract class ModeleNumRefPartnership
abstract class ModeleNumRefPartnership extends CommonNumRefGenerator
{
/**
* @var string Error code (or message)
*/
public $error = '';

/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}

/**
* Returns the default description of the numbering template
*
* @return string Descriptive text
*/
public function info()
{
global $langs;
$langs->load("partnership");
return $langs->trans("NoDescription");
}

/**
* Returns an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("partnership");
return $langs->trans("NoExample");
}

/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @param Object $object Object we need next value for
* @return boolean false if conflict, true if ok
*/
public function canBeActivated($object)
{
return true;
}

/**
* Returns next assigned value
*
* @param Object $object Object we need next value for
* @return string Valeur
*/
public function getNextValue($object)
{
global $langs;
return $langs->trans("NotAvailable");
}

/**
* Returns version of numbering module
*
* @return string Valeur
*/
public 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;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
// No overload code
}

0 comments on commit 6f0bd65

Please sign in to comment.