Merge HEAD, branch 'develop' of github.com:Dolibarr/dolibarr into dev_new_project_task_add_contact
This commit is contained in:
commit
79b0f08a8d
@ -33,8 +33,8 @@ $langs->load("admin");
|
|||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$what = GETPOST('what', 'alpha');
|
$what = GETPOST('what', 'alpha');
|
||||||
$export_type = GETPOST('export_type', 'alpha');
|
$export_type = GETPOST('export_type', 'alpha');
|
||||||
$file = GETPOST('zipfilename_template', 'alpha');
|
$file = trim(GETPOST('zipfilename_template', 'alpha'));
|
||||||
$compression = GETPOST('compression');
|
$compression = GETPOST('compression', 'aZ09');
|
||||||
|
|
||||||
$file = dol_sanitizeFileName($file);
|
$file = dol_sanitizeFileName($file);
|
||||||
$file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2)$/i', '', $file);
|
$file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2)$/i', '', $file);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2010-2017 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2017 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2014-2018 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2014-2020 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||||
@ -2035,7 +2035,7 @@ if ($action == 'create')
|
|||||||
// Send
|
// Send
|
||||||
if (empty($user->socid)) {
|
if (empty($user->socid)) {
|
||||||
if ($object->statut == 1) {
|
if ($object->statut == 1) {
|
||||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) {
|
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
||||||
} else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>';
|
} else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,6 +97,8 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
|
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls";
|
||||||
$sql .= " WHERE active=1";
|
$sql .= " WHERE active=1";
|
||||||
|
$sql .= " AND cls.code <> 'LOST'";
|
||||||
|
$sql .= $this->db->order('cls.rowid', 'ASC');
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
@ -124,7 +126,6 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$colorseriesstat[$objp->rowid] = $badgeStatus6;
|
$colorseriesstat[$objp->rowid] = $badgeStatus6;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$colorseriesstat[$objp->rowid] = $badgeStatus2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
@ -134,12 +135,11 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
|
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
$this->max = $max;
|
$this->max = $max;
|
||||||
|
|
||||||
$this->info_box_head = array(
|
$this->info_box_head = array(
|
||||||
'text' => $langs->trans("Statistics") . ' - ' . $langs->trans("OpportunitiesStatusForOpenedProjects"),
|
'text' => $langs->trans("Statistics") . ' - ' . $langs->trans("OpportunitiesStatusForOpenedProjects"),
|
||||||
$max
|
'graph' => '1'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
|
if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
|
||||||
@ -187,6 +187,8 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$stringtoprint = '';
|
$stringtoprint = '';
|
||||||
$stringtoprint .= '<div class="div-table-responsive-no-min ">';
|
$stringtoprint .= '<div class="div-table-responsive-no-min ">';
|
||||||
$listofstatus = array_keys($listofoppstatus);
|
$listofstatus = array_keys($listofoppstatus);
|
||||||
|
$liststatus = array();
|
||||||
|
$data = array('');
|
||||||
foreach ($listofstatus as $status) {
|
foreach ($listofstatus as $status) {
|
||||||
$labelStatus = '';
|
$labelStatus = '';
|
||||||
if ($status != 7) {
|
if ($status != 7) {
|
||||||
@ -198,7 +200,8 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
$labelStatus = $listofopplabel[$status];
|
$labelStatus = $listofopplabel[$status];
|
||||||
}
|
}
|
||||||
|
|
||||||
$dataseries[] = array($labelStatus,(isset($valsamount[$status]) ? (float) $valsamount[$status] : 0));
|
$data[] = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0);
|
||||||
|
$liststatus[] = $labelStatus;
|
||||||
if (!$conf->use_javascript_ajax) {
|
if (!$conf->use_javascript_ajax) {
|
||||||
$stringtoprint .= '<tr class="oddeven">';
|
$stringtoprint .= '<tr class="oddeven">';
|
||||||
$stringtoprint .= '<td>' . $labelStatus . '</td>';
|
$stringtoprint .= '<td>' . $labelStatus . '</td>';
|
||||||
@ -207,16 +210,21 @@ class box_funnel_of_prospection extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$dataseries[] = $data;
|
||||||
if ($conf->use_javascript_ajax) {
|
if ($conf->use_javascript_ajax) {
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
|
||||||
$dolgraph = new DolGraph();
|
$dolgraph = new DolGraph();
|
||||||
|
$dolgraph->SetMinValue(0);
|
||||||
$dolgraph->SetData($dataseries);
|
$dolgraph->SetData($dataseries);
|
||||||
|
$dolgraph->SetLegend($liststatus);
|
||||||
$dolgraph->SetDataColor(array_values($colorseriesstat));
|
$dolgraph->SetDataColor(array_values($colorseriesstat));
|
||||||
//$dolgraph->SetLegend(array('PROSP',$dataseries['PROSP']));
|
|
||||||
$dolgraph->setShowLegend(2);
|
$dolgraph->setShowLegend(2);
|
||||||
$dolgraph->setShowPercent(1);
|
$dolgraph->setShowPercent(1);
|
||||||
$dolgraph->SetType(array('pie'));
|
$dolgraph->setTitle('FunnelOfProspection');
|
||||||
|
$dolgraph->SetType(array('horizontalbars'));
|
||||||
$dolgraph->SetHeight('200');
|
$dolgraph->SetHeight('200');
|
||||||
|
$dolgraph->SetWidth('600');
|
||||||
|
$dolgraph->mode = 'depth';
|
||||||
$dolgraph->draw('idgraphstatus');
|
$dolgraph->draw('idgraphstatus');
|
||||||
$stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
|
$stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,8 +104,7 @@ class DolGraph
|
|||||||
$this->bgcolor = array(235, 235, 224);
|
$this->bgcolor = array(235, 235, 224);
|
||||||
|
|
||||||
$color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
|
$color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
|
||||||
if (is_readable($color_file))
|
if (is_readable($color_file)) {
|
||||||
{
|
|
||||||
include_once $color_file;
|
include_once $color_file;
|
||||||
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
|
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
|
||||||
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
|
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
|
||||||
@ -261,7 +260,7 @@ class DolGraph
|
|||||||
* Set type
|
* Set type
|
||||||
*
|
*
|
||||||
* @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be:
|
* @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be:
|
||||||
* 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horirontalbars'...
|
* 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horizontalbars'...
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function SetType($type)
|
public function SetType($type)
|
||||||
@ -466,10 +465,8 @@ class DolGraph
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $theme_bgcolor, $theme_bgcoloronglet;
|
global $theme_bgcolor, $theme_bgcoloronglet;
|
||||||
|
|
||||||
if (!is_array($bg_color))
|
if (!is_array($bg_color)) {
|
||||||
{
|
if ($bg_color == 'onglet') {
|
||||||
if ($bg_color == 'onglet')
|
|
||||||
{
|
|
||||||
//print 'ee'.join(',',$theme_bgcoloronglet);
|
//print 'ee'.join(',',$theme_bgcoloronglet);
|
||||||
$this->bgcolor = $theme_bgcoloronglet;
|
$this->bgcolor = $theme_bgcoloronglet;
|
||||||
} else {
|
} else {
|
||||||
@ -492,10 +489,8 @@ class DolGraph
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $theme_bgcolor, $theme_bgcoloronglet;
|
global $theme_bgcolor, $theme_bgcoloronglet;
|
||||||
|
|
||||||
if (!is_array($bg_colorgrid))
|
if (!is_array($bg_colorgrid)) {
|
||||||
{
|
if ($bg_colorgrid == 'onglet') {
|
||||||
if ($bg_colorgrid == 'onglet')
|
|
||||||
{
|
|
||||||
//print 'ee'.join(',',$theme_bgcoloronglet);
|
//print 'ee'.join(',',$theme_bgcoloronglet);
|
||||||
$this->bgcolorgrid = $theme_bgcoloronglet;
|
$this->bgcolorgrid = $theme_bgcoloronglet;
|
||||||
} else {
|
} else {
|
||||||
@ -535,10 +530,8 @@ class DolGraph
|
|||||||
$nblines = count($this->data);
|
$nblines = count($this->data);
|
||||||
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
||||||
|
|
||||||
for ($j = 0; $j < $nblines; $j++)
|
for ($j = 0; $j < $nblines; $j++) {
|
||||||
{
|
for ($i = 0; $i < $nbvalues; $i++) {
|
||||||
for ($i = 0; $i < $nbvalues; $i++)
|
|
||||||
{
|
|
||||||
$vals[$k] = $this->data[$j][$i + 1];
|
$vals[$k] = $this->data[$j][$i + 1];
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
@ -564,10 +557,8 @@ class DolGraph
|
|||||||
$nblines = count($this->data);
|
$nblines = count($this->data);
|
||||||
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
|
||||||
|
|
||||||
for ($j = 0; $j < $nblines; $j++)
|
for ($j = 0; $j < $nblines; $j++) {
|
||||||
{
|
for ($i = 0; $i < $nbvalues; $i++) {
|
||||||
for ($i = 0; $i < $nbvalues; $i++)
|
|
||||||
{
|
|
||||||
$vals[$k] = $this->data[$j][$i + 1];
|
$vals[$k] = $this->data[$j][$i + 1];
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
@ -589,8 +580,7 @@ class DolGraph
|
|||||||
if ($max != 0) $max++;
|
if ($max != 0) $max++;
|
||||||
$size = dol_strlen(abs(ceil($max)));
|
$size = dol_strlen(abs(ceil($max)));
|
||||||
$factor = 1;
|
$factor = 1;
|
||||||
for ($i = 0; $i < ($size - 1); $i++)
|
for ($i = 0; $i < ($size - 1); $i++) {
|
||||||
{
|
|
||||||
$factor *= 10;
|
$factor *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,8 +605,7 @@ class DolGraph
|
|||||||
if ($min != 0) $min--;
|
if ($min != 0) $min--;
|
||||||
$size = dol_strlen(abs(floor($min)));
|
$size = dol_strlen(abs(floor($min)));
|
||||||
$factor = 1;
|
$factor = 1;
|
||||||
for ($i = 0; $i < ($size - 1); $i++)
|
for ($i = 0; $i < ($size - 1); $i++) {
|
||||||
{
|
|
||||||
$factor *= 10;
|
$factor *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,20 +624,17 @@ class DolGraph
|
|||||||
*/
|
*/
|
||||||
public function draw($file, $fileurl = '')
|
public function draw($file, $fileurl = '')
|
||||||
{
|
{
|
||||||
if (empty($file))
|
if (empty($file)) {
|
||||||
{
|
|
||||||
$this->error = "Call to draw method was made with empty value for parameter file.";
|
$this->error = "Call to draw method was made with empty value for parameter file.";
|
||||||
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (!is_array($this->data))
|
if (!is_array($this->data)) {
|
||||||
{
|
|
||||||
$this->error = "Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
|
$this->error = "Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
|
||||||
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (count($this->data) < 1)
|
if (count($this->data) < 1) {
|
||||||
{
|
|
||||||
$this->error = "Call to draw method was made but SetData was is an empty dataset";
|
$this->error = "Call to draw method was made but SetData was is an empty dataset";
|
||||||
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_WARNING);
|
dol_syslog(get_class($this) . "::draw " . $this->error, LOG_WARNING);
|
||||||
}
|
}
|
||||||
@ -680,8 +666,7 @@ class DolGraph
|
|||||||
|
|
||||||
dol_syslog(get_class($this) . "::draw_jflot this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
dol_syslog(get_class($this) . "::draw_jflot this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
||||||
|
|
||||||
if (empty($this->width) && empty($this->height))
|
if (empty($this->width) && empty($this->height)) {
|
||||||
{
|
|
||||||
print 'Error width or height not set';
|
print 'Error width or height not set';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -712,8 +697,7 @@ class DolGraph
|
|||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar')))
|
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
|
||||||
{
|
|
||||||
foreach ($values as $x => $y) {
|
foreach ($values as $x => $y) {
|
||||||
if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
|
if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
|
||||||
}
|
}
|
||||||
@ -730,8 +714,7 @@ class DolGraph
|
|||||||
|
|
||||||
$this->stringtoshow = '<!-- Build using jflot -->' . "\n";
|
$this->stringtoshow = '<!-- Build using jflot -->' . "\n";
|
||||||
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
|
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
|
||||||
if (!empty($this->shownographyet))
|
if (!empty($this->shownographyet)) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>';
|
$this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>';
|
||||||
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
||||||
return;
|
return;
|
||||||
@ -745,12 +728,10 @@ class DolGraph
|
|||||||
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
||||||
$this->stringtoshow .= '$(function () {' . "\n";
|
$this->stringtoshow .= '$(function () {' . "\n";
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
if ($nblot < 0)
|
if ($nblot < 0) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<!-- No series of data -->' . "\n";
|
$this->stringtoshow .= '<!-- No series of data -->' . "\n";
|
||||||
} else {
|
} else {
|
||||||
while ($i < $nblot)
|
while ($i < $nblot) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<!-- Serie ' . $i . ' -->' . "\n";
|
$this->stringtoshow .= '<!-- Serie ' . $i . ' -->' . "\n";
|
||||||
$this->stringtoshow .= $serie[$i] . "\n";
|
$this->stringtoshow .= $serie[$i] . "\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -759,8 +740,7 @@ class DolGraph
|
|||||||
$this->stringtoshow .= "\n";
|
$this->stringtoshow .= "\n";
|
||||||
|
|
||||||
// Special case for Graph of type 'pie'
|
// Special case for Graph of type 'pie'
|
||||||
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar')))
|
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
|
||||||
{
|
|
||||||
$datacolor = array();
|
$datacolor = array();
|
||||||
foreach ($this->datacolor as $val) {
|
foreach ($this->datacolor as $val) {
|
||||||
if (is_array($val)) $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B)
|
if (is_array($val)) $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B)
|
||||||
@ -814,8 +794,7 @@ class DolGraph
|
|||||||
pan: {
|
pan: {
|
||||||
interactive: true
|
interactive: true
|
||||||
},';
|
},';
|
||||||
if (count($datacolor))
|
if (count($datacolor)) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= 'colors: ' . (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)) . ',';
|
$this->stringtoshow .= 'colors: ' . (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)) . ',';
|
||||||
}
|
}
|
||||||
$this->stringtoshow .= 'legend: {show: ' . ($showlegend ? 'true' : 'false') . ', position: \'ne\' }
|
$this->stringtoshow .= 'legend: {show: ' . ($showlegend ? 'true' : 'false') . ', position: \'ne\' }
|
||||||
@ -876,8 +855,7 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'function plotWithOptions_' . $tag . '() {' . "\n";
|
$this->stringtoshow .= 'function plotWithOptions_' . $tag . '() {' . "\n";
|
||||||
$this->stringtoshow .= '$.plot($("#placeholder_' . $tag . '"), [ ' . "\n";
|
$this->stringtoshow .= '$.plot($("#placeholder_' . $tag . '"), [ ' . "\n";
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
while ($i < $nblot)
|
while ($i < $nblot) {
|
||||||
{
|
|
||||||
if ($i > $firstlot) $this->stringtoshow .= ', ' . "\n";
|
if ($i > $firstlot) $this->stringtoshow .= ', ' . "\n";
|
||||||
$color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
|
$color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
|
||||||
$this->stringtoshow .= '{ ';
|
$this->stringtoshow .= '{ ';
|
||||||
@ -899,8 +877,7 @@ class DolGraph
|
|||||||
// Xaxis
|
// Xaxis
|
||||||
$this->stringtoshow .= ', xaxis: { ticks: [' . "\n";
|
$this->stringtoshow .= ', xaxis: { ticks: [' . "\n";
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach ($this->data as $key => $valarray)
|
foreach ($this->data as $key => $valarray) {
|
||||||
{
|
|
||||||
if ($x > 0) $this->stringtoshow .= ', ' . "\n";
|
if ($x > 0) $this->stringtoshow .= ', ' . "\n";
|
||||||
$this->stringtoshow .= ' [' . $x . ', "' . $valarray[0] . '"]';
|
$this->stringtoshow .= ' [' . $x . ', "' . $valarray[0] . '"]';
|
||||||
$x++;
|
$x++;
|
||||||
@ -949,8 +926,7 @@ class DolGraph
|
|||||||
|
|
||||||
dol_syslog(get_class($this) . "::draw_chart this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
dol_syslog(get_class($this) . "::draw_chart this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
|
||||||
|
|
||||||
if (empty($this->width) && empty($this->height))
|
if (empty($this->width) && empty($this->height)) {
|
||||||
{
|
|
||||||
print 'Error width or height not set';
|
print 'Error width or height not set';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -971,7 +947,8 @@ class DolGraph
|
|||||||
// Works with line but not with bars
|
// Works with line but not with bars
|
||||||
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
|
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
|
||||||
|
|
||||||
$serie = array(); $arrayofgroupslegend = array();
|
$serie = array();
|
||||||
|
$arrayofgroupslegend = array();
|
||||||
//var_dump($this->data);
|
//var_dump($this->data);
|
||||||
|
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
@ -1023,9 +1000,8 @@ class DolGraph
|
|||||||
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
|
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
|
||||||
|
|
||||||
$this->stringtoshow = '<!-- Build using chart -->' . "\n";
|
$this->stringtoshow = '<!-- Build using chart -->' . "\n";
|
||||||
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle'.(empty($this->cssprefix) ? '' : ' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
|
if (!empty($this->title)&&$this->title!='FunnelOfProspection') $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
|
||||||
if (!empty($this->shownographyet))
|
if (!empty($this->shownographyet)) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>';
|
$this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>';
|
||||||
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
|
||||||
return;
|
return;
|
||||||
@ -1041,12 +1017,10 @@ class DolGraph
|
|||||||
|
|
||||||
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
|
||||||
$i = $firstlot;
|
$i = $firstlot;
|
||||||
if ($nblot < 0)
|
if ($nblot < 0) {
|
||||||
{
|
|
||||||
$this->stringtoshow .= '<!-- No series of data -->';
|
$this->stringtoshow .= '<!-- No series of data -->';
|
||||||
} else {
|
} else {
|
||||||
while ($i < $nblot)
|
while ($i < $nblot) {
|
||||||
{
|
|
||||||
//$this->stringtoshow .= '<!-- Series '.$i.' -->'."\n";
|
//$this->stringtoshow .= '<!-- Series '.$i.' -->'."\n";
|
||||||
//$this->stringtoshow .= $serie[$i]."\n";
|
//$this->stringtoshow .= $serie[$i]."\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -1055,8 +1029,7 @@ class DolGraph
|
|||||||
$this->stringtoshow .= "\n";
|
$this->stringtoshow .= "\n";
|
||||||
|
|
||||||
// Special case for Graph of type 'pie', 'piesemicircle', or 'polar'
|
// Special case for Graph of type 'pie', 'piesemicircle', or 'polar'
|
||||||
if (isset($this->type[$firstlot]) && (in_array($this->type[$firstlot], array('pie', 'polar', 'piesemicircle'))))
|
if (isset($this->type[$firstlot]) && (in_array($this->type[$firstlot], array('pie', 'polar', 'piesemicircle')))) {
|
||||||
{
|
|
||||||
$type = $this->type[$firstlot]; // pie or polar
|
$type = $this->type[$firstlot]; // pie or polar
|
||||||
$this->stringtoshow .= 'var options = {' . "\n";
|
$this->stringtoshow .= 'var options = {' . "\n";
|
||||||
$legendMaxLines = 0; // Does not work
|
$legendMaxLines = 0; // Does not work
|
||||||
@ -1077,7 +1050,8 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'elements: { arc: {' . "\n";
|
$this->stringtoshow .= 'elements: { arc: {' . "\n";
|
||||||
// Color of earch arc
|
// Color of earch arc
|
||||||
$this->stringtoshow .= 'backgroundColor: [';
|
$this->stringtoshow .= 'backgroundColor: [';
|
||||||
$i = 0; $foundnegativecolor = 0;
|
$i = 0;
|
||||||
|
$foundnegativecolor = 0;
|
||||||
foreach ($legends as $val) // Loop on each serie
|
foreach ($legends as $val) // Loop on each serie
|
||||||
{
|
{
|
||||||
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
|
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
|
||||||
@ -1155,8 +1129,10 @@ class DolGraph
|
|||||||
// Other cases, graph of type 'bars', 'lines', 'linesnopoint'
|
// Other cases, graph of type 'bars', 'lines', 'linesnopoint'
|
||||||
else {
|
else {
|
||||||
$type = 'bar';
|
$type = 'bar';
|
||||||
|
$isfunnel = false;
|
||||||
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
|
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
|
||||||
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar';
|
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar';
|
||||||
|
if ($this->title == 'FunnelOfProspection') $isfunnel = true;
|
||||||
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
|
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
|
||||||
|
|
||||||
$this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
|
$this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
|
||||||
@ -1164,6 +1140,9 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'legend: { display: false }, ';
|
$this->stringtoshow .= 'legend: { display: false }, ';
|
||||||
}
|
}
|
||||||
$this->stringtoshow .= 'scales: { xAxes: [{ ';
|
$this->stringtoshow .= 'scales: { xAxes: [{ ';
|
||||||
|
if ($isfunnel) {
|
||||||
|
$this->stringtoshow .= ' ticks: { beginAtZero: true}, display: false,';
|
||||||
|
}
|
||||||
//$this->stringtoshow .= 'type: \'time\', '; // Need Moment.js
|
//$this->stringtoshow .= 'type: \'time\', '; // Need Moment.js
|
||||||
$this->stringtoshow .= 'distribution: \'linear\'';
|
$this->stringtoshow .= 'distribution: \'linear\'';
|
||||||
if ($type == 'bar' && count($arrayofgroupslegend) > 0) {
|
if ($type == 'bar' && count($arrayofgroupslegend) > 0) {
|
||||||
@ -1174,8 +1153,19 @@ class DolGraph
|
|||||||
$this->stringtoshow .= ', yAxes: [{ stacked: true }]';
|
$this->stringtoshow .= ', yAxes: [{ stacked: true }]';
|
||||||
}
|
}
|
||||||
$this->stringtoshow .= ' }';
|
$this->stringtoshow .= ' }';
|
||||||
|
if ($isfunnel) {
|
||||||
|
$this->stringtoshow .= ', tooltips: {mode: \'nearest\',
|
||||||
|
callbacks: {
|
||||||
|
title: function(tooltipItem, data) {
|
||||||
|
return data.datasets[tooltipItem[0].datasetIndex].label;
|
||||||
|
},
|
||||||
|
label: function(tooltipItem, data) {
|
||||||
|
return data.datasets[tooltipItem.datasetIndex].data[0][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},';
|
||||||
|
}
|
||||||
$this->stringtoshow .= '};';
|
$this->stringtoshow .= '};';
|
||||||
|
|
||||||
$this->stringtoshow .= '
|
$this->stringtoshow .= '
|
||||||
var ctx = document.getElementById("canvas_' . $tag . '").getContext("2d");
|
var ctx = document.getElementById("canvas_' . $tag . '").getContext("2d");
|
||||||
var chart = new Chart(ctx, {
|
var chart = new Chart(ctx, {
|
||||||
@ -1187,12 +1177,14 @@ class DolGraph
|
|||||||
labels: [';
|
labels: [';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
if (!$isfunnel);{
|
||||||
foreach ($legends as $val) // Loop on each serie
|
foreach ($legends as $val) // Loop on each serie
|
||||||
{
|
{
|
||||||
if ($i > 0) $this->stringtoshow .= ', ';
|
if ($i > 0) $this->stringtoshow .= ', ';
|
||||||
$this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'";
|
$this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//var_dump($arrayofgroupslegend);
|
//var_dump($arrayofgroupslegend);
|
||||||
|
|
||||||
@ -1205,6 +1197,7 @@ class DolGraph
|
|||||||
$oldstacknum = -1;
|
$oldstacknum = -1;
|
||||||
while ($i < $nblot) // Loop on each serie
|
while ($i < $nblot) // Loop on each serie
|
||||||
{
|
{
|
||||||
|
$foundnegativecolor = 0;
|
||||||
$usecolorvariantforgroupby = 0;
|
$usecolorvariantforgroupby = 0;
|
||||||
// We used a 'group by' and we have too many colors so we generated color variants per
|
// We used a 'group by' and we have too many colors so we generated color variants per
|
||||||
if (is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
|
if (is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
|
||||||
@ -1245,9 +1238,26 @@ class DolGraph
|
|||||||
$color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)';
|
$color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)';
|
||||||
$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
|
$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
|
||||||
} else { // We do not use a 'group by'
|
} else { // We do not use a 'group by'
|
||||||
$color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)';
|
if (is_array($this->datacolor[$i])) $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; // If datacolor is array(R, G, B)
|
||||||
|
else {
|
||||||
|
$tmp = str_replace('#', '', $this->datacolor[$i]);
|
||||||
|
if (strpos($tmp, '-') !== false) {
|
||||||
|
$foundnegativecolor++;
|
||||||
|
$color = '#FFFFFF'; // If $val is '-123'
|
||||||
|
} else {
|
||||||
|
$color = "#" . $tmp; // If $val is '123' or '#123'
|
||||||
$bordercolor = $color;
|
$bordercolor = $color;
|
||||||
//$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor));
|
}
|
||||||
|
if ($foundnegativecolor) {
|
||||||
|
if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B)
|
||||||
|
else {
|
||||||
|
$tmp = str_replace('#', '', $this->datacolor[$i]);
|
||||||
|
if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123'
|
||||||
|
else $bordercolor = 'null'; // If $val is '123' or '#123'
|
||||||
|
}
|
||||||
|
$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i > 0) $this->stringtoshow .= ', ';
|
if ($i > 0) $this->stringtoshow .= ', ';
|
||||||
@ -1257,11 +1267,22 @@ class DolGraph
|
|||||||
$this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', ';
|
$this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', ';
|
||||||
$this->stringtoshow .= 'pointStyle: \'' . ($this->type[$i] == 'linesnopoint' ? 'line' : 'circle') . '\', ';
|
$this->stringtoshow .= 'pointStyle: \'' . ($this->type[$i] == 'linesnopoint' ? 'line' : 'circle') . '\', ';
|
||||||
$this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', ';
|
$this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', ';
|
||||||
if ($type == 'bar') { $this->stringtoshow .= 'borderWidth: \'1\', '; }
|
if ($isfunnel){
|
||||||
|
$this->stringtoshow .= 'borderWidth: \'2\', ';
|
||||||
|
}
|
||||||
|
elseif ($type == 'bar' || $type == 'horizontalBar') {
|
||||||
|
$this->stringtoshow .= 'borderWidth: \'1\', ';
|
||||||
|
}
|
||||||
$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
|
$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
|
||||||
$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
|
$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
|
||||||
if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
|
if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
|
||||||
$this->stringtoshow .= 'data: ['.$serie[$i].']';
|
$this->stringtoshow .='data: [';
|
||||||
|
if ($isfunnel){
|
||||||
|
$this->stringtoshow .= '['.-$serie[$i].','.$serie[$i].']';
|
||||||
|
}else {
|
||||||
|
$this->stringtoshow .= $serie[$i];
|
||||||
|
}
|
||||||
|
$this->stringtoshow .=']';
|
||||||
$this->stringtoshow .= '}' . "\n";
|
$this->stringtoshow .= '}' . "\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -1301,8 +1322,7 @@ class DolGraph
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
if ($shownographyet)
|
if ($shownographyet) {
|
||||||
{
|
|
||||||
$s = '<div class="nographyet" style="width:' . (preg_match('/%/', $this->width) ? $this->width : $this->width . 'px') . '; height:' . (preg_match('/%/', $this->height) ? $this->height : $this->height . 'px') . ';"></div>';
|
$s = '<div class="nographyet" style="width:' . (preg_match('/%/', $this->width) ? $this->width : $this->width . 'px') . '; height:' . (preg_match('/%/', $this->height) ? $this->height : $this->height . 'px') . ';"></div>';
|
||||||
$s .= '<div class="nographyettext margintoponly">';
|
$s .= '<div class="nographyettext margintoponly">';
|
||||||
if (is_numeric($shownographyet)) {
|
if (is_numeric($shownographyet)) {
|
||||||
|
|||||||
@ -1995,7 +1995,7 @@ class Form
|
|||||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
|
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
|
||||||
$urloption .= '&socid='.$socid;
|
$urloption .= '&socid='.$socid;
|
||||||
}
|
}
|
||||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
|
||||||
|
|
||||||
if (!empty($conf->variants->enabled)) {
|
if (!empty($conf->variants->enabled)) {
|
||||||
$out .= '
|
$out .= '
|
||||||
@ -6197,6 +6197,7 @@ class Form
|
|||||||
$tmpfieldstoshow = '';
|
$tmpfieldstoshow = '';
|
||||||
foreach ($objecttmp->fields as $key => $val)
|
foreach ($objecttmp->fields as $key => $val)
|
||||||
{
|
{
|
||||||
|
if (!dol_eval($val['enabled'], 1, 1)) continue;
|
||||||
if ($val['showoncombobox']) $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
|
if ($val['showoncombobox']) $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
|
||||||
}
|
}
|
||||||
if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow;
|
if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow;
|
||||||
@ -6294,8 +6295,7 @@ class Form
|
|||||||
}
|
}
|
||||||
if (empty($outputmode))
|
if (empty($outputmode))
|
||||||
{
|
{
|
||||||
if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid)
|
if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
|
||||||
{
|
|
||||||
$out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
|
$out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
|
||||||
} else {
|
} else {
|
||||||
$out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
|
$out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
* @param string $url Ajax Url to call for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list)
|
* @param string $url Ajax Url to call for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list)
|
||||||
* @param string $urloption More parameters on URL request
|
* @param string $urloption More parameters on URL request
|
||||||
* @param int $minLength Minimum number of chars to trigger that Ajax search
|
* @param int $minLength Minimum number of chars to trigger that Ajax search
|
||||||
* @param int $autoselect Automatic selection if just one value
|
* @param int $autoselect Automatic selection if just one value (trigger("change") on field is done is search return only 1 result)
|
||||||
* @param array $ajaxoptions Multiple options array
|
* @param array $ajaxoptions Multiple options array
|
||||||
* - Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done
|
* - Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done
|
||||||
* - Ex: array('disabled'=> )
|
* - Ex: array('disabled'=> )
|
||||||
|
|||||||
@ -931,7 +931,8 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
|
|||||||
// List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
// List of special chars for filenames in windows are defined on page https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
||||||
// Char '>' '<' '|' '$' and ';' are special chars for shells.
|
// Char '>' '<' '|' '$' and ';' are special chars for shells.
|
||||||
// Char '/' and '\' are file delimiters.
|
// Char '/' and '\' are file delimiters.
|
||||||
$filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';');
|
// -- car can be used into filename to inject special paramaters like --use-compress-program to make command with file as parameter making remote execution of command
|
||||||
|
$filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';', '--');
|
||||||
return dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
|
return dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -413,6 +413,7 @@ class Product extends CommonObject
|
|||||||
public $fields = array(
|
public $fields = array(
|
||||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
||||||
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
||||||
|
'barcode' =>array('type'=>'varchar(255)', 'label'=>'Barcode', 'enabled'=>'!empty($conf->barcode->enabled)', 'visible'=>-1, 'showoncombobox'=>1),
|
||||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1),
|
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1),
|
||||||
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
|
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
|
||||||
|
|||||||
@ -376,7 +376,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
$login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
|
$login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
|
||||||
print __METHOD__." login=".$login."\n";
|
print __METHOD__." login=".$login."\n";
|
||||||
$this->assertEquals($login, 'admin');
|
$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed');
|
||||||
|
|
||||||
$login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authetntication method
|
$login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authetntication method
|
||||||
print __METHOD__." login=".$login."\n";
|
print __METHOD__." login=".$login."\n";
|
||||||
@ -553,4 +553,27 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testDolSanitizeFileName
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDolSanitizeFileName()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
//$dummyuser=new User($db);
|
||||||
|
//$result=restrictedArea($dummyuser,'societe');
|
||||||
|
|
||||||
|
$result=dol_sanitizeFileName('bad file | evilaction');
|
||||||
|
$this->assertEquals('bad file _ evilaction', $result);
|
||||||
|
|
||||||
|
$result=dol_sanitizeFileName('bad file --evilparam');
|
||||||
|
$this->assertEquals('bad file _evilparam', $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user