';
$more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 0cccbe6ad8c..bfd5a6f64f7 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -263,23 +263,7 @@ class FormActions
// Type
print '
';
- // TODO Code common with code into comm/action/list.php
- $imgpicto = '';
- if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
- {
- if ($actioncomm->type_picto) {
- $imgpicto = img_picto('', $actioncomm->type_picto);
- } else {
- if ($actioncomm->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright');
- elseif ($actioncomm->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright');
- elseif ($actioncomm->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright');
- elseif ($actioncomm->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright');
- elseif ($actioncomm->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright');
- elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright');
- elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright');
- }
- }
- print $imgpicto;
+ print $actioncomm->getTypePicto();
if ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') {
print $langs->trans("Message");
} else {
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index d7cf03c41e0..c310c352690 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -368,7 +368,9 @@ class FormTicket
if (response.num) {
var selecthtml_str = response.value;
var selecthtml_dom=$.parseHTML(selecthtml_str);
- $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
+ $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ }
} else {
$("#inputautocomplete"+htmlname).val("");
}
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index f8dd34ce0ac..739035f71a5 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -500,7 +500,9 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
if (response.num) {
var selecthtml_str = response.value;
var selecthtml_dom=$.parseHTML(selecthtml_str);
- $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
+ $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+ }
} else {
$("#inputautocomplete"+htmlname).val("");
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 7192a887526..94f4d238ee3 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -13,7 +13,7 @@
* Copyright (C) 2014 Cédric GROSS
* Copyright (C) 2014-2015 Marcos García
* Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018-2021 Frédéric France
* Copyright (C) 2019 Thibault Foucart
* Copyright (C) 2020 Open-Dsi
* Copyright (C) 2021 Gauthier VERDOL
@@ -2480,12 +2480,14 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
$htmllink = $value;
- if (empty($value)) return ' ';
+ if (empty($value)) {
+ return ' ';
+ }
if (!empty($type)) {
$htmllink = '';
- // TODO use dictionary definition for picto $dictsocialnetworks[$type]['icon']
- $htmllink .= img_picto($langs->trans(dol_ucfirst($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0);
+ // Use dictionary definition for picto $dictsocialnetworks[$type]['icon']
+ $htmllink .= ' ';
if ($type == 'skype') {
$htmllink .= $value;
$htmllink .= ' ';
@@ -2501,7 +2503,9 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor
if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
$addlink = 'AC_SKYPE';
$link = '';
- if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = ' '.img_object($langs->trans("AddAction"), "calendar").'';
+ if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
+ $link = ' '.img_object($langs->trans("AddAction"), "calendar").'';
+ }
$htmllink .= ($link ? ' '.$link : '');
}
} else {
@@ -3263,12 +3267,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if (empty($srconly) && in_array($pictowithouttext, array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building',
- 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cron', 'cubes',
+ 'cash-register', 'category', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes',
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt',
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group',
'help', 'holiday',
'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot',
- 'margin', 'map-marker-alt', 'member', 'money-bill-alt', 'mrp', 'note', 'next',
+ 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next',
'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom',
'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder',
'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser',
@@ -3291,7 +3295,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'supplier_invoice', 'ticket',
'error', 'warning',
'recruitmentcandidature', 'recruitmentjobposition', 'resource',
- 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice',
+ 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'user-cog',
'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda'
)
)) {
@@ -3318,7 +3322,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'email'=>'at',
'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle',
'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group', 'loan'=>'money-bill-alt',
- 'member'=>'users', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
+ 'member'=>'users', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'group'=>'users', 'movement'=>'people-carry',
'sign-out'=>'sign-out-alt',
'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star',
@@ -3412,13 +3416,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
// Define $color
$arrayconvpictotocolor = array(
'address'=>'#6c6aa8', 'building'=>'#6c6aa8', 'bom'=>'#a69944',
- 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'dynamicprice'=>'#a69944',
+ 'cog'=>'#999', 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'dynamicprice'=>'#a69944',
'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999',
'dolly'=>'#a69944', 'dollyrevert'=>'#a69944', 'lot'=>'#a69944',
'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944',
'other'=>'#ddd',
'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba',
- 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'uparrow'=>'#555', 'globe-americas'=>'#aaa',
+ 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa',
'website'=>'#304'
);
if (isset($arrayconvpictotocolor[$pictowithouttext])) {
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 9d084ec4f24..d41d055b996 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -50,8 +50,19 @@ class Cronjob extends CommonObject
*/
public $entity;
+ /**
+ * @var string Job type
+ */
public $jobtype;
+
+ /**
+ * @var string|int Date for last cron object update
+ */
public $tms = '';
+
+ /**
+ * @var string|int Date for cron job create
+ */
public $datec = '';
/**
@@ -59,6 +70,9 @@ class Cronjob extends CommonObject
*/
public $label;
+ /**
+ * @var string Job command
+ */
public $command;
public $classesname;
public $objectname;
@@ -67,20 +81,50 @@ class Cronjob extends CommonObject
public $md5params;
public $module_name;
public $priority;
+
/**
* @var string|int Date for last job execution
*/
public $datelastrun = '';
+
/**
* @var string|int Date for next job execution
*/
public $datenextrun = '';
+
+ /**
+ * @var string|int Date for end job execution
+ */
public $dateend = '';
+
+ /**
+ * @var string|int Date for first start job execution
+ */
public $datestart = '';
+
+ /**
+ * @var string|int Date for last result job execution
+ */
public $datelastresult = '';
+
+ /**
+ * @var string Last result from end job execution
+ */
public $lastresult;
+
+ /**
+ * @var string Last output from end job execution
+ */
public $lastoutput;
+
+ /**
+ * @var string Unit frequency of job execution
+ */
public $unitfrequency;
+
+ /**
+ * @var int Frequency of job execution
+ */
public $frequency;
/**
@@ -88,6 +132,9 @@ class Cronjob extends CommonObject
*/
public $status;
+ /**
+ * @var int Is job processing
+ */
public $processing;
/**
@@ -100,9 +147,25 @@ class Cronjob extends CommonObject
*/
public $fk_user_mod;
+ /**
+ * @var int Number of run job execution
+ */
public $nbrun;
+
+ /**
+ * @var int Maximum run job execution
+ */
+ public $maxrun;
+
+ /**
+ * @var string Libname
+ */
public $libname;
- public $test; // A test condition to know if job is visible/qualified
+
+ /**
+ * @var string A test condition to know if job is visible/qualified
+ */
+ public $test;
const STATUS_DISABLED = 0;
const STATUS_ENABLED = 1;
@@ -152,7 +215,12 @@ class Cronjob extends CommonObject
if (isset($this->frequency)) $this->frequency = trim($this->frequency);
if (isset($this->status)) $this->status = trim($this->status);
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
- if (isset($this->nbrun)) $this->nbrun = trim($this->nbrun);
+ if (isset($this->nbrun)) {
+ $this->nbrun = (int) $this->nbrun;
+ }
+ if (isset($this->maxrun)) {
+ $this->maxrun = (int) $this->maxrun;
+ }
if (isset($this->libname)) $this->libname = trim($this->libname);
if (isset($this->test)) $this->test = trim($this->test);
@@ -262,7 +330,10 @@ class Cronjob extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
+ if (!$resql) {
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
+ }
if (!$error)
{
@@ -1253,8 +1324,7 @@ class Cronjob extends CommonObject
}
$result = $this->update($user);
- if ($result < 0)
- {
+ if ($result < 0) {
dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR);
return -1;
}
@@ -1289,14 +1359,16 @@ class Cronjob extends CommonObject
$this->labelStatus = array(); // Force reset o array because label depends on other fields
$this->labelStatusShort = array();
- if (empty($this->labelStatus) || empty($this->labelStatusShort))
- {
+ if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
$langs->load('users');
$moretext = '';
- if ($processing) $moretext = ' ('.$langs->trans("Running").')';
- elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')';
+ if ($processing) {
+ $moretext = ' ('.$langs->trans("Running").')';
+ } elseif ($lastresult) {
+ $moretext .= ' ('.$langs->trans("Error").')';
+ }
$this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled').$moretext;
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Scheduled').$moretext;
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index ad4946ee9f9..aabbe1791b3 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -99,6 +99,7 @@ VirtualStock=Virtual stock
VirtualStockAtDate=Virtual stock at date
VirtualStockAtDateDesc=Virtual stock once all pending orders that are planned to be done before the date will be finished
VirtualStockDesc=Virtual stock is the calculated stock available once all open/pending actions (that affect stocks) are closed (purchase orders received, sales orders shipped, manufacturing orders produced, etc)
+AtDate=At date
IdWarehouse=Id warehouse
DescWareHouse=Description warehouse
LieuWareHouse=Localisation warehouse
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 208d053aa98..7838581fdc4 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1701,8 +1701,7 @@ if (is_array($listofmodules) && count($listofmodules) > 0) {
foreach ($objMod->config_page_url as $page)
{
$urlpage = $page;
- if ($i++)
- {
+ if ($i++) {
$linktoenabledisable .= ' '.img_picto(ucfirst($page), "setup").'';
// print ' '.ucfirst($page).' ';
} else {
@@ -1712,7 +1711,8 @@ if (is_array($listofmodules) && count($listofmodules) > 0) {
$urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1);
$linktoenabledisable .= ' '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'';
} else {
- // Case standard admin page (not a page provided by the module but a page
+ // Case standard admin page (not a page provided by the
+ // module but a page provided by dolibarr)
$urltouse = DOL_URL_ROOT.'/admin/'.$urlpage;
$linktoenabledisable .= ' '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'';
}
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index e93b8686d79..93bbc8a6612 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -61,8 +61,11 @@ $scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
$arrayofparameters = array(
- 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
- 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
+ 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
+ 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
+ //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
+ //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
+ //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
);
$error = 0;
@@ -208,11 +211,57 @@ if ($action == 'edit') {
print ' ';
print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ';
- foreach ($arrayofparameters as $key => $val) {
- print '| ';
- $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
- print $form->textwithpicto($langs->trans($key), $tooltiphelp);
- print ' | | ';
+ foreach ($arrayofparameters as $constname => $val) {
+ if ($val['enabled']==1) {
+ $setupnotempty++;
+ print '| ';
+ $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+ print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'';
+ print ' | ';
+
+ if ($val['type'] == 'textarea') {
+ print '\n";
+ } elseif ($val['type']== 'html') {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+ $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor->Create();
+ } elseif ($val['type'] == 'yesno') {
+ print $form->selectyesno($constname, $conf->global->{$constname}, 1);
+ } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $tmp = explode(':', $val['type']);
+ $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
+ //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
+ $arrayofmessagename = array();
+ if (is_array($formmail->lines_model)) {
+ foreach ($formmail->lines_model as $modelmail) {
+ //var_dump($modelmail);
+ $moreonlabel = '';
+ if (!empty($arrayofmessagename[$modelmail->label])) {
+ $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ')';
+ }
+ // The 'label' is the key that is unique if we exclude the language
+ $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
+ }
+ }
+ print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+ } elseif (preg_match('/category:/', $val['type'])) {
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+ $formother = new FormOther($db);
+
+ $tmp = explode(':', $val['type']);
+ print img_picto('', 'category', 'class="pictofixedwidth"');
+ print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
+ } else {
+ print '';
+ }
+ print ' | ';
+ }
}
print ' ';
@@ -227,13 +276,48 @@ if ($action == 'edit') {
print ' ';
print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ';
- foreach ($arrayofparameters as $key => $val) {
- $setupnotempty++;
+ foreach ($arrayofparameters as $constname => $val) {
+ if ($val['enabled']==1) {
+ $setupnotempty++;
+ print '| ';
+ $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+ print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
+ print ' | ';
- print ' | | ';
- $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
- print $form->textwithpicto($langs->trans($key), $tooltiphelp);
- print ' | '.$conf->global->$key.' | ';
+ if ($val['type'] == 'textarea') {
+ print dol_nl2br($conf->global->{$constname});
+ } elseif ($val['type']== 'html') {
+ print $conf->global->{$constname};
+ } elseif ($val['type'] == 'yesno') {
+ print ajax_constantonoff($constname);
+ } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $tmp = explode(':', $val['type']);
+
+ $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+ if ($template<0) {
+ setEventMessages(null, $formmail->errors, 'errors');
+ }
+ print $langs->trans($template->label);
+ } elseif (preg_match('/category:/', $val['type'])) {
+ $c = new Categorie($db);
+ $result = $c->fetch($conf->global->{$constname});
+ if ($result < 0) {
+ setEventMessages(null, $c->errors, 'errors');
+ }
+ $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
+ $toprint = array();
+ foreach ($ways as $way) {
+ $toprint[] = 'color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '';
+ }
+ print '' . implode(' ', $toprint) . ' ';
+ } else {
+ print $conf->global->{$constname};
+ }
+ print '';
+ }
}
print ' ';
diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php
index 6ab8a99ac76..d67a72d2d63 100644
--- a/htdocs/product/stock/movement_list.php
+++ b/htdocs/product/stock/movement_list.php
@@ -66,8 +66,14 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$result = restrictedArea($user, 'stock');
$idproduct = GETPOST('idproduct', 'int');
-$year = GETPOST("year");
-$month = GETPOST("month");
+$search_date_startday = GETPOST('search_date_startday', 'int');
+$search_date_startmonth = GETPOST('search_date_startmonth', 'int');
+$search_date_startyear = GETPOST('search_date_startyear', 'int');
+$search_date_endday = GETPOST('search_date_endday', 'int');
+$search_date_endmonth = GETPOST('search_date_endmonth', 'int');
+$search_date_endyear = GETPOST('search_date_endyear', 'int');
+$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'), 'tzuserrel');
+$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'), 'tzuserrel');
$search_ref = GETPOST('search_ref', 'alpha');
$search_movement = GETPOST("search_movement");
$search_product_ref = trim(GETPOST("search_product_ref"));
@@ -105,7 +111,7 @@ $arrayfields = array(
'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'),
- 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1),
+ 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>0),
'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))),
'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))),
'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))),
@@ -113,7 +119,7 @@ $arrayfields = array(
'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0),
'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1),
'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1),
- 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1),
+ 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>0),
'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1),
'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1),
'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0),
@@ -162,8 +168,14 @@ if (empty($reshook))
// Do we click on purge search criteria ?
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{
- $year = '';
- $month = '';
+ $search_date_startday = '';
+ $search_date_startmonth = '';
+ $search_date_startyear = '';
+ $search_date_endday = '';
+ $search_date_endmonth = '';
+ $search_date_endyear = '';
+ $search_date_start = '';
+ $search_date_end = '';
$search_ref = '';
$search_movement = "";
$search_type_mouvement = "";
@@ -461,7 +473,7 @@ $sql .= " m.batch, m.price,";
$sql .= " m.type_mouvement,";
$sql .= " m.fk_projet as fk_project,";
$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
-$sql .= " u.login, u.photo, u.lastname, u.firstname";
+$sql .= " u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status";
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
@@ -482,17 +494,18 @@ $sql .= " AND m.fk_entrepot = e.rowid";
$sql .= " AND e.entity IN (".getEntity('stock').")";
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
if ($id > 0) $sql .= " AND e.rowid ='".$id."'";
-$sql .= dolSqlDateFilter('m.datem', 0, $month, $year);
+if (!empty($search_date_start)) $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'";
+if (!empty($search_date_end)) $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'";
if ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct);
if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1);
-if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement);
-if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
-if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref);
-if (!empty($search_product)) $sql .= natural_search('p.label', $search_product);
+if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement);
+if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
+if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref);
+if (!empty($search_product)) $sql .= natural_search('p.label', $search_product);
if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2);
-if (!empty($search_user)) $sql .= natural_search('u.login', $search_user);
-if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch);
-if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id);
+if (!empty($search_user)) $sql .= natural_search('u.login', $search_user);
+if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch);
+if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id);
if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1);
if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
// Add where from extra fields
@@ -711,6 +724,12 @@ if ($resql)
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($id > 0) $param .= '&id='.urlencode($id);
+ if ($search_date_startday) $param .= '&search_date_startday='.urlencode($search_date_startday);
+ if ($search_date_startmonth) $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
+ if ($search_date_startyear) $param .= '&search_date_startyear='.urlencode($search_date_startyear);
+ if ($search_date_endday) $param .= '&search_date_endday='.urlencode($search_date_endday);
+ if ($search_date_endmonth) $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
+ if ($search_date_endyear) $param .= '&search_date_endyear='.urlencode($search_date_endyear);
if ($search_movement) $param .= '&search_movement='.urlencode($search_movement);
if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode);
if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
@@ -789,16 +808,15 @@ if ($resql)
print ' ';
print ' | ';
}
- if (!empty($arrayfields['m.datem']['checked']))
+ if (! empty($arrayfields['m.datem']['checked']))
{
- // Date
- print '
';
- print '';
- if (empty($conf->productbatch->enabled)) print ' ';
- //else print ' ';
- $syear = $year ? $year : -1;
- print '';
- //print $formother->selectyear($syear,'year',1, 20, 5);
+ print ' | ';
+ print ' ';
+ print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel');
+ print ' ';
+ print '';
+ print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel');
+ print ' ';
print ' | ';
}
if (!empty($arrayfields['p.ref']['checked']))
@@ -1013,6 +1031,8 @@ if ($resql)
$userstatic->lastname = $objp->lastname;
$userstatic->firstname = $objp->firstname;
$userstatic->photo = $objp->photo;
+ $userstatic->email = $objp->user_email;
+ $userstatic->statut = $objp->user_status;
$productstatic->id = $objp->rowid;
$productstatic->ref = $objp->product_ref;
@@ -1063,11 +1083,7 @@ if ($resql)
if (!empty($arrayfields['p.label']['checked']))
{
// Product label
- print '
';
- /*$productstatic->id=$objp->rowid;
- $productstatic->ref=$objp->produit;
- $productstatic->type=$objp->type;
- print $productstatic->getNomUrl(1,'',16);*/
+ print ' | ';
print $productstatic->label;
print " | \n";
}
@@ -1089,7 +1105,7 @@ if ($resql)
// Warehouse
if (!empty($arrayfields['e.ref']['checked']))
{
- print '
';
+ print ' | ';
print $warehousestatic->getNomUrl(1);
print " | \n";
}
diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php
index 91159984a35..f115bafbdf4 100644
--- a/htdocs/product/stock/stockatdate.php
+++ b/htdocs/product/stock/stockatdate.php
@@ -243,9 +243,12 @@ $title = $langs->trans('StockAtDate');
$sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,';
$sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
-$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock';
+$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock, ';
if ($fk_warehouse > 0) {
+ $sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue";
$sql .= ', SUM(ps.reel) as stock_reel';
+} else {
+ $sql .= " SUM(p.pmp * p.stock) as estimatedvalue, SUM(p.price * p.stock) as sellvalue";
}
// Add fields from hooks
$parameters = array();
@@ -271,6 +274,9 @@ if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"';
if ($fk_warehouse > 0) {
$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
$sql .= ' p.tms, p.duration, p.tobuy, p.stock';
+} else {
+ $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
+ $sql .= ' p.tms, p.duration, p.tobuy, p.stock';
}
// Add where from hooks
$parameters = array();
@@ -403,6 +409,9 @@ print '
| ';
print '
| ';
if ($mode == 'future') {
print '
| ';
+} else {
+ print '
| ';
+ print '
| ';
}
// Fields from hook
$parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
@@ -424,6 +433,7 @@ if ($fk_warehouse > 0) {
print '
';
print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'p.ref', $param, '', '', $sortfield, $sortorder);
print_liste_field_titre('Label', $_SERVER["PHP_SELF"], 'p.label', $param, '', '', $sortfield, $sortorder);
+
if ($mode == 'future') {
print_liste_field_titre('CurrentStock', $_SERVER["PHP_SELF"], $fieldtosortcurrentstock, $param, '', '', $sortfield, $sortorder, 'right ');
print_liste_field_titre('', $_SERVER["PHP_SELF"]);
@@ -431,6 +441,8 @@ if ($mode == 'future') {
print_liste_field_titre('VirtualStock', $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc');
} else {
print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ', $langs->trans("AtDate"), 1);
+ print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', $langs->trans("AtDate"), 1);
print_liste_field_titre('', $_SERVER["PHP_SELF"]);
print_liste_field_titre('CurrentStock', $_SERVER["PHP_SELF"], $fieldtosortcurrentstock, $param, '', '', $sortfield, $sortorder, 'right ');
}
@@ -531,6 +543,21 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Stock at date
print '| '.($stock ? $stock : ''.$stock.'').' | ';
+ // PMP value
+ print '';
+ if (price2num($objp->estimatedvalue, 'MT')) print price(price2num($objp->estimatedvalue, 'MT'), 1);
+ else print '';
+ print ' | ';
+
+ // Selling value
+ print '';
+ if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue, 'MT'), 1);
+ else {
+ $htmltext = $langs->trans("OptionMULTIPRICESIsOn");
+ print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
+ }
+ print' | ';
+
print '';
if ($nbofmovement > 0) {
print ''.$langs->trans("Movements").'';
@@ -560,7 +587,7 @@ $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // N
print $hookmanager->resPrint;
if (empty($date) || ! $dateIsValid) {
- $colspan = 6;
+ $colspan = 8;
if ($mode == 'future') $colspan++;
print ' |
| '.$langs->trans("EnterADateCriteria").' |
';
}