diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 8e9c6f2a321..c5184a18454 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -86,6 +86,7 @@ $hookmanager->initHooks(array('contactcard', 'globalcard'));
if ($id > 0) {
$object->fetch($id);
+ $object->info($id);
}
if (!($object->id > 0) && $action == 'view') {
@@ -101,6 +102,9 @@ $permissiontoadd = $user->rights->societe->contact->creer;
if ($user->socid) {
$socid = $user->socid;
}
+if ($object->priv && $object->user_creation->id != $user->id) {
+ accessforbidden();
+}
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 037dda8d135..c720e05797a 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -1123,6 +1123,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
$sql .= " WHERE t.fk_soc = ".((int) $object->id);
+ $sql .= " AND ((t.fk_user_creat = ".((int) $user->id)." AND t.priv = 1) OR t.priv = 0)";
if ($search_rowid) {
$sql .= natural_search('t.rowid', $search_rowid);
}
diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php
index b243b8c8342..36c5b2ea07d 100644
--- a/htdocs/opensurvey/card.php
+++ b/htdocs/opensurvey/card.php
@@ -209,7 +209,7 @@ $toutsujet = explode(",", $object->sujet);
$listofanswers = array();
foreach ($toutsujet as $value) {
$tmp = explode('@', $value);
- $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox'));
+ $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox'));
}
$toutsujet = str_replace("@", "
", $toutsujet);
$toutsujet = str_replace("°", "'", $toutsujet);
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index b7fadbdb60d..8848af12629 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -274,7 +274,7 @@ class Opensurveysondage extends CommonObject
$this->sujet = $obj->sujet;
$this->fk_user_creat = $obj->fk_user_creat;
- $this->date_m = $this->db->jdate($obj->tls);
+ $this->date_m = $this->db->jdate(!empty($obj->tls) ? $obj->tls : "");
$ret = 1;
} else {
$sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey);
@@ -686,7 +686,7 @@ class Opensurveysondage extends CommonObject
{
$result = 0;
- $sql .= " SELECT COUNT(id_users) as nb FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
+ $sql = " SELECT COUNT(id_users) as nb FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
$sql .= " WHERE id_sondage = '".$this->db->escape($this->ref)."'";
$resql = $this->db->query($sql);
diff --git a/htdocs/opensurvey/exportcsv.php b/htdocs/opensurvey/exportcsv.php
index a7e8b709793..1e9005b6af4 100644
--- a/htdocs/opensurvey/exportcsv.php
+++ b/htdocs/opensurvey/exportcsv.php
@@ -63,9 +63,9 @@ $now = dol_now();
$nbcolonnes = substr_count($object->sujet, ',') + 1;
$toutsujet = explode(",", $object->sujet);
-
+$somme = array();
// affichage des sujets du sondage
-$input .= $langs->trans("Name").";";
+$input = $langs->trans("Name").";";
for ($i = 0; $toutsujet[$i]; $i++) {
if ($object->format == "D") {
$input .= ''.dol_print_date($toutsujet[$i], 'dayhour').';';
@@ -105,6 +105,9 @@ if ($resql) {
//affichage des resultats
$ensemblereponses = $obj->reponses;
for ($k = 0; $k < $nbcolonnes; $k++) {
+ if (empty($somme[$k])) {
+ $somme[$k] = 0;
+ }
$car = substr($ensemblereponses, $k, 1);
if ($car == "1") {
$input .= 'OK;';
diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php
index e03ee278574..626499e2412 100644
--- a/htdocs/opensurvey/list.php
+++ b/htdocs/opensurvey/list.php
@@ -40,6 +40,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'opensurveylist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
+$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$id = GETPOST('id', 'alpha');
$search_ref = GETPOST('search_ref', 'alpha');
@@ -175,16 +176,16 @@ $sql .= " WHERE p.entity IN (".getEntity('survey').")";
if ($search_status != '-1' && $search_status != '') {
$sql .= natural_search("p.status", $search_status, 2);
}
-if ($search_expired == 'expired') {
+if (!empty($search_expired) && $search_expired == 'expired') {
$sql .= " AND p.date_fin < '".$db->idate($now)."'";
}
-if ($search_expired == 'opened') {
+if (!empty($search_expired) && $search_expired == 'opened') {
$sql .= " AND p.date_fin >= '".$db->idate($now)."'";
}
-if ($search_ref) {
+if (!empty($search_ref)) {
$sql .= natural_search("p.id_sondage", $search_ref);
}
-if ($search_title) {
+if (!empty($search_title)) {
$sql .= natural_search("p.titre", $search_title);
}
// Add where from extra fields
diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php
index f8a2648a809..bedec1eb1aa 100644
--- a/htdocs/opensurvey/results.php
+++ b/htdocs/opensurvey/results.php
@@ -435,7 +435,7 @@ $toutsujet = explode(",", $object->sujet);
$listofanswers = array();
foreach ($toutsujet as $value) {
$tmp = explode('@', $value);
- $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox'));
+ $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox'));
}
$toutsujet = str_replace("@", "
", $toutsujet);
$toutsujet = str_replace("°", "'", $toutsujet);
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 2e9f37f80b4..fce9813987c 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -68,6 +68,14 @@ $search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int');
$search_datehour = '';
$search_datewithhour = '';
+$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, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
+$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
$search_note = GETPOST('search_note', 'alpha');
$search_duration = GETPOST('search_duration', 'int');
$search_value = GETPOST('search_value', 'int');
@@ -77,6 +85,9 @@ $search_user = GETPOST('search_user', 'int');
$search_valuebilled = GETPOST('search_valuebilled', 'int');
$search_product_ref = GETPOST('search_product_ref', 'alpha');
$search_company = GETPOST('$search_company', 'alpha');
+$search_company_alias = GETPOST('$search_company_alias', 'alpha');
+$search_project_ref = GETPOST('$search_project_ref', 'alpha');
+$search_project_label = GETPOST('$search_project_label', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@@ -166,8 +177,19 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_value = '';
$search_date_creation = '';
$search_date_update = '';
+ $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_task_ref = '';
$search_company = '';
+ $search_company_alias = '';
+ $search_project_ref = '';
+ $search_project_label = '';
$search_task_label = '';
$search_user = 0;
$search_valuebilled = '';
@@ -1220,7 +1242,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$arrayfields = array();
$arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1);
$arrayfields['p.fk_soc'] = array('label'=>$langs->trans("ThirdParty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1);
+ $arrayfields['s.name_alias'] = array('label'=>$langs->trans("AliasNameShort"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1');
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
+ if (! empty($allprojectforuser)) {
+ $arrayfields['p.project_ref'] = ['label' => $langs->trans('RefProject'), 'checked' => 1];
+ $arrayfields['p.project_label'] = ['label' => $langs->trans('ProjectLabel'), 'checked' => 1];
+ }
$arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1);
$arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1);
}
@@ -1259,6 +1286,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_company != '') {
$param .= '&$search_company='.urlencode($search_company);
}
+ if ($search_company_alias != '') {
+ $param .= '&$search_company_alias='.urlencode($search_company_alias);
+ }
+ if ($search_project_ref != '') {
+ $param .= '&$search_project_ref='.urlencode($search_project_ref);
+ }
+ if ($search_project_label != '') {
+ $param .= '&$search_project_label='.urlencode($search_project_label);
+ }
if ($search_task_label != '') {
$param .= '&search_task_label='.urlencode($search_task_label);
}
@@ -1271,6 +1307,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
+ 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);
+ }
+
/*
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -1460,7 +1515,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= " pt.ref, pt.label, pt.fk_projet,";
$sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
$sql .= " il.fk_facture as invoice_id, inv.fk_statut,";
- $sql .= " p.fk_soc,";
+ $sql .= " p.fk_soc,s.name_alias,";
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
@@ -1503,6 +1558,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_company) {
$sql .= natural_search('s.nom', $search_company);
}
+ if ($search_company_alias) {
+ $sql .= natural_search('s.name_alias', $search_company_alias);
+ }
+ if ($search_project_ref) {
+ $sql .= natural_search('p.ref', $search_project_ref);
+ }
+ if ($search_project_label) {
+ $sql .= natural_search('p.title', $search_project_label);
+ }
if ($search_task_label) {
$sql .= natural_search('pt.label', $search_task_label);
}
@@ -1519,6 +1583,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)';
}
+ if ($search_date_start) {
+ $sql .= " AND t.task_date >= '".$db->idate($search_date_start)."'";
+ }
+ if ($search_date_end) {
+ $sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'";
+ }
+
$sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year);
// Add where from hooks
@@ -1741,12 +1812,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '