diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 2d6c4ecf551..822193260e2 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -45,7 +45,7 @@ $socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid'];
$id = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id;
// TODO: revoir les droits car pas clair
-//$result = restrictedArea($user, 'commercial', $id, 'actioncomm', 'actions', '', 'id');
+//$result = restrictedArea($user, 'agenda', $id, 'actioncomm', 'actions', '', 'id');
if (isset($_GET["error"])) $error=$_GET["error"];
@@ -273,22 +273,26 @@ if ($_POST["action"] == 'add_action')
/*
* Action suppression de l'action
- *
*/
-if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
+if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes')
{
$actioncomm = new ActionComm($db);
$actioncomm->fetch($_GET["id"]);
- $result=$actioncomm->delete();
- if ($result >= 0)
+ if ($user->rights->agenda->myactions->create
+ || $user->rights->agenda->allactions->create)
{
- Header("Location: index.php");
- exit;
- }
- else
- {
- $mesg=$actioncomm->error;
+ $result=$actioncomm->delete();
+
+ if ($result >= 0)
+ {
+ Header("Location: index.php");
+ exit;
+ }
+ else
+ {
+ $mesg=$actioncomm->error;
+ }
}
}
@@ -644,7 +648,7 @@ if ($_GET["id"])
// Confirmation suppression action
if ($_GET["action"] == 'delete')
{
- $ret=$html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAction"),$langs->trans("ConfirmDeleteAction"),"confirm_delete");
+ $ret=$html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAction"),$langs->trans("ConfirmDeleteAction"),"confirm_delete",'','',1);
if ($ret == 'html') print '
';
}
@@ -867,7 +871,7 @@ if ($_GET["id"])
print '
';
- if ($_GET["action"] != 'edit' && $_GET["action"] != 'delete')
+ if ($_GET["action"] != 'edit')
{
if ($user->rights->agenda->allactions->create)
{
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 30be0144452..c10c0ece27a 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -225,14 +225,30 @@ $sql.= ' AND a.fk_user_author = u.rowid';
$sql.= ' AND u.entity in (0,'.$conf->entity.')';
if ($_GET["action"] == 'show_day')
{
- $sql.= ' AND datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,$_GET["day"],$year));
- $sql.= ' AND '.$db->idate(dol_mktime(23,59,59,$month,$_GET["day"],$year));
+ $sql.= ' AND (';
+ $sql.= ' (datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,$_GET["day"],$year));
+ $sql.= ' AND '.$db->idate(dol_mktime(23,59,59,$month,$_GET["day"],$year)).')';
+ $sql.= ' OR ';
+ $sql.= ' (datep2 BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,$_GET["day"],$year));
+ $sql.= ' AND '.$db->idate(dol_mktime(23,59,59,$month,$_GET["day"],$year)).')';
+ $sql.= ' OR ';
+ $sql.= ' (datep < '.$db->idate(dol_mktime(0,0,0,$month,$_GET["day"],$year));
+ $sql.= ' AND datep2 > '.$db->idate(dol_mktime(23,59,59,$month,$_GET["day"],$year)).')';
+ $sql.= ')';
}
else
{
// To limit array
- $sql.= ' AND datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7)); // Start 7 days before
- $sql.= ' AND '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)); // End 7 days after + 3 to go from 28 to 31
+ $sql.= ' AND (';
+ $sql.= ' (datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7)); // Start 7 days before
+ $sql.= ' AND '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)).')'; // End 7 days after + 3 to go from 28 to 31
+ $sql.= ' OR ';
+ $sql.= ' (datep2 BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7));
+ $sql.= ' AND '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)).')';
+ $sql.= ' OR ';
+ $sql.= ' (datep < '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7));
+ $sql.= ' AND datep2 > '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)).')';
+ $sql.= ')';
}
if ($filtera > 0 || $filtert > 0 || $filterd > 0)
{
@@ -257,6 +273,8 @@ if ($resql)
while ($i < $num)
{
$obj = $db->fetch_object($resql);
+
+ // Create a new object action
$action=new ActionComm($db);
$action->id=$obj->id;
$action->datep=$obj->datep;
@@ -289,22 +307,37 @@ if ($resql)
$action->ponctuel=1;
}
+ if ($action->date_start_in_calendar < $firstdaytoshow) $action->date_start_in_calendar=$firstdaytoshow;
+ if ($action->date_end_in_calendar > $lastdaytoshow) $action->date_end_in_calendar=$lastdaytoshow;
+
// Add an entry in actionarray for each day
$daycursor=$action->date_start_in_calendar;
$annee = date('Y',$daycursor);
$mois = date('m',$daycursor);
$jour = date('d',$daycursor);
- $loop=true;
+ // Loop on each day covered by action to prepare an index to show on calendar
+ $loop=true; $j=0;
$daykey=dol_mktime(0,0,0,$mois,$jour,$annee);
do
{
- $actionarray[$daykey][]=$action;
+ //if ($action->id==408) print 'daykey='.$daykey.' '.$action->datep.' '.$action->datef.'
';
+
+ //if ($action->datef && $action->datef == $daykey && $action->datep < $action->datef)
+ //{ // We discard such index. This means it's end of a range ending on last day + 1 at 00:00:00.
+ //}
+ //else
+ //{
+ $actionarray[$daykey][]=$action;
+ $j++;
+ //}
$daykey+=60*60*24;
if ($daykey > $action->date_end_in_calendar) $loop=false;
}
while ($loop);
$i++;
+
+ //print 'Event '.$i.' id='.$action->id.' (start='.dol_print_date($action->datep).'-end='.dol_print_date($action->datef).') was added in '.$j.' different index days in array
';
}
}
else
@@ -502,7 +535,7 @@ llxFooter('$Date$ - $Revision$');
* @param unknown_type $maxPrint Nb of actions to show each day on month view (0 means non limit)
* @param unknown_type nbofchartoshow Nb of characters to show for event line
*/
-function show_day_events($db, $day, $month, $year, $monthshown, $style, $actionarray, $maxPrint=0, $nbofchartoshow=14)
+function show_day_events($db, $day, $month, $year, $monthshown, $style, &$actionarray, $maxPrint=0, $nbofchartoshow=14)
{
global $user, $conf, $langs;
global $filtera, $filtert, $filted;