diff --git a/ChangeLog b/ChangeLog index 08d53ea7cdb..7e0f337f0e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,6 +56,7 @@ For users: - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message - Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe. - New: [ task #1204 ] add a External reference to contract +- New: [ task #1218 ] Can drag and drop an event from calendar to change its day. For translators: - Update language files. diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index f04c9e372a9..b6da05ecfd2 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014 Cedric GROSS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -384,7 +385,48 @@ if ($action == 'update') } } +/* + * Action move update, used when user move an event in calendar by drag'n drop + */ +if ($action == 'mupdate') +{ + $object->fetch($id); + $shour = dol_print_date($object->datep,"%H"); + $smin = dol_print_date($object->datep, "%M"); + + $newdate=GETPOST('newdate','alpha'); + if (empty($newdate) || strpos($newdate,'dayevent_') != 0 ) + { + header("Location: ".$backtopage); + exit; + } + $datep=dol_mktime($shour, $smin, 0,substr($newdate,13,2) , substr($newdate,15,2), substr($newdate,9,4)); + if ($datep!=$object->datep) + { + if (!empty($object->datef)) + { + $object->datef+=$datep-$object->datep; + } + $object->datep=$datep; + $result=$object->update($user); + if ($result < 0) + { + setEventMessage($object->error,'errors'); + setEventMessage($object->errors,'errors'); + } + } + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else + { + $action=''; + } + +} /* * View */ diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index fe6e218f1a1..0964da3e2b9 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2014 Cedric GROSS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -330,7 +331,12 @@ if ($conf->use_javascript_ajax) $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; $s.='jQuery(".family_birthday").toggle();' . "\n"; - $s.='});' . "\n"; + if ($action=="show_week" || $action=="show_month" || empty($action)) + { + $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s.='});' . "\n"; + } $s.='' . "\n"; if (! empty($conf->use_javascript_ajax)) { @@ -932,6 +938,12 @@ if (empty($action) || $action == 'show_month') // View by month echo " \n"; } echo "\n"; + echo '
'; + echo ''; + echo ''; + echo '' ; + echo '
'; + } elseif ($action == 'show_week') // View by week { @@ -992,6 +1004,11 @@ elseif ($action == 'show_week') // View by week echo " \n"; echo "\n"; + echo '
'; + echo ''; + echo ''; + echo '' ; + echo '
'; } else // View by day { @@ -1089,7 +1106,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print ''; } print ''; - print ''; + print ''; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); @@ -1134,9 +1151,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $numicals[dol_string_nospecial($event->icalname)]++; } $color=$event->icalcolor; - $cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other'); + $cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other unsortable'); } - else if ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex=2; $cssclass='family_birthday'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); } + else if ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); } else { $numother++; $cssclass='family_other'; } if ($color == -1) // Color was not forced. Set color according to color index. { @@ -1158,6 +1175,24 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } $cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; + if (empty($event->fulldayevent)) + { + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + $tmpyearend = date('Y',$event->date_end_in_calendar); + $tmpmonthend = date('m',$event->date_end_in_calendar); + $tmpdayend = date('d',$event->date_end_in_calendar); + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) + { + $cssclass.= " unsortable"; + } + } + if ($event->type_code =='AC_OTH_AUTO') + { + $cssclass.= " unsortable"; + } + } + // Show rect of event print '
'; print '
  • '; @@ -1242,7 +1277,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Show title if ($event->type_code == 'ICALEVENT') print dol_trunc($event->libelle,$maxnbofchar); - else print $event->getNomUrl(0,$maxnbofchar,'cal_event'); + else print $event->getNomUrl(0,$maxnbofchar,'cal_event id_'.$event->id); if ($event->type_code == 'ICALEVENT') print '
    ('.dol_trunc($event->icalname,$maxnbofchar).')'; @@ -1327,8 +1362,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached print 'jQuery(".family_mytasks_day_'.$ymd.'").toggle();'; print '}'."\n"; - + print '});'."\n"; + print ''."\n"; }