76 global $user, $langs, $conf;
82 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
83 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
84 $societestatic =
new Societe($this->db);
87 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleFutureActions", $max));
89 if ($user->hasRight(
'agenda',
'myactions',
'read')) {
90 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
92 $sql .=
", ta.libelle as type_label";
93 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
94 $sql .=
", s.code_client, s.code_compta, s.client";
95 $sql .=
", s.logo, s.email, s.entity";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
97 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
98 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
101 $sql .=
" WHERE a.fk_action = ta.id";
102 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
104 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
105 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
108 $sql .=
" AND s.rowid = ".((int) $user->socid);
110 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
111 $sql .=
" AND (a.fk_user_author = ".((int) $user->id).
" OR a.fk_user_action = ".((int) $user->id).
" OR a.fk_user_done = ".((int) $user->id).
")";
113 $sql .=
" AND a.datep > '".$this->db->idate($now).
"'";
114 $sql .=
" ORDER BY a.datep ASC";
115 $sql .= $this->db->plimit($max, 0);
117 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
118 $result = $this->db->query($sql);
121 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
123 $num = $this->db->num_rows($result);
126 while ($line < $num) {
128 $objp = $this->db->fetch_object($result);
129 $datelimite = $this->db->jdate($objp->dp);
131 $actionstatic->id = $objp->id;
132 $actionstatic->label = $objp->label;
133 $actionstatic->type_label = $objp->type_label;
134 $actionstatic->code = $objp->code;
136 $societestatic->id = $objp->socid;
137 $societestatic->name = $objp->name;
139 $societestatic->code_client = $objp->code_client;
140 $societestatic->code_compta = $objp->code_compta;
141 $societestatic->client = $objp->client;
142 $societestatic->logo = $objp->logo;
143 $societestatic->email = $objp->email;
144 $societestatic->entity = $objp->entity;
146 if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) {
153 $this->info_box_contents[$line][0] = array(
154 'td' =>
'class="tdoverflowmax200"',
155 'text' => $actionstatic->getNomUrl(1),
160 $this->info_box_contents[$line][1] = array(
161 'td' =>
'class="tdoverflowmax100"',
162 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
166 $this->info_box_contents[$line][2] = array(
167 'td' =>
'class="center nowraponall"',
168 'text' => $datelimite ?
dol_print_date($datelimite,
"dayhour",
'tzuserrel') :
'',
172 $this->info_box_contents[$line][3] = array(
173 'td' =>
'class="right"',
174 'text' => ($objp->percentage >= 0 ? $objp->percentage.
'%' :
''),
178 $this->info_box_contents[$line][4] = array(
179 'td' =>
'class="right" width="18"',
180 'text' => $actionstatic->LibStatut($objp->percentage, 3),
188 $this->info_box_contents[$line][0] = array(
189 'td' =>
'class="center"',
190 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoActionsToDo").
'</span>'
194 $this->db->free($result);
196 $this->info_box_contents[0][0] = array(
199 'text' => ($this->db->error().
' sql='.$sql)
203 $this->info_box_contents[0][0] = array(
204 'td' =>
'class="nohover left"',
205 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
218 public function showBox($head =
null, $contents =
null, $nooutput = 0)
220 global $langs, $conf;
221 $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
224 $actioncejour =
false;
225 $contents = $this->info_box_contents;
226 if (is_countable($contents) && count($contents) > 0) {
227 $nblines = count($contents);
229 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo")) {
230 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
231 $out .=
'<table width=100%>';
232 for ($line = 0, $n = $nblines; $line < $n; $line++) {
233 if (isset($contents[$line])) {
236 $actioncejour =
true;
239 $logo = $contents[$line][0][
'logo'];
240 $label = $contents[$line][1][
'text'];
241 $urlevent = $contents[$line][1][
'url'];
242 $logosoc = $contents[$line][2][
'logo'];
243 $nomsoc = $contents[$line][3][
'text'];
244 $urlsoc = $contents[$line][3][
'url'];
245 $dateligne = $contents[$line][4][
'text'];
246 $percentage = $contents[$line][5][
'text'];
247 $out .=
'<tr class="oddeven">';
248 $out .=
'<td class="center">';
251 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
252 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
253 $out .=
'<td class="center">'.$dateligne.
'</td>';
254 $out .=
'<td class="center">'.$percentage.
'</td>';
262 $out .=
'<script nonce="'.getNonce().
'">';
263 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
265 $out .=
'setTimeout(function(){';
266 $out .=
'$("#dialogboxaction").dialog("close");';
267 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
271 $out .=
'<script nonce="'.getNonce().
'">';
272 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';