Skip to content

Commit

Permalink
Merge branch 'Dolibarr:develop' into sendReminderForExpiredSubscription
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoLoGeek authored Jul 1, 2024
2 parents 1c898a1 + f7c0253 commit 849ac1f
Show file tree
Hide file tree
Showing 25 changed files with 236 additions and 175 deletions.
22 changes: 9 additions & 13 deletions htdocs/asset/admin/setup.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.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 @@ -19,9 +19,9 @@
*/

/**
* \file htdocs/asset/admin/setup.php
* \file htdocs/asset/admin/setup.php
* \ingroup asset
* \brief Asset setup page.
* \brief Asset setup page.
*/

// Load Dolibarr environment
Expand Down Expand Up @@ -197,18 +197,14 @@
$head = assetAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "asset");

// Setup page goes here
echo '<span class="opacitymedium">'.$langs->trans("AssetSetupPage").'</span>';


foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ($myTmpObjectArray['includerefgeneration']) {
/*
* Assets Numbering model
*/
$setupnotempty++;

print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
print load_fiche_titre($langs->trans("AssetNumberingModules", $myTmpObjectKey), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
Expand Down Expand Up @@ -236,7 +232,7 @@
$module = new $file($db);
'@phan-var-force CommonNumRefGenerator $module';

// Show modules according to features level
// Show modules according to feature level
if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
continue;
}
Expand All @@ -251,7 +247,7 @@
print $module->info($langs);
print '</td>';

// Show example of numbering model
// Show example of the numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
Expand Down
36 changes: 18 additions & 18 deletions htdocs/asset/class/asset.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
Expand All @@ -19,9 +19,9 @@
*/

/**
* \file asset/class/asset.class.php
* \ingroup asset
* \brief This file is a CRUD class file for Asset (Create/Read/Update/Delete)
* \file asset/class/asset.class.php
* \ingroup asset
* \brief This file is a CRUD class file for Asset (Create/Read/Update/Delete)
*/

require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
Expand All @@ -37,12 +37,12 @@ class Asset extends CommonObject
public $module = 'asset';

/**
* @var string ID to identify managed object.
* @var string ID to identify a managed object.
*/
public $element = 'asset';

/**
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
* @var string Name of table without prefix where an object is stored. This is also the key used for extrafields management.
*/
public $table_element = 'asset';

Expand All @@ -64,20 +64,20 @@ class Asset extends CommonObject
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'noteditable' says if field is not editable (1 or 0)
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
* 'default' is a default value for creation (can still be overwritten by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and the field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
* 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommended to name the field fk_...).
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into a list (for example for percentage)
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example, 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'showoncombobox' if the value of the field must be visible into the label of the combobox that list record
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
* 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
* 'arrayofkeyval' to set a list of values if a type is a list of predefined values. For example, array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
* 'autofocusoncreate' to have field having the focus on a creation form. Only 1 field should have this property set to 1.
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
* 'validate' is 1 if need to validate with $this->validateField()
* 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
* 'validate' is 1 if you need to validate with $this->validateField()
* 'copytoclipboard' is 1 or 2 to allow adding a picto to copy value into clipboard (1=picto after label, 2=picto after value)
*
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
Expand Down Expand Up @@ -992,7 +992,7 @@ public function calculationDepreciation()

// futures depreciation lines
//-----------------------------------------------------
$nb_days_in_year = getDolGlobalInt('ASSET_DEPRECIATION_DURATION_PER_YEAR', 365);
$nb_days_in_year = getDolGlobalInt('ASSET_DEPRECIATION_DURATION_PER_YEAR', 360);
$nb_days_in_month = getDolGlobalInt('ASSET_DEPRECIATION_DURATION_PER_MONTH', 30);
$period_amount = (float) price2num($depreciation_period_amount / $fields['duration'], 'MT');
$first_period_found = false;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Propal extends CommonObject
public $datep;

/**
* @var integer|'' $delivery_date;
* @var null|int|'' $delivery_date;
*/
public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)

