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(
"ReferringItems");
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 $showuserlogin = (!empty($showuserlogin) || !empty($arrayfields[
'u.user'][
'checked'])) ? 1 : 0;
1455 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1456 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1458 print
'<div class="div-table-responsive">';
1459 print
"\n" .
'<table class="tagtable liste noborder">' .
"\n";
1461 $param =
"socid=" . urlencode((
string) (
$object->id));
1462 if ($search_rowid !=
'') {
1463 $param .=
'&search_rowid=' . urlencode((
string) ($search_rowid));
1465 if ($search_status !=
'') {
1466 $param .=
'&search_status=' . urlencode((
string) ($search_status));
1468 if (count($search_roles) > 0) {
1469 $param .= implode(
'&search_roles[]=', $search_roles);
1471 if ($search_name !=
'') {
1472 $param .=
'&search_name=' . urlencode($search_name);
1474 if ($search_poste !=
'') {
1475 $param .=
'&search_poste=' . urlencode($search_poste);
1477 if ($search_address !=
'') {
1478 $param .=
'&search_address=' . urlencode($search_address);
1480 if ($search_note_private !=
'') {
1481 $param .=
'&search_note_private=' . urlencode($search_note_private);
1483 if ($search_birthday_dtstart !=
'') {
1484 $param .=
'&search_birthday_dtstart=' . urlencode((
string) $search_birthday_dtstart);
1486 if ($search_birthday_dtend !=
'') {
1487 $param .=
'&search_birthday_dtend=' . urlencode((
string) $search_birthday_dtend);
1489 if ($optioncss !=
'') {
1490 $param .=
'&optioncss=' . urlencode($optioncss);
1494 $extrafieldsobjectkey = $contactstatic->table_element;
1495 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_param.tpl.php';
1497 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1498 $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,";
1499 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1500 $sql .=
" t.note_private";
1501 $sql .=
" FROM " . MAIN_DB_PREFIX .
"socpeople as t";
1502 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1503 $sql .=
" WHERE t.fk_soc = " . ((int)
$object->id);
1504 $sql .=
" AND t.entity IN (" .
getEntity(
'socpeople') .
")";
1505 $sql .=
" AND ((t.fk_user_creat = " . ((int) $user->id) .
" AND t.priv = 1) OR t.priv = 0)";
1506 if ($search_rowid) {
1509 if ($search_status !=
'' && $search_status !=
'-1') {
1510 $sql .=
" AND t.statut = " . ((int) $search_status);
1513 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1515 if ($search_poste) {
1518 if ($search_address) {
1519 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1521 if ($search_note_private) {
1524 if ($search_birthday_dtstart !=
'') {
1525 $sql .=
" AND t.birthday >= '" . $db->idate($search_birthday_dtstart) .
"'";
1527 if ($search_birthday_dtend !=
'') {
1528 $sql .=
" AND t.birthday <= '" . $db->idate($search_birthday_dtend) .
"'";
1530 if (count($search_roles) > 0) {
1531 $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)) .
"))";
1534 $extrafieldsobjectkey = $contactstatic->table_element;
1535 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_sql.tpl.php';
1537 $parameters = array(
'socid' =>
$object->id);
1538 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
1539 $sql .= $hookmanager->resPrint;
1540 if ($sortfield ==
"t.name") {
1541 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1543 $sql .=
" ORDER BY $sortfield $sortorder";
1546 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1547 $result = $db->query($sql);
1549 dol_print_error($db);
1552 $num = $db->num_rows($result);
1556 print
'<tr class="liste_titre">';
1558 if (
$conf->main_checkbox_left_column) {
1559 print
'<td class="liste_titre right">';
1560 print $form->showFilterButtons();
1563 foreach ($contactstatic->fields as $key => $val) {
1565 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1566 $align .= ($align ?
' ' :
'') .
'center';
1568 if (in_array($val[
'type'], array(
'timestamp'))) {
1569 $align .= ($align ?
' ' :
'') .
'nowrap';
1571 if ($key ==
'status' || $key ==
'statut') {
1572 $align .= ($align ?
' ' :
'') .
'center';
1574 if (!empty($arrayfields[
't.' . $key][
'checked']) || !empty($arrayfields[
'sc.' . $key][
'checked'])) {
1575 print
'<td class="liste_titre' . ($align ?
' ' . $align :
'') .
'">';
1576 if (in_array($key, array(
'statut'))) {
1577 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');
1578 } elseif (in_array($key, array(
'role'))) {
1579 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1580 } elseif (in_array($key, array(
'birthday'))) {
1581 print
'<div class="nowrap">';
1582 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1584 print
'<div class="nowrap">';
1585 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1588 print
'<input type="text" class="flat maxwidth75" name="search_' . $key .
'" value="' . (!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'') .
'">';
1593 if ($showuserlogin) {
1594 print
'<td class="liste_titre"></td>';
1597 $extrafieldsobjectkey = $contactstatic->table_element;
1598 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_input.tpl.php';
1601 $parameters = array(
'arrayfields' => $arrayfields);
1602 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1603 print $hookmanager->resPrint;
1605 if (!
$conf->main_checkbox_left_column) {
1606 print
'<td class="liste_titre right">';
1607 print $form->showFilterButtons();
1610 print
'</tr>' .
"\n";
1615 print
'<tr class="liste_titre">';
1617 if (
$conf->main_checkbox_left_column) {
1618 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1620 foreach ($contactstatic->fields as $key => $val) {
1622 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1623 $align .= ($align ?
' ' :
'') .
'center';
1625 if (in_array($val[
'type'], array(
'timestamp'))) {
1626 $align .= ($align ?
' ' :
'') .
'nowrap';
1628 if ($key ==
'status' || $key ==
'statut') {
1629 $align .= ($align ?
' ' :
'') .
'center';
1631 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
1632 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.' . $key,
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1634 if ($key ==
'role') {
1635 $align .= ($align ?
' ' :
'') .
'left';
1637 if (!empty($arrayfields[
'sc.' . $key][
'checked'])) {
1638 print
getTitleFieldOfList($arrayfields[
'sc.' . $key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1641 if ($showuserlogin) {
1642 print
'<th class="wrapcolumntitle liste_titre">' . $langs->trans(
"DolibarrLogin") .
'</th>';
1645 $extrafieldsobjectkey = $contactstatic->table_element;
1646 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_title.tpl.php';
1648 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1649 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
1650 print $hookmanager->resPrint;
1652 if (!
$conf->main_checkbox_left_column) {
1653 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1655 print
'</tr>' .
"\n";
1659 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1663 $obj = $db->fetch_object($result);
1665 $contactstatic->id = $obj->rowid;
1666 $contactstatic->ref = $obj->rowid;
1667 $contactstatic->status = $obj->statut;
1668 $contactstatic->statut = $obj->statut;
1669 $contactstatic->lastname = $obj->lastname;
1670 $contactstatic->firstname = $obj->firstname;
1671 $contactstatic->civility_id = $obj->civility_id;
1672 $contactstatic->civility_code = $obj->civility_id;
1673 $contactstatic->poste = $obj->poste;
1674 $contactstatic->address = $obj->address;
1675 $contactstatic->zip = $obj->zip;
1676 $contactstatic->town = $obj->town;
1677 $contactstatic->phone_pro = $obj->phone_pro;
1678 $contactstatic->phone_mobile = $obj->phone_mobile;
1679 $contactstatic->phone_perso = $obj->phone_perso;
1680 $contactstatic->email = $obj->email;
1681 $contactstatic->socialnetworks = $obj->socialnetworks;
1682 $contactstatic->photo = $obj->photo;
1683 $contactstatic->fk_soc = $obj->fk_soc;
1684 $contactstatic->entity = $obj->entity;
1686 $country_code =
getCountry($obj->country_id,
'2');
1687 $contactstatic->country_code = $country_code;
1689 $contactstatic->setGenderFromCivility();
1690 $contactstatic->fetch_optionals();
1692 $resultRole = $contactstatic->fetchRoles();
1693 if ($resultRole < 0) {
1694 setEventMessages(
null, $contactstatic->errors,
'errors');
1697 if (is_array($contactstatic->array_options)) {
1698 foreach ($contactstatic->array_options as $key => $val) {
1703 print
'<tr class="oddeven">';
1706 if (
$conf->main_checkbox_left_column) {
1707 print
'<td class="nowrap center">';
1710 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1711 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1712 print img_object($langs->trans(
"Event"),
"action");
1713 print
'</a> ';
1717 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1718 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' .
newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1724 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1725 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) .
'">';
1734 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1736 print $contactstatic->id;
1741 if (!empty($arrayfields[
't.name'][
'checked'])) {
1742 print
'<td class="tdoverflowmax150">';
1743 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0,
'user');
1744 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage=' . urlencode($backtopage));
1749 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1750 print
'<td class="tdoverflowmax100" title="' .
dol_escape_htmltag($obj->poste) .
'">';
1758 if (!empty($arrayfields[
't.address'][
'checked'])) {
1759 $addresstoshow = $contactstatic->getBannerAddress(
'contact',
$object);
1760 print
'<td class="tdoverflowmax150 classfortooltip" title="'.dolPrintHTMLForAttribute($addresstoshow).
'">';
1761 print $addresstoshow;
1766 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1767 print
'<td class="center">';
1768 print dolPrintHTML($obj->note_private);
1773 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1774 print
'<td class="tdoverflowmax150">';
1775 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1780 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1781 print
'<td class="nowraponall">';
1787 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1788 print
'<td class="center">' . $contactstatic->getLibStatut(5) .
'</td>';
1791 if ($showuserlogin) {
1792 print
'<td class="tdoverflowmax125">';
1793 $tmpuser =
new User($db);
1795 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1796 if ($resfetch > 0) {
1797 print $tmpuser->getNomUrl(-1,
'', 0, 0, 24, 1);
1803 $extrafieldsobjectkey = $contactstatic->table_element;
1804 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_print_fields.tpl.php';
1807 if (!
$conf->main_checkbox_left_column) {
1808 print
'<td class="nowrap center">';
1811 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1812 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1813 print img_object($langs->trans(
"Event"),
"action");
1814 print
'</a> ';
1818 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1819 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' .
newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1825 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1826 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) .
'">';
1839 $colspan = 1 + ($showuserlogin ? 1 : 0);
1840 foreach ($arrayfields as $key => $val) {
1841 if (!empty($val[
'checked'])) {
1845 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
1848 $colspan = 1 + ($showuserlogin ? 1 : 0);
1849 foreach ($arrayfields as $key => $val) {
1850 if (!empty($val[
'checked'])) {
1854 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
1856 print
"\n</table>\n";
1859 print
'</form>' .
"\n";
1907function show_actions_done(
$conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC',
$module =
'')
1909 global $hookmanager, $user;
1912 global $param, $massactionbutton;
1914 $start_year =
GETPOSTINT(
'dateevent_startyear');
1915 $start_month =
GETPOSTINT(
'dateevent_startmonth');
1916 $start_day =
GETPOSTINT(
'dateevent_startday');
1918 $end_month =
GETPOSTINT(
'dateevent_endmonth');
1923 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1924 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1926 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1927 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1929 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1933 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
1936 if (!is_object($filterobj) && !is_object($objcon)) {
1937 dol_print_error(
null,
'BadParameter');
1946 $sortfield_list = explode(
',', $sortfield);
1947 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1948 $sortfield_new_list = array();
1949 foreach ($sortfield_list as $sortfield_value) {
1950 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1952 $sortfield_new = implode(
',', $sortfield_new_list);
1954 $complete = (string) (!empty($filters[
'search_complete']) ? $filters[
'search_complete'] :
'');
1955 $percent = $complete !==
'' ? $complete : -1;
1956 if ((
string) $complete ==
'0') {
1958 } elseif ((
int) $complete == 100) {
1966 $hookmanager->initHooks(array(
'agendadao'));
1968 $sql =
"SELECT a.id, a.label as label,";
1969 $sql .=
" a.datep as dp,";
1970 $sql .=
" a.datep2 as dp2,";
1971 $sql .=
" a.percent as percent, 'action' as type,";
1972 $sql .=
" a.fk_element, a.elementtype,";
1973 $sql .=
" a.fk_contact,";
1974 $sql .=
" a.code, a.fulldayevent,";
1975 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1976 $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";
1977 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1978 $sql .=
", sp.lastname, sp.firstname";
1979 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1981 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1983 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1984 $sql .=
", m.lastname, m.firstname";
1985 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1987 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1989 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1991 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1993 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1995 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Holiday') {
1997 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
1999 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
2000 if (!empty($filterobj->fields[
'ref'])) {
2002 } elseif (!empty($filterobj->fields[
'label'])) {
2003 $sql .=
", o.label";
2008 if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
2011 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2014 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2015 $filters[
'search_filtert'] = (string) $user->id;
2019 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2020 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
2021 if (!empty($hookmanager->resPrint)) {
2022 $sql .= $hookmanager->resPrint;
2025 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm as a";
2027 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"user as u on u.rowid = a.fk_user_action";
2029 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"c_actioncomm as c ON a.fk_action = c.id";
2034 $force_filter_contact =
false;
2035 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2036 $force_filter_contact =
true;
2038 if (is_object($objcon) && $objcon->id > 0) {
2039 $force_filter_contact =
true;
2043 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2044 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
2045 if (!empty($hookmanager->resPrint)) {
2046 $sql .= $hookmanager->resPrint;
2048 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
2049 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople as sp ON a.fk_contact = sp.rowid";
2050 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2051 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"element_resources as er";
2052 $sql .=
" ON er.resource_type = 'dolresource'";
2053 $sql .=
" AND er.element_type = 'action'";
2054 $sql .=
" AND er.element_id = a.id";
2055 $sql .=
" AND er.resource_id = " . ((int) $filterobj->id);
2056 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
2058 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2059 $sql .=
", " . MAIN_DB_PREFIX .
"adherent as m";
2060 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2061 $sql .=
", " . MAIN_DB_PREFIX .
"commande_fournisseur as o";
2062 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2063 $sql .=
", " . MAIN_DB_PREFIX .
"product as o";
2064 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2065 $sql .=
", " . MAIN_DB_PREFIX .
"ticket as o";
2066 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2067 $sql .=
", " . MAIN_DB_PREFIX .
"bom_bom as o";
2068 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2069 $sql .=
", " . MAIN_DB_PREFIX .
"contrat as o";
2070 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Holiday') {
2071 $sql .=
", " . MAIN_DB_PREFIX .
"holiday as o";
2072 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2073 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"expedition as s ON a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2074 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Propal') {
2075 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"propal as o ON a.fk_element = o.rowid AND a.elementtype = 'propal'";
2077 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2078 && ((!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'])))
2079 && $filterobj->table_element && $filterobj->element
2081 $sql .=
", " . MAIN_DB_PREFIX . $filterobj->table_element .
" as o";
2084 $sql .=
" WHERE a.entity IN (" .
getEntity(
'agenda') .
")";
2085 if (!$force_filter_contact) {
2086 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
2087 $sql .=
" AND a.fk_soc = " . ((int) $filterobj->id);
2088 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2090 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
2091 $sql .=
" AND a.fk_project = " . ((int) $filterobj->id);
2092 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2093 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
2094 if ($filterobj->id) {
2095 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2097 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
2098 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
2099 if ($filterobj->id) {
2100 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2102 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2103 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
2104 if ($filterobj->id) {
2105 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2107 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
2108 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
2109 if ($filterobj->id) {
2110 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2112 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
2113 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice_supplier'";
2114 if ($filterobj->id) {
2115 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2117 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2118 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
2119 if ($filterobj->id) {
2120 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2122 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2123 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
2124 if ($filterobj->id) {
2125 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2127 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2128 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
2129 if ($filterobj->id) {
2130 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2132 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2133 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
2134 if ($filterobj->id) {
2135 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2137 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Holiday') {
2138 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'holiday'";
2139 if ($filterobj->id) {
2140 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2142 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2143 $sql .=
" AND a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2144 if ($filterobj->id) {
2145 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2148 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2149 && ((!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'])))
2150 && $filterobj->table_element && $filterobj->element
2153 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '" . $db->escape($filterobj->element. (
$module ?
"@" .
$module :
"")) .
"'";
2154 if ($filterobj->id) {
2155 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2157 } elseif (is_object($filterobj)) {
2158 return 'Bad value for $filterobj';
2161 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2162 $sql .=
" AND (u.rowid = " . ((int) $filterobj->id) .
' OR ';
2163 $sql .=
" EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2164 $sql .=
" AND r.element_type = '" . $db->escape($filterobj->table_element) .
"' AND r.fk_element = " . ((int) $filterobj->id) .
')';
2167 if (is_object($objcon) && $objcon->id > 0) {
2168 $sql .=
" AND EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2169 $sql .=
" AND r.element_type = '" . $db->escape($objcon->table_element) .
"' AND r.fk_element = " . ((int) $objcon->id) .
')';
2173 if (!empty($tms_start) && !empty($tms_end)) {
2174 $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) .
"'))";
2175 } elseif (empty($tms_start) && !empty($tms_end)) {
2176 $sql .=
" AND ((a.datep <= '" . $db->idate($tms_end) .
"') OR (a.datep2 <= '" . $db->idate($tms_end) .
"'))";
2177 } elseif (!empty($tms_start) && empty($tms_end)) {
2178 $sql .=
" AND ((a.datep >= '" . $db->idate($tms_start) .
"') OR (a.datep2 >= '" . $db->idate($tms_start) .
"'))";
2181 if (is_array($actioncode) && !empty($actioncode)) {
2184 foreach ($actioncode as $key => $code) {
2185 if ((
string) $code ===
'-1' || (
string) $code ===
'') {
2191 if (!empty($code)) {
2200 } elseif (!empty($actioncode) && $actioncode !=
'-1') {
2207 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' =>
$module);
2208 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
2209 if (!empty($hookmanager->resPrint)) {
2210 $sql .= $hookmanager->resPrint;
2214 if (is_array($actioncode) && $objcon !==
null) {
2215 foreach ($actioncode as $code) {
2217 if (!empty($sql2)) {
2219 $sql = $sql .
" UNION " . $sql2;
2220 } elseif (empty($sql)) {
2226 } elseif ($objcon !==
null) {
2228 if (!empty($sql) && !empty($sql2)) {
2229 $sql = $sql .
" UNION " . $sql2;
2230 } elseif (empty($sql) && !empty($sql2)) {
2236 $MAXWITHOUTPAGINATION =
getDolGlobalInt(
'AGENDA_MAX_EVENTS_ON_PAGE_WITHOUT_PAGINATION', 100);
2242 $limit = $MAXWITHOUTPAGINATION;
2245 $sql .= $db->order($sortfield_new, $sortorder);
2247 $sql .= $db->plimit($limit + 1, $offset);
2250 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
2252 $resql = $db->query($sql);
2255 $num = $db->num_rows($resql);
2257 $imaxinloop = ($limit ? min($num, $limit) : $num);
2258 while ($i < $imaxinloop) {
2259 $obj = $db->fetch_object($resql);
2264 if ($obj->type ==
'action') {
2266 $contactaction->id = $obj->id;
2267 $result = $contactaction->fetchResources();
2269 dol_print_error($db);
2270 setEventMessage(
"company.lib::show_actions_done Error fetch resource",
'errors');
2276 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
2280 $histo[$numaction] = array(
2281 'type' => $obj->type,
2282 'tododone' => $tododone,
2283 'id' => (
int) $obj->id,
2284 'datestart' => $db->jdate($obj->dp),
2285 'dateend' => $db->jdate($obj->dp2),
2286 'fulldayevent' => (
int) $obj->fulldayevent,
2287 'note' => $obj->label,
2288 'percent' => (
int) $obj->percent,
2290 'userid' => (
int) $obj->user_id,
2291 'login' => $obj->user_login,
2292 'userfirstname' => $obj->user_firstname,
2293 'userlastname' => $obj->user_lastname,
2294 'userphoto' => $obj->user_photo,
2296 'contact_id' => (
int) $obj->fk_contact,
2297 'socpeopleassigned' => $contactaction->socpeopleassigned,
2298 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
2299 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
2300 'fk_element' => (int) $obj->fk_element,
2301 'elementtype' => $obj->elementtype,
2303 'code' => $obj->code,
2306 'acode' => $obj->acode,
2307 'alabel' => $obj->alabel,
2308 'libelle' => $obj->alabel,
2309 'apicto' => $obj->apicto
2312 $histo[$numaction] = array(
2313 'type' => $obj->type,
2314 'tododone' =>
'done',
2315 'id' => (
int) $obj->id,
2316 'datestart' => $db->jdate($obj->dp),
2317 'dateend' => $db->jdate($obj->dp2),
2318 'fulldayevent' => (
int) $obj->fulldayevent,
2319 'note' => $obj->label,
2320 'percent' => (
int) $obj->percent,
2322 'code' => $obj->code,
2325 'acode' => $obj->acode,
2327 'userid' => (
int) $obj->user_id,
2328 'login' => $obj->user_login,
2329 'userfirstname' => $obj->user_firstname,
2330 'userlastname' => $obj->user_lastname,
2331 'userphoto' => $obj->user_photo
2339 dol_print_error($db);
2343 '@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';
2346 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
2348 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
2349 include_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
2350 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
2351 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
2356 $userstatic =
new User($db);
2357 $userlinkcache = array();
2358 $contactstatic =
new Contact($db);
2359 $elementlinkcache = array();
2361 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" spellcheck="false">';
2362 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2364 $objcon && get_class($objcon) ==
'Contact' &&
2365 (is_null($filterobj) || get_class($filterobj) ==
'Societe')
2367 $out .=
'<input type="hidden" name="id" value="' . $objcon->id .
'" />';
2369 $out .=
'<input type="hidden" name="id" value="' . $filterobj->id .
'" />';
2371 if ($filterobj && get_class($filterobj) ==
'Societe') {
2372 $out .=
'<input type="hidden" name="socid" value="' . $filterobj->id .
'" />';
2374 $out .=
'<input type="hidden" name="userid" value="' . $filterobj->id .
'" />';
2379 $out .=
'<div class="div-table-responsive-no-min">';
2380 $out .=
'<table class="noborder centpercent">';
2382 $out .=
'<tr class="liste_titre_filter">';
2385 if (
$conf->main_checkbox_left_column) {
2386 $out .=
'<th class="liste_titre width50 middle">';
2387 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2388 $out .= $searchpicto;
2393 $out .=
'<td class="liste_titre"></td>';
2397 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="' . (isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'') .
'"></td>';
2399 $out .=
'<td class="liste_titre center">';
2400 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
2403 $out .=
'<td class="liste_titre">';
2404 $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');
2407 $out .=
'<td class="liste_titre">';
2408 $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);
2411 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth200" name="search_agenda_label" value="' . $filters[
'search_agenda_label'] .
'"></td>';
2412 $out .=
'<td class="liste_titre"></td>';
2413 $out .=
'<td class="liste_titre"></td>';
2415 $out .=
'<td class="liste_titre parentonrightofpage">';
2416 $out .= $formactions->form_select_status_action(
'formaction', $percent, 1,
'search_complete', 1, 2,
'search_status width100 onrightofpage', 1);
2419 if (!
$conf->main_checkbox_left_column) {
2420 $out .=
'<td class="liste_titre" align="middle">';
2421 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2422 $out .= $searchpicto;
2427 $out .=
'<tr class="liste_titre">';
2429 if (
$conf->main_checkbox_left_column) {
2430 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2432 if ($donetodo && $filterobj !==
null) {
2434 if (get_class($filterobj) ==
'Societe') {
2435 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&socid=' . $filterobj->id .
'&status=done">';
2437 if (get_class($filterobj) ==
'User') {
2438 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&userid=' . $filterobj->id .
'&status=done">';
2440 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2441 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2442 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2444 if (get_class($filterobj) ==
'Societe') {
2447 if (get_class($filterobj) ==
'User') {
2452 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2453 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2456 $out .=
getTitleFieldOfList(
"Title", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2457 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2458 $out .=
getTitleFieldOfList(
"LinkedObject", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2459 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2461 if (!
$conf->main_checkbox_left_column) {
2462 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2466 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/cactioncomm.class.php';
2468 $arraylist = $caction->liste_array(1,
'code',
'', (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 0 : 1),
'', 1);
2470 foreach ($histo as $key => $value) {
2471 $actionstatic->fetch($histo[$key][
'id']);
2473 if (empty($actionstatic->code)) {
2474 $actionstatic->code = $histo[$key][
'acode'];
2476 $actionstatic->type_picto = $histo[$key][
'apicto'] ??
'';
2477 $actionstatic->type_code = $histo[$key][
'acode'];
2479 $out .=
'<tr class="oddeven">';
2482 if (
$conf->main_checkbox_left_column) {
2483 $out .=
'<td></td>';
2488 $out .=
'<td class="nowrap">';
2493 $out .=
'<td class="nowraponall">';
2494 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2495 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'">' . img_object($langs->trans(
"ShowEMailing"),
"email") .
' ';
2496 $out .= $histo[$key][
'id'];
2499 $out .= $actionstatic->getNomUrl(1, -1);
2504 $out .=
'<td class="center nowraponall nopaddingtopimp nopaddingbottomimp">';
2506 $out .=
dolOutputDates($histo[$key][
'datestart'], $histo[$key][
'dateend'], (
int) $histo[$key][
'fulldayevent'], 0,
'',
'tzuserrel', 1);
2510 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2513 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2516 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2519 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2523 $out .= img_warning($langs->trans(
"Late")) .
' ';
2528 $out .=
'<td class="tdoverflowmax125">';
2529 if ($histo[$key][
'userid'] > 0) {
2530 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2531 $link = $userlinkcache[$histo[$key][
'userid']];
2533 $userstatic->fetch($histo[$key][
'userid']);
2534 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2535 $userlinkcache[$histo[$key][
'userid']] = $link;
2545 $labelOfTypeToShow = $actionstatic->type_code;
2547 $code = $actionstatic->code;
2548 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labelOfTypeToShow])) {
2549 $labelOfTypeToShow =
'AC_OTH';
2551 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2552 $labelOfTypeToShow = $langs->trans(
"Message");
2554 if (!empty($arraylist[$labelOfTypeToShow])) {
2555 $labelOfTypeToShow = $arraylist[$labelOfTypeToShow];
2556 } elseif ($actionstatic->type_code ==
'AC_EMAILING') {
2557 $langs->load(
"mails");
2558 $labelOfTypeToShow = $langs->trans(
"Emailing");
2560 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labelOfTypeToShow && !empty($arraylist[$actionstatic->code])) {
2561 $labelOfTypeToShow .=
' - ' . $arraylist[$actionstatic->code];
2565 $labelOfTypeToShowLong = $labelOfTypeToShow;
2566 if ($actionstatic->type_code ==
'AC_OTH_AUTO') {
2567 $labelOfTypeToShowLong .=
' (auto)';
2570 $out .=
'<td class="tdoverflowmax125" title="' . $labelOfTypeToShowLong .
'">';
2572 $out .= $actionstatic->getTypePicto();
2573 $out .= $labelOfTypeToShow;
2574 if (preg_match(
'/PRIVATE/', $actionstatic->code)) {
2575 $out .=
' ' . img_picto($langs->trans(
"Private"),
'lock',
'class="valignmiddle"');
2580 $out .=
'<td class="tdoverflowmax300"';
2581 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2582 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2584 $label = $histo[$key][
'note'];
2585 $actionstatic->id = $histo[$key][
'id'];
2587 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2590 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2591 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2592 $label = ($transcode !=
"Action" . $histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2593 $label .=
' - ' . $histo[$key][
'note'];
2594 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'"';
2596 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2603 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2604 $out .=
'<td class="valignmiddle">';
2606 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2607 $result = $contact->fetch($cid);
2610 dol_print_error($db, $contact->error);
2611 } elseif ($result > 0) {
2612 if (count($histo[$key][
'socpeopleassigned']) > 1) {
2613 $out .= $contact->getNomUrl(-2,
'', 0,
'', -1, 0,
'paddingright');
2615 $out .= $contact->getNomUrl(-3,
'', 0,
'', -1, 0,
'paddingright');
2616 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2617 if (!empty($contact->phone_pro)) {
2625 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2626 $contactstatic->lastname = $histo[$key][
'lastname'];
2627 $contactstatic->firstname = $histo[$key][
'firstname'];
2628 $contactstatic->id = $histo[$key][
'contact_id'];
2629 $contactstatic->photo = $histo[$key][
'contact_photo'];
2630 $out .=
'<td width="120">' . $contactstatic->getNomUrl(-1,
'', 10) .
'</td>';
2632 $out .=
'<td> </td>';
2636 $out .=
'<td class="tdoverflowmax200 nowraponall">';
2637 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2638 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2639 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2641 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2642 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2644 $link =
dolGetElementUrl((
int) $histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2645 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2652 $out .=
'<td class="nowrap center">';
2653 $out .= $actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']);
2657 if (!
$conf->main_checkbox_left_column) {
2658 $out .=
'<td></td>';
2663 if (empty($histo)) {
2665 $out .=
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
2668 if ($num > $MAXWITHOUTPAGINATION) {
2669 $langs->load(
"errors");
2671 $out .=
'<tr><td class="center" colspan="' . $colspan .
'"><span class="opacitymedium">...' . $langs->trans(
"WarningTooManyDataPleaseUseMoreFilters", $MAXWITHOUTPAGINATION) .
'...</span></td></tr>';
2674 $out .=
"</table>\n";