46 dol_syslog(
'Company::societe_prepare_head', LOG_DEBUG);
47 global $db, $langs,
$conf, $user;
53 $head[$h][0] = DOL_URL_ROOT .
'/societe/card.php?socid=' .
$object->id;
54 $head[$h][1] = $langs->trans(
"ThirdParty");
55 $head[$h][2] =
'card';
59 if (!
getDolGlobalString(
'MAIN_DISABLE_CONTACTS_TAB') && $user->hasRight(
'societe',
'contact',
'lire')) {
63 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
64 $cachekey =
'count_contacts_thirdparty_' .
$object->id;
67 if (!is_null($dataretrieved)) {
68 $nbContact = $dataretrieved;
70 $sql =
"SELECT COUNT(p.rowid) as nb";
71 $sql .=
" FROM " . MAIN_DB_PREFIX .
"socpeople as p";
73 $parameters = array(
'contacttab' =>
true);
74 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters,
$object);
75 $sql .= $hookmanager->resPrint;
76 $sql .=
" WHERE p.fk_soc = " . ((int)
$object->id);
79 $parameters = array(
'contacttab' =>
true);
80 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
81 $sql .= $hookmanager->resPrint;
82 $resql = $db->query($sql);
84 $obj = $db->fetch_object($resql);
85 $nbContact = $obj->nb;
91 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/contact.php', [
'socid' =>
$object->id]);
92 $head[$h][1] = $langs->trans(
'ContactsAddresses');
94 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbContact .
'</span>';
96 $head[$h][2] =
'contact';
101 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/societecontact.php', [
'socid' =>
$object->id]);
102 $nbContact = count(
$object->liste_contact(-1,
'internal')) + count(
$object->liste_contact(-1,
'external'));
103 $head[$h][1] = $langs->trans(
"ContactsAddressesExt");
104 if ($nbContact > 0) {
105 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbContact .
'</span>';
107 $head[$h][2] =
'contactext';
112 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/comm/card.php', [
'socid' =>
$object->id]);
115 $head[$h][1] .= $langs->trans(
"Prospect");
118 $head[$h][1] .=
' | ';
121 $head[$h][1] .= $langs->trans(
"Customer");
123 $head[$h][2] =
'customer';
127 $langs->load(
"products");
129 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/price.php', [
'socid' =>
$object->id]);
130 $head[$h][1] = $langs->trans(
"CustomerPrices");
131 $head[$h][2] =
'price';
135 $supplier_module_enabled = 0;
137 $supplier_module_enabled = 1;
139 if ($supplier_module_enabled == 1 &&
$object->fournisseur && $user->hasRight(
'fournisseur',
'lire')) {
140 $head[$h][0] = DOL_URL_ROOT .
'/fourn/card.php?socid=' .
$object->id;
141 $head[$h][1] = $langs->trans(
"Supplier");
142 $head[$h][2] =
'supplier';
146 if (
isModEnabled(
'accounting') &&
getDolGlobalString(
'ACCOUNTING_ENABLE_TABONTHIRDPARTY') && ($user->hasRight(
'accounting',
'mouvements',
'lire'))) {
148 if (!empty(
$object->code_compta_client)) {
149 $subledger_start_account = $subledger_end_account =
$object->code_compta_client;
151 } elseif (!empty(
$object->code_compta_fournisseur)) {
152 $subledger_start_account = $subledger_end_account =
$object->code_compta_fournisseur;
155 $subledger_start_account = $subledger_end_account =
'';
159 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/accountancy/bookkeeping/listbyaccount.php', [
'socid' =>
$object->id,
'mode' => $mode,
'type' =>
'sub',
'search_accountancy_code_start' => $subledger_start_account,
'search_accountancy_code_end' => $subledger_end_account]);
160 $head[$h][1] = $langs->trans(
"Accounting");
161 $head[$h][2] =
'accounting';
165 if (
isModEnabled(
'project') && ($user->hasRight(
'projet',
'lire'))) {
166 dol_syslog(
'Company::societe_prepare_head::isModEnabled::project', LOG_DEBUG);
169 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
170 $cachekey =
'count_projects_thirdparty_' .
$object->id;
173 if (!is_null($dataretrieved)) {
174 $nbProject = $dataretrieved;
176 $sql =
"SELECT COUNT(n.rowid) as nb";
177 $sql .=
" FROM " . MAIN_DB_PREFIX .
"projet as n";
178 $sql .=
" WHERE fk_soc = " . ((int)
$object->id);
179 $sql .=
" AND entity IN (" .
getEntity(
'project') .
")";
180 $resql = $db->query($sql);
182 $obj = $db->fetch_object($resql);
183 $nbProject = $obj->nb;
185 dol_print_error($db);
189 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/project.php', [
'socid' =>
$object->id]);
190 $head[$h][1] = $langs->trans(
"Projects");
191 if ($nbProject > 0) {
192 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbProject .
'</span>';
194 $head[$h][2] =
'project';
200 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/resource/element_resource.php', [
'element' =>
'societe',
'element_id' =>
$object->id]);
201 $head[$h][1] = $langs->trans(
"Resources");
202 $head[$h][2] =
'resources';
210 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/consumption.php', [
'socid' =>
$object->id]);
211 $head[$h][1] = $langs->trans(
"Referers");
212 $head[$h][2] =
'consumption';
219 $foundonexternalonlinesystem = 0;
220 $langs->load(
"bills");
222 $title = $langs->trans(
"PaymentModes");
230 include_once DOL_DOCUMENT_ROOT .
'/societe/class/societeaccount.class.php';
232 $stripecu = $societeaccount->getCustomerAccount(
$object->id,
'stripe', $servicestatus);
234 $foundonexternalonlinesystem++;
238 $sql =
"SELECT COUNT(n.rowid) as nb";
239 $sql .=
" FROM " . MAIN_DB_PREFIX .
"societe_rib as n";
240 $sql .=
" WHERE n.fk_soc = " . ((int)
$object->id);
242 $sql .=
" AND (n.stripe_card_ref IS NULL OR n.stripe_card_ref ='')";
244 $sql .=
" AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = " . ((int) $servicestatus) .
"))";
247 $resql = $db->query($sql);
249 $obj = $db->fetch_object($resql);
250 $nbBankAccount = $obj->nb;
252 dol_print_error($db);
257 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/paymentmodes.php', [
'socid' =>
$object->id]);
258 $head[$h][1] = $title;
259 if ($foundonexternalonlinesystem) {
260 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
261 } elseif ($nbBankAccount > 0) {
262 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbBankAccount .
'</span>';
264 $head[$h][2] =
'rib';
269 dol_syslog(
'Company::societe_prepare_head::isModEnabled::website', LOG_DEBUG);
270 $site_filter_list = array();
272 $site_filter_list[] =
'dolibarr_website';
275 $site_filter_list[] =
'dolibarr_portal';
278 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/website.php', [
'id' =>
$object->id]);
279 $head[$h][1] = $langs->trans(
"WebSiteAccounts");
281 $sql =
"SELECT COUNT(n.rowid) as nb";
282 $sql .=
" FROM " . MAIN_DB_PREFIX .
"societe_account as n";
283 $sql .=
" WHERE fk_soc = " . ((int)
$object->id);
284 $sql .=
" AND entity IN (" .
getEntity(
'thirdpartyaccount') .
")";
285 if (!empty($site_filter_list)) {
286 $sql .=
" AND n.site IN (" . $db->sanitize(
"'" . implode(
"','", $site_filter_list) .
"'", 1) .
")";
288 $resql = $db->query($sql);
290 $obj = $db->fetch_object($resql);
293 dol_print_error($db);
296 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
298 $head[$h][2] =
'website';
303 if ($user->hasRight(
'partnership',
'read')) {
304 $langs->load(
"partnership");
305 $nbPartnership = is_array(
$object->partnerships) ? count(
$object->partnerships) : 0;
306 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/partnership/partnership_list.php', [
'socid' =>
$object->id]);
307 $head[$h][1] = $langs->trans(
"Partnerships");
309 $sql =
"SELECT COUNT(n.rowid) as nb";
310 $sql .=
" FROM " . MAIN_DB_PREFIX .
"partnership as n";
311 $sql .=
" WHERE fk_soc = " . ((int)
$object->id);
312 $sql .=
" AND entity IN (" .
getEntity(
'partnership') .
")";
313 $resql = $db->query($sql);
315 $obj = $db->fetch_object($resql);
318 dol_print_error($db);
321 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
323 $head[$h][2] =
'partnerships';
324 if ($nbPartnership > 0) {
325 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbPartnership .
'</span>';
332 if (
isModEnabled(
'ticket') && $user->hasRight(
"ticket",
"read")) {
333 dol_syslog(
'Company::societe_prepare_head::isModEnabled::ticket', LOG_DEBUG);
337 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
338 $cachekey =
'count_ticket_thirdparty_' .
$object->id;
340 if (!is_null($nbticketretreived)) {
341 $nbTicket = $nbticketretreived;
344 $sql =
"SELECT COUNT(t.rowid) as nb";
345 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
346 $sql .=
" WHERE t.fk_soc = " . ((int)
$object->id);
347 $resql = $db->query($sql);
349 $obj = $db->fetch_object($resql);
350 $nbTicket = $obj->nb;
352 dol_print_error($db);
357 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/ticket/list.php', [
'socid' =>
$object->id]);
358 $head[$h][1] = $langs->trans(
"Tickets");
360 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbTicket .
'</span>';
362 $head[$h][2] =
'ticket';
367 dol_syslog(
'Company::societe_prepare_head::isModEnabled::eventorganization', LOG_DEBUG);
368 $langs->load(
'eventorganization');
369 if ($subtabs ==
'attendees') {
370 $url_for_list =
'/eventorganization/conferenceorboothattendee_list.php';
373 $url_for_list =
'/eventorganization/conferenceorbooth_list.php';
375 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT . $url_for_list, [
'thirdpartyid' =>
$object->id,
'withthirdparty' => 1]);
376 $head[$h][1] = $langs->trans(
"EventOrganization");
381 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
382 $cachekey =
'count_conferenceorbooth_thirdparty_'.$object->id;
384 if (!is_null($dataretrieved)) {
385 $nbConfOrBooth = $dataretrieved;
387 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
389 $result = $conforbooth->fetchAll(
'',
'', 0, 0,
'(t.fk_soc:=:'.((
int)
$object->id).
")");
391 if (!is_array($result) && $result < 0) {
392 setEventMessages($conforbooth->error, $conforbooth->errors,
'errors');
394 $nbConfOrBooth = count($result);
398 $cachekey =
'count_attendees_thirdparty_'.$object->id;
400 if (!is_null($dataretrieved)) {
401 $nbAttendees = $dataretrieved;
403 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
405 $result = $conforboothattendee->fetchAll(
'',
'', 0, 0,
'(t.fk_soc:=:'.((
int)
$object->id).
')');
407 if (!is_array($result) && $result < 0) {
408 setEventMessages($conforboothattendee->error, $conforboothattendee->errors,
'errors');
410 $nbAttendees = count($result);
414 if ($nbConfOrBooth > 0 || $nbAttendees > 0) {
415 $head[$h][1] .=
'<span class="badge marginleftonlyshort">';
416 $head[$h][1] .=
'<span title="'.dol_escape_htmltag($langs->trans(
"ConferenceOrBooth")).
'">'.$nbConfOrBooth.
'</span>';
417 $head[$h][1] .=
' + ';
418 $head[$h][1] .=
'<span title="'.dol_escape_htmltag($langs->trans(
"Attendees")).
'">'.$nbAttendees.
'</span>';
419 $head[$h][1] .=
'</span>';
422 $head[$h][2] =
'eventorganization';
432 if ($user->socid == 0) {
435 $langs->load(
'mails');
438 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
439 $cachekey =
'count_notifications_thirdparty_' .
$object->id;
441 if (!is_null($dataretrieved)) {
442 $nbNotif = $dataretrieved;
445 $sql =
"SELECT COUNT(n.rowid) as nb";
446 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_action_trigger as a,";
447 $sql .=
" " . MAIN_DB_PREFIX .
"notify_def as n,";
448 $sql .=
" " . MAIN_DB_PREFIX .
"socpeople as c";
449 $sql .=
" WHERE a.rowid = n.fk_action";
450 $sql .=
" AND c.rowid = n.fk_contact";
451 $sql .=
" AND c.fk_soc = " . ((int)
$object->id);
452 $resql = $db->query($sql);
454 $obj = $db->fetch_object($resql);
457 dol_print_error($db);
462 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/notify/card.php', [
'socid' =>
$object->id]);
463 $head[$h][1] = $langs->trans(
"Notifications");
465 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNotif .
'</span>';
467 $head[$h][2] =
'notify';
473 if (!empty(
$object->note_private)) {
476 if (!empty(
$object->note_public)) {
479 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/note.php', [
'id' =>
$object->id]);
480 $head[$h][1] = $langs->trans(
"Notes");
482 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbNote .
'</span>';
484 $head[$h][2] =
'note';
490 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
491 $cachekey =
'count_attached_thirdparty_' .
$object->id;
493 if (!is_null($dataretrieved)) {
494 $totalAttached = $dataretrieved;
496 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
497 require_once DOL_DOCUMENT_ROOT .
'/core/class/link.class.php';
499 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
501 $totalAttached = $nbFiles + $nbLinks;
505 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/document.php', [
'socid' =>
$object->id]);
506 $head[$h][1] = $langs->trans(
"Documents");
507 if (($totalAttached) > 0) {
508 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . ($totalAttached) .
'</span>';
510 $head[$h][2] =
'document';
514 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/societe/messaging.php', [
'socid' =>
$object->id]);
515 $head[$h][1] = $langs->trans(
"Events");
516 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
517 dol_syslog(
'Company::societe_prepare_head::isModEnabled::agenda', LOG_DEBUG);
520 require_once DOL_DOCUMENT_ROOT .
'/core/lib/memory.lib.php';
521 $cachekey =
'count_events_thirdparty_' .
$object->id;
523 if (!is_null($dataretrieved)) {
524 $nbEvent = $dataretrieved;
526 $sql =
"SELECT COUNT(id) as nb";
527 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm";
528 $sql .=
" WHERE fk_soc = " . ((int)
$object->id);
529 $sql .=
" AND entity IN (" .
getEntity(
'agenda') .
")";
530 $resql = $db->query($sql);
532 $obj = $db->fetch_object($resql);
535 dol_syslog(
'Failed to count actioncomm ' . $db->lasterror(), LOG_ERR);
541 $head[$h][1] .= $langs->trans(
"Agenda");
543 $head[$h][1] .=
'<span class="badge marginleftonlyshort">' . $nbEvent .
'</span>';
546 $head[$h][2] =
'agenda';
1291 global $user, $extrafields, $hookmanager;
1292 global $contextpage;
1294 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formcompany.class.php';
1296 $form =
new Form($db);
1298 $optioncss =
GETPOST(
'optioncss',
'alpha');
1299 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1300 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1303 $search_status =
GETPOST(
"search_status",
"intcomma");
1304 if ($search_status ==
'') {
1308 $search_rowid =
GETPOST(
"search_rowid",
"intcomma");
1309 $search_name =
GETPOST(
"search_name",
'alpha');
1310 $search_address =
GETPOST(
"search_address",
'alpha');
1311 $search_poste =
GETPOST(
"search_poste",
'alpha');
1312 $search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
1313 $search_roles =
GETPOST(
"search_roles",
'array');
1314 $search_birthday_dtstart =
GETPOST(
"search_birthday_dtstart",
'alpha');
1315 $search_birthday_dtend =
GETPOST(
"search_birthday_dtend",
'alpha');
1317 if ($search_birthday_dtstart !=
'' || $search_birthday_dtend !=
'') {
1323 $searchAddressPhoneDBFields = array(
1351 $sortfield =
"t.lastname";
1355 $user->fetch_clicktodial();
1359 $contactstatic =
new Contact($db);
1361 $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1363 $contactstatic->fields = array(
1364 'rowid' => array(
'type' =>
'integer',
'label' =>
"TechnicalID",
'enabled' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ?
'1' :
'0'),
'visible' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'position' => 1),
1365 'name' => array(
'type' =>
'varchar(128)',
'label' =>
'Name',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 10,
'searchall' => 1),
1366 'poste' => array(
'type' =>
'varchar(128)',
'label' =>
'PostOrFunction',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 2,
'index' => 1,
'position' => 20),
1367 'address' => array(
'type' =>
'varchar(128)',
'label' =>
'Address',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 3,
'index' => 1,
'position' => 30),
1368 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => (
string) ((
int) !
getDolGlobalBool(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'visible' => 3,
'position' => 35),
1369 'role' => array(
'type' =>
'checkbox',
'label' =>
'Role',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 4,
'index' => 1,
'position' => 40),
1370 'birthday' => array(
'type' =>
'date',
'label' =>
'Birthday',
'enabled' =>
'1',
'visible' => -1,
'notnull' => 0,
'position' => 45),
1371 'statut' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'default' =>
'0',
'index' => 1,
'position' => 50,
'arrayofkeyval' => array(0 => $contactstatic->LibStatut(0, 1), 1 => $contactstatic->LibStatut(1, 1))),
1375 $arrayfields = array(
1376 't.rowid' => array(
'label' =>
"TechnicalID",
'checked' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ?
'1' :
'0'),
'enabled' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ?
'1' :
'0'),
'position' => 1),
1377 't.name' => array(
'label' =>
"Name",
'checked' =>
'1',
'position' => 10),
1378 't.poste' => array(
'label' =>
"PostOrFunction",
'checked' =>
'1',
'position' => 20),
1379 't.address' => array(
'label' => (empty(
$conf->dol_optimize_smallscreen) ? $langs->trans(
"Address") .
' / ' . $langs->trans(
"Phone") .
' / ' . $langs->trans(
"Email") : $langs->trans(
"Address")),
'checked' =>
'1',
'position' => 30),
1380 't.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'position' => 35),
1381 'sc.role' => array(
'label' =>
"ContactByDefaultFor",
'checked' =>
'1',
'position' => 40),
1382 't.birthday' => array(
'label' =>
"Birthday",
'checked' =>
'0',
'position' => 45),
1383 't.statut' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 50,
'class' =>
'center'),
1384 'u.user' => array(
'label' =>
"DolibarrLogin",
'checked' =>
'1',
'position' => 50,
'class' =>
'center'),
1387 $extrafieldsobjectkey = $contactstatic->table_element;
1388 $extrafieldsobjectprefix =
'ef.';
1389 $extrafieldspositionoffset = 1000;
1390 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1394 foreach ($arrayfields as $key => $val) {
1395 $queryName =
'search_' . substr($key, 2);
1396 if (
GETPOST($queryName,
'alpha')) {
1397 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1400 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1403 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1405 $search_status =
'';
1407 $search_roles = array();
1408 $search_address =
'';
1410 $search_note_private =
'';
1411 $search_birthday_dtstart =
'';
1412 $search_birthday_dtend =
'';
1414 $search_array_options = array();
1416 foreach ($contactstatic->fields as $key => $val) {
1421 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1424 $newcardbutton =
'';
1425 $parameters = array(
'socid' =>
$object->id);
1426 $reshook = $hookmanager->executeHooks(
'printNewCardButton', $parameters,
$object);
1427 if (empty($reshook)) {
1428 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1429 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1430 $newcardbutton .=
dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT .
'/contact/card.php?socid=' .
$object->id .
'&action=create&backtopage=' . urlencode($backtopage));
1433 $newcardbutton = $hookmanager->resPrint;
1438 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1441 print
'<form method="POST" id="searchFormList" action="' . $_SERVER[
"PHP_SELF"] .
'" name="formfilter">';
1442 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1443 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1444 print
'<input type="hidden" name="socid" value="' .
$object->id .
'">';
1445 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1446 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1447 print
'<input type="hidden" name="page" value="' . $page .
'">';
1449 $arrayofmassactions = array();
1452 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1453 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1454 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1455 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1457 print
'<div class="div-table-responsive">';
1458 print
"\n" .
'<table class="tagtable liste noborder">' .
"\n";
1460 $param =
"socid=" . urlencode((
string) (
$object->id));
1461 if ($search_rowid !=
'') {
1462 $param .=
'&search_rowid=' . urlencode((
string) ($search_rowid));
1464 if ($search_status !=
'') {
1465 $param .=
'&search_status=' . urlencode((
string) ($search_status));
1467 if (count($search_roles) > 0) {
1468 $param .= implode(
'&search_roles[]=', $search_roles);
1470 if ($search_name !=
'') {
1471 $param .=
'&search_name=' . urlencode($search_name);
1473 if ($search_poste !=
'') {
1474 $param .=
'&search_poste=' . urlencode($search_poste);
1476 if ($search_address !=
'') {
1477 $param .=
'&search_address=' . urlencode($search_address);
1479 if ($search_note_private !=
'') {
1480 $param .=
'&search_note_private=' . urlencode($search_note_private);
1482 if ($search_birthday_dtstart !=
'') {
1483 $param .=
'&search_birthday_dtstart=' . urlencode((
string) $search_birthday_dtstart);
1485 if ($search_birthday_dtend !=
'') {
1486 $param .=
'&search_birthday_dtend=' . urlencode((
string) $search_birthday_dtend);
1488 if ($optioncss !=
'') {
1489 $param .=
'&optioncss=' . urlencode($optioncss);
1493 $extrafieldsobjectkey = $contactstatic->table_element;
1494 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_param.tpl.php';
1496 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1497 $sql .=
" t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo, t.fk_soc,";
1498 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1499 $sql .=
" t.note_private";
1500 $sql .=
" FROM " . MAIN_DB_PREFIX .
"socpeople as t";
1501 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1502 $sql .=
" WHERE t.fk_soc = " . ((int)
$object->id);
1503 $sql .=
" AND t.entity IN (" .
getEntity(
'socpeople') .
")";
1504 $sql .=
" AND ((t.fk_user_creat = " . ((int) $user->id) .
" AND t.priv = 1) OR t.priv = 0)";
1505 if ($search_rowid) {
1508 if ($search_status !=
'' && $search_status !=
'-1') {
1509 $sql .=
" AND t.statut = " . ((int) $search_status);
1512 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1514 if ($search_poste) {
1517 if ($search_address) {
1518 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1520 if ($search_note_private) {
1523 if ($search_birthday_dtstart !=
'') {
1524 $sql .=
" AND t.birthday >= '" . $db->idate($search_birthday_dtstart) .
"'";
1526 if ($search_birthday_dtend !=
'') {
1527 $sql .=
" AND t.birthday <= '" . $db->idate($search_birthday_dtend) .
"'";
1529 if (count($search_roles) > 0) {
1530 $sql .=
" AND t.rowid IN (SELECT sc.fk_socpeople FROM " . MAIN_DB_PREFIX .
"societe_contacts as sc WHERE sc.fk_c_type_contact IN (" . $db->sanitize(implode(
',', $search_roles)) .
"))";
1533 $extrafieldsobjectkey = $contactstatic->table_element;
1534 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_sql.tpl.php';
1536 $parameters = array(
'socid' =>
$object->id);
1537 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
1538 $sql .= $hookmanager->resPrint;
1539 if ($sortfield ==
"t.name") {
1540 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1542 $sql .=
" ORDER BY $sortfield $sortorder";
1545 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1546 $result = $db->query($sql);
1548 dol_print_error($db);
1551 $num = $db->num_rows($result);
1555 print
'<tr class="liste_titre">';
1557 if (
$conf->main_checkbox_left_column) {
1558 print
'<td class="liste_titre right">';
1559 print $form->showFilterButtons();
1562 foreach ($contactstatic->fields as $key => $val) {
1564 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1565 $align .= ($align ?
' ' :
'') .
'center';
1567 if (in_array($val[
'type'], array(
'timestamp'))) {
1568 $align .= ($align ?
' ' :
'') .
'nowrap';
1570 if ($key ==
'status' || $key ==
'statut') {
1571 $align .= ($align ?
' ' :
'') .
'center';
1573 if (!empty($arrayfields[
't.' . $key][
'checked']) || !empty($arrayfields[
'sc.' . $key][
'checked'])) {
1574 print
'<td class="liste_titre' . ($align ?
' ' . $align :
'') .
'">';
1575 if (in_array($key, array(
'statut'))) {
1576 print $form->selectarray(
'search_status', array(
'-1' =>
'',
'0' => $contactstatic->LibStatut(0, 1),
'1' => $contactstatic->LibStatut(1, 1)), $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'onrightofpage');
1577 } elseif (in_array($key, array(
'role'))) {
1578 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1579 } elseif (in_array($key, array(
'birthday'))) {
1580 print
'<div class="nowrap">';
1581 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1583 print
'<div class="nowrap">';
1584 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1587 print
'<input type="text" class="flat maxwidth75" name="search_' . $key .
'" value="' . (!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'') .
'">';
1592 if ($showuserlogin) {
1593 print
'<td class="liste_titre"></td>';
1596 $extrafieldsobjectkey = $contactstatic->table_element;
1597 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_input.tpl.php';
1600 $parameters = array(
'arrayfields' => $arrayfields);
1601 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1602 print $hookmanager->resPrint;
1604 if (!
$conf->main_checkbox_left_column) {
1605 print
'<td class="liste_titre right">';
1606 print $form->showFilterButtons();
1609 print
'</tr>' .
"\n";
1614 print
'<tr class="liste_titre">';
1616 if (
$conf->main_checkbox_left_column) {
1617 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1619 foreach ($contactstatic->fields as $key => $val) {
1621 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1622 $align .= ($align ?
' ' :
'') .
'center';
1624 if (in_array($val[
'type'], array(
'timestamp'))) {
1625 $align .= ($align ?
' ' :
'') .
'nowrap';
1627 if ($key ==
'status' || $key ==
'statut') {
1628 $align .= ($align ?
' ' :
'') .
'center';
1630 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
1631 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.' . $key,
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1633 if ($key ==
'role') {
1634 $align .= ($align ?
' ' :
'') .
'left';
1636 if (!empty($arrayfields[
'sc.' . $key][
'checked'])) {
1637 print
getTitleFieldOfList($arrayfields[
'sc.' . $key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1640 if ($showuserlogin) {
1641 print
'<th class="wrapcolumntitle liste_titre">' . $langs->trans(
"DolibarrLogin") .
'</th>';
1644 $extrafieldsobjectkey = $contactstatic->table_element;
1645 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_title.tpl.php';
1647 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1648 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
1649 print $hookmanager->resPrint;
1651 if (!
$conf->main_checkbox_left_column) {
1652 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1654 print
'</tr>' .
"\n";
1658 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1662 $obj = $db->fetch_object($result);
1664 $contactstatic->id = $obj->rowid;
1665 $contactstatic->ref = $obj->rowid;
1666 $contactstatic->status = $obj->statut;
1667 $contactstatic->statut = $obj->statut;
1668 $contactstatic->lastname = $obj->lastname;
1669 $contactstatic->firstname = $obj->firstname;
1670 $contactstatic->civility_id = $obj->civility_id;
1671 $contactstatic->civility_code = $obj->civility_id;
1672 $contactstatic->poste = $obj->poste;
1673 $contactstatic->address = $obj->address;
1674 $contactstatic->zip = $obj->zip;
1675 $contactstatic->town = $obj->town;
1676 $contactstatic->phone_pro = $obj->phone_pro;
1677 $contactstatic->phone_mobile = $obj->phone_mobile;
1678 $contactstatic->phone_perso = $obj->phone_perso;
1679 $contactstatic->email = $obj->email;
1680 $contactstatic->socialnetworks = $obj->socialnetworks;
1681 $contactstatic->photo = $obj->photo;
1682 $contactstatic->fk_soc = $obj->fk_soc;
1683 $contactstatic->entity = $obj->entity;
1685 $country_code =
getCountry($obj->country_id,
'2');
1686 $contactstatic->country_code = $country_code;
1688 $contactstatic->setGenderFromCivility();
1689 $contactstatic->fetch_optionals();
1691 $resultRole = $contactstatic->fetchRoles();
1692 if ($resultRole < 0) {
1693 setEventMessages(
null, $contactstatic->errors,
'errors');
1696 if (is_array($contactstatic->array_options)) {
1697 foreach ($contactstatic->array_options as $key => $val) {
1702 print
'<tr class="oddeven">';
1705 if (
$conf->main_checkbox_left_column) {
1706 print
'<td class="nowrap center">';
1709 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1710 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1711 print img_object($langs->trans(
"Event"),
"action");
1712 print
'</a> ';
1716 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1717 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' .
newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1723 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1724 print
'<a class="marginleftonly right" href="' . DOL_URL_ROOT .
'/societe/contact.php?action=delete&token=' .
newToken() .
'&id=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1733 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1735 print $contactstatic->id;
1740 if (!empty($arrayfields[
't.name'][
'checked'])) {
1741 print
'<td class="tdoverflowmax150">';
1742 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0,
'user');
1743 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage=' . urlencode($backtopage));
1748 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1749 print
'<td class="tdoverflowmax100" title="' .
dol_escape_htmltag($obj->poste) .
'">';
1757 if (!empty($arrayfields[
't.address'][
'checked'])) {
1758 $addresstoshow = $contactstatic->getBannerAddress(
'contact',
$object);
1759 print
'<td class="tdoverflowmax150 classfortooltip" title="'.dolPrintHTMLForAttribute($addresstoshow).
'">';
1760 print $addresstoshow;
1765 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1766 print
'<td class="center">';
1767 print dolPrintHTML($obj->note_private);
1772 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1773 print
'<td class="tdoverflowmax150">';
1774 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1779 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1780 print
'<td class="nowraponall">';
1786 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1787 print
'<td class="center">' . $contactstatic->getLibStatut(5) .
'</td>';
1790 if ($showuserlogin) {
1791 print
'<td class="tdoverflowmax125">';
1792 $tmpuser =
new User($db);
1794 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1795 if ($resfetch > 0) {
1796 print $tmpuser->getNomUrl(-1,
'', 0, 0, 24, 1);
1802 $extrafieldsobjectkey = $contactstatic->table_element;
1803 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_print_fields.tpl.php';
1806 if (!
$conf->main_checkbox_left_column) {
1807 print
'<td class="nowrap center">';
1810 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1811 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1812 print img_object($langs->trans(
"Event"),
"action");
1813 print
'</a> ';
1817 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1818 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' .
newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1824 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1825 print
'<a class="marginleftonly right" href="' . DOL_URL_ROOT .
'/societe/contact.php?action=delete&token=' .
newToken() .
'&id=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1838 $colspan = 1 + ($showuserlogin ? 1 : 0);
1839 foreach ($arrayfields as $key => $val) {
1840 if (!empty($val[
'checked'])) {
1844 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
1847 $colspan = 1 + ($showuserlogin ? 1 : 0);
1848 foreach ($arrayfields as $key => $val) {
1849 if (!empty($val[
'checked'])) {
1853 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
1855 print
"\n</table>\n";
1858 print
'</form>' .
"\n";
1906function show_actions_done(
$conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC',
$module =
'')
1908 global $hookmanager, $user;
1911 global $param, $massactionbutton;
1913 $start_year =
GETPOSTINT(
'dateevent_startyear');
1914 $start_month =
GETPOSTINT(
'dateevent_startmonth');
1915 $start_day =
GETPOSTINT(
'dateevent_startday');
1917 $end_month =
GETPOSTINT(
'dateevent_endmonth');
1922 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1923 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1925 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1926 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1928 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1932 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
1935 if (!is_object($filterobj) && !is_object($objcon)) {
1936 dol_print_error(
null,
'BadParameter');
1945 $sortfield_list = explode(
',', $sortfield);
1946 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1947 $sortfield_new_list = array();
1948 foreach ($sortfield_list as $sortfield_value) {
1949 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1951 $sortfield_new = implode(
',', $sortfield_new_list);
1953 $complete = (string) (!empty($filters[
'search_complete']) ? $filters[
'search_complete'] :
'');
1954 $percent = $complete !==
'' ? $complete : -1;
1955 if ((
string) $complete ==
'0') {
1957 } elseif ((
int) $complete == 100) {
1965 $hookmanager->initHooks(array(
'agendadao'));
1967 $sql =
"SELECT a.id, a.label as label,";
1968 $sql .=
" a.datep as dp,";
1969 $sql .=
" a.datep2 as dp2,";
1970 $sql .=
" a.percent as percent, 'action' as type,";
1971 $sql .=
" a.fk_element, a.elementtype,";
1972 $sql .=
" a.fk_contact,";
1973 $sql .=
" a.code, a.fulldayevent,";
1974 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1975 $sql .=
" u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
1976 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1977 $sql .=
", sp.lastname, sp.firstname";
1978 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1980 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1982 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1983 $sql .=
", m.lastname, m.firstname";
1984 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1986 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1988 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1990 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1992 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1994 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Holiday') {
1996 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
1998 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1999 if (!empty($filterobj->fields[
'ref'])) {
2001 } elseif (!empty($filterobj->fields[
'label'])) {
2002 $sql .=
", o.label";
2007 if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
2010 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2013 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2014 $filters[
'search_filtert'] = (string) $user->id;
2018 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2019 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
2020 if (!empty($hookmanager->resPrint)) {
2021 $sql .= $hookmanager->resPrint;
2024 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm as a";
2026 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"user as u on u.rowid = a.fk_user_action";
2028 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"c_actioncomm as c ON a.fk_action = c.id";
2033 $force_filter_contact =
false;
2034 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2035 $force_filter_contact =
true;
2037 if (is_object($objcon) && $objcon->id > 0) {
2038 $force_filter_contact =
true;
2042 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2043 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
2044 if (!empty($hookmanager->resPrint)) {
2045 $sql .= $hookmanager->resPrint;
2047 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
2048 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople as sp ON a.fk_contact = sp.rowid";
2049 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2050 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"element_resources as er";
2051 $sql .=
" ON er.resource_type = 'dolresource'";
2052 $sql .=
" AND er.element_type = 'action'";
2053 $sql .=
" AND er.element_id = a.id";
2054 $sql .=
" AND er.resource_id = " . ((int) $filterobj->id);
2055 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
2057 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2058 $sql .=
", " . MAIN_DB_PREFIX .
"adherent as m";
2059 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2060 $sql .=
", " . MAIN_DB_PREFIX .
"commande_fournisseur as o";
2061 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2062 $sql .=
", " . MAIN_DB_PREFIX .
"product as o";
2063 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2064 $sql .=
", " . MAIN_DB_PREFIX .
"ticket as o";
2065 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2066 $sql .=
", " . MAIN_DB_PREFIX .
"bom_bom as o";
2067 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2068 $sql .=
", " . MAIN_DB_PREFIX .
"contrat as o";
2069 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Holiday') {
2070 $sql .=
", " . MAIN_DB_PREFIX .
"holiday as o";
2071 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2072 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"expedition as s ON a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2073 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Propal') {
2074 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"propal as o ON a.fk_element = o.rowid AND a.elementtype = 'propal'";
2076 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2077 && ((!empty($filterobj->fields[
'ref']) && is_array($filterobj->fields[
'ref'])) || (!empty($filterobj->fields[
'label']) && is_array($filterobj->fields[
'label'])) || (!empty($filterobj->fields[
'titre']) && is_array($filterobj->fields[
'titre'])))
2078 && $filterobj->table_element && $filterobj->element
2080 $sql .=
", " . MAIN_DB_PREFIX . $filterobj->table_element .
" as o";
2083 $sql .=
" WHERE a.entity IN (" .
getEntity(
'agenda') .
")";
2084 if (!$force_filter_contact) {
2085 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
2086 $sql .=
" AND a.fk_soc = " . ((int) $filterobj->id);
2087 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2089 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
2090 $sql .=
" AND a.fk_project = " . ((int) $filterobj->id);
2091 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2092 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
2093 if ($filterobj->id) {
2094 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2096 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
2097 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
2098 if ($filterobj->id) {
2099 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2101 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2102 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
2103 if ($filterobj->id) {
2104 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2106 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
2107 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
2108 if ($filterobj->id) {
2109 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2111 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
2112 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice_supplier'";
2113 if ($filterobj->id) {
2114 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2116 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2117 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
2118 if ($filterobj->id) {
2119 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2121 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2122 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
2123 if ($filterobj->id) {
2124 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2126 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2127 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
2128 if ($filterobj->id) {
2129 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2131 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2132 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
2133 if ($filterobj->id) {
2134 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2136 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Holiday') {
2137 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'holiday'";
2138 if ($filterobj->id) {
2139 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2141 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2142 $sql .=
" AND a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2143 if ($filterobj->id) {
2144 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2147 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2148 && ((!empty($filterobj->fields[
'ref']) && is_array($filterobj->fields[
'ref'])) || (!empty($filterobj->fields[
'label']) && is_array($filterobj->fields[
'label'])) || (!empty($filterobj->fields[
'titre']) && is_array($filterobj->fields[
'titre'])))
2149 && $filterobj->table_element && $filterobj->element
2152 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '" . $db->escape($filterobj->element. (
$module ?
"@" .
$module :
"")) .
"'";
2153 if ($filterobj->id) {
2154 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2156 } elseif (is_object($filterobj)) {
2157 return 'Bad value for $filterobj';
2160 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2161 $sql .=
" AND (u.rowid = " . ((int) $filterobj->id) .
' OR ';
2162 $sql .=
" EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2163 $sql .=
" AND r.element_type = '" . $db->escape($filterobj->table_element) .
"' AND r.fk_element = " . ((int) $filterobj->id) .
')';
2166 if (is_object($objcon) && $objcon->id > 0) {
2167 $sql .=
" AND EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2168 $sql .=
" AND r.element_type = '" . $db->escape($objcon->table_element) .
"' AND r.fk_element = " . ((int) $objcon->id) .
')';
2172 if (!empty($tms_start) && !empty($tms_end)) {
2173 $sql .=
" AND ((a.datep BETWEEN '" . $db->idate($tms_start) .
"' AND '" . $db->idate($tms_end) .
"') OR (a.datep2 BETWEEN '" . $db->idate($tms_start) .
"' AND '" . $db->idate($tms_end) .
"'))";
2174 } elseif (empty($tms_start) && !empty($tms_end)) {
2175 $sql .=
" AND ((a.datep <= '" . $db->idate($tms_end) .
"') OR (a.datep2 <= '" . $db->idate($tms_end) .
"'))";
2176 } elseif (!empty($tms_start) && empty($tms_end)) {
2177 $sql .=
" AND ((a.datep >= '" . $db->idate($tms_start) .
"') OR (a.datep2 >= '" . $db->idate($tms_start) .
"'))";
2180 if (is_array($actioncode) && !empty($actioncode)) {
2183 foreach ($actioncode as $key => $code) {
2184 if ((
string) $code ===
'-1' || (
string) $code ===
'') {
2190 if (!empty($code)) {
2199 } elseif (!empty($actioncode) && $actioncode !=
'-1') {
2206 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' =>
$module);
2207 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
2208 if (!empty($hookmanager->resPrint)) {
2209 $sql .= $hookmanager->resPrint;
2213 if (is_array($actioncode) && $objcon !==
null) {
2214 foreach ($actioncode as $code) {
2216 if (!empty($sql2)) {
2218 $sql = $sql .
" UNION " . $sql2;
2219 } elseif (empty($sql)) {
2225 } elseif ($objcon !==
null) {
2227 if (!empty($sql) && !empty($sql2)) {
2228 $sql = $sql .
" UNION " . $sql2;
2229 } elseif (empty($sql) && !empty($sql2)) {
2235 $MAXWITHOUTPAGINATION =
getDolGlobalInt(
'AGENDA_MAX_EVENTS_ON_PAGE_WITHOUT_PAGINATION', 100);
2241 $limit = $MAXWITHOUTPAGINATION;
2244 $sql .= $db->order($sortfield_new, $sortorder);
2246 $sql .= $db->plimit($limit + 1, $offset);
2249 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
2251 $resql = $db->query($sql);
2254 $num = $db->num_rows($resql);
2256 $imaxinloop = ($limit ? min($num, $limit) : $num);
2257 while ($i < $imaxinloop) {
2258 $obj = $db->fetch_object($resql);
2263 if ($obj->type ==
'action') {
2265 $contactaction->id = $obj->id;
2266 $result = $contactaction->fetchResources();
2268 dol_print_error($db);
2269 setEventMessage(
"company.lib::show_actions_done Error fetch resource",
'errors');
2275 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
2279 $histo[$numaction] = array(
2280 'type' => $obj->type,
2281 'tododone' => $tododone,
2282 'id' => (
int) $obj->id,
2283 'datestart' => $db->jdate($obj->dp),
2284 'dateend' => $db->jdate($obj->dp2),
2285 'fulldayevent' => (
int) $obj->fulldayevent,
2286 'note' => $obj->label,
2287 'percent' => (
int) $obj->percent,
2289 'userid' => (
int) $obj->user_id,
2290 'login' => $obj->user_login,
2291 'userfirstname' => $obj->user_firstname,
2292 'userlastname' => $obj->user_lastname,
2293 'userphoto' => $obj->user_photo,
2295 'contact_id' => (
int) $obj->fk_contact,
2296 'socpeopleassigned' => $contactaction->socpeopleassigned,
2297 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
2298 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
2299 'fk_element' => (int) $obj->fk_element,
2300 'elementtype' => $obj->elementtype,
2302 'code' => $obj->code,
2305 'acode' => $obj->acode,
2306 'alabel' => $obj->alabel,
2307 'libelle' => $obj->alabel,
2308 'apicto' => $obj->apicto
2311 $histo[$numaction] = array(
2312 'type' => $obj->type,
2313 'tododone' =>
'done',
2314 'id' => (
int) $obj->id,
2315 'datestart' => $db->jdate($obj->dp),
2316 'dateend' => $db->jdate($obj->dp2),
2317 'fulldayevent' => (
int) $obj->fulldayevent,
2318 'note' => $obj->label,
2319 'percent' => (
int) $obj->percent,
2321 'code' => $obj->code,
2324 'acode' => $obj->acode,
2326 'userid' => (
int) $obj->user_id,
2327 'login' => $obj->user_login,
2328 'userfirstname' => $obj->user_firstname,
2329 'userlastname' => $obj->user_lastname,
2330 'userphoto' => $obj->user_photo
2338 dol_print_error($db);
2342 '@phan-var-force array<int,array{userid:int,type:string,tododone:string,apicto:string,acode:string,alabel:string,note:string,id:int,percent:int<0,100>,datestart:int,dateend:int,fulldayevent:int,fk_element:string,elementtype:string,contact_id:int,lastname:string,firstname:string,contact_photo:string,socpeopleassigned:int[],login:string,userfirstname:string,userlastname:string,userphoto:string}> $histo';
2345 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
2347 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
2348 include_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
2349 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
2350 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
2355 $userstatic =
new User($db);
2356 $userlinkcache = array();
2357 $contactstatic =
new Contact($db);
2358 $elementlinkcache = array();
2360 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2361 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2363 $objcon && get_class($objcon) ==
'Contact' &&
2364 (is_null($filterobj) || get_class($filterobj) ==
'Societe')
2366 $out .=
'<input type="hidden" name="id" value="' . $objcon->id .
'" />';
2368 $out .=
'<input type="hidden" name="id" value="' . $filterobj->id .
'" />';
2370 if ($filterobj && get_class($filterobj) ==
'Societe') {
2371 $out .=
'<input type="hidden" name="socid" value="' . $filterobj->id .
'" />';
2373 $out .=
'<input type="hidden" name="userid" value="' . $filterobj->id .
'" />';
2378 $out .=
'<div class="div-table-responsive-no-min">';
2379 $out .=
'<table class="noborder centpercent">';
2381 $out .=
'<tr class="liste_titre_filter">';
2384 if (
$conf->main_checkbox_left_column) {
2385 $out .=
'<th class="liste_titre width50 middle">';
2386 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2387 $out .= $searchpicto;
2392 $out .=
'<td class="liste_titre"></td>';
2396 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="' . (isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'') .
'"></td>';
2398 $out .=
'<td class="liste_titre center">';
2399 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
2402 $out .=
'<td class="liste_titre">';
2403 $out .= $form->select_dolusers((isset($filters[
'search_filtert']) && $filters[
'search_filtert'] > 0 ? $filters[
'search_filtert'] :
''),
'search_filtert', 1,
null, 0,
'',
'',
'0', 0, 0,
'', 2,
'',
'minwidth100 maxwidth250 widthcentpercentminusx');
2406 $out .=
'<td class="liste_titre">';
2407 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'',
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, (
getDolGlobalString(
'AGENDA_USE_MULTISELECT_TYPE') ? 1 : 0), 1,
'selecttype combolargeelem minwidth75 maxwidth125', 1);
2410 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth200" name="search_agenda_label" value="' . $filters[
'search_agenda_label'] .
'"></td>';
2411 $out .=
'<td class="liste_titre"></td>';
2412 $out .=
'<td class="liste_titre"></td>';
2414 $out .=
'<td class="liste_titre parentonrightofpage">';
2415 $out .= $formactions->form_select_status_action(
'formaction', $percent, 1,
'search_complete', 1, 2,
'search_status width100 onrightofpage', 1);
2418 if (!
$conf->main_checkbox_left_column) {
2419 $out .=
'<td class="liste_titre" align="middle">';
2420 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2421 $out .= $searchpicto;
2426 $out .=
'<tr class="liste_titre">';
2428 if (
$conf->main_checkbox_left_column) {
2429 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2431 if ($donetodo && $filterobj !==
null) {
2433 if (get_class($filterobj) ==
'Societe') {
2434 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&socid=' . $filterobj->id .
'&status=done">';
2436 if (get_class($filterobj) ==
'User') {
2437 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&userid=' . $filterobj->id .
'&status=done">';
2439 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2440 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2441 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2443 if (get_class($filterobj) ==
'Societe') {
2446 if (get_class($filterobj) ==
'User') {
2451 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2452 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2455 $out .=
getTitleFieldOfList(
"Title", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2456 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2457 $out .=
getTitleFieldOfList(
"LinkedObject", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2458 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2460 if (!
$conf->main_checkbox_left_column) {
2461 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2465 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/cactioncomm.class.php';
2467 $arraylist = $caction->liste_array(1,
'code',
'', (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 0 : 1),
'', 1);
2469 foreach ($histo as $key => $value) {
2470 $actionstatic->fetch($histo[$key][
'id']);
2472 if (empty($actionstatic->code)) {
2473 $actionstatic->code = $histo[$key][
'acode'];
2475 $actionstatic->type_picto = $histo[$key][
'apicto'] ??
'';
2476 $actionstatic->type_code = $histo[$key][
'acode'];
2478 $out .=
'<tr class="oddeven">';
2481 if (
$conf->main_checkbox_left_column) {
2482 $out .=
'<td></td>';
2487 $out .=
'<td class="nowrap">';
2492 $out .=
'<td class="nowraponall">';
2493 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2494 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'">' . img_object($langs->trans(
"ShowEMailing"),
"email") .
' ';
2495 $out .= $histo[$key][
'id'];
2498 $out .= $actionstatic->getNomUrl(1, -1);
2503 $out .=
'<td class="center nowraponall nopaddingtopimp nopaddingbottomimp">';
2505 $out .=
dolOutputDates($histo[$key][
'datestart'], $histo[$key][
'dateend'], (
int) $histo[$key][
'fulldayevent'], 0,
'',
'tzuserrel', 1);
2509 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2512 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2515 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2518 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2522 $out .= img_warning($langs->trans(
"Late")) .
' ';
2527 $out .=
'<td class="tdoverflowmax125">';
2528 if ($histo[$key][
'userid'] > 0) {
2529 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2530 $link = $userlinkcache[$histo[$key][
'userid']];
2532 $userstatic->fetch($histo[$key][
'userid']);
2533 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2534 $userlinkcache[$histo[$key][
'userid']] = $link;
2544 $labelOfTypeToShow = $actionstatic->type_code;
2546 $code = $actionstatic->code;
2547 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labelOfTypeToShow])) {
2548 $labelOfTypeToShow =
'AC_OTH';
2550 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2551 $labelOfTypeToShow = $langs->trans(
"Message");
2553 if (!empty($arraylist[$labelOfTypeToShow])) {
2554 $labelOfTypeToShow = $arraylist[$labelOfTypeToShow];
2555 } elseif ($actionstatic->type_code ==
'AC_EMAILING') {
2556 $langs->load(
"mails");
2557 $labelOfTypeToShow = $langs->trans(
"Emailing");
2559 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labelOfTypeToShow && !empty($arraylist[$actionstatic->code])) {
2560 $labelOfTypeToShow .=
' - ' . $arraylist[$actionstatic->code];
2564 $labelOfTypeToShowLong = $labelOfTypeToShow;
2565 if ($actionstatic->type_code ==
'AC_OTH_AUTO') {
2566 $labelOfTypeToShowLong .=
' (auto)';
2569 $out .=
'<td class="tdoverflowmax125" title="' . $labelOfTypeToShowLong .
'">';
2571 $out .= $actionstatic->getTypePicto();
2572 $out .= $labelOfTypeToShow;
2573 if (preg_match(
'/PRIVATE/', $actionstatic->code)) {
2574 $out .=
' ' . img_picto($langs->trans(
"Private"),
'lock',
'class="valignmiddle"');
2579 $out .=
'<td class="tdoverflowmax300"';
2580 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2581 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2583 $label = $histo[$key][
'note'];
2584 $actionstatic->id = $histo[$key][
'id'];
2586 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2589 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2590 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2591 $label = ($transcode !=
"Action" . $histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2592 $label .=
' - ' . $histo[$key][
'note'];
2593 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'"';
2595 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2602 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2603 $out .=
'<td class="valignmiddle">';
2605 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2606 $result = $contact->fetch($cid);
2609 dol_print_error($db, $contact->error);
2610 } elseif ($result > 0) {
2611 if (count($histo[$key][
'socpeopleassigned']) > 1) {
2612 $out .= $contact->getNomUrl(-2,
'', 0,
'', -1, 0,
'paddingright');
2614 $out .= $contact->getNomUrl(-3,
'', 0,
'', -1, 0,
'paddingright');
2615 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2616 if (!empty($contact->phone_pro)) {
2624 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2625 $contactstatic->lastname = $histo[$key][
'lastname'];
2626 $contactstatic->firstname = $histo[$key][
'firstname'];
2627 $contactstatic->id = $histo[$key][
'contact_id'];
2628 $contactstatic->photo = $histo[$key][
'contact_photo'];
2629 $out .=
'<td width="120">' . $contactstatic->getNomUrl(-1,
'', 10) .
'</td>';
2631 $out .=
'<td> </td>';
2635 $out .=
'<td class="tdoverflowmax200 nowraponall">';
2636 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2637 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2638 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2640 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2641 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2643 $link =
dolGetElementUrl((
int) $histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2644 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2651 $out .=
'<td class="nowrap center">';
2652 $out .= $actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']);
2656 if (!
$conf->main_checkbox_left_column) {
2657 $out .=
'<td></td>';
2662 if (empty($histo)) {
2664 $out .=
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
2667 if ($num > $MAXWITHOUTPAGINATION) {
2668 $langs->load(
"errors");
2670 $out .=
'<tr><td class="center" colspan="' . $colspan .
'"><span class="opacitymedium">...' . $langs->trans(
"WarningTooManyDataPleaseUseMoreFilters", $MAXWITHOUTPAGINATION) .
'...</span></td></tr>';
2673 $out .=
"</table>\n";