Expand Down Expand Up @@ -2247,7 +2247,7 @@ public function setDeliveryDate($user, $delivery_date, $notrigger = 0)
$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql .= " SET date_livraison = ".($delivery_date != '' ? "'".$this->db->idate($delivery_date)."'" : 'null');
$sql .= " SET date_livraison = ".(isDolTms($delivery_date) ? "'".$this->db->idate($delivery_date)."'" : 'null');
$sql .= " WHERE rowid = ".((int) $this->id);

dol_syslog(__METHOD__, LOG_DEBUG);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@
print '</td></tr>';
}
} else {
print '<tr class="oddeven">';
print '<tr class="oddeven '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ? 'opacitymedium' : '').'">';

// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,7 @@
} else {
// Show line of result
$j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
print '<tr data-rowid="'.$object->id.'" class="oddeven '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ? 'opacitymedium' : '').'">';

// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Facture extends CommonInvoice
public $datem;

/**
* @var int Date expected for delivery
* @var null|int|'' Date expected for delivery
*/
public $delivery_date; // Date expected of shipment (date of start of shipment, not the reception that occurs some days after)

Expand Down
8 changes: 3 additions & 5 deletions htdocs/core/class/CMailFile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1431,12 +1431,10 @@ public function dump_mail()
fclose($fp);
dolChmod($outputfile);

