78 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
79 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
80 $societestatic =
new Societe($this->db);
83 $text = $langs->trans(
"BoxTitleFutureActions", $max);
84 $this->info_box_head = array(
85 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/comm/action/list.php?sortfield=a.datep&datestart_dtstartday='.
dol_print_date($now,
'%d').
'&datestart_dtstartmonth='.
dol_print_date($now,
'%m').
'&datestart_dtstartyear='.
dol_print_date($now,
'%Y').
'&sortorder=ASC"><span class="badge">...</span></a>'
88 if ($user->hasRight(
'agenda',
'myactions',
'read')) {
89 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
91 $sql .=
", ta.libelle as type_label";
92 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
93 $sql .=
", s.code_client, s.code_compta as code_compta_client, s.client";
94 $sql .=
", s.logo, s.email, s.entity";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
96 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
97 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
99 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
100 $sql .=
" WHERE a.fk_action = ta.id";
101 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
103 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
104 $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).
")";
107 $sql .=
" AND s.rowid = ".((int) $user->socid);
109 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
110 $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).
")";
112 $sql .=
" AND a.datep > '".$this->db->idate($now).
"'";
113 $sql .=
" ORDER BY a.datep ASC";
114 $sql .= $this->db->plimit($max, 0);
116 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
117 $result = $this->db->query($sql);
120 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
122 $num = $this->db->num_rows($result);
125 while ($line < $num) {
127 $objp = $this->db->fetch_object($result);
128 $datelimite = $this->db->jdate($objp->dp);
130 $actionstatic->id = $objp->id;
131 $actionstatic->label = $objp->label;
132 $actionstatic->type_label = $objp->type_label;
133 $actionstatic->code = $objp->code;
135 $societestatic->id = $objp->socid;
136 $societestatic->name = $objp->name;
138 $societestatic->code_client = $objp->code_client;
139 $societestatic->code_compta = $objp->code_compta;
140 $societestatic->code_compta_client = $objp->code_compta_client;
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),
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;
222 if (is_countable($contents) && count($contents) > 0) {
223 $nblines = count($contents);
225 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo")) {
226 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
227 $out .=
'<table width=100%>';
228 for ($line = 0, $n = $nblines; $line < $n; $line++) {
229 if (isset($contents[$line])) {
232 $actioncejour =
true;
235 $logo = $contents[$line][0][
'logo'];
236 $label = $contents[$line][1][
'text'];
237 $urlevent = $contents[$line][1][
'url'];
238 $logosoc = $contents[$line][2][
'logo'];
239 $nomsoc = $contents[$line][3][
'text'];
240 $urlsoc = $contents[$line][3][
'url'];
241 $dateligne = $contents[$line][4][
'text'];
242 $percentage = $contents[$line][5][
'text'];
243 $out .=
'<tr class="oddeven">';
244 $out .=
'<td class="center">';
247 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
248 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
249 $out .=
'<td class="center">'.$dateligne.
'</td>';
250 $out .=
'<td class="center">'.$percentage.
'</td>';
258 $out .=
'<script nonce="'.getNonce().
'">';
259 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
261 $out .=
'setTimeout(function(){';
262 $out .=
'$("#dialogboxaction").dialog("close");';
263 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
267 $out .=
'<script nonce="'.getNonce().
'">';
268 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';