75 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
76 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
77 $societestatic =
new Societe($this->db);
80 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleOldestActionsToDo", $max));
82 if ($user->hasRight(
'agenda',
'myactions',
'read')) {
83 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
85 $sql .=
", ta.libelle as type_label";
86 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
87 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
88 $sql .=
", s.logo, s.email, s.entity";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
90 if (!$user->hasRight(
'societe',
'client',
'voir')) {
91 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
93 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
94 $sql .=
" WHERE a.fk_action = ta.id";
95 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
96 $sql .=
" AND a.percent >= 0 AND a.percent < 100";
97 if (!$user->hasRight(
'societe',
'client',
'voir')) {
98 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
101 $sql .=
" AND s.rowid = ".((int) $user->socid);
103 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
104 $sql .=
" AND (a.fk_user_author = ".((int) $user->id).
" OR a.fk_user_action = ".((int) $user->id).
")";
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_client = $objp->code_compta_client;
133 $societestatic->client = $objp->client;
134 $societestatic->logo = $objp->logo;
135 $societestatic->email = $objp->email;
136 $societestatic->entity = $objp->entity;
138 if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) {
145 $this->info_box_contents[$line][0] = array(
146 'td' =>
'class="tdoverflowmax200"',
147 'text' => $actionstatic->getNomUrl(1),
152 $this->info_box_contents[$line][1] = array(
153 'td' =>
'class="tdoverflowmax100"',
154 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
158 $this->info_box_contents[$line][2] = array(
159 'td' =>
'class="center nowraponall"',
160 'text' => $datelimite ?
dol_print_date($datelimite,
"dayhour",
'tzuserrel') :
'',
164 $this->info_box_contents[$line][3] = array(
165 'td' =>
'class="right"',
166 'text' => ($objp->percentage >= 0 ? $objp->percentage.
'%' :
''),
170 $this->info_box_contents[$line][4] = array(
171 'td' =>
'class="right" width="18"',
172 'text' => $actionstatic->LibStatut($objp->percentage, 3),
186 $this->db->free($result);
188 $this->info_box_contents[0][0] = array(
191 'text' => ($this->db->error().
' sql='.$sql)
195 $this->info_box_contents[0][0] = array(
196 'td' =>
'class="nohover left"',
197 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
212 public function showBox($head =
null, $contents =
null, $nooutput = 0)
214 global $langs,
$conf;
215 $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
218 $actioncejour =
false;
219 $contents = $this->info_box_contents;
220 if (is_countable($contents) && count($contents) > 0) {
221 $nblines = count($contents);
223 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo")) {
224 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
225 $out .=
'<table width=100%>';
226 for ($line = 0, $n = $nblines; $line < $n; $line++) {
227 if (isset($contents[$line])) {
230 $actioncejour =
true;
233 $logo = $contents[$line][0][
'logo'];
234 $label = $contents[$line][1][
'text'];
235 $urlevent = $contents[$line][1][
'url'];
236 $logosoc = $contents[$line][2][
'logo'];
237 $nomsoc = $contents[$line][3][
'text'];
238 $urlsoc = $contents[$line][3][
'url'];
239 $dateligne = $contents[$line][4][
'text'];
240 $percentage = $contents[$line][5][
'text'];
241 $out .=
'<tr class="oddeven">';
242 $out .=
'<td class="center">';
245 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
246 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
247 $out .=
'<td class="center">'.$dateligne.
'</td>';
248 $out .=
'<td class="center">'.$percentage.
'</td>';
256 $out .=
'<script nonce="'.getNonce().
'">';
257 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
259 $out .=
'setTimeout(function(){';
260 $out .=
'$("#dialogboxaction").dialog("close");';
261 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
265 $out .=
'<script nonce="'.getNonce().
'">';
266 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';