diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 1997423d3a8..607f8e14c4e 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -287,17 +287,18 @@ if ($action == 'add')
{
unset($_SESSION['assignedtouser']);
- if ($user->id != $object->ownerid) $moreparam="&usertodo=-1"; // We force to remove filter so created record is visible when going back to per user view.
+ $moreparam='';
+ if ($user->id != $object->ownerid) $moreparam="usertodo=-1"; // We force to remove filter so created record is visible when going back to per user view.
$db->commit();
if (! empty($backtopage))
{
- dol_syslog("Back to ".$backtopage.$moreparam);
- header("Location: ".$backtopage.$moreparam);
+ dol_syslog("Back to ".$backtopage.($moreparam?(preg_match('/\?/',$backtopage)?'&'.$moreparam:'?'.$moreparam):''));
+ header("Location: ".$backtopage.($moreparam?(preg_match('/\?/',$backtopage)?'&'.$moreparam:'?'.$moreparam):''));
}
elseif($idaction)
{
- header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.$moreparam);
+ header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam?'&'.$moreparam:''));
}
else
{
@@ -379,8 +380,6 @@ if ($action == 'update')
// Users
$listofuserid=array();
- $assignedtouser=(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
- if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first
if (! empty($_SESSION['assignedtouser'])) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
@@ -390,11 +389,18 @@ if ($action == 'update')
if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val;
}
}
+ else {
+ $assignedtouser=(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
+ if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first
+ }
- $object->userassigned=array(); // Clear old content
+ $object->userassigned=array(); $object->userownerid=0; // Clear old content
+ $i=0;
foreach($listofuserid as $key => $val)
{
+ if ($i == 0) $object->userownerid = $val['id'];
$object->userassigned[$val['id']]=array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>($user->id == $val['id'] ? $transparency : ''));
+ $i++;
}
if (! empty($conf->global->AGENDA_ENABLE_DONEBY))
@@ -1070,7 +1076,7 @@ if ($id > 0)
$listofuserid=array();
if (empty($donotclearsession))
{
- if (is_object($object->userownerid)) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first
+ if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first
if (! empty($object->userassigned)) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 43bc2be4272..df0a359dd56 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -543,9 +543,9 @@ class ActionComm extends CommonObject
$sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null');
$sql.= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null"); // deprecated
$sql.= ", note = ".($this->note ? "'".$this->db->escape($this->note)."'":"null");
- $sql.= ", fk_soc =". ($this->socid > 0 ? "'".$this->socid."'":"null");
$sql.= ", fk_project =". ($this->fk_project > 0 ? "'".$this->fk_project."'":"null");
- $sql.= ", fk_contact =". ($contactid > 0 ? "'".$this->contactid."'":"null");
+ $sql.= ", fk_soc =". ($socid > 0 ? "'".$socid."'":"null");
+ $sql.= ", fk_contact =". ($contactid > 0 ? "'".$contactid."'":"null");
$sql.= ", priority = '".$this->priority."'";
$sql.= ", fulldayevent = '".$this->fulldayevent."'";
$sql.= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'":"null");
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index e540e164d96..2db6936e1d3 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -219,10 +219,10 @@ if (empty($action) || $action=='show_month')
$max_day_in_prev_month = date("t",dol_mktime(0,0,0,$prev_month,1,$prev_year)); // Nb of days in previous month
$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); // Nb of days in next month
- // tmpday is a negative or null cursor to know how many days before the 1 to show on month view (if tmpday=0 we start on monday)
- $tmpday = -date("w",dol_mktime(0,0,0,$month,1,$year))+2;
+ // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
+ $tmpday = -date("w",dol_mktime(12,0,0,$month,1,$year,true))+2; // date('w') is 0 fo sunday
$tmpday+=((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)-1);
- if ($tmpday >= 1) $tmpday -= 7;
+ if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow=dol_mktime(0,0,0,$prev_month,$max_day_in_prev_month+$tmpday,$prev_year);
$next_day=7 - ($max_day_in_month+1-$tmpday) % 7;
@@ -918,7 +918,7 @@ if (empty($action) || $action == 'show_month') // View by month
echo "
\n";
for ($iter_day = 0; $iter_day < 7; $iter_day++)
{
- /* Show days before the beginning of the current month (previous month) */
+ /* Show days before the beginning of the current month (previous month) */
if ($tmpday <= 0)
{
$style='cal_other_month cal_past';
@@ -931,21 +931,20 @@ if (empty($action) || $action == 'show_month') // View by month
elseif ($tmpday <= $max_day_in_month)
{
$curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
-
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_current_month_right';
$today=0;
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
if ($today) $style='cal_today';
if ($curtime < $todaytms) $style.=' cal_past';
-
+ //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style);
echo ' | ';
show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
echo " | \n";
}
/* Show days after the current month (next month) */
else
- {
+ {
$style='cal_other_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' ';
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 0e50e75451e..51ddb81c0b4 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -956,7 +956,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
//$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
$string1=' ';
- $style1='peruser_notbusy';
+ if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy';
+ else $style1='peruser_busy';
foreach($cases1[$h] as $id => $ev)
{
if ($ev['busy']) $style1='peruser_busy';
@@ -967,7 +968,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
//$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
$string2=' ';
- $style2='peruser_notbusy';
+ if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy';
+ else $style2='peruser_busy';
foreach($cases2[$h] as $id => $ev)
{
if ($ev['busy']) $style2='peruser_busy';
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index cd327d785c9..b344da39112 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1200,8 +1200,10 @@ else if ($action == 'down' && $user->rights->propal->creer) {
$action = 'edit_extras';
}
-if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) {
- if ($action == 'addcontact') {
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer)
+{
+ if ($action == 'addcontact')
+ {
if ($object->id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]);
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 9b727f15e5e..245f187d166 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1775,8 +1775,10 @@ else if ($action == 'print_file' and $user->rights->printipp->read) {
$action = '';
}
-if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) {
- if ($action == 'addcontact') {
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
+{
+ if ($action == 'addcontact')
+ {
$result = $object->fetch($id);
if ($result > 0 && $id > 0) {
@@ -3324,12 +3326,13 @@ if ($action == 'create')
// Other attributes (TODO Move this into an include)
$res = $object->fetch_optionals($object->id, $extralabels);
- $parameters = array('colspan' => ' colspan="2"');
+ $parameters = array('colspan' => ' colspan="5"', "cols" => 5);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook
- if (empty($reshook) && ! empty($extrafields->attribute_label)) {
-
- foreach ($extrafields->attribute_label as $key => $label) {
+ if (empty($reshook) && ! empty($extrafields->attribute_label))
+ {
+ foreach ($extrafields->attribute_label as $key => $label)
+ {
if ($action == 'edit_extras') {
$value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options ["options_" . $key]);
} else {
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index f65136ec81d..3da33709165 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -156,7 +156,7 @@ abstract class CommonObject
* Add a link between element $this->element and a contact
*
* @param int $fk_socpeople Id of contact to link
- * @param int $type_contact Type of contact (code or id)
+ * @param int $type_contact Type of contact (code or id). For example: SALESREPFOLL
* @param int $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user)
* @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
@@ -192,9 +192,10 @@ abstract class CommonObject
// On recherche id type_contact
$sql = "SELECT tc.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
- $sql.= " WHERE element='".$this->element."'";
- $sql.= " AND source='".$source."'";
- $sql.= " AND code='".$type_contact."' AND active=1";
+ $sql.= " WHERE tc.element='".$this->element."'";
+ $sql.= " AND tc.source='".$source."'";
+ $sql.= " AND tc.code='".$type_contact."' AND tc.active=1";
+ //print $sql;
$resql=$this->db->query($sql);
if ($resql)
{
@@ -337,12 +338,14 @@ abstract class CommonObject
/**
* Delete all links between an object $this and all its contacts
*
- * @return int >0 if OK, <0 if KO
+ * @param string $source '' or 'internal' or 'external'
+ * @param string $code Type of contact (code or id)
+ * @return int >0 if OK, <0 if KO
*/
- function delete_linked_contact()
+ function delete_linked_contact($source='',$code='')
{
$temp = array();
- $typeContact = $this->liste_type_contact('');
+ $typeContact = $this->liste_type_contact($source,'',0,0,$code);
foreach($typeContact as $key => $value)
{
@@ -351,7 +354,7 @@ abstract class CommonObject
$listId = implode(",", $temp);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
- $sql.= " WHERE element_id =".$this->id;
+ $sql.= " WHERE element_id = ".$this->id;
$sql.= " AND fk_c_type_contact IN (".$listId.")";
dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG);
@@ -360,7 +363,7 @@ abstract class CommonObject
return 1;
}
else
- {
+ {
$this->error=$this->db->lasterror();
return -1;
}
@@ -478,21 +481,23 @@ abstract class CommonObject
* @param string $source 'internal', 'external' or 'all'
* @param string $order Sort order by : 'code' or 'rowid'
* @param string $option 0=Return array id->label, 1=Return array code->label
- * @param string $activeonly 0=all type of contact, 1=only the active
+ * @param string $activeonly 0=all status of contact, 1=only the active
+ * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
*/
- function liste_type_contact($source='internal', $order='code', $option=0, $activeonly=0)
+ function liste_type_contact($source='internal', $order='', $option=0, $activeonly=0, $code='')
{
global $langs;
+ if (empty($order)) $order='code';
+
$tab = array();
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE tc.element='".$this->element."'";
- if ($activeonly == 1)
- $sql.= " AND tc.active=1"; // only the active type
-
- if (! empty($source)) $sql.= " AND tc.source='".$source."'";
+ if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active type
+ if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$source."'";
+ if (! empty($code)) $sql.= " AND tc.code='".$code."'";
$sql.= " ORDER by tc.".$order;
//print "sql=".$sql;
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 4bfe5d5a255..34a653b61ea 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -2365,9 +2365,9 @@ table.cal_month { border-spacing: 0px; }
.cal_past_month { opacity: 0.6; background: #EEEEEE; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
.cal_current_month { background: #FFFFFF; border-left: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
.cal_current_month_peruserleft { background: #FFFFFF; border-left: solid 3px #6C7C7B; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
-.cal_today { background: #FFFFF0; border-left: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
-.cal_today_peruser { background: #FFFFF0; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #A0A0A0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
-.cal_today_peruser_peruserleft { background: #FFFFF0; border-left: solid 3px #6C7C7B; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #A0A0A0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
+.cal_today { background: #FDFDF0; border-left: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
+.cal_today_peruser { background: #FDFDF0; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
+.cal_today_peruser_peruserleft { background: #FDFDF0; border-left: solid 3px #6C7C7B; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; }
.cal_past { }
.cal_peruser { padding: 0px; }
.peruser_busy { background: #CC8888; }
|