67 global $user, $langs, $conf;
71 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
72 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
73 $societestatic =
new Societe($this->db);
76 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleOldestActionsToDo", $max));
78 if ($user->hasRight(
'agenda',
'myactions',
'read')) {
79 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
81 $sql .=
", ta.libelle as type_label";
82 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
83 $sql .=
", s.code_client, s.code_compta, s.client";
84 $sql .=
", s.logo, s.email, s.entity";
85 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
86 if (!$user->hasRight(
'societe',
'client',
'voir')) {
87 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
89 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
90 $sql .=
" WHERE a.fk_action = ta.id";
91 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
92 $sql .=
" AND a.percent >= 0 AND a.percent < 100";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
97 $sql .=
" AND s.rowid = ".((int) $user->socid);
99 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
100 $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).
")";
102 $sql .=
" ORDER BY a.datep ASC";
103 $sql .= $this->db->plimit($max, 0);
105 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
106 $result = $this->db->query($sql);
109 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
111 $num = $this->db->num_rows($result);
114 while ($line < $num) {
116 $objp = $this->db->fetch_object($result);
117 $datelimite = $this->db->jdate($objp->dp);
119 $actionstatic->id = $objp->id;
120 $actionstatic->label = $objp->label;
121 $actionstatic->type_label = $objp->type_label;
122 $actionstatic->code = $objp->code;
124 $societestatic->id = $objp->socid;
125 $societestatic->name = $objp->name;
127 $societestatic->code_client = $objp->code_client;
128 $societestatic->code_compta = $objp->code_compta;
129 $societestatic->client = $objp->client;
130 $societestatic->logo = $objp->logo;
131 $societestatic->email = $objp->email;
132 $societestatic->entity = $objp->entity;
134 if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) {
141 $this->info_box_contents[$line][0] = array(
142 'td' =>
'class="tdoverflowmax200"',
143 'text' => $actionstatic->getNomUrl(1),
148 $this->info_box_contents[$line][1] = array(
149 'td' =>
'class="tdoverflowmax100"',
150 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
154 $this->info_box_contents[$line][2] = array(
155 'td' =>
'class="center nowraponall"',
156 'text' => $datelimite ?
dol_print_date($datelimite,
"dayhour",
'tzuserrel') :
'',
160 $this->info_box_contents[$line][3] = array(
161 'td' =>
'class="right"',
162 'text' => ($objp->percentage >= 0 ? $objp->percentage.
'%' :
''),
166 $this->info_box_contents[$line][4] = array(
167 'td' =>
'class="right" width="18"',
168 'text' => $actionstatic->LibStatut($objp->percentage, 3),
176 $this->info_box_contents[$line][0] = array(
177 'td' =>
'class="center"',
178 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoActionsToDo").
'</span>'
182 $this->db->free($result);
184 $this->info_box_contents[0][0] = array(
187 'text' => ($this->db->error().
' sql='.$sql)
191 $this->info_box_contents[0][0] = array(
192 'td' =>
'class="nohover left"',
193 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
206 public function showBox($head =
null, $contents =
null, $nooutput = 0)
208 global $langs, $conf;
209 $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
212 $actioncejour =
false;
213 $contents = $this->info_box_contents;
214 if (is_countable($contents) && count($contents) > 0) {
215 $nblines = count($contents);
217 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo")) {
218 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
219 $out .=
'<table width=100%>';
220 for ($line = 0, $n = $nblines; $line < $n; $line++) {
221 if (isset($contents[$line])) {
224 $actioncejour =
true;
227 $logo = $contents[$line][0][
'logo'];
228 $label = $contents[$line][1][
'text'];
229 $urlevent = $contents[$line][1][
'url'];
230 $logosoc = $contents[$line][2][
'logo'];
231 $nomsoc = $contents[$line][3][
'text'];
232 $urlsoc = $contents[$line][3][
'url'];
233 $dateligne = $contents[$line][4][
'text'];
234 $percentage = $contents[$line][5][
'text'];
235 $out .=
'<tr class="oddeven">';
236 $out .=
'<td class="center">';
239 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
240 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
241 $out .=
'<td class="center">'.$dateligne.
'</td>';
242 $out .=
'<td class="center">'.$percentage.
'</td>';
250 $out .=
'<script nonce="'.getNonce().
'">';
251 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
253 $out .=
'setTimeout(function(){';
254 $out .=
'$("#dialogboxaction").dialog("close");';
255 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
259 $out .=
'<script nonce="'.getNonce().
'">';
260 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';