Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,35 @@ All notable changes to this project will be documented in this file.

## [Unreleased]



## Release 2.6
- FIX : Enregistrement du pdf docedit, non changement de ref - *14/06/2024* - 2.6.2
- FIX : replace code $_REQUEST conflict with attachment module - *21/03/2024* - 2.6.1
- FIX : Compatibility V19 *21/11/2023* - 2.6.0

## Release 2.5

- FIX : Remove php exec call and use copy instead *03/10/2022* - 2.5.1
- NEW : Option to keep version number on restore *03/10/2022* - 2.5.0 [PR# Open-DSI](https://github.com/ATM-Consulting/dolibarr_module_propalehistory/pull/56)
un nouveau paramètre permettant de restaurer une proposition commerciale tout en gardant le numéro de version
![image](https://user-images.githubusercontent.com/45359511/182880333-4a486bb5-9067-446e-af5d-8d2cfc1eebed.png)

Ajout d'un champ complémentaite caché pour savoir sur quelle version on est.
On garde le même fonctionnement qu'avant lorsque cette option n'est pas activée.
- Ajout d'un champ complémentaire caché pour savoir sur quelle version on est.
- On garde le même fonctionnement qu'avant lorsque cette option n'est pas activée.

Lorsque cette option est activée :
- Lorsque cette option est activée :
- On garde le même comportement lorsqu'on archive une version (ex : si on est sur la version 1 et qu'on archive alors on passe au numéro de version suivante)
- Lorsqu'on restaure une version alors on garde son numéro au lieu de restaurer sur la version courante
- Par contre lorsqu'on supprime une version alors on ne bouche pas les trous pour pouvoir se repérer avec les numéros de version


## Version 2.4
## Release 2.4

- FIX : Editor name *03/08/2022* - 2.4.1
- NEW : restore public note and extra fields - *29/07/2022* - 2.4.0[PR# Open-DSI](https://github.com/ATM-Consulting/dolibarr_module_propalehistory/pull/55)

## Version 2.3
## Release 2.3

- FIX : Compatibility PHP 8 - *15/07/2022* - 2.3.3
- FIX : Module icon *12/07/2022* 2.3.2
Expand All @@ -39,19 +48,19 @@ All notable changes to this project will be documented in this file.
by activating this conf, reset proposal date and end validity date with today date if above const is enabled


## Version 2.0
## Release 2.0
- FIX : v16 token - *02/06/2022* - 2.0.5
- FIX : hack stockage de la ref propale - 2.0.4 - *13/05/2022*
- FIX: Suppression de conf pour ajouter son comportement par défaut - 2.0.3 - *04/04/2022*
- FIX: token - 2.0.2 - *16/03/2022*
- FIX: v14 compatibility - setDateLivraison -> setDeliveryDate - 2.0.1 - *27/07/2021*
- NEW: compatible with Dolibarr v13 and v14, **no longer compatible with v11 and lower** - *2021-06-28* - 2.0.0

## Version 1.4
## Release 1.4

- FIX - Compatibility V14 : Edit the descriptor: editor_name, editor_url and family - *2021-06-10* - 1.4.7


## Version 1.0
## Release 1.0

initial version
50 changes: 50 additions & 0 deletions backport/v19/core/class/commonhookactions.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <[email protected]>
*
* 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/>.
*/

/**
* \file htdocs/core/class/commonhookactions.class.php
* \ingroup core
* \brief File of parent class of all other hook actions classes
*/

namespace propalehistory;

if(file_exists(DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php';
/**
* Parent class of all other hook actions classes
*/
abstract class RetroCompatCommonHookActions extends \CommonHookActions {

}
}
else {
/**
* Parent class of all other hook actions classes
*/
abstract class RetroCompatCommonHookActions {
/**
* @var string String of results.
*/
public $resprints;

/**
* @var array Array of results.
*/
public $results = array();
}
}
25 changes: 15 additions & 10 deletions class/actions_propalehistory.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
class ActionsPropalehistory

require_once __DIR__.'/../backport/v19/core/class/commonhookactions.class.php';
class ActionsPropalehistory extends \propalehistory\RetroCompatCommonHookActions
{
/** Overloading the doActions function : replacing the parent's function with the one below
* @param parameters meta datas of the hook (context, etc...)
Expand Down Expand Up @@ -57,7 +59,7 @@ function formObjectOptions($parameters, &$object, &$action, $hookmanager)
}
$versionNum = TPropaleHist::listeVersions($db, $object);

if ($versionNum > 1 && !$conf->global->PROPALEHISTORY_HIDE_VERSION_ON_TABS) {
if ($versionNum > 1 && !getDolGlobalInt('PROPALEHISTORY_HIDE_VERSION_ON_TABS')) {
?>
<script type="text/javascript">
$("a#comm").first().append(" / v. <?php echo $versionNum; ?>");
Expand All @@ -74,7 +76,7 @@ function formObjectOptions($parameters, &$object, &$action, $hookmanager)
function afterPDFCreation($parameters, &$object, &$action, $hookmanager) {
global $langs, $db, $user, $conf;

if (!empty($conf->global->PROPALEHISTORY_SHOW_VERSION_PDF)) {
if (getDolGlobalString('PROPALEHISTORY_SHOW_VERSION_PDF')) {
$object_src = $parameters['object'];
if (isset($object_src)) {
$obj = $object_src;
Expand All @@ -97,7 +99,7 @@ function afterPDFCreation($parameters, &$object, &$action, $hookmanager) {
function beforePDFCreation($parameters, &$object, &$action, $hookmanager) {
global $langs, $db, $user, $conf;

if (!empty($conf->global->PROPALEHISTORY_SHOW_VERSION_PDF)) {
if (getDolGlobalString('PROPALEHISTORY_SHOW_VERSION_PDF')) {
$object_src = $parameters['object'];
if (isset($object_src)) {
$obj = $object_src;
Expand All @@ -113,7 +115,8 @@ function beforePDFCreation($parameters, &$object, &$action, $hookmanager) {

$versionNum = TPropaleHist::getVersionNumFromProposalOrVersionList($db, $obj);

if ($versionNum > 1) {
// TODO voir pour trouver une autre méthode DANGER pour la création des PDF
if ($versionNum > 1 && empty($object->context['docEditPdfGeneration'])) {
$obj->context['propale_history'] = array('original_ref' => $obj->ref);
$obj->ref .= '/' . ($versionNum);
}
Expand All @@ -137,11 +140,13 @@ function formConfirm($parameters, &$object, &$action, $hookmanager)
{
global $conf, $langs, $db, $user;

if (in_array('propalcard', explode(':', $parameters['context'])) && ! empty($conf->global->PROPALEHISTORY_ARCHIVE_ON_MODIFY))
if (in_array('propalcard', explode(':', $parameters['context'])) && getDolGlobalString('PROPALEHISTORY_ARCHIVE_ON_MODIFY'))
{
// Ask if proposal archive wanted
if ($_REQUEST['action'] == 'modif') { // $action peut être changé à 'modif' dans doActions() après l'affichage de la pop-in : on teste $_REQUEST['action'] à la place

// Ask if proposal archive wanted
// $action peut être changé à 'modif' dans doActions() après l'affichage de la pop-in : on teste $_REQUEST['action'] à la place
// CE code revient dans sa version antérieure dû à un bug provoqué dans attachment
if ( array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'modif') {
$formquestion = array(
array('type' => 'checkbox', 'name' => 'archive_proposal', 'label' => $langs->trans("ArchiveProposalCheckboxLabel"), 'value' => 1),
);
Expand Down Expand Up @@ -175,7 +180,7 @@ function doActions($parameters, &$object, &$action, $hookmanager) {
}
$ATMdb = new TPDOdb;

if (in_array('propalcard', explode(':', $parameters['context'])) && ! empty($conf->global->PROPALEHISTORY_ARCHIVE_ON_MODIFY))
if (in_array('propalcard', explode(':', $parameters['context'])) && getDolGlobalString('PROPALEHISTORY_ARCHIVE_ON_MODIFY'))
{

if ($action == 'modif') {
Expand Down Expand Up @@ -240,7 +245,7 @@ function doActions($parameters, &$object, &$action, $hookmanager) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit();
} elseif($actionATM == 'restaurer') {
if (!empty($conf->global->PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM)) {
if (getDolGlobalString('PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM')) {
$versionNumSelected = GETPOST('versionNum', 'int');

// save current proposal version before restoring
Expand Down
61 changes: 33 additions & 28 deletions class/propaleHist.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ static function archiverPropale(&$PDOdb, &$object)
{
global $conf, $db, $langs;

if (!empty($conf->global->PROPALEHISTORY_ARCHIVE_PDF_TOO)) {
if (getDolGlobalString('PROPALEHISTORY_ARCHIVE_PDF_TOO')) {
TPropaleHist::archivePDF($object);
}

// set proposal version number before saving
$update_extras = false;
if (!empty($conf->global->PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM)) {
if (getDolGlobalString('PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM')) {
$object->array_options['options_propalehistory_version_num'] = self::getVersionNumNext($db, $object->id); // get next version number
$update_extras = true;
} else {
Expand All @@ -96,7 +96,7 @@ static function archiverPropale(&$PDOdb, &$object)

$newVersionPropale->save($PDOdb);

if (!empty($conf->global->PROPALEHISTORY_ARCHIVE_AND_RESET_DATES) && $object->id > 0) {
if (getDolGlobalString('PROPALEHISTORY_ARCHIVE_AND_RESET_DATES') && $object->id > 0) {
$now = dol_now();
$fin_validite = $now + ($object->duree_validite * 24 * 3600);

Expand All @@ -119,30 +119,30 @@ static function archiverPropale(&$PDOdb, &$object)
$db->commit();
}

if (!$error && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
if (!$error && !getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
// reload the object with new lines
$ret = $object->fetch($object->id);
$ret = $object->fetch_thirdparty($object->socid);

// Define output language
$outputlangs = $langs;
if (!empty($conf->global->MAIN_MULTILANGS)) {
if (getDolGlobalString('MAIN_MULTILANGS')) {
$outputlangs = new Translate('', $conf);
$newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
}

// PDF
$hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$hidedetails = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
$hidedesc = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
$hideref = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);

$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}

// update to next version to work on (only if we work on last version)
if (!$error && !empty($conf->global->PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM)) {
if (!$error && getDolGlobalString('PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM')) {
$object->array_options['options_propalehistory_version_num']++;
$res = $object->insertExtraFields();
if ($res < 0) {
Expand Down Expand Up @@ -199,16 +199,16 @@ static function generatePDF(&$object)

// Define output language
$outputlangs = $langs;
if (!empty($conf->global->MAIN_MULTILANGS)) {
if (getDolGlobalString('MAIN_MULTILANGS')) {
$outputlangs = new Translate('', $conf);
$newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
}

// PDF
$hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$hidedetails = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
$hidedesc = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
$hideref = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);

return $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
Expand Down Expand Up @@ -294,10 +294,15 @@ static function restaurerPropale(&$PDOdb, &$object, $versionNum = 0) {

$object->set_availability($user, $propale->availability_id);
$object->set_date($user, $propale->date);
if(version_compare( DOL_VERSION, '19.0.0','<')) {
$dateLivraison = $propale->delivery_date;
} else {
$dateLivraison = $propale->date_livraison;
}
if (is_callable(array($object, 'setDeliveryDate'))) {
$object->setDeliveryDate($user, $propale->date_livraison);
$object->setDeliveryDate($user, $dateLivraison);
} else {
$object->set_date_livraison($user, $propale->date_livraison);
$object->set_date_livraison($user, $dateLivraison);
}
$object->set_echeance($user, $propale->fin_validite);
$object->set_ref_client($user, $propale->ref_client);
Expand Down Expand Up @@ -336,7 +341,7 @@ public static function getVersionNumFromProposalOrVersionList(&$db, $proposal, $

$fromVersionList = false;

if (!empty($conf->global->PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM)) {
if (getDolGlobalString('PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM')) {
if (!empty($proposal->array_options['options_propalehistory_version_num'])) {
$versionNum = $proposal->array_options['options_propalehistory_version_num'];
} else {
Expand Down Expand Up @@ -385,7 +390,7 @@ protected static function getVersionNumLastFromVersionList($versionList = array(
if (!empty($versionList)) {
$versionNumLast = count($versionList);

if (!empty($conf->global->PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM)) {
if (getDolGlobalString('PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM')) {
$versionPropale = new TPropaleHist;

foreach ($versionList as $row) {
Expand Down Expand Up @@ -465,7 +470,7 @@ static function listeVersions(&$db, $object) {

foreach ($TVersion as &$row) {
$versionNumRow = $i;
if (!empty($conf->global->PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM)) {
if (getDolGlobalString('PROPALEHISTORY_RESTORE_KEEP_VERSION_NUM')) {
$versionPropale = new TPropaleHist;
$versionPropale->serialized_parent_propale = $row->serialized_parent_propale;
$propale = $versionPropale->getObject();
Expand Down Expand Up @@ -538,16 +543,16 @@ function __construct($db, $socid="")
$this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION;

$langs->load("propal");
$this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft"));
$this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated"));
$this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned"));
$this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned"));
$this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled"));
$this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort"));
$this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened"));
$this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort"));
$this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort"));
$this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort"));
$this->labelstatut[0]=(getDolGlobalString('PROPAL_STATUS_DRAFT_LABEL') ? getDolGlobalString('PROPAL_STATUS_DRAFT_LABEL') : $langs->trans("PropalStatusDraft"));
$this->labelstatut[1]=(getDolGlobalString('PROPAL_STATUS_VALIDATED_LABEL') ? getDolGlobalString('PROPAL_STATUS_VALIDATED_LABEL') : $langs->trans("PropalStatusValidated"));
$this->labelstatut[2]=(getDolGlobalString('PROPAL_STATUS_SIGNED_LABEL') ? getDolGlobalString('PROPAL_STATUS_SIGNED_LABEL') : $langs->trans("PropalStatusSigned"));
$this->labelstatut[3]=(getDolGlobalString('PROPAL_STATUS_NOTSIGNED_LABEL') ? getDolGlobalString('PROPAL_STATUS_NOTSIGNED_LABEL') : $langs->trans("PropalStatusNotSigned"));
$this->labelstatut[4]=(getDolGlobalString('PROPAL_STATUS_BILLED_LABEL') ? getDolGlobalString('PROPAL_STATUS_BILLED_LABEL') : $langs->trans("PropalStatusBilled"));
$this->labelstatut_short[0]=(getDolGlobalString('PROPAL_STATUS_DRAFTSHORT_LABEL') ? getDolGlobalString('PROPAL_STATUS_DRAFTSHORT_LABEL') : $langs->trans("PropalStatusDraftShort"));
$this->labelstatut_short[1]=(getDolGlobalString('PROPAL_STATUS_VALIDATEDSHORT_LABEL') ?getDolGlobalString('PROPAL_STATUS_VALIDATEDSHORT_LABEL') : $langs->trans("Opened"));
$this->labelstatut_short[2]=(getDolGlobalString('PROPAL_STATUS_SIGNEDSHORT_LABEL') ? getDolGlobalString('PROPAL_STATUS_SIGNEDSHORT_LABEL') : $langs->trans("PropalStatusSignedShort"));
$this->labelstatut_short[3]=(getDolGlobalString('PROPAL_STATUS_NOTSIGNEDSHORT_LABEL') ? getDolGlobalString('PROPAL_STATUS_NOTSIGNEDSHORT_LABEL') : $langs->trans("PropalStatusNotSignedShort"));
$this->labelstatut_short[4]=(getDolGlobalString('PROPAL_STATUS_BILLEDSHORT_LABEL') ? getDolGlobalString('PROPAL_STATUS_BILLEDSHORT_LABEL') : $langs->trans("PropalStatusBilledShort"));
}

function getLinesArray($filters = '')
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modPropalehistory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct($db)
// (where XXX is value of numeric property 'numero' of module)
$this->description = "Gestion de l'historique des propositions commerciales";
// Possible values for version are: 'development', 'experimental' or version
$this->version = '2.5.1';
$this->version = '2.6.2';
// Url to the file with your last numberversion of this module
require_once __DIR__ . '/../../class/techatm.class.php';
$this->url_last_version = \propalehistory\TechATM::getLastModuleVersionUrl($this);
Expand Down
Loading