68 global $user, $langs, $conf;
74 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
75 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
76 $societestatic =
new Societe($this->db);
79 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleFutureActions", $max));
81 if ($user->hasRight(
'agenda',
'myactions',
'read')) {
82 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
84 $sql .=
", ta.libelle as type_label";
85 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
86 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
87 $sql .=
", s.logo, s.email, s.entity";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
89 if (!$user->hasRight(
'societe',
'client',
'voir')) {
90 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
92 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
93 $sql .=
" WHERE a.fk_action = ta.id";
94 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
96 if (!$user->hasRight(
'societe',
'client',
'voir')) {
97 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
100 $sql .=
" AND s.rowid = ".((int) $user->socid);
102 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
103 $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).
")";
105 $sql .=
" AND a.datep > '".$this->db->idate($now).
"'";
106 $sql .=
" ORDER BY a.datep ASC";
107 $sql .= $this->db->plimit($max, 0);
109 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
110 $result = $this->db->query($sql);
113 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
115 $num = $this->db->num_rows($result);
118 while ($line < $num) {
120 $objp = $this->db->fetch_object($result);
121 $datelimite = $this->db->jdate($objp->dp);
123 $actionstatic->id = $objp->id;
124 $actionstatic->label = $objp->label;
125 $actionstatic->type_label = $objp->type_label;
126 $actionstatic->code = $objp->code;
128 $societestatic->id = $objp->socid;
129 $societestatic->name = $objp->name;
131 $societestatic->code_client = $objp->code_client;
132 $societestatic->code_compta = $objp->code_compta;
133 $societestatic->code_compta_client = $objp->code_compta_client;
134 $societestatic->client = $objp->client;
135 $societestatic->logo = $objp->logo;
136 $societestatic->email = $objp->email;
137 $societestatic->entity = $objp->entity;
139 if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) {
146 $this->info_box_contents[$line][0] = array(
147 'td' =>
'class="tdoverflowmax200"',
148 'text' => $actionstatic->getNomUrl(1),
153 $this->info_box_contents[$line][1] = array(
154 'td' =>
'class="tdoverflowmax100"',
155 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
159 $this->info_box_contents[$line][2] = array(
160 'td' =>
'class="center nowraponall"',
161 'text' => $datelimite ?
dol_print_date($datelimite,
"dayhour",
'tzuserrel') :
'',
165 $this->info_box_contents[$line][3] = array(
166 'td' =>
'class="right"',
167 'text' => ($objp->percentage >= 0 ? $objp->percentage.
'%' :
''),
171 $this->info_box_contents[$line][4] = array(
172 'td' =>
'class="right" width="18"',
173 'text' => $actionstatic->LibStatut($objp->percentage, 3),
181 $this->info_box_contents[$line][0] = array(
182 'td' =>
'class="center"',
183 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoActionsToDo").
'</span>'
187 $this->db->free($result);
189 $this->info_box_contents[0][0] = array(
192 'text' => ($this->db->error().
' sql='.$sql)
196 $this->info_box_contents[0][0] = array(
197 'td' =>
'class="nohover left"',
198 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
213 public function showBox($head =
null, $contents =
null, $nooutput = 0)
215 global $langs, $conf;
216 $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
219 $actioncejour =
false;
220 $contents = $this->info_box_contents;
221 if (is_countable($contents) && count($contents) > 0) {
222 $nblines = count($contents);
224 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo")) {
225 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
226 $out .=
'<table width=100%>';
227 for ($line = 0, $n = $nblines; $line < $n; $line++) {
228 if (isset($contents[$line])) {
231 $actioncejour =
true;
234 $logo = $contents[$line][0][
'logo'];
235 $label = $contents[$line][1][
'text'];
236 $urlevent = $contents[$line][1][
'url'];
237 $logosoc = $contents[$line][2][
'logo'];
238 $nomsoc = $contents[$line][3][
'text'];
239 $urlsoc = $contents[$line][3][
'url'];
240 $dateligne = $contents[$line][4][
'text'];
241 $percentage = $contents[$line][5][
'text'];
242 $out .=
'<tr class="oddeven">';
243 $out .=
'<td class="center">';
246 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
247 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
248 $out .=
'<td class="center">'.$dateligne.
'</td>';
249 $out .=
'<td class="center">'.$percentage.
'</td>';
257 $out .=
'<script nonce="'.getNonce().
'">';
258 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
260 $out .=
'setTimeout(function(){';
261 $out .=
'$("#dialogboxaction").dialog("close");';
262 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
266 $out .=
'<script nonce="'.getNonce().
'">';
267 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';