diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index a7bd3acbbb8..d4f6b1caca4 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1629,7 +1629,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Template to use by default
- print '
' . $langs->trans('Model') . '
';
+ print '
' . $langs->trans('DefaultModel') . '
';
print '
';
include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db);
diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php
index e38097e4e3a..81488bdb1d6 100644
--- a/htdocs/commande/class/commandestats.class.php
+++ b/htdocs/commande/class/commandestats.class.php
@@ -81,7 +81,8 @@ class CommandeStats extends Stats
$this->where.= " c.fk_statut > 2"; // Only approved & ordered
}
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
- $this->where.= " AND c.entity = ".$conf->entity;
+ $this->where.= ' AND c.entity IN ('.getEntity('commande', 1).')';
+
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 52a32e00067..e3fda63ef94 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -2051,7 +2051,7 @@ class Contrat extends CommonObject
$sql = "SELECT count(c.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
- if (!$user->rights->contrat->activer && !$user->societe_id)
+ if (!$user->rights->contrat->lire && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index de42ced0997..e9a7607d011 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4470,10 +4470,10 @@ abstract class CommonObject
switch($mode) {
case "view":
- $out .= $extrafields->showOutputField($key,$value);
+ $out .= $extrafields->showOutputField($key, $value);
break;
case "edit":
- $out .= $extrafields->showInputField($key,$value,'',$keyprefix,'',0,$this->id);
+ $out .= $extrafields->showInputField($key, $value, '', $keyprefix, '', 0, $this->id);
break;
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index ca7f0c24958..b18738bde9f 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -660,7 +660,7 @@ class ExtraFields
* Return HTML string to put an input field into a page
*
* @param string $key Key of attribute
- * @param string $value Value to show (for date type it must be in timestamp format)
+ * @param string $value Preselected value to show (for date type it must be in timestamp format)
* @param string $moreparam To add more parametes on html input tag
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
@@ -668,7 +668,7 @@ class ExtraFields
* @param int $objectid Current object id
* @return string
*/
- function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$showsize=0, $objectid=0)
+ function showInputField($key, $value, $moreparam='', $keyprefix='', $keysuffix='', $showsize=0, $objectid=0)
{
global $conf,$langs;
@@ -1163,10 +1163,17 @@ class ExtraFields
dol_include_once($InfoFieldList[1]);
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
{
- $object = new $InfoFieldList[0]($this->db);
- if (!empty($value)) $object->fetch($value);
- $valuetoshow=$object->ref;
- if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ref is id because name is not unique
+ $valuetoshow=$value;
+ if (!empty($value))
+ {
+ $object = new $InfoFieldList[0]($this->db);
+ $resfetch=$object->fetch($value);
+ if ($resfetch > 0)
+ {
+ $valuetoshow=$object->ref;
+ if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
+ }
+ }
$out.='';
}
else
diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php
index 1a608f6bc2e..332a7d0547e 100644
--- a/htdocs/core/extrafieldsinexport.inc.php
+++ b/htdocs/core/extrafieldsinexport.inc.php
@@ -8,7 +8,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra))
}
// Add extra fields
-$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND entity IN (0, ".$conf->entity.')';
+$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.')';
//print $sql;
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php
index 033a8690071..3081cc8c726 100644
--- a/htdocs/core/modules/modAdherent.class.php
+++ b/htdocs/core/modules/modAdherent.class.php
@@ -285,19 +285,11 @@ class modAdherent extends DolibarrModules
$this->export_label[$r]='MembersAndSubscriptions';
$this->export_permission[$r]=array(array("adherent","export"));
$this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount');
- $this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.subscription'=>'Numeric');
+ $this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric');
$this->export_entities_array[$r]=array('a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription');
-
- // Add extra fields
- $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity = ".$conf->entity;
- $resql=$this->db->query($sql);
- while ($obj=$this->db->fetch_object($resql))
- {
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_entities_array[$r][$fieldname]='member';
- }
+ // Add extra fields
+ $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';
diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php
index 30404a02699..3edb3fa4fdc 100644
--- a/htdocs/core/modules/modProjet.class.php
+++ b/htdocs/core/modules/modProjet.class.php
@@ -215,101 +215,32 @@ class modProjet extends DolibarrModules
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("projet","export"));
- $this->export_dependencies_array[$r]=array('task_time'=>'ptt.rowid');
+ $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
- 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text",
- 'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
- 'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
+ 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.description'=>"Text",
+ 'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
+ 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
- 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.description'=>"project");
+ 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'cls.code'=>"project",'p.opp_percent'=>'project','p.description'=>"project");
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
- 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'Status','p.description'=>"Description");
+ 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.description'=>"Description");
// Add fields for project
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
- // Add extra fields
- $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet'";
- $resql=$this->db->query($sql);
- if ($resql) // This can fail when class is used on old database (during migration for example)
- {
- while ($obj=$this->db->fetch_object($resql))
- {
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
- {
- case 'int':
- case 'double':
- case 'price':
- $typeFilter="Numeric";
- break;
- case 'date':
- case 'datetime':
- $typeFilter="Date";
- break;
- case 'boolean':
- $typeFilter="Boolean";
- break;
- case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
- break;
- }
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='project';
- }
- }
- // End add extra fields
-
+ $keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// Add fields for tasks
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
// Add extra fields
- $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task'";
- $resql=$this->db->query($sql);
- if ($resql) // This can fail when class is used on old database (during migration for example)
- {
- while ($obj=$this->db->fetch_object($resql))
- {
- $fieldname='extra2.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
- {
- case 'int':
- case 'double':
- case 'price':
- $typeFilter="Numeric";
- break;
- case 'date':
- case 'datetime':
- $typeFilter="Date";
- break;
- case 'boolean':
- $typeFilter="Boolean";
- break;
- case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
- break;
- }
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='projecttask';
- }
- }
+ $keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// End add extra fields
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
@@ -317,7 +248,8 @@ class modProjet extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'projet as p';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
+ $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
+ $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index edb0d42321c..f9320caddea 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -767,7 +767,7 @@ if ($action == 'create')
$liste = ModelePdfExpedition::liste_modeles($db);
if (count($liste) > 1)
{
- print "
';
$object = new ExpenseReport($db);
$include_users = $object->fetch_users_approver_expensereport();
- $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users
- if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR;
- if (GETPOST('fk_user_validator') > 0) $defaultselectuser=GETPOST('fk_user_validator');
- $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users);
- print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
+ if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport");
+ else
+ {
+ $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users
+ if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver
+ if (GETPOST('fk_user_validator') > 0) $defaultselectuser=GETPOST('fk_user_validator');
+ $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users);
+ print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
+ }
print '
';
print '';
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index feb61c130e7..0e2fe371fd8 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -1519,7 +1519,8 @@ class ExpenseReport extends CommonObject
/**
- * Return list of people with permission to validate trips and expenses
+ * Return list of people with permission to validate expense reports.
+ * Search for permission "approve expense report"
*
* @return array Array of user ids
*/
@@ -1527,10 +1528,15 @@ class ExpenseReport extends CommonObject
{
$users_validator=array();
- $sql = "SELECT fk_user";
+ $sql = "SELECT DISTINCT ur.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd";
- $sql.= " WHERE ur.fk_id = rd.id and module = 'expensereport' AND perms = 'approve'"; // Permission 'Approve';
-
+ $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve';
+ $sql.= "UNION";
+ $sql.= " SELECT DISTINCT ugu.fk_user";
+ $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd";
+ $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve';
+ //print $sql;
+
dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql);
$result = $this->db->query($sql);
if($result)
diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php
index 57c970b9fc8..25ead4de0c1 100644
--- a/htdocs/expensereport/class/expensereportstats.class.php
+++ b/htdocs/expensereport/class/expensereportstats.class.php
@@ -56,14 +56,17 @@ class ExpenseReportStats extends Stats
$this->userid = $userid;
$object=new ExpenseReport($this->db);
- $this->from = MAIN_DB_PREFIX.$object->table_element;
+ $this->from = MAIN_DB_PREFIX.$object->table_element." as e";
$this->field='total_ht';
- $this->where = " fk_statut > 0 and date_valid > '2000-01-01'";
+ $this->where = " e.fk_statut > 0";
+ //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have.
+ $this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')';
+
//$this->where.= " AND entity = ".$conf->entity;
if ($this->socid)
{
- $this->where.=" AND fk_soc = ".$this->socid;
+ $this->where.=" AND e.fk_soc = ".$this->socid;
}
// Only me and subordinates
@@ -71,10 +74,10 @@ class ExpenseReportStats extends Stats
{
$childids = $user->getAllChildIds();
$childids[]=$user->id;
- $this->where.=" AND fk_user_author IN (".(join(',',$childids)).")";
+ $this->where.=" AND e.fk_user_author IN (".(join(',',$childids)).")";
}
- if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid;
+ if ($this->userid > 0) $this->where.=' AND e.fk_user_author = '.$this->userid;
}
@@ -102,9 +105,9 @@ class ExpenseReportStats extends Stats
*/
function getNbByMonth($year)
{
- $sql = "SELECT MONTH(date_valid) as dm, count(*)";
+ $sql = "SELECT MONTH(e.date_valid) as dm, count(*)";
$sql.= " FROM ".$this->from;
- $sql.= " WHERE YEAR(date_valid) = ".$year;
+ $sql.= " WHERE YEAR(e.date_valid) = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
@@ -123,9 +126,9 @@ class ExpenseReportStats extends Stats
*/
function getAmountByMonth($year)
{
- $sql = "SELECT date_format(date_valid,'%m') as dm, sum(".$this->field.")";
+ $sql = "SELECT date_format(e.date_valid,'%m') as dm, sum(".$this->field.")";
$sql.= " FROM ".$this->from;
- $sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'";
+ $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'";
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
@@ -143,9 +146,9 @@ class ExpenseReportStats extends Stats
*/
function getAverageByMonth($year)
{
- $sql = "SELECT date_format(date_valid,'%m') as dm, avg(".$this->field.")";
+ $sql = "SELECT date_format(e.date_valid,'%m') as dm, avg(".$this->field.")";
$sql.= " FROM ".$this->from;
- $sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'";
+ $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'";
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC');
@@ -160,7 +163,7 @@ class ExpenseReportStats extends Stats
*/
function getAllByYear()
{
- $sql = "SELECT date_format(date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+ $sql = "SELECT date_format(e.date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
$sql.= " FROM ".$this->from;
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year";
diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php
index 48c34acd128..dfea6d4d17a 100644
--- a/htdocs/exports/class/export.class.php
+++ b/htdocs/exports/class/export.class.php
@@ -377,6 +377,9 @@ class Export
case 'Duree':
case 'Numeric':
case 'Number':
+ // Must be a string text to allow to use comparison strings like "<= 999"
+ $szFilterField='';
+ break;
case 'Status':
if (! empty($conf->global->MAIN_ACTIVATE_HTML5)) $szFilterField='';
else $szFilterField='';
diff --git a/htdocs/index.php b/htdocs/index.php
index a723ddb5157..f4be0dc9c63 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -173,7 +173,7 @@ if (empty($user->societe_id))
! empty($conf->propal->enabled) && $user->rights->propale->lire,
! empty($conf->commande->enabled) && $user->rights->commande->lire,
! empty($conf->facture->enabled) && $user->rights->facture->lire,
- ! empty($conf->contrat->enabled) && $user->rights->contrat->activer,
+ ! empty($conf->contrat->enabled) && $user->rights->contrat->lire,
! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire,
! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS),
! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS),
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index c2872ecc8f1..ed5ab21bd6c 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -205,8 +205,8 @@ Info=Log
Family=Family
Description=Description
Designation=Description
-Model=Model
-DefaultModel=Default model
+Model=Doc template
+DefaultModel=Default doc template
Action=Event
About=About
Number=Number
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index d803b55c875..4dab8237c16 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -62,8 +62,10 @@ $month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("mo
$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
$day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
-$search_project_ref = GETPOST('search_project_ref', 'alpha');
-
+$search_task_ref=GETPOST('search_task_ref', 'alpha');
+$search_task_label=GETPOST('search_task_label', 'alpha');
+$search_project_ref=GETPOST('search_project_ref', 'alpha');
+$search_thirdparty=GETPOST('search_thirdparty', 'alpha');
$monthofday=GETPOST('addtimemonth');
$dayofday=GETPOST('addtimeday');
@@ -84,7 +86,10 @@ $object=new Task($db);
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$action = '';
+ $search_task_ref = '';
+ $search_task_label = '';
$search_project_ref = '';
+ $search_thirdparty = '';
}
if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search"))
{
@@ -293,6 +298,9 @@ if ($id)
$onlyopenedproject=1; // or -1
$morewherefilter='';
+if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref);
+if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label);
+if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty);
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
@@ -416,10 +424,11 @@ print '
';
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index 09f1604e931..6d20078a785 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -927,7 +927,7 @@ elseif ($object->id > 0)
/* Change percent of default percent of new status is higher */
if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent))
{
- if (jQuery("#opp_percent").val() != \'\' && ! jQuery("#oldopppercent").text()) jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->trans("PreviousValue")).': \'+jQuery("#opp_percent").val()+\' %\');
+ if (jQuery("#opp_percent").val() != \'\' && ! jQuery("#oldopppercent").text()) jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+jQuery("#opp_percent").val()+\' %\');
jQuery("#opp_percent").val(defaultpercent);
}
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 27099ef4d91..15e3b154b20 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -623,7 +623,7 @@ class Task extends CommonObject
* @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
* @param string $filteronprojref Filter on project ref
* @param string $filteronprojstatus Filter on project status
- * @param string $morewherefilter Add more filter into where SQL request
+ * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...')
* @param string $filteronprojuser Filter on user that is a contact of project
* @param string $filterontaskuser Filter on user assigned to task
* @return array Array of tasks