Add hook formatEvent and fix bug into per user view.
This commit is contained in:
parent
844b5f30df
commit
e7a9447d94
@ -68,7 +68,7 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|
|
||||
if ($user->societe_id && $socid) $result = restrictedArea($user,'societe',$socid);
|
||||
|
||||
$error=GETPOST("error");
|
||||
$donotclearsession=0;
|
||||
$donotclearsession=GETPOST('donotclearsession')?GETPOST('donotclearsession'):0;
|
||||
|
||||
$cactioncomm = new CActionComm($db);
|
||||
$object = new ActionComm($db);
|
||||
@ -358,22 +358,22 @@ if ($action == 'update')
|
||||
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
|
||||
|
||||
$object->fk_action = dol_getIdFromCode($db, $_POST["actioncode"], 'c_actioncomm');
|
||||
$object->label = $_POST["label"];
|
||||
$object->label = GETPOST("label");
|
||||
$object->datep = $datep;
|
||||
$object->datef = $datef;
|
||||
$object->percentage = $percentage;
|
||||
$object->priority = $_POST["priority"];
|
||||
$object->fulldayevent= $_POST["fullday"]?1:0;
|
||||
$object->priority = GETPOST("priority");
|
||||
$object->fulldayevent= GETPOST("fullday")?1:0;
|
||||
$object->location = GETPOST('location');
|
||||
$object->socid = $_POST["socid"];
|
||||
$object->contactid = $_POST["contactid"];
|
||||
$object->socid = GETPOST("socid");
|
||||
$object->contactid = GETPOST("contactid");
|
||||
//$object->societe->id = $_POST["socid"]; // deprecated
|
||||
//$object->contact->id = $_POST["contactid"]; // deprecated
|
||||
$object->fk_project = $_POST["projectid"];
|
||||
$object->note = $_POST["note"];
|
||||
$object->pnote = $_POST["note"];
|
||||
$object->fk_element = $_POST["fk_element"];
|
||||
$object->elementtype = $_POST["elementtype"];
|
||||
$object->fk_project = GETPOST("projectid");
|
||||
$object->note = GETPOST("note");
|
||||
$object->pnote = GETPOST("note");
|
||||
$object->fk_element = GETPOST("fk_element");
|
||||
$object->elementtype = GETPOST("elementtype");
|
||||
|
||||
if (! $datef && $percentage == 100)
|
||||
{
|
||||
@ -603,6 +603,7 @@ if ($action == 'create')
|
||||
print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="donotclearsession" value="1">';
|
||||
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
|
||||
|
||||
if (GETPOST("actioncode") == 'AC_RDV') print_fiche_titre($langs->trans("AddActionRendezVous"));
|
||||
@ -1225,7 +1226,7 @@ if ($id > 0)
|
||||
|
||||
// Link to agenda views
|
||||
print '<div id="agendaviewbutton">';
|
||||
print '<form name="listactionsfiltermonth" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left">';
|
||||
print '<form name="listactionsfiltermonth" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="show_month">';
|
||||
print '<input type="hidden" name="year" value="'.dol_print_date($object->datep,'%Y').'">';
|
||||
@ -1234,7 +1235,7 @@ if ($id > 0)
|
||||
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
|
||||
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewcal" value="'.$langs->trans("ViewCal").'">';
|
||||
print '</form>'."\n";
|
||||
print '<form name="listactionsfilterweek" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left">';
|
||||
print '<form name="listactionsfilterweek" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="show_week">';
|
||||
print '<input type="hidden" name="year" value="'.dol_print_date($object->datep,'%Y').'">';
|
||||
@ -1243,7 +1244,7 @@ if ($id > 0)
|
||||
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
|
||||
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
|
||||
print '</form>'."\n";
|
||||
print '<form name="listactionsfilterday" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left">';
|
||||
print '<form name="listactionsfilterday" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="show_day">';
|
||||
print '<input type="hidden" name="year" value="'.dol_print_date($object->datep,'%Y').'">';
|
||||
@ -1252,7 +1253,7 @@ if ($id > 0)
|
||||
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
|
||||
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewday" value="'.$langs->trans("ViewDay").'">';
|
||||
print '</form>'."\n";
|
||||
print '<form name="listactionsfilterperuser" action="'.DOL_URL_ROOT.'/comm/action/peruser.php" method="POST" style="float: left">';
|
||||
print '<form name="listactionsfilterperuser" action="'.DOL_URL_ROOT.'/comm/action/peruser.php" method="POST" style="float: left; padding-right: 10px;">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="show_peruser">';
|
||||
print '<input type="hidden" name="year" value="'.dol_print_date($object->datep,'%Y').'">';
|
||||
|
||||
@ -95,14 +95,16 @@ class ActionComm extends CommonObject
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
//$this->author = new stdClass();
|
||||
//$this->usermod = new stdClass();
|
||||
//$this->usertodo = new stdClass();
|
||||
//$this->userdone = new stdClass();
|
||||
$this->societe = new stdClass();
|
||||
$this->contact = new stdClass();
|
||||
$this->societe = new stdClass(); // deprecated
|
||||
$this->contact = new stdClass(); // deprecated
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,6 +526,9 @@ class ActionComm extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0));
|
||||
$contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0));
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
|
||||
@ -534,9 +539,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->societe->id > 0 ? "'".$this->societe->id."'":"null");
|
||||
$sql.= ", fk_soc =". ($this->socid > 0 ? "'".$this->socid."'":"null");
|
||||
$sql.= ", fk_project =". ($this->fk_project > 0 ? "'".$this->fk_project."'":"null");
|
||||
$sql.= ", fk_contact =". ($this->contact->id > 0 ? "'".$this->contact->id."'":"null");
|
||||
$sql.= ", fk_contact =". ($contactid > 0 ? "'".$this->contactid."'":"null");
|
||||
$sql.= ", priority = '".$this->priority."'";
|
||||
$sql.= ", fulldayevent = '".$this->fulldayevent."'";
|
||||
$sql.= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'":"null");
|
||||
|
||||
@ -320,7 +320,7 @@ $sql.= ' a.datea2,';
|
||||
$sql.= ' a.percent,';
|
||||
$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
|
||||
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
|
||||
$sql.= ' a.fk_soc, a.fk_contact,';
|
||||
$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,';
|
||||
$sql.= ' ca.code, ca.color';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
@ -415,6 +415,9 @@ if ($resql)
|
||||
//$event->societe->id=$obj->fk_soc; // deprecated
|
||||
//$event->contact->id=$obj->fk_contact; // deprecated
|
||||
|
||||
$event->fk_element=$obj->fk_element;
|
||||
$event->elementtype=$obj->elementtype;
|
||||
|
||||
// Defined date_start_in_calendar and date_end_in_calendar property
|
||||
// They are date start and end of action but modified to not be outside calendar view.
|
||||
if ($event->percentage <= 0)
|
||||
@ -709,7 +712,7 @@ $db->close();
|
||||
function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false)
|
||||
{
|
||||
global $db;
|
||||
global $user, $conf, $langs;
|
||||
global $user, $conf, $langs, $hookmanager, $action;
|
||||
global $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form
|
||||
global $theme_datacolor;
|
||||
global $cachethirdparties, $cachecontacts, $colorindexused;
|
||||
@ -743,6 +746,10 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show
|
||||
//if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
$ponct=($event->date_start_in_calendar == $event->date_end_in_calendar);
|
||||
|
||||
// Define $color (Hex string like '0088FF') and $cssclass of event
|
||||
|
||||
@ -114,8 +114,8 @@ class HookManager
|
||||
*
|
||||
* @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...)
|
||||
* @param array $parameters Array of parameters
|
||||
* @param Object $object Object to use hooks on
|
||||
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||
* @param Object $object Object to use hooks on
|
||||
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||
* @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO.
|
||||
* For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints.
|
||||
* Can also return some values into an array ->results.
|
||||
@ -144,7 +144,8 @@ class HookManager
|
||||
'moveUploadedFile',
|
||||
'pdf_writelinedesc',
|
||||
'paymentsupplierinvoices',
|
||||
'printSearchForm'
|
||||
'printSearchForm',
|
||||
'formatEvent'
|
||||
)
|
||||
)) $hooktype='addreplace';
|
||||
|
||||
|
||||
@ -989,10 +989,10 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks
|
||||
background-position:top;
|
||||
background-repeat:repeat-x;
|
||||
<?php } ?>
|
||||
border-left: 1px solid #CCCCCC;
|
||||
border-right: 1px solid #D0D0D0;
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
border-top: 1px solid #DDDDDD;
|
||||
border-left: 1px solid #AAA;
|
||||
border-right: 1px solid #CCC;
|
||||
border-bottom: 1px solid #CCC;
|
||||
border-top: 1px solid #CCC;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-moz-box-shadow: 3px 3px 4px #DDD;
|
||||
@ -1021,10 +1021,10 @@ div.blockvmenusearch
|
||||
background-image: linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
|
||||
<?php } ?>
|
||||
|
||||
border-left: 1px solid #DDDDDD;
|
||||
border-right: 1px solid #CCCCCC;
|
||||
border-bottom: 1px solid #CCCCCC;
|
||||
border-top: 1px solid #E8E8E8;
|
||||
border-left: 1px solid #AAA;
|
||||
border-right: 1px solid #CCC;
|
||||
border-bottom: 1px solid #CCC;
|
||||
border-top: 1px solid #CCC;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-moz-box-shadow: 3px 3px 4px #DDD;
|
||||
@ -1032,39 +1032,6 @@ div.blockvmenusearch
|
||||
box-shadow: 3px 3px 4px #DDD;
|
||||
}
|
||||
|
||||
div.blockvmenubookmarksold
|
||||
{
|
||||
border-right: 1px solid #555555;
|
||||
border-bottom: 1px solid #555555;
|
||||
font-family: <?php print $fontlist ?>;
|
||||
color: #000000;
|
||||
text-align: <?php print $left; ?>;
|
||||
text-decoration: none;
|
||||
padding-left: 5px;
|
||||
padding-right: 1px;
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
margin: 6px 0px 8px 2px;
|
||||
background: #E3E6E8;
|
||||
|
||||
<?php if ($usecss3) { ?>
|
||||
background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1b; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
|
||||
background-image: -moz-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1b; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
|
||||
background-image: -webkit-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1b; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
|
||||
background-image: -ms-linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1b; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
|
||||
background-image: linear-gradient(bottom, rgb(<?php echo $colorbackvmenu1b; ?>) 90%, rgb(<?php echo $colorbackvmenu2; ?>) 100%);
|
||||
<?php } ?>
|
||||
|
||||
border-left: 1px solid #CCCCCC;
|
||||
border-right: 1px solid #BBBBBB;
|
||||
border-bottom: 1px solid #BBBBBB;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-moz-box-shadow: 3px 3px 4px #DDD;
|
||||
-webkit-box-shadow: 3px 3px 4px #DDD;
|
||||
box-shadow: 3px 3px 4px #DDD;
|
||||
}
|
||||
|
||||
div.blockvmenuhelp
|
||||
{
|
||||
<?php if (empty($conf->dol_optimize_smallscreen)) { ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user