28 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastactions";
36 public $boximg =
"object_action";
37 public $boxlabel =
"BoxLastActions";
38 public $depends = array(
"agenda");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->enabled = $conf->agenda->enabled;
65 $this->hidden = !($user->rights->agenda->myactions->read);
76 global $user, $langs, $conf;
80 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
81 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
85 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastActionsToDo", $max));
87 if ($user->rights->agenda->myactions->read) {
88 $sql =
"SELECT a.id, a.label, a.datep as dp, a.percent as percentage";
90 $sql .=
", ta.libelle as type_label";
91 $sql .=
", s.rowid as socid, s.nom as name, s.name_alias";
92 $sql .=
", s.code_client, s.code_compta, s.client";
93 $sql .=
", s.logo, s.email, s.entity";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm AS ta, ".MAIN_DB_PREFIX.
"actioncomm AS a";
95 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
97 $sql .=
" WHERE a.fk_action = ta.id";
98 $sql .=
" AND a.entity IN (".getEntity(
'actioncomm').
")";
99 $sql .=
" AND a.percent >= 0 AND a.percent < 100";
100 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.
")";
101 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
102 if (!$user->rights->agenda->allactions->read) $sql .=
" AND (a.fk_user_author = ".$user->id.
" OR a.fk_user_action = ".$user->id.
" OR a.fk_user_done = ".$user->id.
")";
103 $sql .=
" ORDER BY a.datec DESC";
104 $sql .= $this->
db->plimit($max, 0);
106 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
107 $result = $this->
db->query($sql);
110 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
112 $num = $this->
db->num_rows($result);
115 while ($line < $num) {
117 $objp = $this->
db->fetch_object($result);
118 $datelimite = $this->
db->jdate($objp->dp);
120 $actionstatic->id = $objp->id;
121 $actionstatic->label = $objp->label;
122 $actionstatic->type_label = $objp->type_label;
123 $actionstatic->code = $objp->code;
125 $societestatic->id = $objp->socid;
126 $societestatic->name = $objp->name;
128 $societestatic->code_client = $objp->code_client;
129 $societestatic->code_compta = $objp->code_compta;
130 $societestatic->client = $objp->client;
131 $societestatic->logo = $objp->logo;
132 $societestatic->email = $objp->email;
133 $societestatic->entity = $objp->entity;
135 if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning))
139 $label = empty($objp->label) ? $objp->type_label : $objp->label;
141 $this->info_box_contents[$line][0] = array(
143 'text' => $actionstatic->getNomUrl(1),
148 $this->info_box_contents[$line][1] = array(
150 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) :
''),
154 $this->info_box_contents[$line][2] = array(
155 'td' =>
'class="nowrap left"',
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 opacitymedium"',
178 'text'=>$langs->trans(
"NoActionsToDo")
181 $this->
db->free($result);
183 $this->info_box_contents[0][0] = array(
186 'text' => ($this->
db->error().
' sql='.$sql)
190 $this->info_box_contents[0][0] = array(
191 'td' =>
'class="nohover opacitymedium left"',
192 'text' => $langs->trans(
"ReadPermissionNotAllowed")
205 public function showBox($head = null, $contents = null, $nooutput = 0)
207 global $langs, $conf;
208 $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
210 if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE))
212 $actioncejour =
false;
213 $contents = $this->info_box_contents;
214 $nblines = count($contents);
215 if ($contents[0][0][
'text'] != $langs->trans(
"NoActionsToDo"))
217 $out .=
'<div id="dialogboxaction" title="'.$nblines.
" ".$langs->trans(
"ActionsToDo").
'">';
218 $out .=
'<table width=100%>';
219 for ($line = 0, $n = $nblines; $line < $n; $line++)
221 if (isset($contents[$line]))
225 $actioncejour =
true;
228 $logo = $contents[$line][0][
'logo'];
229 $label = $contents[$line][1][
'text'];
230 $urlevent = $contents[$line][1][
'url'];
231 $logosoc = $contents[$line][2][
'logo'];
232 $nomsoc = $contents[$line][3][
'text'];
233 $urlsoc = $contents[$line][3][
'url'];
234 $dateligne = $contents[$line][4][
'text'];
235 $percentage = $contents[$line][5][
'text'];
236 $out .=
'<tr class="oddeven">';
237 $out .=
'<td class="center">';
240 $out .=
'<td class="center"><a href="'.$urlevent.
'">'.$label.
'</a></td>';
241 $out .=
'<td class="center"><a href="'.$urlsoc.
'">'.
img_object(
"", $logosoc).
" ".$nomsoc.
'</a></td>';
242 $out .=
'<td class="center">'.$dateligne.
'</td>';
243 $out .=
'<td class="center">'.$percentage.
'</td>';
253 $out .=
'$("#dialogboxaction").dialog({ autoOpen: true });';
254 if ($conf->global->SHOW_DIALOG_HOMEPAGE > 1)
256 $out .=
'setTimeout(function(){';
257 $out .=
'$("#dialogboxaction").dialog("close");';
258 $out .=
'}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).
');';
263 $out .=
'$("#dialogboxaction").dialog({ autoOpen: false });';
268 if ($nooutput)
return $out;
loadBox($max=5)
Load data for box to show them later.
Class to manage the box to show last events.
Class to manage agenda events (actions)
dol_now($mode= 'auto')
Return date for now.
__construct($db, $param)
Constructor.
$conf db
API class for accounts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).