-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: LegalDisplay & InformationsSharing objects
- Loading branch information
1 parent
79c6a4d
commit 707e355
Showing
39 changed files
with
11,407 additions
and
97 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
520 changes: 520 additions & 0 deletions
520
core/modules/digiriskdolibarr/doc/doc_generic_informationssharing_odt.modules.php
Large diffs are not rendered by default.
Oops, something went wrong.
520 changes: 520 additions & 0 deletions
520
core/modules/digiriskdolibarr/doc/doc_generic_legaldisplay_odt.modules.php
Large diffs are not rendered by default.
Oops, something went wrong.
1,368 changes: 1,368 additions & 0 deletions
1,368
core/modules/digiriskdolibarr/doc/pdf_standard_informationssharing.modules.php
Large diffs are not rendered by default.
Oops, something went wrong.
1,368 changes: 1,368 additions & 0 deletions
1,368
core/modules/digiriskdolibarr/doc/pdf_standard_legaldisplay.modules.php
Large diffs are not rendered by default.
Oops, something went wrong.
150 changes: 150 additions & 0 deletions
150
core/modules/digiriskdolibarr/mod_informationssharing_advanced.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> | ||
* 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> | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
* or see https://www.gnu.org/ | ||
*/ | ||
|
||
/** | ||
* \file htdocs/core/modules/digiriskdolibarr/mod_informationssharing_advanced.php | ||
* \ingroup digiriskdolibarr | ||
* \brief File containing class for advanced numbering model of InformationsSharing | ||
*/ | ||
|
||
dol_include_once('/digiriskdolibarr/core/modules/digiriskdolibarr/modules_informationssharing.php'); | ||
|
||
|
||
/** | ||
* Class to manage customer Bom numbering rules advanced | ||
*/ | ||
class mod_informationssharing_advanced extends ModeleNumRefInformationsSharing | ||
{ | ||
/** | ||
* Dolibarr version of the loaded document | ||
* @var string | ||
*/ | ||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' | ||
|
||
/** | ||
* @var string Error message | ||
*/ | ||
public $error = ''; | ||
|
||
/** | ||
* @var string name | ||
*/ | ||
public $name = 'advanced'; | ||
|
||
|
||
/** | ||
* Returns the description of the numbering model | ||
* | ||
* @return string Texte descripif | ||
*/ | ||
public function info() | ||
{ | ||
global $conf, $langs, $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="maskconstBom" value="DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADVANCED_MASK">'; | ||
$texte .= '<table class="nobordernopadding" width="100%">'; | ||
|
||
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("InformationsSharing"), $langs->transnoentities("InformationsSharing")); | ||
$tooltip .= $langs->trans("GenericMaskCodes2"); | ||
$tooltip .= $langs->trans("GenericMaskCodes3"); | ||
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("InformationsSharing"), $langs->transnoentities("InformationsSharing")); | ||
$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" size="24" name="maskInformationsSharing" value="'.$conf->global->DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>'; | ||
|
||
$texte .= '<td class="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; | ||
|
||
$texte .= '</tr>'; | ||
|
||
$texte .= '</table>'; | ||
$texte .= '</form>'; | ||
|
||
return $texte; | ||
} | ||
|
||
/** | ||
* Return an example of numbering | ||
* | ||
* @return string Example | ||
*/ | ||
public function getExample() | ||
{ | ||
global $conf, $db, $langs, $mysoc; | ||
|
||
$object = new InformationsSharing($db); | ||
$object->initAsSpecimen(); | ||
|
||
/*$old_code_client = $mysoc->code_client; | ||
$old_code_type = $mysoc->typent_code; | ||
$mysoc->code_client = 'CCCCCCCCCC'; | ||
$mysoc->typent_code = 'TTTTTTTTTT';*/ | ||
|
||
$numExample = $this->getNextValue($object); | ||
|
||
/*$mysoc->code_client = $old_code_client; | ||
$mysoc->typent_code = $old_code_type;*/ | ||
|
||
if (!$numExample) | ||
{ | ||
$numExample = $langs->trans('NotConfigured'); | ||
} | ||
return $numExample; | ||
} | ||
|
||
/** | ||
* Return next free value | ||
* | ||
* @param Object $object Object we need next value for | ||
* @return string Value if KO, <0 if KO | ||
*/ | ||
public function getNextValue($object) | ||
{ | ||
global $db, $conf; | ||
|
||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; | ||
|
||
// We get cursor rule | ||
$mask = $conf->global->DIGIRISKDOLIBARR_INFORMATIONSSHARING_ADVANCED_MASK; | ||
|
||
if (!$mask) | ||
{ | ||
$this->error = 'NotConfigured'; | ||
return 0; | ||
} | ||
|
||
$date = $object->date; | ||
|
||
$numFinal = get_next_value($db, $mask, 'digiriskdolibarr_informationssharing', 'ref', '', null, $date); | ||
|
||
return $numFinal; | ||
} | ||
} |
160 changes: 160 additions & 0 deletions
160
core/modules/digiriskdolibarr/mod_informationssharing_standard.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?php | ||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> | ||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> | ||
* | ||
* 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 <https://www.gnu.org/licenses/>. | ||
* or see https://www.gnu.org/ | ||
*/ | ||
|
||
/** | ||
* \file htdocs/core/modules/digiriskdolibarr/mod_informationssharing_standard.php | ||
* \ingroup digiriskdolibarr | ||
* \brief File of class to manage InformationsSharing numbering rules standard | ||
*/ | ||
dol_include_once('/digiriskdolibarr/core/modules/digiriskdolibarr/modules_informationssharing.php'); | ||
|
||
|
||
/** | ||
* Class to manage customer order numbering rules standard | ||
*/ | ||
class mod_informationssharing_standard extends ModeleNumRefInformationsSharing | ||
{ | ||
/** | ||
* Dolibarr version of the loaded document | ||
* @var string | ||
*/ | ||
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' | ||
|
||
public $prefix = 'INFORMATIONSSHARING'; | ||
|
||
/** | ||
* @var string Error code (or message) | ||
*/ | ||
public $error = ''; | ||
|
||
/** | ||
* @var string name | ||
*/ | ||
public $name = 'standard'; | ||
|
||
|
||
/** | ||
* Return description of numbering module | ||
* | ||
* @return string Text with description | ||
*/ | ||
public function info() | ||
{ | ||
global $langs; | ||
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); | ||
} | ||
|
||
|
||
/** | ||
* Return an example of numbering | ||
* | ||
* @return string Example | ||
*/ | ||
public function getExample() | ||
{ | ||
return $this->prefix."0501-0001"; | ||
} | ||
|
||
|
||
/** | ||
* 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) | ||
{ | ||
global $conf, $langs, $db; | ||
|
||
$coyymm = ''; $max = ''; | ||
|
||
$posindice = strlen($this->prefix) + 6; | ||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; | ||
$sql .= " FROM ".MAIN_DB_PREFIX."digiriskdolibarr_informationssharing"; | ||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; | ||
if ($object->ismultientitymanaged == 1) { | ||
$sql .= " AND entity = ".$conf->entity; | ||
} | ||
elseif ($object->ismultientitymanaged == 2) { | ||
// TODO | ||
} | ||
|
||
$resql = $db->query($sql); | ||
if ($resql) | ||
{ | ||
$row = $db->fetch_row($resql); | ||
if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } | ||
} | ||
if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) | ||
{ | ||
$langs->load("errors"); | ||
$this->error = $langs->trans('ErrorNumRefModel', $max); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Return next free value | ||
* | ||
* @param Object $object Object we need next value for | ||
* @return string Value if KO, <0 if KO | ||
*/ | ||
public function getNextValue($object) | ||
{ | ||
global $db, $conf; | ||
|
||
// first we get the max value | ||
$posindice = strlen($this->prefix) + 6; | ||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; | ||
$sql .= " FROM ".MAIN_DB_PREFIX."digiriskdolibarr_informationssharing"; | ||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; | ||
if ($object->ismultientitymanaged == 1) { | ||
$sql .= " AND entity = ".$conf->entity; | ||
} | ||
elseif ($object->ismultientitymanaged == 2) { | ||
// TODO | ||
} | ||
|
||
$resql = $db->query($sql); | ||
if ($resql) | ||
{ | ||
$obj = $db->fetch_object($resql); | ||
if ($obj) $max = intval($obj->max); | ||
else $max = 0; | ||
} | ||
else | ||
{ | ||
dol_syslog("mod_informationssharing_standard::getNextValue", LOG_DEBUG); | ||
return -1; | ||
} | ||
|
||
//$date=time(); | ||
$date = $object->date_creation; | ||
$yymm = strftime("%y%m", $date); | ||
|
||
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is | ||
else $num = sprintf("%04s", $max + 1); | ||
|
||
dol_syslog("mod_informationssharing_standard::getNextValue return ".$this->prefix.$yymm."-".$num); | ||
return $this->prefix.$yymm."-".$num; | ||
} | ||
} |
Oops, something went wrong.