// Move dolibarr_mail.log into a dolibarr_mail.YYYYMMDD.log
if (getDolGlobalString('MAIN_MAIL_DEBUG_LOG_WITH_DATE')) {
$destfile = $dolibarr_main_data_root."/dolibarr_mail.".dol_print_date(dol_now(), 'dayhourlog', 'gmt').".log";

// Move dolibarr_mail.log into a dolibarr_mail.log.v123456789
if (getDolGlobalInt('MAIN_MAIL_DEBUG_LOG_WITH_DATE')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_move($outputfile, $destfile, 0, 1, 0, 0);
archiveOrBackupFile($outputfile, getDolGlobalInt('MAIN_MAIL_DEBUG_LOG_WITH_DATE'));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/lib/company.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
'sc.role' => array('label' => "ContactByDefaultFor", 'checked' => 1, 'position' => 40),
't.birthday' => array('label' => "Birthday", 'checked' => 0, 'position' => 45),
't.statut' => array('label' => "Status", 'checked' => 1, 'position' => 50, 'class' => 'center'),
'u.user'=>array('label'=>"DolibarrLogin", 'checked'=>1, 'position'=>50, 'class'=>'center'),
);
// Extra fields
if (!empty($extrafields->attributes[$contactstatic->table_element]['label']) && is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) {
Expand Down
12 changes: 6 additions & 6 deletions htdocs/core/lib/files.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3735,16 +3735,16 @@ function dragAndDropFileUpload($htmlname)
/**
* Manage backup versions for a given file, ensuring only a maximum number of versions are kept.
*
* @param string $filetpl Full path of the source filename for the backups. Example /mydir/mydocuments/mymodule/filename.ext
* @param string $srcfile Full path of the source filename for the backups. Example /mydir/mydocuments/mymodule/filename.ext
* @param int $max_versions The maximum number of backup versions to keep.
* @param string $archivedir Target directory of backups (without ending /). Keep empty to save into the same directory than source file.
* @param string $suffix 'v' (versioned files) or 'd' (archived files after deletion)
* @param string $moveorcopy 'move' or 'copy'
* @return bool Returns true if successful, false otherwise.
*/
function archiveOrBackupFile($filetpl, $max_versions = 5, $archivedir = '', $suffix = "v", $moveorcopy = 'move')
function archiveOrBackupFile($srcfile, $max_versions = 5, $archivedir = '', $suffix = "v", $moveorcopy = 'move')
{
$base_file_pattern = ($archivedir ? $archivedir : dirname($filetpl)).'/'.basename($filetpl).".".$suffix;
$base_file_pattern = ($archivedir ? $archivedir : dirname($srcfile)).'/'.basename($srcfile).".".$suffix;
$files_in_directory = glob($base_file_pattern . "*");

// Extract the modification timestamps for each file
Expand Down Expand Up @@ -3786,13 +3786,13 @@ function archiveOrBackupFile($filetpl, $max_versions = 5, $archivedir = '', $suf
}

$timestamp = dol_now('gmt');
$new_backup = $filetpl . ".v" . $timestamp;
$new_backup = $srcfile . ".v" . $timestamp;

// Move or copy the original file to the new backup with the timestamp
if ($moveorcopy == 'move') {
$result = dol_move($filetpl, $new_backup, '0', 1, 0, 0);
$result = dol_move($srcfile, $new_backup, '0', 1, 0, 0);
} else {
$result = dol_copy($filetpl, $new_backup, '0', 1, 0, 0);
$result = dol_copy($srcfile, $new_backup, '0', 1, 0, 0);
}

if (!$result) {
Expand Down
50 changes: 50 additions & 0 deletions htdocs/core/lib/website.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,56 @@ function getImagePublicURLOfObject($object, $no = 1, $extName = '')
return $image_path;
}

/**
* Return list of public files of a given object.
*
* @param Object $object Object
* @return array List of public files of object
*/
function getPublicFilesOfObject($object)
{
global $db;

$files = array();

include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$regexforimg = getListOfPossibleImageExt(0);
$regexforimg = '/('.$regexforimg.')$/i';

$sql = "SELECT rowid, ref, share, filename, cover, position";
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_files";
$sql .= " WHERE entity IN (".getEntity($object->element).")";
$sql .= " AND src_object_type = '".$db->escape($object->element)."' AND src_object_id = ".((int) $object->id);
$sql .= $db->order("cover,position,rowid", "ASC,ASC,ASC");

$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj) {
if (!empty($obj->share)) {
$files[$obj->rowid]['filename'] = $obj->filename;
$files[$obj->rowid]['position'] = $obj->position;
if (defined('USEDOLIBARRSERVER') || defined('USEDOLIBARREDITOR')) {
if (preg_match($regexforimg, $obj->filename)) {
$files[$obj->rowid]['url'] = DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($obj->share);
} else {
$files[$obj->rowid]['url'] = DOL_URL_ROOT.'/document.php?hashp='.urlencode($obj->share);
}
} else {
$files[$obj->rowid]['url'] = '/wrapper.php?hashp='.urlencode($obj->share);
}
}
}
$i++;
}
}

return $files;
}


/**
* Return list of containers object that match a criteria.
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/modules/modAsset.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
/* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Alexandre Spangaro <alexandre@inovea-conseil.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
Expand Down Expand Up @@ -106,8 +106,8 @@ public function __construct($db)
$this->const[1] = array(
"ASSET_DEPRECIATION_DURATION_PER_YEAR",
"chaine",
"365",
"Duration per year to calculate depreciation. In some case, can be 360 days",
"360",
"Duration per year to calculate depreciation. In some case, can be 365 days",
0,
'current',
1
Expand Down Expand Up @@ -232,7 +232,7 @@ public function __construct($db)

/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* The init function adds constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/class/fournisseur.commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CommandeFournisseur extends CommonOrder
public $methode_commande;

/**
* @var int Expected Delivery Date
* @var null|int|'' Expected Delivery Date
*/
public $delivery_date;

Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/commande/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@
print '</td></tr>';
}
} else {
print '<tr class="oddeven">';
print '<tr class="oddeven '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->billed == 1) ? 'opacitymedium' : '').'">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@
} else {
// Show line of result
$j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
print '<tr data-rowid="'.$object->id.'" class="oddeven '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->fk_statut > 1) ? 'opacitymedium' : '').'">';

// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
Expand Down
Loading

0 comments on commit 849ac1f

Please sign in to comment.