Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/core/lib/functions.lib.php
This commit is contained in:
Laurent Destailleur 2021-01-28 14:47:06 +01:00
commit 9ec5ba46fb
10 changed files with 65 additions and 50 deletions

View File

@ -4,7 +4,7 @@ Priority: optional
Maintainer: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> Maintainer: Laurent Destailleur (eldy) <eldy@users.sourceforge.net>
# Uploaders: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> # Only if differs from Maintainer # Uploaders: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> # Only if differs from Maintainer
Standards-Version: 3.9.6 Standards-Version: 3.9.6
Homepage: http://www.dolibarr.org Homepage: https://www.dolibarr.org
Build-Depends: debhelper (>= 9), po-debconf Build-Depends: debhelper (>= 9), po-debconf
# This package need at least debian 7 or ubuntu 13.04 or any distribution based on this version # This package need at least debian 7 or ubuntu 13.04 or any distribution based on this version

View File

@ -119,9 +119,8 @@ llxHeader('', $langs->trans("Mailing"), 'EN:Module_EMailing|FR:Module_Mailing|ES
$form = new Form($db); $form = new Form($db);
if ($filteremail) if ($filteremail) {
{ $sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
$sql .= " mc.statut as sendstatut"; $sql .= " mc.statut as sendstatut";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
@ -131,7 +130,7 @@ if ($filteremail)
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "m.rowid"; if (!$sortfield) $sortfield = "m.rowid";
} else { } else {
$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; $sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE m.entity = ".$conf->entity; $sql .= " WHERE m.entity = ".$conf->entity;
if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
@ -238,9 +237,10 @@ if ($resql)
print $email->getNomUrl(1); print $email->getNomUrl(1);
print '</td>'; print '</td>';
// Title
print '<td>'.$obj->title.'</td>'; print '<td>'.$obj->title.'</td>';
// Date creation
// Date creation
print '<td class="center">'; print '<td class="center">';
print dol_print_date($db->jdate($obj->datec), 'day'); print dol_print_date($db->jdate($obj->datec), 'day');
print '</td>'; print '</td>';

View File

@ -1191,23 +1191,23 @@ class Facture extends CommonInvoice
{ {
unset($object->lines[$i]); unset($object->lines[$i]);
} }
// Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month)
// Bloc to update dates of service (month by month only if previously filled and similare to start and end of month)
// If it's a service with start and end dates // If it's a service with start and end dates
if (!empty($line->date_start) && !empty($line->date_end)) { if (!empty($conf->global->INVOICE_AUTO_NEXT_MONTH_ON_LINES) && !empty($line->date_start) && !empty($line->date_end)) {
// Get the dates // Get the dates
$start = dol_getdate($line->date_start); $start = dol_getdate($line->date_start);
$end = dol_getdate($line->date_end); $end = dol_getdate($line->date_end);
// Get the first and last day of the month // Get the first and last day of the month
$first = dol_get_first_day($start['year'], $start['mon']); $first = dol_get_first_day($start['year'], $start['mon']);
$last = dol_get_first_day($end['year'], $end['mon']); $last = dol_get_last_day($end['year'], $end['mon']);
// Get diff betweend start/end of month and previously filled //print dol_print_date(dol_mktime(0, 0, 0, $start['mon'], $start['mday'], $start['year'], 'gmt'), 'dayhour').' '.dol_print_date($first, 'dayhour').'<br>';
$diffFirst = num_between_day($first, dol_mktime($start['hours'], $start['minutes'], $start['seconds'], $start['mon'], $start['mday'], $start['year'], 'user')); //print dol_mktime(23, 59, 59, $end['mon'], $end['mday'], $end['year'], 'gmt').' '.$last.'<br>';exit;
$diffLast = num_between_day(dol_mktime($end['hours'], $end['minutes'], $end['seconds'], $end['mon'], $end['mday'], $end['year'], 'user'), $last); // If start date is first date of month and end date is last date of month
if (dol_mktime(0, 0, 0, $start['mon'], $start['mday'], $start['year'], 'gmt') == $first
// If there is <= 1d (or 2?) of start/or/end of month && dol_mktime(23, 59, 59, $end['mon'], $end['mday'], $end['year'], 'gmt') == $last) {
if ($diffFirst <= 2 && $diffLast <= 2) {
$nextMonth = dol_get_next_month($end['mon'], $end['year']); $nextMonth = dol_get_next_month($end['mon'], $end['year']);
$newFirst = dol_get_first_day($nextMonth['year'], $nextMonth['month']); $newFirst = dol_get_first_day($nextMonth['year'], $nextMonth['month']);
$newLast = dol_get_last_day($nextMonth['year'], $nextMonth['month']); $newLast = dol_get_last_day($nextMonth['year'], $nextMonth['month']);

View File

@ -161,8 +161,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,";
$sql .= " s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
$sql .= " cc.rowid, cc.code"; $sql .= " cc.rowid, cc.code";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user";
// Add Group from hooks // Add Group from hooks
$parameters = array(); $parameters = array();

View File

@ -356,7 +356,8 @@ function dol_stringtotime($string, $gm = 1)
} }
/** Return previous day /**
* Return previous day
* *
* @param int $day Day * @param int $day Day
* @param int $month Month * @param int $month Month
@ -371,7 +372,8 @@ function dol_get_prev_day($day, $month, $year)
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
} }
/** Return next day /**
* Return next day
* *
* @param int $day Day * @param int $day Day
* @param int $month Month * @param int $month Month
@ -386,7 +388,8 @@ function dol_get_next_day($day, $month, $year)
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
} }
/** Return previous month /**
* Return previous month
* *
* @param int $month Month * @param int $month Month
* @param int $year Year * @param int $year Year
@ -405,7 +408,8 @@ function dol_get_prev_month($month, $year)
return array('year' => $prev_year, 'month' => $prev_month); return array('year' => $prev_year, 'month' => $prev_month);
} }
/** Return next month /**
* Return next month
* *
* @param int $month Month * @param int $month Month
* @param int $year Year * @param int $year Year
@ -424,7 +428,8 @@ function dol_get_next_month($month, $year)
return array('year' => $next_year, 'month' => $next_month); return array('year' => $next_year, 'month' => $next_month);
} }
/** Return previous week /**
* Return previous week
* *
* @param int $day Day * @param int $day Day
* @param int $week Week * @param int $week Week
@ -442,7 +447,8 @@ function dol_get_prev_week($day, $week, $month, $year)
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
} }
/** Return next week /**
* Return next week
* *
* @param int $day Day * @param int $day Day
* @param int $week Week * @param int $week Week
@ -461,7 +467,8 @@ function dol_get_next_week($day, $week, $month, $year)
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
} }
/** Return GMT time for first day of a month or year /**
* Return GMT time for first day of a month or year
* *
* @param int $year Year * @param int $year Year
* @param int $month Month * @param int $month Month
@ -478,7 +485,9 @@ function dol_get_first_day($year, $month = 1, $gm = false)
} }
/** Return GMT time for last day of a month or year /**
* Return GMT time for last day of a month or year.
* Note: The timestamp contains last day and last hours (23:59:59)
* *
* @param int $year Year * @param int $year Year
* @param int $month Month * @param int $month Month
@ -504,7 +513,8 @@ function dol_get_last_day($year, $month = 12, $gm = false)
return $datelim; return $datelim;
} }
/** Return GMT time for last hour of a given GMT date (it removes hours, min and second part) /**
* Return GMT time for last hour of a given GMT date (it removes hours, min and second part)
* *
* @param int $date Date * @param int $date Date
* @return int Date for last hour of a given date * @return int Date for last hour of a given date
@ -515,7 +525,8 @@ function dol_get_last_hour($date)
return dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], false); return dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], false);
} }
/** Return GMT time for first hour of a given GMT date (it removes hours, min and second part) /**
* Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
* *
* @param int $date Date * @param int $date Date
* @return int Date for last hour of a given date * @return int Date for last hour of a given date

View File

@ -1984,8 +1984,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
{ {
global $conf, $langs; global $conf, $langs;
if ($tzoutput == 'auto' && property_exists($conf, 'tzuserinputkey')) { if ($tzoutput === 'auto') {
$tzoutput = $conf->tzuserinputkey; $tzoutput = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey);
} }
// Clean parameters // Clean parameters

View File

@ -2185,7 +2185,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
$sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")";
$sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee"; $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,";
$sql2 .= " s.logo, s.email, s.entity, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee";
$sql2 .= " ORDER BY p.title, p.ref"; $sql2 .= " ORDER BY p.title, p.ref";
$resql = $db->query($sql2); $resql = $db->query($sql2);

View File

@ -217,8 +217,9 @@ if (empty($reshook))
if (!empty($origin) && !empty($originid)) if (!empty($origin) && !empty($originid))
{ {
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin']; $regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $_POST['origin'], $regs)) $element = $subelement = GETPOST('origin', 'alphanohtml');
if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs))
{ {
$element = $regs[1]; $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
@ -478,8 +479,7 @@ if (empty($reshook))
$desc = GETPOST('np_desc', 'restricthtml'); $desc = GETPOST('np_desc', 'restricthtml');
$date_intervention = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); $date_intervention = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int'));
$duration = empty($conf->global->FICHINTER_WITHOUT_DURATION) ?convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')) : 0; $duration = empty($conf->global->FICHINTER_WITHOUT_DURATION) ? convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')) : 0;
// Extrafields // Extrafields
$extrafields->fetch_name_optionals_label($object->table_element_line); $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -1335,8 +1335,7 @@ if ($action == 'create')
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($action == 'editline') if ($action == 'editline') {
{
print '<input type="hidden" name="action" value="updateline">'; print '<input type="hidden" name="action" value="updateline">';
print '<input type="hidden" name="line_id" value="'.GETPOST('line_id', 'int').'">'; print '<input type="hidden" name="line_id" value="'.GETPOST('line_id', 'int').'">';
} else { } else {
@ -1348,8 +1347,9 @@ if ($action == 'create')
$sql .= ' ft.date as date_intervention'; $sql .= ' ft.date as date_intervention';
$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
$sql .= ' WHERE ft.fk_fichinter = '.$object->id; $sql .= ' WHERE ft.fk_fichinter = '.$object->id;
if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION)) if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION)) {
$sql .= ' AND ft.duree <> 0'; $sql .= ' AND ft.duree <> 0';
}
$sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid'; $sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid';
$resql = $db->query($sql); $resql = $db->query($sql);
@ -1376,13 +1376,11 @@ if ($action == 'create')
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
} }
while ($i < $num) while ($i < $num) {
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
// Ligne en mode visu // Ligne en mode visu
if ($action != 'editline' || GETPOST('line_id', 'int') != $objp->rowid) if ($action != 'editline' || GETPOST('line_id', 'int') != $objp->rowid) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// No. // No.
@ -1402,8 +1400,7 @@ if ($action == 'create')
print "</td>\n"; print "</td>\n";
// Icon to edit and delete
// Econ to edit and delete
if ($object->statut == 0 && $user->rights->ficheinter->creer) if ($object->statut == 0 && $user->rights->ficheinter->creer)
{ {
print '<td class="center">'; print '<td class="center">';

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2019 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2021 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr> * Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr> * Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017-2020 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2017-2020 Ferran Marcet <fmarcet@2byte.es>
@ -228,6 +228,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
foreach ($_POST as $key => $value) foreach ($_POST as $key => $value)
{ {
// without batch module enabled // without batch module enabled
$reg = array();
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
{ {
$pos++; $pos++;
@ -269,16 +270,20 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int'); $dto = price2num(GETPOST("dto_".$reg[1].'_'.$reg[2], 'int'), '');
if (empty($dto)) {
$dto = 0;
}
//update supplier price //update supplier price
if (GETPOSTISSET($saveprice)) { if (GETPOSTISSET($saveprice)) {
// TODO Use class // TODO Use class
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET unitprice='".GETPOST($pu)."'"; $sql .= " SET unitprice='".price2num(GETPOST($pu), 'MU')."'";
$sql .= ", price=".GETPOST($pu)."*quantity"; $sql .= ", price=".price2num(GETPOST($pu), 'MU')."*quantity";
$sql .= ", remise_percent='".(!empty($dto) ? $dto : 0)."'"; $sql .= ", remise_percent = ".((float) $dto);
$sql .= " WHERE fk_soc=".$object->socid; $sql .= " WHERE fk_soc=".((int) $object->socid);
$sql .= " AND fk_product=".GETPOST($prod, 'int'); $sql .= " AND fk_product=".((int) GETPOST($prod, 'int'));
$resql = $db->query($sql); $resql = $db->query($sql);
} }

View File

@ -322,7 +322,7 @@ $sql .= " WHERE p.entity IN (".getEntity('project').")";
$sql .= " AND p.fk_statut = 1"; $sql .= " AND p.fk_statut = 1";
if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2
if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql .= " GROUP BY s.rowid, s.nom, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas, s.status"; $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur, s.logo, s.email, s.entity, s.canvas, s.status";
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
//$sql .= $db->plimit($max + 1, 0); //$sql .= $db->plimit($max + 1, 0);