67 global $user, $langs, $conf;
73 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
74 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
75 $societestatic =
new Societe($this->db);
78 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleFutureActions", $max));
80 if ($user->hasRight(
'agenda',
'myactions',
'read')) {
81 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
83 $sql .=
", ta.libelle as type_label";
84 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
85 $sql .=
", s.code_client, s.code_compta, s.client";
86 $sql .=
", s.logo, s.email, s.entity";
87 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
88 if (!$user->hasRight(
'societe',
'client',
'voir')) {
89 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
91 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
92 $sql .=
" WHERE a.fk_action = ta.id";
93 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
95 if (!$user->hasRight(
'societe',
'client',
'voir')) {
96 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
99 $sql .=
" AND s.rowid = ".((int) $user->socid);
101 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
102 $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).
")";
104 $sql .=
" AND a.datep > '".$this->db->idate($now).
"'";
105 $sql .=
" ORDER BY a.datep ASC";
106 $sql .= $this->db->plimit($max, 0);
108 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
109 $result = $this->db->query($sql);
112 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
114 $num = $this->db->num_rows($result);
117 while ($line < $num) {
119 $objp = $this->db->fetch_object($result);
120 $datelimite = $this->db->jdate($objp->dp);
122 $actionstatic->id = $objp->id;
123 $actionstatic->label = $objp->label;
124 $actionstatic->type_label = $objp->type_label;
125 $actionstatic->code = $objp->code;
127 $societestatic->id = $objp->socid;
128 $societestatic->name = $objp->name;
130 $societestatic->code_client = $objp->code_client;
131 $societestatic->code_compta = $objp->code_compta;
132 $societestatic->client = $objp->client;
133 $societestatic->logo = $objp->logo;
134 $societestatic->email = $objp->email;
135 $societestatic->entity = $objp->entity;
137 if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) {
144 $this->info_box_contents[$line][0] = array(
145 'td' =>
'class="tdoverflowmax200"',
146 'text' => $actionstatic->getNomUrl(1),
151 $this->info_box_contents[$line][1] = array(
152 'td' =>
'class="tdoverflowmax100"',
153 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
157 $this->info_box_contents[$line][2] = array(
158 'td' =>
'class="center nowraponall"',
159 'text' => $datelimite ?
dol_print_date($datelimite,
"dayhour",
'tzuserrel') :
'',
163 $this->info_box_contents[$line][3] = array(
164 'td' =>
'class="right"',
165 'text' => ($objp->percentage >= 0 ? $objp->percentage.
'%' :
''),
169 $this->info_box_contents[$line][4] = array(
170 'td' =>
'class="right" width="18"',
171 'text' => $actionstatic->LibStatut($objp->percentage, 3),
179 $this->info_box_contents[$line][0] = array(
180 'td' =>
'class="center"',
181 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoActionsToDo").
'</span>'
185 $this->db->free($result);
187 $this->info_box_contents[0][0] = array(
190 'text' => ($this->db->error().
' sql='.$sql)
194 $this->info_box_contents[0][0] = array(
195 'td' =>
'class="nohover left"',
196 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
209 public function showBox($head =
null, $contents =
null, $nooutput = 0)
211 global $langs, $conf;
212 $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
215 $actioncejour =
false;
216 $contents = $this->info_box_contents;
217 if (is_countable($contents) && count($contents) > 0) {
218 $nblines = count($contents);
220 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo")) {
221 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
222 $out .=
'<table width=100%>';
223 for ($line = 0, $n = $nblines; $line < $n; $line++) {
224 if (isset($contents[$line])) {
227 $actioncejour =
true;
230 $logo = $contents[$line][0][
'logo'];
231 $label = $contents[$line][1][
'text'];
232 $urlevent = $contents[$line][1][
'url'];
233 $logosoc = $contents[$line][2][
'logo'];
234 $nomsoc = $contents[$line][3][
'text'];
235 $urlsoc = $contents[$line][3][
'url'];
236 $dateligne = $contents[$line][4][
'text'];
237 $percentage = $contents[$line][5][
'text'];
238 $out .=
'<tr class="oddeven">';
239 $out .=
'<td class="center">';
242 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
243 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
244 $out .=
'<td class="center">'.$dateligne.
'</td>';
245 $out .=
'<td class="center">'.$percentage.
'</td>';
253 $out .=
'<script nonce="'.getNonce().
'">';
254 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
256 $out .=
'setTimeout(function(){';
257 $out .=
'$("#dialogboxaction").dialog("close");';
258 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
262 $out .=
'<script nonce="'.getNonce().
'">';
263 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';