46 dol_syslog(
'Company::societe_prepare_head', LOG_DEBUG);
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;
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;
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);
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);
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;
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) {
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);
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';
1284 global $user, $extrafields, $hookmanager;
1285 global $contextpage;
1287 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formcompany.class.php';
1291 $optioncss =
GETPOST(
'optioncss',
'alpha');
1292 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1293 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1296 $search_status =
GETPOST(
"search_status",
"intcomma");
1297 if ($search_status ==
'') {
1301 $search_rowid =
GETPOST(
"search_rowid",
"intcomma");
1302 $search_name =
GETPOST(
"search_name",
'alpha');
1303 $search_address =
GETPOST(
"search_address",
'alpha');
1304 $search_poste =
GETPOST(
"search_poste",
'alpha');
1305 $search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
1306 $search_roles =
GETPOST(
"search_roles",
'array');
1307 $search_birthday_dtstart =
GETPOST(
"search_birthday_dtstart",
'alpha');
1308 $search_birthday_dtend =
GETPOST(
"search_birthday_dtend",
'alpha');
1310 if ($search_birthday_dtstart !=
'' || $search_birthday_dtend !=
'') {
1316 $searchAddressPhoneDBFields = array(
1344 $sortfield =
"t.lastname";
1348 $user->fetch_clicktodial();
1354 $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1356 $contactstatic->fields = array(
1357 'rowid' => array(
'type' =>
'integer',
'label' =>
"TechnicalID",
'enabled' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ?
'1' :
'0'),
'visible' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'position' => 1),
1358 'name' => array(
'type' =>
'varchar(128)',
'label' =>
'Name',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 10,
'searchall' => 1),
1359 'poste' => array(
'type' =>
'varchar(128)',
'label' =>
'PostOrFunction',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 2,
'index' => 1,
'position' => 20),
1360 'address' => array(
'type' =>
'varchar(128)',
'label' =>
'Address',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 3,
'index' => 1,
'position' => 30),
1361 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => (
string) ((
int) !
getDolGlobalBool(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'visible' => 3,
'position' => 35),
1362 'role' => array(
'type' =>
'checkbox',
'label' =>
'Role',
'enabled' =>
'1',
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 4,
'index' => 1,
'position' => 40),
1363 'birthday' => array(
'type' =>
'date',
'label' =>
'Birthday',
'enabled' =>
'1',
'visible' => -1,
'notnull' => 0,
'position' => 45),
1364 '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))),
1368 $arrayfields = array(
1369 't.rowid' => array(
'label' =>
"TechnicalID",
'checked' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ?
'1' :
'0'),
'enabled' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ?
'1' :
'0'),
'position' => 1),
1370 't.name' => array(
'label' =>
"Name",
'checked' =>
'1',
'position' => 10),
1371 't.poste' => array(
'label' =>
"PostOrFunction",
'checked' =>
'1',
'position' => 20),
1372 '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),
1373 't.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'position' => 35),
1374 'sc.role' => array(
'label' =>
"ContactByDefaultFor",
'checked' =>
'1',
'position' => 40),
1375 't.birthday' => array(
'label' =>
"Birthday",
'checked' =>
'0',
'position' => 45),
1376 't.statut' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 50,
'class' =>
'center'),
1377 'u.user' => array(
'label' =>
"DolibarrLogin",
'checked' =>
'1',
'position' => 50,
'class' =>
'center'),
1380 $extrafieldsobjectkey = $contactstatic->table_element;
1381 $extrafieldsobjectprefix =
'ef.';
1382 $extrafieldspositionoffset = 1000;
1383 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_array_fields.tpl.php';
1387 foreach ($arrayfields as $key => $val) {
1388 $queryName =
'search_' . substr($key, 2);
1389 if (
GETPOST($queryName,
'alpha')) {
1390 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1393 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1396 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1398 $search_status =
'';
1400 $search_roles = array();
1401 $search_address =
'';
1403 $search_note_private =
'';
1404 $search_birthday_dtstart =
'';
1405 $search_birthday_dtend =
'';
1407 $search_array_options = array();
1409 foreach ($contactstatic->fields as $key => $val) {
1414 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1417 $newcardbutton =
'';
1418 $parameters = array(
'socid' =>
$object->id);
1419 $reshook = $hookmanager->executeHooks(
'printNewCardButton', $parameters,
$object);
1420 if (empty($reshook)) {
1421 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1422 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1423 $newcardbutton .= dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT .
'/contact/card.php?socid=' .
$object->id .
'&action=create&backtopage=' . urlencode($backtopage));
1426 $newcardbutton = $hookmanager->resPrint;
1431 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1434 print
'<form method="POST" id="searchFormList" action="' . $_SERVER[
"PHP_SELF"] .
'" name="formfilter">';
1435 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
1436 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1437 print
'<input type="hidden" name="socid" value="' .
$object->id .
'">';
1438 print
'<input type="hidden" name="sortorder" value="' . $sortorder .
'">';
1439 print
'<input type="hidden" name="sortfield" value="' . $sortfield .
'">';
1440 print
'<input type="hidden" name="page" value="' . $page .
'">';
1442 $arrayofmassactions = array();
1445 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1446 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1447 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1448 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1450 print
'<div class="div-table-responsive">';
1451 print
"\n" .
'<table class="tagtable liste noborder">' .
"\n";
1453 $param =
"socid=" . urlencode((
string) (
$object->id));
1454 if ($search_rowid !=
'') {
1455 $param .=
'&search_rowid=' . urlencode((
string) ($search_rowid));
1457 if ($search_status !=
'') {
1458 $param .=
'&search_status=' . urlencode((
string) ($search_status));
1460 if (count($search_roles) > 0) {
1461 $param .= implode(
'&search_roles[]=', $search_roles);
1463 if ($search_name !=
'') {
1464 $param .=
'&search_name=' . urlencode($search_name);
1466 if ($search_poste !=
'') {
1467 $param .=
'&search_poste=' . urlencode($search_poste);
1469 if ($search_address !=
'') {
1470 $param .=
'&search_address=' . urlencode($search_address);
1472 if ($search_note_private !=
'') {
1473 $param .=
'&search_note_private=' . urlencode($search_note_private);
1475 if ($search_birthday_dtstart !=
'') {
1476 $param .=
'&search_birthday_dtstart=' . urlencode((
string) $search_birthday_dtstart);
1478 if ($search_birthday_dtend !=
'') {
1479 $param .=
'&search_birthday_dtend=' . urlencode((
string) $search_birthday_dtend);
1481 if ($optioncss !=
'') {
1482 $param .=
'&optioncss=' . urlencode($optioncss);
1486 $extrafieldsobjectkey = $contactstatic->table_element;
1487 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_param.tpl.php';
1489 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1490 $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,";
1491 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1492 $sql .=
" t.note_private";
1493 $sql .=
" FROM " . MAIN_DB_PREFIX .
"socpeople as t";
1494 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1495 $sql .=
" WHERE t.fk_soc = " . ((int)
$object->id);
1496 $sql .=
" AND t.entity IN (" .
getEntity(
'socpeople') .
")";
1497 $sql .=
" AND ((t.fk_user_creat = " . ((int) $user->id) .
" AND t.priv = 1) OR t.priv = 0)";
1498 if ($search_rowid) {
1501 if ($search_status !=
'' && $search_status !=
'-1') {
1502 $sql .=
" AND t.statut = " . ((int) $search_status);
1505 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1507 if ($search_poste) {
1510 if ($search_address) {
1511 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1513 if ($search_note_private) {
1516 if ($search_birthday_dtstart !=
'') {
1517 $sql .=
" AND t.birthday >= '" .
$db->idate($search_birthday_dtstart) .
"'";
1519 if ($search_birthday_dtend !=
'') {
1520 $sql .=
" AND t.birthday <= '" .
$db->idate($search_birthday_dtend) .
"'";
1522 if (count($search_roles) > 0) {
1523 $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)) .
"))";
1526 $extrafieldsobjectkey = $contactstatic->table_element;
1527 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_sql.tpl.php';
1529 $parameters = array(
'socid' =>
$object->id);
1530 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
1531 $sql .= $hookmanager->resPrint;
1532 if ($sortfield ==
"t.name") {
1533 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1535 $sql .=
" ORDER BY $sortfield $sortorder";
1538 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1539 $result =
$db->query($sql);
1544 $num =
$db->num_rows($result);
1548 print
'<tr class="liste_titre">';
1550 if (
$conf->main_checkbox_left_column) {
1551 print
'<td class="liste_titre right">';
1552 print $form->showFilterButtons();
1555 foreach ($contactstatic->fields as $key => $val) {
1557 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1558 $align .= ($align ?
' ' :
'') .
'center';
1560 if (in_array($val[
'type'], array(
'timestamp'))) {
1561 $align .= ($align ?
' ' :
'') .
'nowrap';
1563 if ($key ==
'status' || $key ==
'statut') {
1564 $align .= ($align ?
' ' :
'') .
'center';
1566 if (!empty($arrayfields[
't.' . $key][
'checked']) || !empty($arrayfields[
'sc.' . $key][
'checked'])) {
1567 print
'<td class="liste_titre' . ($align ?
' ' . $align :
'') .
'">';
1568 if (in_array($key, array(
'statut'))) {
1569 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');
1570 } elseif (in_array($key, array(
'role'))) {
1571 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1572 } elseif (in_array($key, array(
'birthday'))) {
1573 print
'<div class="nowrap">';
1574 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1576 print
'<div class="nowrap">';
1577 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1580 print
'<input type="text" class="flat maxwidth75" name="search_' . $key .
'" value="' . (!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'') .
'">';
1585 if ($showuserlogin) {
1586 print
'<td class="liste_titre"></td>';
1589 $extrafieldsobjectkey = $contactstatic->table_element;
1590 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_input.tpl.php';
1593 $parameters = array(
'arrayfields' => $arrayfields);
1594 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1595 print $hookmanager->resPrint;
1597 if (!
$conf->main_checkbox_left_column) {
1598 print
'<td class="liste_titre right">';
1599 print $form->showFilterButtons();
1602 print
'</tr>' .
"\n";
1607 print
'<tr class="liste_titre">';
1609 if (
$conf->main_checkbox_left_column) {
1610 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1612 foreach ($contactstatic->fields as $key => $val) {
1614 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1615 $align .= ($align ?
' ' :
'') .
'center';
1617 if (in_array($val[
'type'], array(
'timestamp'))) {
1618 $align .= ($align ?
' ' :
'') .
'nowrap';
1620 if ($key ==
'status' || $key ==
'statut') {
1621 $align .= ($align ?
' ' :
'') .
'center';
1623 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
1624 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.' . $key,
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1626 if ($key ==
'role') {
1627 $align .= ($align ?
' ' :
'') .
'left';
1629 if (!empty($arrayfields[
'sc.' . $key][
'checked'])) {
1630 print
getTitleFieldOfList($arrayfields[
'sc.' . $key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1633 if ($showuserlogin) {
1634 print
'<th class="wrapcolumntitle liste_titre">' . $langs->trans(
"DolibarrLogin") .
'</th>';
1637 $extrafieldsobjectkey = $contactstatic->table_element;
1638 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_title.tpl.php';
1640 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1641 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
1642 print $hookmanager->resPrint;
1644 if (!
$conf->main_checkbox_left_column) {
1645 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1647 print
'</tr>' .
"\n";
1651 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1655 $obj =
$db->fetch_object($result);
1657 $contactstatic->id = $obj->rowid;
1658 $contactstatic->ref = $obj->rowid;
1659 $contactstatic->status = $obj->statut;
1660 $contactstatic->statut = $obj->statut;
1661 $contactstatic->lastname = $obj->lastname;
1662 $contactstatic->firstname = $obj->firstname;
1663 $contactstatic->civility_id = $obj->civility_id;
1664 $contactstatic->civility_code = $obj->civility_id;
1665 $contactstatic->poste = $obj->poste;
1666 $contactstatic->address = $obj->address;
1667 $contactstatic->zip = $obj->zip;
1668 $contactstatic->town = $obj->town;
1669 $contactstatic->phone_pro = $obj->phone_pro;
1670 $contactstatic->phone_mobile = $obj->phone_mobile;
1671 $contactstatic->phone_perso = $obj->phone_perso;
1672 $contactstatic->email = $obj->email;
1673 $contactstatic->socialnetworks = $obj->socialnetworks;
1674 $contactstatic->photo = $obj->photo;
1675 $contactstatic->fk_soc = $obj->fk_soc;
1676 $contactstatic->entity = $obj->entity;
1678 $country_code =
getCountry($obj->country_id,
'2');
1679 $contactstatic->country_code = $country_code;
1681 $contactstatic->setGenderFromCivility();
1682 $contactstatic->fetch_optionals();
1684 $resultRole = $contactstatic->fetchRoles();
1685 if ($resultRole < 0) {
1689 if (is_array($contactstatic->array_options)) {
1690 foreach ($contactstatic->array_options as $key => $val) {
1695 print
'<tr class="oddeven">';
1698 if (
$conf->main_checkbox_left_column) {
1699 print
'<td class="nowrap center">';
1702 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1703 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1704 print
img_object($langs->trans(
"Event"),
"action");
1705 print
'</a> ';
1709 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1710 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' . newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1716 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1717 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) .
'">';
1726 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1728 print $contactstatic->id;
1733 if (!empty($arrayfields[
't.name'][
'checked'])) {
1734 print
'<td class="tdoverflowmax150">';
1735 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0,
'user');
1736 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage=' . urlencode($backtopage));
1741 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1742 print
'<td class="tdoverflowmax100" title="' .
dol_escape_htmltag($obj->poste) .
'">';
1750 if (!empty($arrayfields[
't.address'][
'checked'])) {
1751 $addresstoshow = $contactstatic->getBannerAddress(
'contact',
$object);
1752 print
'<td class="tdoverflowmax150 classfortooltip" title="'.dolPrintHTMLForAttribute($addresstoshow).
'">';
1753 print $addresstoshow;
1758 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1759 print
'<td class="center">';
1765 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1766 print
'<td class="tdoverflowmax150">';
1767 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1772 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1773 print
'<td class="nowraponall">';
1779 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1780 print
'<td class="center">' . $contactstatic->getLibStatut(5) .
'</td>';
1783 if ($showuserlogin) {
1784 print
'<td class="tdoverflowmax125">';
1787 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1788 if ($resfetch > 0) {
1789 print $tmpuser->getNomUrl(-1,
'', 0, 0, 24, 1);
1795 $extrafieldsobjectkey = $contactstatic->table_element;
1796 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_print_fields.tpl.php';
1799 if (!
$conf->main_checkbox_left_column) {
1800 print
'<td class="nowrap center">';
1803 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1804 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1805 print
img_object($langs->trans(
"Event"),
"action");
1806 print
'</a> ';
1810 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1811 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' . newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1817 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1818 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) .
'">';
1831 $colspan = 1 + ($showuserlogin ? 1 : 0);
1832 foreach ($arrayfields as $key => $val) {
1833 if (!empty($val[
'checked'])) {
1837 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
1840 $colspan = 1 + ($showuserlogin ? 1 : 0);
1841 foreach ($arrayfields as $key => $val) {
1842 if (!empty($val[
'checked'])) {
1846 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
1848 print
"\n</table>\n";
1851 print
'</form>' .
"\n";
1899function show_actions_done(
$conf, $langs,
$db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1901 global $hookmanager, $user;
1904 global $param, $massactionbutton;
1906 $start_year =
GETPOSTINT(
'dateevent_startyear');
1907 $start_month =
GETPOSTINT(
'dateevent_startmonth');
1908 $start_day =
GETPOSTINT(
'dateevent_startday');
1910 $end_month =
GETPOSTINT(
'dateevent_endmonth');
1915 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1916 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1918 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1919 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1921 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1925 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
1928 if (!is_object($filterobj) && !is_object($objcon)) {
1938 $sortfield_list = explode(
',', $sortfield);
1939 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1940 $sortfield_new_list = array();
1941 foreach ($sortfield_list as $sortfield_value) {
1942 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1944 $sortfield_new = implode(
',', $sortfield_new_list);
1946 $complete = (
string) (!empty($filters[
'search_complete']) ? $filters[
'search_complete'] :
'');
1947 $percent = $complete !==
'' ? $complete : -1;
1948 if ((
string) $complete ==
'0') {
1950 } elseif ((
int) $complete == 100) {
1958 $hookmanager->initHooks(array(
'agendadao'));
1960 $sql =
"SELECT a.id, a.label as label,";
1961 $sql .=
" a.datep as dp,";
1962 $sql .=
" a.datep2 as dp2,";
1963 $sql .=
" a.percent as percent, 'action' as type,";
1964 $sql .=
" a.fk_element, a.elementtype,";
1965 $sql .=
" a.fk_contact,";
1966 $sql .=
" a.code, a.fulldayevent,";
1967 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1968 $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";
1969 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1970 $sql .=
", sp.lastname, sp.firstname";
1971 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1973 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1975 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1976 $sql .=
", m.lastname, m.firstname";
1977 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1979 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1981 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1983 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1985 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1987 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
1989 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1990 if (!empty($filterobj->fields[
'ref'])) {
1992 } elseif (!empty($filterobj->fields[
'label'])) {
1993 $sql .=
", o.label";
1998 if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
2001 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2004 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2005 $filters[
'search_filtert'] = (
string) $user->id;
2009 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2010 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
2011 if (!empty($hookmanager->resPrint)) {
2012 $sql .= $hookmanager->resPrint;
2015 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm as a";
2017 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"user as u on u.rowid = a.fk_user_action";
2019 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"c_actioncomm as c ON a.fk_action = c.id";
2024 $force_filter_contact =
false;
2025 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2026 $force_filter_contact =
true;
2028 if (is_object($objcon) && $objcon->id > 0) {
2029 $force_filter_contact =
true;
2033 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2034 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
2035 if (!empty($hookmanager->resPrint)) {
2036 $sql .= $hookmanager->resPrint;
2038 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
2039 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople as sp ON a.fk_contact = sp.rowid";
2040 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2041 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"element_resources as er";
2042 $sql .=
" ON er.resource_type = 'dolresource'";
2043 $sql .=
" AND er.element_type = 'action'";
2044 $sql .=
" AND er.element_id = a.id";
2045 $sql .=
" AND er.resource_id = " . ((int) $filterobj->id);
2046 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
2048 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2049 $sql .=
", " . MAIN_DB_PREFIX .
"adherent as m";
2050 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2051 $sql .=
", " . MAIN_DB_PREFIX .
"commande_fournisseur as o";
2052 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2053 $sql .=
", " . MAIN_DB_PREFIX .
"product as o";
2054 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2055 $sql .=
", " . MAIN_DB_PREFIX .
"ticket as o";
2056 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2057 $sql .=
", " . MAIN_DB_PREFIX .
"bom_bom as o";
2058 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2059 $sql .=
", " . MAIN_DB_PREFIX .
"contrat as o";
2060 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2061 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"expedition as s ON a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2062 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Propal') {
2063 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"propal as o ON a.fk_element = o.rowid AND a.elementtype = 'propal'";
2065 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2066 && ((!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'])))
2067 && $filterobj->table_element && $filterobj->element
2069 $sql .=
", " . MAIN_DB_PREFIX . $filterobj->table_element .
" as o";
2072 $sql .=
" WHERE a.entity IN (" .
getEntity(
'agenda') .
")";
2073 if (!$force_filter_contact) {
2074 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
2075 $sql .=
" AND a.fk_soc = " . ((int) $filterobj->id);
2076 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2078 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
2079 $sql .=
" AND a.fk_project = " . ((int) $filterobj->id);
2080 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2081 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
2082 if ($filterobj->id) {
2083 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2085 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
2086 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
2087 if ($filterobj->id) {
2088 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2090 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2091 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
2092 if ($filterobj->id) {
2093 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2095 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
2096 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
2097 if ($filterobj->id) {
2098 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2100 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
2101 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice_supplier'";
2102 if ($filterobj->id) {
2103 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2105 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2106 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
2107 if ($filterobj->id) {
2108 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2110 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2111 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
2112 if ($filterobj->id) {
2113 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2115 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2116 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
2117 if ($filterobj->id) {
2118 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2120 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2121 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
2122 if ($filterobj->id) {
2123 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2125 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2126 $sql .=
" AND a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2127 if ($filterobj->id) {
2128 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2131 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2132 && ((!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'])))
2133 && $filterobj->table_element && $filterobj->element
2136 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '" .
$db->escape($filterobj->element) . ($module ?
"@" . $module :
"") .
"'";
2137 if ($filterobj->id) {
2138 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2140 } elseif (is_object($filterobj)) {
2141 return 'Bad value for $filterobj';
2144 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2145 $sql .=
" AND (u.rowid = " . ((int) $filterobj->id) .
' OR ';
2146 $sql .=
" EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2147 $sql .=
" AND r.element_type = '" .
$db->escape($filterobj->table_element) .
"' AND r.fk_element = " . ((int) $filterobj->id) .
')';
2150 if (is_object($objcon) && $objcon->id > 0) {
2151 $sql .=
" AND EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2152 $sql .=
" AND r.element_type = '" .
$db->escape($objcon->table_element) .
"' AND r.fk_element = " . ((int) $objcon->id) .
')';
2156 if (!empty($tms_start) && !empty($tms_end)) {
2157 $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) .
"'))";
2158 } elseif (empty($tms_start) && !empty($tms_end)) {
2159 $sql .=
" AND ((a.datep <= '" .
$db->idate($tms_end) .
"') OR (a.datep2 <= '" .
$db->idate($tms_end) .
"'))";
2160 } elseif (!empty($tms_start) && empty($tms_end)) {
2161 $sql .=
" AND ((a.datep >= '" .
$db->idate($tms_start) .
"') OR (a.datep2 >= '" .
$db->idate($tms_start) .
"'))";
2164 if (is_array($actioncode) && !empty($actioncode)) {
2167 foreach ($actioncode as $key => $code) {
2168 if ((
string) $code ===
'-1' || (
string) $code ===
'') {
2174 if (!empty($code)) {
2183 } elseif (!empty($actioncode) && $actioncode !=
'-1') {
2190 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
2191 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
2192 if (!empty($hookmanager->resPrint)) {
2193 $sql .= $hookmanager->resPrint;
2197 if (is_array($actioncode) && $objcon !==
null) {
2198 foreach ($actioncode as $code) {
2200 if (!empty($sql2)) {
2202 $sql = $sql .
" UNION " . $sql2;
2203 } elseif (empty($sql)) {
2209 } elseif ($objcon !==
null) {
2211 if (!empty($sql) && !empty($sql2)) {
2212 $sql = $sql .
" UNION " . $sql2;
2213 } elseif (empty($sql) && !empty($sql2)) {
2219 $MAXWITHOUTPAGINATION =
getDolGlobalInt(
'AGENDA_MAX_EVENTS_ON_PAGE_WITHOUT_PAGINATION', 100);
2225 $limit = $MAXWITHOUTPAGINATION;
2228 $sql .=
$db->order($sortfield_new, $sortorder);
2230 $sql .=
$db->plimit($limit + 1, $offset);
2233 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
2235 $resql =
$db->query($sql);
2238 $num =
$db->num_rows($resql);
2240 $imaxinloop = ($limit ? min($num, $limit) : $num);
2241 while ($i < $imaxinloop) {
2242 $obj =
$db->fetch_object($resql);
2247 if ($obj->type ==
'action') {
2249 $contactaction->id = $obj->id;
2250 $result = $contactaction->fetchResources();
2253 setEventMessage(
"company.lib::show_actions_done Error fetch resource",
'errors');
2259 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
2263 $histo[$numaction] = array(
2264 'type' => $obj->type,
2265 'tododone' => $tododone,
2266 'id' => (
int) $obj->id,
2267 'datestart' =>
$db->jdate($obj->dp),
2268 'dateend' =>
$db->jdate($obj->dp2),
2269 'fulldayevent' => (
int) $obj->fulldayevent,
2270 'note' => $obj->label,
2271 'percent' => (
int) $obj->percent,
2273 'userid' => (
int) $obj->user_id,
2274 'login' => $obj->user_login,
2275 'userfirstname' => $obj->user_firstname,
2276 'userlastname' => $obj->user_lastname,
2277 'userphoto' => $obj->user_photo,
2279 'contact_id' => (
int) $obj->fk_contact,
2280 'socpeopleassigned' => $contactaction->socpeopleassigned,
2281 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
2282 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
2283 'fk_element' => (int) $obj->fk_element,
2284 'elementtype' => $obj->elementtype,
2286 'code' => $obj->code,
2289 'acode' => $obj->acode,
2290 'alabel' => $obj->alabel,
2291 'libelle' => $obj->alabel,
2292 'apicto' => $obj->apicto
2295 $histo[$numaction] = array(
2296 'type' => $obj->type,
2297 'tododone' =>
'done',
2298 'id' => (
int) $obj->id,
2299 'datestart' =>
$db->jdate($obj->dp),
2300 'dateend' =>
$db->jdate($obj->dp2),
2301 'fulldayevent' => (
int) $obj->fulldayevent,
2302 'note' => $obj->label,
2303 'percent' => (
int) $obj->percent,
2305 'code' => $obj->code,
2308 'acode' => $obj->acode,
2310 'userid' => (
int) $obj->user_id,
2311 'login' => $obj->user_login,
2312 'userfirstname' => $obj->user_firstname,
2313 'userlastname' => $obj->user_lastname,
2314 'userphoto' => $obj->user_photo
2326 '@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';
2329 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
2331 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
2332 include_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
2333 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
2334 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
2340 $userlinkcache = array();
2342 $elementlinkcache = array();
2344 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2345 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
2347 $objcon && get_class($objcon) ==
'Contact' &&
2348 (is_null($filterobj) || get_class($filterobj) ==
'Societe')
2350 $out .=
'<input type="hidden" name="id" value="' . $objcon->id .
'" />';
2352 $out .=
'<input type="hidden" name="id" value="' . $filterobj->id .
'" />';
2354 if ($filterobj && get_class($filterobj) ==
'Societe') {
2355 $out .=
'<input type="hidden" name="socid" value="' . $filterobj->id .
'" />';
2357 $out .=
'<input type="hidden" name="userid" value="' . $filterobj->id .
'" />';
2362 $out .=
'<div class="div-table-responsive-no-min">';
2363 $out .=
'<table class="noborder centpercent">';
2365 $out .=
'<tr class="liste_titre_filter">';
2368 if (
$conf->main_checkbox_left_column) {
2369 $out .=
'<th class="liste_titre width50 middle">';
2370 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2371 $out .= $searchpicto;
2376 $out .=
'<td class="liste_titre"></td>';
2380 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="' . (isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'') .
'"></td>';
2382 $out .=
'<td class="liste_titre center">';
2383 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
2386 $out .=
'<td class="liste_titre">';
2387 $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');
2390 $out .=
'<td class="liste_titre">';
2391 $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);
2394 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth200" name="search_agenda_label" value="' . $filters[
'search_agenda_label'] .
'"></td>';
2395 $out .=
'<td class="liste_titre"></td>';
2396 $out .=
'<td class="liste_titre"></td>';
2398 $out .=
'<td class="liste_titre parentonrightofpage">';
2399 $out .= $formactions->form_select_status_action(
'formaction', $percent, 1,
'search_complete', 1, 2,
'search_status width100 onrightofpage', 1);
2402 if (!
$conf->main_checkbox_left_column) {
2403 $out .=
'<td class="liste_titre" align="middle">';
2404 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2405 $out .= $searchpicto;
2410 $out .=
'<tr class="liste_titre">';
2412 if (
$conf->main_checkbox_left_column) {
2413 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2415 if ($donetodo && $filterobj !==
null) {
2417 if (get_class($filterobj) ==
'Societe') {
2418 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&socid=' . $filterobj->id .
'&status=done">';
2420 if (get_class($filterobj) ==
'User') {
2421 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&userid=' . $filterobj->id .
'&status=done">';
2423 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2424 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2425 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2427 if (get_class($filterobj) ==
'Societe') {
2430 if (get_class($filterobj) ==
'User') {
2435 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2436 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2439 $out .=
getTitleFieldOfList(
"Title", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2440 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2441 $out .=
getTitleFieldOfList(
"LinkedObject", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2442 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2444 if (!
$conf->main_checkbox_left_column) {
2445 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2449 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/cactioncomm.class.php';
2451 $arraylist = $caction->liste_array(1,
'code',
'', (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 0 : 1),
'', 1);
2453 foreach ($histo as $key => $value) {
2454 $actionstatic->fetch($histo[$key][
'id']);
2456 if (empty($actionstatic->code)) {
2457 $actionstatic->code = $histo[$key][
'acode'];
2459 $actionstatic->type_picto = $histo[$key][
'apicto'] ??
'';
2460 $actionstatic->type_code = $histo[$key][
'acode'];
2462 $out .=
'<tr class="oddeven">';
2465 if (
$conf->main_checkbox_left_column) {
2466 $out .=
'<td></td>';
2471 $out .=
'<td class="nowrap">';
2476 $out .=
'<td class="nowraponall">';
2477 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2478 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'">' .
img_object($langs->trans(
"ShowEMailing"),
"email") .
' ';
2479 $out .= $histo[$key][
'id'];
2482 $out .= $actionstatic->getNomUrl(1, -1);
2487 $out .=
'<td class="center nowraponall nopaddingtopimp nopaddingbottomimp">';
2489 $out .=
dolOutputDates($histo[$key][
'datestart'], $histo[$key][
'dateend'], (
int) $histo[$key][
'fulldayevent'], 0,
'',
'tzuserrel', 1);
2493 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2496 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2499 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2502 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2511 $out .=
'<td class="tdoverflowmax125">';
2512 if ($histo[$key][
'userid'] > 0) {
2513 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2514 $link = $userlinkcache[$histo[$key][
'userid']];
2516 $userstatic->fetch($histo[$key][
'userid']);
2517 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2518 $userlinkcache[$histo[$key][
'userid']] = $link;
2528 $labelOfTypeToShow = $actionstatic->type_code;
2530 $code = $actionstatic->code;
2531 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labelOfTypeToShow])) {
2532 $labelOfTypeToShow =
'AC_OTH';
2534 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2535 $labelOfTypeToShow = $langs->trans(
"Message");
2537 if (!empty($arraylist[$labelOfTypeToShow])) {
2538 $labelOfTypeToShow = $arraylist[$labelOfTypeToShow];
2539 } elseif ($actionstatic->type_code ==
'AC_EMAILING') {
2540 $langs->load(
"mails");
2541 $labelOfTypeToShow = $langs->trans(
"Emailing");
2543 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labelOfTypeToShow && !empty($arraylist[$actionstatic->code])) {
2544 $labelOfTypeToShow .=
' - ' . $arraylist[$actionstatic->code];
2548 $labelOfTypeToShowLong = $labelOfTypeToShow;
2549 if ($actionstatic->type_code ==
'AC_OTH_AUTO') {
2550 $labelOfTypeToShowLong .=
' (auto)';
2553 $out .=
'<td class="tdoverflowmax125" title="' . $labelOfTypeToShowLong .
'">';
2555 $out .= $actionstatic->getTypePicto();
2556 $out .= $labelOfTypeToShow;
2557 if (preg_match(
'/PRIVATE/', $actionstatic->code)) {
2558 $out .=
' ' .
img_picto($langs->trans(
"Private"),
'lock',
'class="valignmiddle"');
2563 $out .=
'<td class="tdoverflowmax300"';
2564 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2565 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2567 $label = $histo[$key][
'note'];
2568 $actionstatic->id = $histo[$key][
'id'];
2570 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2573 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2574 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2575 $label = ($transcode !=
"Action" . $histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2576 $label .=
' - ' . $histo[$key][
'note'];
2577 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'"';
2579 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2586 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2587 $out .=
'<td class="valignmiddle">';
2589 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2590 $result = $contact->fetch($cid);
2594 } elseif ($result > 0) {
2595 if (count($histo[$key][
'socpeopleassigned']) > 1) {
2596 $out .= $contact->getNomUrl(-2,
'', 0,
'', -1, 0,
'paddingright');
2598 $out .= $contact->getNomUrl(-3,
'', 0,
'', -1, 0,
'paddingright');
2599 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2600 if (!empty($contact->phone_pro)) {
2608 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2609 $contactstatic->lastname = $histo[$key][
'lastname'];
2610 $contactstatic->firstname = $histo[$key][
'firstname'];
2611 $contactstatic->id = $histo[$key][
'contact_id'];
2612 $contactstatic->photo = $histo[$key][
'contact_photo'];
2613 $out .=
'<td width="120">' . $contactstatic->getNomUrl(-1,
'', 10) .
'</td>';
2615 $out .=
'<td> </td>';
2619 $out .=
'<td class="tdoverflowmax200 nowraponall">';
2620 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2621 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2622 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2624 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2625 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2627 $link =
dolGetElementUrl((
int) $histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2628 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2635 $out .=
'<td class="nowrap center">';
2636 $out .= $actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']);
2640 if (!
$conf->main_checkbox_left_column) {
2641 $out .=
'<td></td>';
2646 if (empty($histo)) {
2648 $out .=
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
2651 if ($num > $MAXWITHOUTPAGINATION) {
2652 $langs->load(
"errors");
2654 $out .=
'<tr><td class="center" colspan="' . $colspan .
'"><span class="opacitymedium">...' . $langs->trans(
"WarningTooManyDataPleaseUseMoreFilters", $MAXWITHOUTPAGINATION) .
'...</span></td></tr>';
2657 $out .=
"</table>\n";