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 $showuserlogin = (!empty($showuserlogin) || !empty($arrayfields[
'u.user'][
'checked'])) ? 1 : 0;
1448 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1449 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1451 print
'<div class="div-table-responsive">';
1452 print
"\n" .
'<table class="tagtable liste noborder">' .
"\n";
1454 $param =
"socid=" . urlencode((
string) (
$object->id));
1455 if ($search_rowid !=
'') {
1456 $param .=
'&search_rowid=' . urlencode((
string) ($search_rowid));
1458 if ($search_status !=
'') {
1459 $param .=
'&search_status=' . urlencode((
string) ($search_status));
1461 if (count($search_roles) > 0) {
1462 $param .= implode(
'&search_roles[]=', $search_roles);
1464 if ($search_name !=
'') {
1465 $param .=
'&search_name=' . urlencode($search_name);
1467 if ($search_poste !=
'') {
1468 $param .=
'&search_poste=' . urlencode($search_poste);
1470 if ($search_address !=
'') {
1471 $param .=
'&search_address=' . urlencode($search_address);
1473 if ($search_note_private !=
'') {
1474 $param .=
'&search_note_private=' . urlencode($search_note_private);
1476 if ($search_birthday_dtstart !=
'') {
1477 $param .=
'&search_birthday_dtstart=' . urlencode((
string) $search_birthday_dtstart);
1479 if ($search_birthday_dtend !=
'') {
1480 $param .=
'&search_birthday_dtend=' . urlencode((
string) $search_birthday_dtend);
1482 if ($optioncss !=
'') {
1483 $param .=
'&optioncss=' . urlencode($optioncss);
1487 $extrafieldsobjectkey = $contactstatic->table_element;
1488 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_param.tpl.php';
1490 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1491 $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,";
1492 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1493 $sql .=
" t.note_private";
1494 $sql .=
" FROM " . MAIN_DB_PREFIX .
"socpeople as t";
1495 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1496 $sql .=
" WHERE t.fk_soc = " . ((int)
$object->id);
1497 $sql .=
" AND t.entity IN (" .
getEntity(
'socpeople') .
")";
1498 $sql .=
" AND ((t.fk_user_creat = " . ((int) $user->id) .
" AND t.priv = 1) OR t.priv = 0)";
1499 if ($search_rowid) {
1502 if ($search_status !=
'' && $search_status !=
'-1') {
1503 $sql .=
" AND t.statut = " . ((int) $search_status);
1506 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1508 if ($search_poste) {
1511 if ($search_address) {
1512 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1514 if ($search_note_private) {
1517 if ($search_birthday_dtstart !=
'') {
1518 $sql .=
" AND t.birthday >= '" .
$db->idate($search_birthday_dtstart) .
"'";
1520 if ($search_birthday_dtend !=
'') {
1521 $sql .=
" AND t.birthday <= '" .
$db->idate($search_birthday_dtend) .
"'";
1523 if (count($search_roles) > 0) {
1524 $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)) .
"))";
1527 $extrafieldsobjectkey = $contactstatic->table_element;
1528 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_sql.tpl.php';
1530 $parameters = array(
'socid' =>
$object->id);
1531 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
1532 $sql .= $hookmanager->resPrint;
1533 if ($sortfield ==
"t.name") {
1534 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1536 $sql .=
" ORDER BY $sortfield $sortorder";
1539 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1540 $result =
$db->query($sql);
1545 $num =
$db->num_rows($result);
1549 print
'<tr class="liste_titre">';
1551 if (
$conf->main_checkbox_left_column) {
1552 print
'<td class="liste_titre right">';
1553 print $form->showFilterButtons();
1556 foreach ($contactstatic->fields as $key => $val) {
1558 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1559 $align .= ($align ?
' ' :
'') .
'center';
1561 if (in_array($val[
'type'], array(
'timestamp'))) {
1562 $align .= ($align ?
' ' :
'') .
'nowrap';
1564 if ($key ==
'status' || $key ==
'statut') {
1565 $align .= ($align ?
' ' :
'') .
'center';
1567 if (!empty($arrayfields[
't.' . $key][
'checked']) || !empty($arrayfields[
'sc.' . $key][
'checked'])) {
1568 print
'<td class="liste_titre' . ($align ?
' ' . $align :
'') .
'">';
1569 if (in_array($key, array(
'statut'))) {
1570 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');
1571 } elseif (in_array($key, array(
'role'))) {
1572 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1573 } elseif (in_array($key, array(
'birthday'))) {
1574 print
'<div class="nowrap">';
1575 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1577 print
'<div class="nowrap">';
1578 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1581 print
'<input type="text" class="flat maxwidth75" name="search_' . $key .
'" value="' . (!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'') .
'">';
1586 if ($showuserlogin) {
1587 print
'<td class="liste_titre"></td>';
1590 $extrafieldsobjectkey = $contactstatic->table_element;
1591 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_input.tpl.php';
1594 $parameters = array(
'arrayfields' => $arrayfields);
1595 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1596 print $hookmanager->resPrint;
1598 if (!
$conf->main_checkbox_left_column) {
1599 print
'<td class="liste_titre right">';
1600 print $form->showFilterButtons();
1603 print
'</tr>' .
"\n";
1608 print
'<tr class="liste_titre">';
1610 if (
$conf->main_checkbox_left_column) {
1611 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1613 foreach ($contactstatic->fields as $key => $val) {
1615 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1616 $align .= ($align ?
' ' :
'') .
'center';
1618 if (in_array($val[
'type'], array(
'timestamp'))) {
1619 $align .= ($align ?
' ' :
'') .
'nowrap';
1621 if ($key ==
'status' || $key ==
'statut') {
1622 $align .= ($align ?
' ' :
'') .
'center';
1624 if (!empty($arrayfields[
't.' . $key][
'checked'])) {
1625 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.' . $key,
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1627 if ($key ==
'role') {
1628 $align .= ($align ?
' ' :
'') .
'left';
1630 if (!empty($arrayfields[
'sc.' . $key][
'checked'])) {
1631 print
getTitleFieldOfList($arrayfields[
'sc.' . $key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="' . $align .
'"' :
''), $sortfield, $sortorder, $align .
' ') .
"\n";
1634 if ($showuserlogin) {
1635 print
'<th class="wrapcolumntitle liste_titre">' . $langs->trans(
"DolibarrLogin") .
'</th>';
1638 $extrafieldsobjectkey = $contactstatic->table_element;
1639 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_search_title.tpl.php';
1641 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1642 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
1643 print $hookmanager->resPrint;
1645 if (!
$conf->main_checkbox_left_column) {
1646 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ') .
"\n";
1648 print
'</tr>' .
"\n";
1652 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1656 $obj =
$db->fetch_object($result);
1658 $contactstatic->id = $obj->rowid;
1659 $contactstatic->ref = $obj->rowid;
1660 $contactstatic->status = $obj->statut;
1661 $contactstatic->statut = $obj->statut;
1662 $contactstatic->lastname = $obj->lastname;
1663 $contactstatic->firstname = $obj->firstname;
1664 $contactstatic->civility_id = $obj->civility_id;
1665 $contactstatic->civility_code = $obj->civility_id;
1666 $contactstatic->poste = $obj->poste;
1667 $contactstatic->address = $obj->address;
1668 $contactstatic->zip = $obj->zip;
1669 $contactstatic->town = $obj->town;
1670 $contactstatic->phone_pro = $obj->phone_pro;
1671 $contactstatic->phone_mobile = $obj->phone_mobile;
1672 $contactstatic->phone_perso = $obj->phone_perso;
1673 $contactstatic->email = $obj->email;
1674 $contactstatic->socialnetworks = $obj->socialnetworks;
1675 $contactstatic->photo = $obj->photo;
1676 $contactstatic->fk_soc = $obj->fk_soc;
1677 $contactstatic->entity = $obj->entity;
1679 $country_code =
getCountry($obj->country_id,
'2');
1680 $contactstatic->country_code = $country_code;
1682 $contactstatic->setGenderFromCivility();
1683 $contactstatic->fetch_optionals();
1685 $resultRole = $contactstatic->fetchRoles();
1686 if ($resultRole < 0) {
1690 if (is_array($contactstatic->array_options)) {
1691 foreach ($contactstatic->array_options as $key => $val) {
1696 print
'<tr class="oddeven">';
1699 if (
$conf->main_checkbox_left_column) {
1700 print
'<td class="nowrap center">';
1703 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1704 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1705 print
img_object($langs->trans(
"Event"),
"action");
1706 print
'</a> ';
1710 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1711 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' .
newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1717 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1718 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) .
'">';
1727 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1729 print $contactstatic->id;
1734 if (!empty($arrayfields[
't.name'][
'checked'])) {
1735 print
'<td class="tdoverflowmax150">';
1736 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0,
'user');
1737 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage=' . urlencode($backtopage));
1742 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1743 print
'<td class="tdoverflowmax100" title="' .
dol_escape_htmltag($obj->poste) .
'">';
1751 if (!empty($arrayfields[
't.address'][
'checked'])) {
1752 $addresstoshow = $contactstatic->getBannerAddress(
'contact',
$object);
1753 print
'<td class="tdoverflowmax150 classfortooltip" title="'.dolPrintHTMLForAttribute($addresstoshow).
'">';
1754 print $addresstoshow;
1759 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1760 print
'<td class="center">';
1766 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1767 print
'<td class="tdoverflowmax150">';
1768 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1773 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1774 print
'<td class="nowraponall">';
1780 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1781 print
'<td class="center">' . $contactstatic->getLibStatut(5) .
'</td>';
1784 if ($showuserlogin) {
1785 print
'<td class="tdoverflowmax125">';
1788 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1789 if ($resfetch > 0) {
1790 print $tmpuser->getNomUrl(-1,
'', 0, 0, 24, 1);
1796 $extrafieldsobjectkey = $contactstatic->table_element;
1797 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_list_print_fields.tpl.php';
1800 if (!
$conf->main_checkbox_left_column) {
1801 print
'<td class="nowrap center">';
1804 if (
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1805 print
'<a href="' . DOL_URL_ROOT .
'/comm/action/card.php?action=create&actioncode=&contactid=' . $obj->rowid .
'&socid=' .
$object->id .
'&backtopage=' . urlencode($backtopage) .
'">';
1806 print
img_object($langs->trans(
"Event"),
"action");
1807 print
'</a> ';
1811 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1812 print
'<a class="editfielda paddingleft" href="' . DOL_URL_ROOT .
'/contact/card.php?action=edit&token=' .
newToken() .
'&id=' . $obj->rowid .
'&backtopage=' . urlencode($backtopage) .
'">';
1818 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1819 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) .
'">';
1832 $colspan = 1 + ($showuserlogin ? 1 : 0);
1833 foreach ($arrayfields as $key => $val) {
1834 if (!empty($val[
'checked'])) {
1838 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
1841 $colspan = 1 + ($showuserlogin ? 1 : 0);
1842 foreach ($arrayfields as $key => $val) {
1843 if (!empty($val[
'checked'])) {
1847 print
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
1849 print
"\n</table>\n";
1852 print
'</form>' .
"\n";
1900function show_actions_done(
$conf, $langs,
$db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1902 global $hookmanager, $user;
1905 global $param, $massactionbutton;
1907 $start_year =
GETPOSTINT(
'dateevent_startyear');
1908 $start_month =
GETPOSTINT(
'dateevent_startmonth');
1909 $start_day =
GETPOSTINT(
'dateevent_startday');
1911 $end_month =
GETPOSTINT(
'dateevent_endmonth');
1916 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1917 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1919 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1920 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1922 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1926 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
1929 if (!is_object($filterobj) && !is_object($objcon)) {
1939 $sortfield_list = explode(
',', $sortfield);
1940 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1941 $sortfield_new_list = array();
1942 foreach ($sortfield_list as $sortfield_value) {
1943 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1945 $sortfield_new = implode(
',', $sortfield_new_list);
1947 $complete = (
string) (!empty($filters[
'search_complete']) ? $filters[
'search_complete'] :
'');
1948 $percent = $complete !==
'' ? $complete : -1;
1949 if ((
string) $complete ==
'0') {
1951 } elseif ((
int) $complete == 100) {
1959 $hookmanager->initHooks(array(
'agendadao'));
1961 $sql =
"SELECT a.id, a.label as label,";
1962 $sql .=
" a.datep as dp,";
1963 $sql .=
" a.datep2 as dp2,";
1964 $sql .=
" a.percent as percent, 'action' as type,";
1965 $sql .=
" a.fk_element, a.elementtype,";
1966 $sql .=
" a.fk_contact,";
1967 $sql .=
" a.code, a.fulldayevent,";
1968 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1969 $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";
1970 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1971 $sql .=
", sp.lastname, sp.firstname";
1972 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1974 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1976 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1977 $sql .=
", m.lastname, m.firstname";
1978 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1980 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1982 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1984 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1986 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1988 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
1990 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1991 if (!empty($filterobj->fields[
'ref'])) {
1993 } elseif (!empty($filterobj->fields[
'label'])) {
1994 $sql .=
", o.label";
1999 if (!$user->hasRight(
'agenda',
'myactions',
'read')) {
2002 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2005 if (!$user->hasRight(
'agenda',
'allactions',
'read')) {
2006 $filters[
'search_filtert'] = (
string) $user->id;
2010 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2011 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
2012 if (!empty($hookmanager->resPrint)) {
2013 $sql .= $hookmanager->resPrint;
2016 $sql .=
" FROM " . MAIN_DB_PREFIX .
"actioncomm as a";
2018 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"user as u on u.rowid = a.fk_user_action";
2020 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"c_actioncomm as c ON a.fk_action = c.id";
2025 $force_filter_contact =
false;
2026 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2027 $force_filter_contact =
true;
2029 if (is_object($objcon) && $objcon->id > 0) {
2030 $force_filter_contact =
true;
2034 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
2035 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
2036 if (!empty($hookmanager->resPrint)) {
2037 $sql .= $hookmanager->resPrint;
2039 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
2040 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"socpeople as sp ON a.fk_contact = sp.rowid";
2041 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2042 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"element_resources as er";
2043 $sql .=
" ON er.resource_type = 'dolresource'";
2044 $sql .=
" AND er.element_type = 'action'";
2045 $sql .=
" AND er.element_id = a.id";
2046 $sql .=
" AND er.resource_id = " . ((int) $filterobj->id);
2047 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
2049 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2050 $sql .=
", " . MAIN_DB_PREFIX .
"adherent as m";
2051 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2052 $sql .=
", " . MAIN_DB_PREFIX .
"commande_fournisseur as o";
2053 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2054 $sql .=
", " . MAIN_DB_PREFIX .
"product as o";
2055 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2056 $sql .=
", " . MAIN_DB_PREFIX .
"ticket as o";
2057 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2058 $sql .=
", " . MAIN_DB_PREFIX .
"bom_bom as o";
2059 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2060 $sql .=
", " . MAIN_DB_PREFIX .
"contrat as o";
2061 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2062 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"expedition as s ON a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2063 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Propal') {
2064 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"propal as o ON a.fk_element = o.rowid AND a.elementtype = 'propal'";
2066 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2067 && ((!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'])))
2068 && $filterobj->table_element && $filterobj->element
2070 $sql .=
", " . MAIN_DB_PREFIX . $filterobj->table_element .
" as o";
2073 $sql .=
" WHERE a.entity IN (" .
getEntity(
'agenda') .
")";
2074 if (!$force_filter_contact) {
2075 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
2076 $sql .=
" AND a.fk_soc = " . ((int) $filterobj->id);
2077 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
2079 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
2080 $sql .=
" AND a.fk_project = " . ((int) $filterobj->id);
2081 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2082 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
2083 if ($filterobj->id) {
2084 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2086 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
2087 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
2088 if ($filterobj->id) {
2089 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2091 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2092 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
2093 if ($filterobj->id) {
2094 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2096 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
2097 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
2098 if ($filterobj->id) {
2099 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2101 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
2102 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice_supplier'";
2103 if ($filterobj->id) {
2104 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2106 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2107 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
2108 if ($filterobj->id) {
2109 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2111 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2112 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
2113 if ($filterobj->id) {
2114 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2116 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
2117 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
2118 if ($filterobj->id) {
2119 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2121 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
2122 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
2123 if ($filterobj->id) {
2124 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2126 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Expedition') {
2127 $sql .=
" AND a.fk_element = s.rowid AND a.elementtype = 'shipping'";
2128 if ($filterobj->id) {
2129 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2132 is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
2133 && ((!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'])))
2134 && $filterobj->table_element && $filterobj->element
2137 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '" .
$db->escape($filterobj->element. ($module ?
"@" . $module :
"")) .
"'";
2138 if ($filterobj->id) {
2139 $sql .=
" AND a.fk_element = " . ((int) $filterobj->id);
2141 } elseif (is_object($filterobj)) {
2142 return 'Bad value for $filterobj';
2145 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
2146 $sql .=
" AND (u.rowid = " . ((int) $filterobj->id) .
' OR ';
2147 $sql .=
" EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2148 $sql .=
" AND r.element_type = '" .
$db->escape($filterobj->table_element) .
"' AND r.fk_element = " . ((int) $filterobj->id) .
')';
2151 if (is_object($objcon) && $objcon->id > 0) {
2152 $sql .=
" AND EXISTS (SELECT r.rowid FROM " . MAIN_DB_PREFIX .
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
2153 $sql .=
" AND r.element_type = '" .
$db->escape($objcon->table_element) .
"' AND r.fk_element = " . ((int) $objcon->id) .
')';
2157 if (!empty($tms_start) && !empty($tms_end)) {
2158 $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) .
"'))";
2159 } elseif (empty($tms_start) && !empty($tms_end)) {
2160 $sql .=
" AND ((a.datep <= '" .
$db->idate($tms_end) .
"') OR (a.datep2 <= '" .
$db->idate($tms_end) .
"'))";
2161 } elseif (!empty($tms_start) && empty($tms_end)) {
2162 $sql .=
" AND ((a.datep >= '" .
$db->idate($tms_start) .
"') OR (a.datep2 >= '" .
$db->idate($tms_start) .
"'))";
2165 if (is_array($actioncode) && !empty($actioncode)) {
2168 foreach ($actioncode as $key => $code) {
2169 if ((
string) $code ===
'-1' || (
string) $code ===
'') {
2175 if (!empty($code)) {
2184 } elseif (!empty($actioncode) && $actioncode !=
'-1') {
2191 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
2192 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
2193 if (!empty($hookmanager->resPrint)) {
2194 $sql .= $hookmanager->resPrint;
2198 if (is_array($actioncode) && $objcon !==
null) {
2199 foreach ($actioncode as $code) {
2201 if (!empty($sql2)) {
2203 $sql = $sql .
" UNION " . $sql2;
2204 } elseif (empty($sql)) {
2210 } elseif ($objcon !==
null) {
2212 if (!empty($sql) && !empty($sql2)) {
2213 $sql = $sql .
" UNION " . $sql2;
2214 } elseif (empty($sql) && !empty($sql2)) {
2220 $MAXWITHOUTPAGINATION =
getDolGlobalInt(
'AGENDA_MAX_EVENTS_ON_PAGE_WITHOUT_PAGINATION', 100);
2226 $limit = $MAXWITHOUTPAGINATION;
2229 $sql .=
$db->order($sortfield_new, $sortorder);
2231 $sql .=
$db->plimit($limit + 1, $offset);
2234 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
2236 $resql =
$db->query($sql);
2239 $num =
$db->num_rows($resql);
2241 $imaxinloop = ($limit ? min($num, $limit) : $num);
2242 while ($i < $imaxinloop) {
2243 $obj =
$db->fetch_object($resql);
2248 if ($obj->type ==
'action') {
2250 $contactaction->id = $obj->id;
2251 $result = $contactaction->fetchResources();
2254 setEventMessage(
"company.lib::show_actions_done Error fetch resource",
'errors');
2260 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
2264 $histo[$numaction] = array(
2265 'type' => $obj->type,
2266 'tododone' => $tododone,
2267 'id' => (
int) $obj->id,
2268 'datestart' =>
$db->jdate($obj->dp),
2269 'dateend' =>
$db->jdate($obj->dp2),
2270 'fulldayevent' => (
int) $obj->fulldayevent,
2271 'note' => $obj->label,
2272 'percent' => (
int) $obj->percent,
2274 'userid' => (
int) $obj->user_id,
2275 'login' => $obj->user_login,
2276 'userfirstname' => $obj->user_firstname,
2277 'userlastname' => $obj->user_lastname,
2278 'userphoto' => $obj->user_photo,
2280 'contact_id' => (
int) $obj->fk_contact,
2281 'socpeopleassigned' => $contactaction->socpeopleassigned,
2282 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
2283 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
2284 'fk_element' => (int) $obj->fk_element,
2285 'elementtype' => $obj->elementtype,
2287 'code' => $obj->code,
2290 'acode' => $obj->acode,
2291 'alabel' => $obj->alabel,
2292 'libelle' => $obj->alabel,
2293 'apicto' => $obj->apicto
2296 $histo[$numaction] = array(
2297 'type' => $obj->type,
2298 'tododone' =>
'done',
2299 'id' => (
int) $obj->id,
2300 'datestart' =>
$db->jdate($obj->dp),
2301 'dateend' =>
$db->jdate($obj->dp2),
2302 'fulldayevent' => (
int) $obj->fulldayevent,
2303 'note' => $obj->label,
2304 'percent' => (
int) $obj->percent,
2306 'code' => $obj->code,
2309 'acode' => $obj->acode,
2311 'userid' => (
int) $obj->user_id,
2312 'login' => $obj->user_login,
2313 'userfirstname' => $obj->user_firstname,
2314 'userlastname' => $obj->user_lastname,
2315 'userphoto' => $obj->user_photo
2327 '@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';
2330 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
2332 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
2333 include_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
2334 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
2335 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
2341 $userlinkcache = array();
2343 $elementlinkcache = array();
2345 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2346 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2348 $objcon && get_class($objcon) ==
'Contact' &&
2349 (is_null($filterobj) || get_class($filterobj) ==
'Societe')
2351 $out .=
'<input type="hidden" name="id" value="' . $objcon->id .
'" />';
2353 $out .=
'<input type="hidden" name="id" value="' . $filterobj->id .
'" />';
2355 if ($filterobj && get_class($filterobj) ==
'Societe') {
2356 $out .=
'<input type="hidden" name="socid" value="' . $filterobj->id .
'" />';
2358 $out .=
'<input type="hidden" name="userid" value="' . $filterobj->id .
'" />';
2363 $out .=
'<div class="div-table-responsive-no-min">';
2364 $out .=
'<table class="noborder centpercent">';
2366 $out .=
'<tr class="liste_titre_filter">';
2369 if (
$conf->main_checkbox_left_column) {
2370 $out .=
'<th class="liste_titre width50 middle">';
2371 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2372 $out .= $searchpicto;
2377 $out .=
'<td class="liste_titre"></td>';
2381 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="' . (isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'') .
'"></td>';
2383 $out .=
'<td class="liste_titre center">';
2384 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
2387 $out .=
'<td class="liste_titre">';
2388 $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');
2391 $out .=
'<td class="liste_titre">';
2392 $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);
2395 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth200" name="search_agenda_label" value="' . $filters[
'search_agenda_label'] .
'"></td>';
2396 $out .=
'<td class="liste_titre"></td>';
2397 $out .=
'<td class="liste_titre"></td>';
2399 $out .=
'<td class="liste_titre parentonrightofpage">';
2400 $out .= $formactions->form_select_status_action(
'formaction', $percent, 1,
'search_complete', 1, 2,
'search_status width100 onrightofpage', 1);
2403 if (!
$conf->main_checkbox_left_column) {
2404 $out .=
'<td class="liste_titre" align="middle">';
2405 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2406 $out .= $searchpicto;
2411 $out .=
'<tr class="liste_titre">';
2413 if (
$conf->main_checkbox_left_column) {
2414 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2416 if ($donetodo && $filterobj !==
null) {
2418 if (get_class($filterobj) ==
'Societe') {
2419 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&socid=' . $filterobj->id .
'&status=done">';
2421 if (get_class($filterobj) ==
'User') {
2422 $tmp .=
'<a href="' . DOL_URL_ROOT .
'/comm/action/list.php?mode=show_list&userid=' . $filterobj->id .
'&status=done">';
2424 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2425 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2426 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2428 if (get_class($filterobj) ==
'Societe') {
2431 if (get_class($filterobj) ==
'User') {
2436 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2437 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2440 $out .=
getTitleFieldOfList(
"Title", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2441 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2442 $out .=
getTitleFieldOfList(
"LinkedObject", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2443 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2445 if (!
$conf->main_checkbox_left_column) {
2446 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2450 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/cactioncomm.class.php';
2452 $arraylist = $caction->liste_array(1,
'code',
'', (
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 0 : 1),
'', 1);
2454 foreach ($histo as $key => $value) {
2455 $actionstatic->fetch($histo[$key][
'id']);
2457 if (empty($actionstatic->code)) {
2458 $actionstatic->code = $histo[$key][
'acode'];
2460 $actionstatic->type_picto = $histo[$key][
'apicto'] ??
'';
2461 $actionstatic->type_code = $histo[$key][
'acode'];
2463 $out .=
'<tr class="oddeven">';
2466 if (
$conf->main_checkbox_left_column) {
2467 $out .=
'<td></td>';
2472 $out .=
'<td class="nowrap">';
2477 $out .=
'<td class="nowraponall">';
2478 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2479 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'">' .
img_object($langs->trans(
"ShowEMailing"),
"email") .
' ';
2480 $out .= $histo[$key][
'id'];
2483 $out .= $actionstatic->getNomUrl(1, -1);
2488 $out .=
'<td class="center nowraponall nopaddingtopimp nopaddingbottomimp">';
2490 $out .=
dolOutputDates($histo[$key][
'datestart'], $histo[$key][
'dateend'], (
int) $histo[$key][
'fulldayevent'], 0,
'',
'tzuserrel', 1);
2494 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2497 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2500 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2503 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2512 $out .=
'<td class="tdoverflowmax125">';
2513 if ($histo[$key][
'userid'] > 0) {
2514 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2515 $link = $userlinkcache[$histo[$key][
'userid']];
2517 $userstatic->fetch($histo[$key][
'userid']);
2518 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2519 $userlinkcache[$histo[$key][
'userid']] = $link;
2529 $labelOfTypeToShow = $actionstatic->type_code;
2531 $code = $actionstatic->code;
2532 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labelOfTypeToShow])) {
2533 $labelOfTypeToShow =
'AC_OTH';
2535 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2536 $labelOfTypeToShow = $langs->trans(
"Message");
2538 if (!empty($arraylist[$labelOfTypeToShow])) {
2539 $labelOfTypeToShow = $arraylist[$labelOfTypeToShow];
2540 } elseif ($actionstatic->type_code ==
'AC_EMAILING') {
2541 $langs->load(
"mails");
2542 $labelOfTypeToShow = $langs->trans(
"Emailing");
2544 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labelOfTypeToShow && !empty($arraylist[$actionstatic->code])) {
2545 $labelOfTypeToShow .=
' - ' . $arraylist[$actionstatic->code];
2549 $labelOfTypeToShowLong = $labelOfTypeToShow;
2550 if ($actionstatic->type_code ==
'AC_OTH_AUTO') {
2551 $labelOfTypeToShowLong .=
' (auto)';
2554 $out .=
'<td class="tdoverflowmax125" title="' . $labelOfTypeToShowLong .
'">';
2556 $out .= $actionstatic->getTypePicto();
2557 $out .= $labelOfTypeToShow;
2558 if (preg_match(
'/PRIVATE/', $actionstatic->code)) {
2559 $out .=
' ' .
img_picto($langs->trans(
"Private"),
'lock',
'class="valignmiddle"');
2564 $out .=
'<td class="tdoverflowmax300"';
2565 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2566 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2568 $label = $histo[$key][
'note'];
2569 $actionstatic->id = $histo[$key][
'id'];
2571 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2574 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2575 $transcode = $langs->trans(
"Action" . $histo[$key][
'acode']);
2576 $label = ($transcode !=
"Action" . $histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2577 $label .=
' - ' . $histo[$key][
'note'];
2578 $out .=
'<a href="' . DOL_URL_ROOT .
'/comm/mailing/card.php?id=' . $histo[$key][
'id'] .
'"';
2580 $label = preg_replace(
'/^\[[^\[]*\]/',
'[...]', $label);
2587 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2588 $out .=
'<td class="valignmiddle">';
2590 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2591 $result = $contact->fetch($cid);
2595 } elseif ($result > 0) {
2596 if (count($histo[$key][
'socpeopleassigned']) > 1) {
2597 $out .= $contact->getNomUrl(-2,
'', 0,
'', -1, 0,
'paddingright');
2599 $out .= $contact->getNomUrl(-3,
'', 0,
'', -1, 0,
'paddingright');
2600 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2601 if (!empty($contact->phone_pro)) {
2609 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2610 $contactstatic->lastname = $histo[$key][
'lastname'];
2611 $contactstatic->firstname = $histo[$key][
'firstname'];
2612 $contactstatic->id = $histo[$key][
'contact_id'];
2613 $contactstatic->photo = $histo[$key][
'contact_photo'];
2614 $out .=
'<td width="120">' . $contactstatic->getNomUrl(-1,
'', 10) .
'</td>';
2616 $out .=
'<td> </td>';
2620 $out .=
'<td class="tdoverflowmax200 nowraponall">';
2621 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2622 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2623 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2625 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2626 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2628 $link =
dolGetElementUrl((
int) $histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2629 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2636 $out .=
'<td class="nowrap center">';
2637 $out .= $actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']);
2641 if (!
$conf->main_checkbox_left_column) {
2642 $out .=
'<td></td>';
2647 if (empty($histo)) {
2649 $out .=
'<tr><td colspan="' . $colspan .
'"><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
2652 if ($num > $MAXWITHOUTPAGINATION) {
2653 $langs->load(
"errors");
2655 $out .=
'<tr><td class="center" colspan="' . $colspan .
'"><span class="opacitymedium">...' . $langs->trans(
"WarningTooManyDataPleaseUseMoreFilters", $MAXWITHOUTPAGINATION) .
'...</span></td></tr>';
2658 $out .=
"</table>\n";