Fix: Missing event in calendar
This commit is contained in:
parent
c9affcb8a2
commit
68fd815137
@ -45,7 +45,7 @@ $socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid'];
|
|||||||
$id = isset($_GET["id"])?$_GET["id"]:'';
|
$id = isset($_GET["id"])?$_GET["id"]:'';
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
// TODO: revoir les droits car pas clair
|
// 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"];
|
if (isset($_GET["error"])) $error=$_GET["error"];
|
||||||
|
|
||||||
@ -273,12 +273,15 @@ if ($_POST["action"] == 'add_action')
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Action suppression de l'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 = new ActionComm($db);
|
||||||
$actioncomm->fetch($_GET["id"]);
|
$actioncomm->fetch($_GET["id"]);
|
||||||
|
|
||||||
|
if ($user->rights->agenda->myactions->create
|
||||||
|
|| $user->rights->agenda->allactions->create)
|
||||||
|
{
|
||||||
$result=$actioncomm->delete();
|
$result=$actioncomm->delete();
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@ -290,6 +293,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
|||||||
{
|
{
|
||||||
$mesg=$actioncomm->error;
|
$mesg=$actioncomm->error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -644,7 +648,7 @@ if ($_GET["id"])
|
|||||||
// Confirmation suppression action
|
// Confirmation suppression action
|
||||||
if ($_GET["action"] == 'delete')
|
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 '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +871,7 @@ if ($_GET["id"])
|
|||||||
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($_GET["action"] != 'edit' && $_GET["action"] != 'delete')
|
if ($_GET["action"] != 'edit')
|
||||||
{
|
{
|
||||||
if ($user->rights->agenda->allactions->create)
|
if ($user->rights->agenda->allactions->create)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -225,14 +225,30 @@ $sql.= ' AND a.fk_user_author = u.rowid';
|
|||||||
$sql.= ' AND u.entity in (0,'.$conf->entity.')';
|
$sql.= ' AND u.entity in (0,'.$conf->entity.')';
|
||||||
if ($_GET["action"] == 'show_day')
|
if ($_GET["action"] == 'show_day')
|
||||||
{
|
{
|
||||||
$sql.= ' AND datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,$_GET["day"],$year));
|
$sql.= ' AND (';
|
||||||
$sql.= ' AND '.$db->idate(dol_mktime(23,59,59,$month,$_GET["day"],$year));
|
$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
|
else
|
||||||
{
|
{
|
||||||
// To limit array
|
// 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 (';
|
||||||
$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.= ' (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)
|
if ($filtera > 0 || $filtert > 0 || $filterd > 0)
|
||||||
{
|
{
|
||||||
@ -257,6 +273,8 @@ if ($resql)
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
// Create a new object action
|
||||||
$action=new ActionComm($db);
|
$action=new ActionComm($db);
|
||||||
$action->id=$obj->id;
|
$action->id=$obj->id;
|
||||||
$action->datep=$obj->datep;
|
$action->datep=$obj->datep;
|
||||||
@ -289,22 +307,37 @@ if ($resql)
|
|||||||
$action->ponctuel=1;
|
$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
|
// Add an entry in actionarray for each day
|
||||||
$daycursor=$action->date_start_in_calendar;
|
$daycursor=$action->date_start_in_calendar;
|
||||||
$annee = date('Y',$daycursor);
|
$annee = date('Y',$daycursor);
|
||||||
$mois = date('m',$daycursor);
|
$mois = date('m',$daycursor);
|
||||||
$jour = date('d',$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);
|
$daykey=dol_mktime(0,0,0,$mois,$jour,$annee);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
//if ($action->id==408) print 'daykey='.$daykey.' '.$action->datep.' '.$action->datef.'<br>';
|
||||||
|
|
||||||
|
//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;
|
$actionarray[$daykey][]=$action;
|
||||||
|
$j++;
|
||||||
|
//}
|
||||||
$daykey+=60*60*24;
|
$daykey+=60*60*24;
|
||||||
if ($daykey > $action->date_end_in_calendar) $loop=false;
|
if ($daykey > $action->date_end_in_calendar) $loop=false;
|
||||||
}
|
}
|
||||||
while ($loop);
|
while ($loop);
|
||||||
$i++;
|
$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<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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 $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
|
* @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 $user, $conf, $langs;
|
||||||
global $filtera, $filtert, $filted;
|
global $filtera, $filtert, $filted;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user