45 global $db, $langs, $conf, $user;
51 $head[$h][0] = DOL_URL_ROOT.
'/societe/card.php?socid='.
$object->id;
52 $head[$h][1] = $langs->trans(
"ThirdParty");
53 $head[$h][2] =
'card';
57 if (!
getDolGlobalString(
'MAIN_DISABLE_CONTACTS_TAB') && $user->hasRight(
'societe',
'contact',
'lire')) {
61 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
62 $cachekey =
'count_contacts_thirdparty_'.$object->id;
65 if (!is_null($dataretrieved)) {
66 $nbContact = $dataretrieved;
68 $sql =
"SELECT COUNT(p.rowid) as nb";
69 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as p";
71 $parameters = array(
'contacttab' =>
true);
72 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters,
$object);
73 $sql .= $hookmanager->resPrint;
74 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
75 $sql .=
" AND p.entity IN (".getEntity(
$object->element).
")";
77 $parameters = array(
'contacttab' =>
true);
78 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
79 $sql .= $hookmanager->resPrint;
80 $resql = $db->query($sql);
82 $obj = $db->fetch_object($resql);
83 $nbContact = $obj->nb;
89 $head[$h][0] = DOL_URL_ROOT.
'/societe/contact.php?socid='.
$object->id;
90 $head[$h][1] = $langs->trans(
'ContactsAddresses');
92 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
94 $head[$h][2] =
'contact';
99 $head[$h][0] = DOL_URL_ROOT.
'/societe/societecontact.php?socid='.
$object->id;
100 $nbContact = count(
$object->liste_contact(-1,
'internal')) + count(
$object->liste_contact(-1,
'external'));
101 $head[$h][1] = $langs->trans(
"ContactsAddressesExt");
102 if ($nbContact > 0) {
103 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
105 $head[$h][2] =
'contactext';
110 $head[$h][0] = DOL_URL_ROOT.
'/comm/card.php?socid='.
$object->id;
113 $head[$h][1] .= $langs->trans(
"Prospect");
116 $head[$h][1] .=
' | ';
119 $head[$h][1] .= $langs->trans(
"Customer");
121 $head[$h][2] =
'customer';
125 $langs->load(
"products");
127 $head[$h][0] = DOL_URL_ROOT.
'/societe/price.php?socid='.
$object->id;
128 $head[$h][1] = $langs->trans(
"CustomerPrices");
129 $head[$h][2] =
'price';
133 $supplier_module_enabled = 0;
134 if (isModEnabled(
'supplier_proposal') || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
135 $supplier_module_enabled = 1;
137 if ($supplier_module_enabled == 1 &&
$object->fournisseur && $user->hasRight(
'fournisseur',
'lire')) {
138 $head[$h][0] = DOL_URL_ROOT.
'/fourn/card.php?socid='.
$object->id;
139 $head[$h][1] = $langs->trans(
"Supplier");
140 $head[$h][2] =
'supplier';
144 if (isModEnabled(
'project') && ($user->hasRight(
'projet',
'lire'))) {
147 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
148 $cachekey =
'count_projects_thirdparty_'.$object->id;
151 if (!is_null($dataretrieved)) {
152 $nbProject = $dataretrieved;
154 $sql =
"SELECT COUNT(n.rowid) as nb";
155 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as n";
156 $sql .=
" WHERE fk_soc = ".((int)
$object->id);
157 $sql .=
" AND entity IN (".getEntity(
'project').
")";
158 $resql = $db->query($sql);
160 $obj = $db->fetch_object($resql);
161 $nbProject = $obj->nb;
167 $head[$h][0] = DOL_URL_ROOT.
'/societe/project.php?socid='.
$object->id;
168 $head[$h][1] = $langs->trans(
"Projects");
169 if ($nbProject > 0) {
170 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbProject.
'</span>';
172 $head[$h][2] =
'project';
178 $head[$h][0] = DOL_URL_ROOT.
'/resource/element_resource.php?element=societe&element_id='.
$object->id;
179 $head[$h][1] = $langs->trans(
"Resources");
180 $head[$h][2] =
'resources';
185 if ((isModEnabled(
'order') || isModEnabled(
'propal') || isModEnabled(
'invoice') || isModEnabled(
'intervention') || isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice"))
187 $head[$h][0] = DOL_URL_ROOT.
'/societe/consumption.php?socid='.
$object->id;
188 $head[$h][1] = $langs->trans(
"Referers");
189 $head[$h][2] =
'consumption';
196 $foundonexternalonlinesystem = 0;
197 $langs->load(
"bills");
199 $title = $langs->trans(
"PaymentModes");
201 if (isModEnabled(
'stripe')) {
207 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
209 $stripecu = $societeaccount->getCustomerAccount(
$object->id,
'stripe', $servicestatus);
211 $foundonexternalonlinesystem++;
215 $sql =
"SELECT COUNT(n.rowid) as nb";
216 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_rib as n";
217 $sql .=
" WHERE n.fk_soc = ".((int)
$object->id);
218 if (!isModEnabled(
'stripe')) {
219 $sql .=
" AND n.stripe_card_ref IS NULL";
221 $sql .=
" AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".((int) $servicestatus).
"))";
224 $resql = $db->query($sql);
226 $obj = $db->fetch_object($resql);
227 $nbBankAccount = $obj->nb;
234 $head[$h][0] = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.urlencode((
string) (
$object->id));
235 $head[$h][1] = $title;
236 if ($foundonexternalonlinesystem) {
237 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
238 } elseif ($nbBankAccount > 0) {
239 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbBankAccount.
'</span>';
241 $head[$h][2] =
'rib';
245 if ((isModEnabled(
'website') || isModEnabled(
'webportal')) && $user->hasRight(
'societe',
'lire')) {
246 $site_filter_list = array();
247 if (isModEnabled(
'website')) {
248 $site_filter_list[] =
'dolibarr_website';
250 if (isModEnabled(
'webportal')) {
251 $site_filter_list[] =
'dolibarr_portal';
254 $head[$h][0] = DOL_URL_ROOT.
'/societe/website.php?id='.urlencode((
string) (
$object->id));
255 $head[$h][1] = $langs->trans(
"WebSiteAccounts");
257 $sql =
"SELECT COUNT(n.rowid) as nb";
258 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as n";
259 $sql .=
" WHERE fk_soc = ".((int)
$object->id);
260 $sql .=
" AND entity IN (".getEntity(
'thirdpartyaccount').
")";
261 if (!empty($site_filter_list)) {
262 $sql .=
" AND n.site IN (".$db->sanitize(
"'".implode(
"','", $site_filter_list).
"'", 1).
")";
264 $resql = $db->query($sql);
266 $obj = $db->fetch_object($resql);
272 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
274 $head[$h][2] =
'website';
279 if ($user->hasRight(
'partnership',
'read')) {
280 $langs->load(
"partnership");
281 $nbPartnership = is_array(
$object->partnerships) ? count(
$object->partnerships) : 0;
282 $head[$h][0] = DOL_URL_ROOT.
'/partnership/partnership_list.php?socid='.
$object->id;
283 $head[$h][1] = $langs->trans(
"Partnerships");
285 $sql =
"SELECT COUNT(n.rowid) as nb";
286 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership as n";
287 $sql .=
" WHERE fk_soc = ".((int)
$object->id);
288 $sql .=
" AND entity IN (".getEntity(
'partnership').
")";
289 $resql = $db->query($sql);
291 $obj = $db->fetch_object($resql);
297 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
299 $head[$h][2] =
'partnerships';
300 if ($nbPartnership > 0) {
301 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbPartnership.
'</span>';
308 if (isModEnabled(
'ticket') && $user->hasRight(
"ticket",
"read")) {
312 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
313 $cachekey =
'count_ticket_thirdparty_'.$object->id;
315 if (!is_null($nbticketretreived)) {
316 $nbTicket = $nbticketretreived;
319 $sql =
"SELECT COUNT(t.rowid) as nb";
320 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
321 $sql .=
" WHERE t.fk_soc = ".((int)
$object->id);
322 $resql = $db->query($sql);
324 $obj = $db->fetch_object($resql);
325 $nbTicket = $obj->nb;
332 $head[$h][0] = DOL_URL_ROOT.
'/ticket/list.php?socid='.urlencode((
string) (
$object->id));
333 $head[$h][1] = $langs->trans(
"Tickets");
335 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbTicket.
'</span>';
337 $head[$h][2] =
'ticket';
348 if ($user->socid == 0) {
350 if (isModEnabled(
'notification')) {
351 $langs->load(
'mails');
354 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
355 $cachekey =
'count_notifications_thirdparty_'.$object->id;
357 if (!is_null($dataretrieved)) {
358 $nbNotif = $dataretrieved;
361 $sql =
"SELECT COUNT(n.rowid) as nb";
362 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as a,";
363 $sql .=
" ".MAIN_DB_PREFIX.
"notify_def as n,";
364 $sql .=
" ".MAIN_DB_PREFIX.
"socpeople as c";
365 $sql .=
" WHERE a.rowid = n.fk_action";
366 $sql .=
" AND c.rowid = n.fk_contact";
367 $sql .=
" AND c.fk_soc = ".((int)
$object->id);
368 $resql = $db->query($sql);
370 $obj = $db->fetch_object($resql);
378 $head[$h][0] = DOL_URL_ROOT.
'/societe/notify/card.php?socid='.urlencode((
string) (
$object->id));
379 $head[$h][1] = $langs->trans(
"Notifications");
381 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNotif.
'</span>';
383 $head[$h][2] =
'notify';
389 if (!empty(
$object->note_private)) {
392 if (!empty(
$object->note_public)) {
395 $head[$h][0] = DOL_URL_ROOT.
'/societe/note.php?id='.urlencode((
string) (
$object->id));
396 $head[$h][1] = $langs->trans(
"Notes");
398 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
400 $head[$h][2] =
'note';
406 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
407 $cachekey =
'count_attached_thirdparty_'.$object->id;
409 if (!is_null($dataretrieved)) {
410 $totalAttached = $dataretrieved;
412 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
413 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
414 $upload_dir = $conf->societe->multidir_output[
$object->entity].
"/".
$object->id;
415 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
417 $totalAttached = $nbFiles + $nbLinks;
421 $head[$h][0] = DOL_URL_ROOT.
'/societe/document.php?socid='.
$object->id;
422 $head[$h][1] = $langs->trans(
"Documents");
423 if (($totalAttached) > 0) {
424 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
426 $head[$h][2] =
'document';
430 $head[$h][0] = DOL_URL_ROOT.
'/societe/messaging.php?socid='.
$object->id;
431 $head[$h][1] = $langs->trans(
"Events");
432 if (isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
435 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
436 $cachekey =
'count_events_thirdparty_'.$object->id;
438 if (!is_null($dataretrieved)) {
439 $nbEvent = $dataretrieved;
441 $sql =
"SELECT COUNT(id) as nb";
442 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
443 $sql .=
" WHERE fk_soc = ".((int)
$object->id);
444 $sql .=
" AND entity IN (".getEntity(
'agenda').
")";
445 $resql = $db->query($sql);
447 $obj = $db->fetch_object($resql);
450 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
456 $head[$h][1] .= $langs->trans(
"Agenda");
458 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
461 $head[$h][2] =
'agenda';
874 global $user, $action, $hookmanager, $form, $massactionbutton, $massaction, $arrayofselected, $arrayofmassactions;
878 if (isModEnabled(
'project') && $user->hasRight(
'projet',
'lire')) {
879 $langs->load(
"projects");
882 if (isModEnabled(
'project') && $user->hasRight(
'projet',
'creer') && empty($nocreatelink)) {
883 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'AddProject'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/projet/card.php?socid='.
$object->id.
'&action=create&backtopage='.urlencode($backtopage));
887 print
load_fiche_titre($langs->trans(
"ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright,
'');
889 print
'<div class="div-table-responsive">'.
"\n";
890 print
'<table class="noborder centpercent">';
892 $sql =
"SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_modification, p.budget_amount";
893 $sql .=
", cls.code as opp_status_code";
894 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
895 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls on p.fk_opp_status = cls.rowid";
896 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
897 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
898 $sql .=
" ORDER BY p.dateo DESC";
900 $result = $db->query($sql);
902 $num = $db->num_rows($result);
904 print
'<tr class="liste_titre">';
906 print
'<td class="center">';
907 $selectedfields = (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
908 print $selectedfields;
911 print
'<td>'.$langs->trans(
"Ref").
'</td>';
912 print
'<td>'.$langs->trans(
"Name").
'</td>';
913 print
'<td class="center">'.$langs->trans(
"DateStart").
'</td>';
914 print
'<td class="center">'.$langs->trans(
"DateEnd").
'</td>';
915 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
916 print
'<td class="center">'.$langs->trans(
"OpportunityStatusShort").
'</td>';
917 print
'<td class="right">'.$langs->trans(
"OpportunityProbabilityShort").
'</td>';
918 print
'<td class="right">'.$langs->trans(
"Status").
'</td>';
920 print
'<td class="center">';
921 $selectedfields = (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
922 print $selectedfields;
928 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
930 $projecttmp =
new Project($db);
935 $obj = $db->fetch_object($result);
936 $projecttmp->fetch($obj->id);
939 $userAccess = $projecttmp->restrictedProjectArea($user);
941 if ($user->hasRight(
'projet',
'lire') && $userAccess > 0) {
942 print
'<tr class="oddeven">';
945 print
'<td class="nowrap center actioncolumn">';
946 if ($massactionbutton || $massaction) {
948 if (in_array($obj->id, $arrayofselected)) {
951 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
956 print
'<td class="nowraponall">';
957 print $projecttmp->getNomUrl(1,
'', 0,
'',
'-', 0, 1,
'',
'project:'.$_SERVER[
"PHP_SELF"].
'?socid=__SOCID__');
961 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
963 print
'<td class="center">'.dol_print_date($db->jdate($obj->do),
"day").
'</td>';
965 print
'<td class="center">'.dol_print_date($db->jdate($obj->de),
"day").
'</td>';
967 print
'<td class="right">';
968 if ($obj->opp_status_code) {
969 print
'<span class="amount">'.price($obj->opp_amount, 1,
'', 1, -1, -1,
'').
'</span>';
973 print
'<td class="center">';
974 if ($obj->opp_status_code) {
975 print $langs->trans(
"OppStatus".$obj->opp_status_code);
979 print
'<td class="right">';
980 if ($obj->opp_percent) {
981 print
price($obj->opp_percent, 1,
'', 1, 0).
'%';
985 print
'<td class="right">'.$projecttmp->getLibStatut(5).
'</td>';
989 print
'<td class="nowrap center actioncolumn">';
990 if ($massactionbutton || $massaction) {
992 if (in_array($obj->id, $arrayofselected)) {
995 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1004 print
'<tr class="oddeven"><td colspan="9"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1014 print
load_fiche_titre($langs->trans(
"ProjectsLinkedToThisThirdParty"),
'',
'');
1017 print
'<div class="div-table-responsive">'.
"\n";
1018 print
'<table class="noborder centpercent">';
1020 $sql =
"SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
1021 $sql .=
", cls.code as opp_status_code";
1022 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
1023 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls on p.fk_opp_status = cls.rowid";
1024 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_contact as ec on p.rowid = ec.element_id";
1025 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sc on ec.fk_socpeople = sc.rowid";
1026 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc on ec.fk_c_type_contact = tc.rowid";
1027 $sql .=
" WHERE sc.fk_soc = ".((int)
$object->id);
1028 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
1029 $sql .=
" AND tc.element = 'project' AND tc.source = 'external'";
1030 $sql .=
" ORDER BY p.dateo DESC";
1032 $result = $db->query($sql);
1034 $num = $db->num_rows($result);
1036 print
'<tr class="liste_titre">';
1037 print
'<td>'.$langs->trans(
"Ref").
'</td>';
1038 print
'<td>'.$langs->trans(
"Name").
'</td>';
1039 print
'<td class="center">'.$langs->trans(
"DateStart").
'</td>';
1040 print
'<td class="center">'.$langs->trans(
"DateEnd").
'</td>';
1041 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
1042 print
'<td class="center">'.$langs->trans(
"OpportunityStatusShort").
'</td>';
1043 print
'<td class="right">'.$langs->trans(
"OpportunityProbabilityShort").
'</td>';
1044 print
'<td class="right">'.$langs->trans(
"Status").
'</td>';
1048 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1050 $projecttmp =
new Project($db);
1055 $obj = $db->fetch_object($result);
1056 $projecttmp->fetch($obj->id);
1059 $userAccess = $projecttmp->restrictedProjectArea($user);
1061 if ($user->rights->projet->lire && $userAccess > 0) {
1062 print
'<tr class="oddeven">';
1065 print
'<td class="nowraponall">';
1066 print $projecttmp->getNomUrl(1,
'', 0,
'',
'-', 0, 1,
'',
'project:'.$_SERVER[
"PHP_SELF"].
'?socid=__SOCID__');
1070 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
1072 print
'<td class="center">'.dol_print_date($db->jdate($obj->do),
"day").
'</td>';
1074 print
'<td class="center">'.dol_print_date($db->jdate($obj->de),
"day").
'</td>';
1076 print
'<td class="right">';
1077 if ($obj->opp_status_code) {
1078 print
'<span class="amount">'.price($obj->opp_amount, 1,
'', 1, -1, -1,
'').
'</span>';
1082 print
'<td class="center">';
1083 if ($obj->opp_status_code) {
1084 print $langs->trans(
"OppStatus".$obj->opp_status_code);
1088 print
'<td class="right">';
1089 if ($obj->opp_percent) {
1090 print
price($obj->opp_percent, 1,
'', 1, 0).
'%';
1094 print
'<td class="right">'.$projecttmp->getLibStatut(5).
'</td>';
1101 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1109 $parameters = array(
'sql' => $sql,
'function' =>
'show_projects');
1110 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object, $action);
1111 print $hookmanager->resPrint;
1136 global $user, $conf, $extrafields, $hookmanager;
1137 global $contextpage;
1139 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
1141 $form =
new Form($db);
1143 $optioncss =
GETPOST(
'optioncss',
'alpha');
1144 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1145 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1148 $search_status =
GETPOST(
"search_status",
"intcomma");
1149 if ($search_status ==
'') {
1153 $search_rowid =
GETPOST(
"search_rowid",
"intcomma");
1154 $search_name =
GETPOST(
"search_name",
'alpha');
1155 $search_address =
GETPOST(
"search_address",
'alpha');
1156 $search_poste =
GETPOST(
"search_poste",
'alpha');
1157 $search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
1158 $search_roles =
GETPOST(
"search_roles",
'array');
1159 $search_birthday_dtstart =
GETPOST(
"search_birthday_dtstart",
'alpha');
1160 $search_birthday_dtend =
GETPOST(
"search_birthday_dtend",
'alpha');
1162 if ($search_birthday_dtstart !=
'' || $search_birthday_dtend !=
'') {
1168 $searchAddressPhoneDBFields = array(
1196 $sortfield =
"t.lastname";
1199 if (isModEnabled(
'clicktodial')) {
1200 $user->fetch_clicktodial();
1204 $contactstatic =
new Contact($db);
1206 $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1208 $contactstatic->fields = array(
1209 'rowid' => array(
'type' =>
'integer',
'label' =>
"TechnicalID",
'enabled' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'visible' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'position' => 1),
1210 'name' => array(
'type' =>
'varchar(128)',
'label' =>
'Name',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 10,
'searchall' => 1),
1211 'poste' => array(
'type' =>
'varchar(128)',
'label' =>
'PostOrFunction',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 2,
'index' => 1,
'position' => 20),
1212 'address' => array(
'type' =>
'varchar(128)',
'label' =>
'Address',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 3,
'index' => 1,
'position' => 30),
1213 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => ((
int) !
getDolGlobalBool(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'visible' => 3,
'position' => 35),
1214 'role' => array(
'type' =>
'checkbox',
'label' =>
'Role',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 4,
'index' => 1,
'position' => 40),
1215 'birthday' => array(
'type' =>
'date',
'label' =>
'Birthday',
'enabled' => 1,
'visible' => -1,
'notnull' => 0,
'position' => 45),
1216 '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))),
1220 $arrayfields = array(
1221 't.rowid' => array(
'label' =>
"TechnicalID",
'checked' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'enabled' => (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'position' => 1),
1222 't.name' => array(
'label' =>
"Name",
'checked' => 1,
'position' => 10),
1223 't.poste' => array(
'label' =>
"PostOrFunction",
'checked' => 1,
'position' => 20),
1224 '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),
1225 't.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'position' => 35),
1226 'sc.role' => array(
'label' =>
"ContactByDefaultFor",
'checked' => 1,
'position' => 40),
1227 't.birthday' => array(
'label' =>
"Birthday",
'checked' => 0,
'position' => 45),
1228 't.statut' => array(
'label' =>
"Status",
'checked' => 1,
'position' => 50,
'class' =>
'center'),
1229 'u.user' => array(
'label' =>
"DolibarrLogin",
'checked' => 1,
'position' => 50,
'class' =>
'center'),
1232 if (!empty($extrafields->attributes[$contactstatic->table_element][
'label']) && is_array($extrafields->attributes[$contactstatic->table_element][
'label']) && count($extrafields->attributes[$contactstatic->table_element][
'label'])) {
1233 foreach ($extrafields->attributes[$contactstatic->table_element][
'label'] as $key => $val) {
1234 if (!empty($extrafields->attributes[$contactstatic->table_element][
'list'][$key])) {
1235 $arrayfields[
"ef.".$key] = array(
1236 'label' => $extrafields->attributes[$contactstatic->table_element][
'label'][$key],
1237 'checked' => (((
int)
dol_eval($extrafields->attributes[$contactstatic->table_element][
'list'][$key], 1, 1,
'1') < 0) ? 0 : 1),
1238 'position' => 1000 + $extrafields->attributes[$contactstatic->table_element][
'pos'][$key],
1239 'enabled' => (abs((
int)
dol_eval($extrafields->attributes[$contactstatic->table_element][
'list'][$key], 1)) != 3 && (int)
dol_eval($extrafields->attributes[$contactstatic->table_element][
'perms'][$key], 1, 1,
'1'))
1247 foreach ($arrayfields as $key => $val) {
1248 $queryName =
'search_'.substr($key, 2);
1249 if (
GETPOST($queryName,
'alpha')) {
1250 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1253 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1256 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1258 $search_status =
'';
1260 $search_roles = array();
1261 $search_address =
'';
1263 $search_note_private =
'';
1264 $search_birthday_dtstart =
'';
1265 $search_birthday_dtend =
'';
1267 $search_array_options = array();
1269 foreach ($contactstatic->fields as $key => $val) {
1274 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1277 $newcardbutton =
'';
1278 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1279 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1280 $newcardbutton .=
dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?socid='.
$object->id.
'&action=create&backtopage='.urlencode($backtopage));
1285 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1288 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
1289 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1290 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1291 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1292 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1293 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1294 print
'<input type="hidden" name="page" value="'.$page.
'">';
1296 $arrayofmassactions = array();
1299 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1300 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1301 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1302 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1304 print
'<div class="div-table-responsive">';
1305 print
"\n".
'<table class="tagtable liste noborder">'.
"\n";
1307 $param =
"socid=".urlencode((
string) (
$object->id));
1308 if ($search_rowid !=
'') {
1309 $param .=
'&search_rowid='.urlencode((
string) ($search_rowid));
1311 if ($search_status !=
'') {
1312 $param .=
'&search_status='.urlencode((
string) ($search_status));
1314 if (count($search_roles) > 0) {
1315 $param .= implode(
'&search_roles[]=', $search_roles);
1317 if ($search_name !=
'') {
1318 $param .=
'&search_name='.urlencode($search_name);
1320 if ($search_poste !=
'') {
1321 $param .=
'&search_poste='.urlencode($search_poste);
1323 if ($search_address !=
'') {
1324 $param .=
'&search_address='.urlencode($search_address);
1326 if ($search_note_private !=
'') {
1327 $param .=
'&search_note_private='.urlencode($search_note_private);
1329 if ($search_birthday_dtstart !=
'') {
1330 $param .=
'&search_birthday_dtstart='.urlencode($search_birthday_dtstart);
1332 if ($search_birthday_dtend !=
'') {
1333 $param .=
'&search_birthday_dtend='.urlencode($search_birthday_dtend);
1335 if ($optioncss !=
'') {
1336 $param .=
'&optioncss='.urlencode($optioncss);
1340 $extrafieldsobjectkey = $contactstatic->table_element;
1341 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1343 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1344 $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,";
1345 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1346 $sql .=
" t.note_private";
1347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as t";
1348 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1349 $sql .=
" WHERE t.fk_soc = ".((int)
$object->id);
1350 $sql .=
" AND t.entity IN (" .getEntity(
'socpeople') .
")";
1351 $sql .=
" AND ((t.fk_user_creat = ".((int) $user->id).
" AND t.priv = 1) OR t.priv = 0)";
1352 if ($search_rowid) {
1355 if ($search_status !=
'' && $search_status !=
'-1') {
1356 $sql .=
" AND t.statut = ".((int) $search_status);
1359 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1361 if ($search_poste) {
1364 if ($search_address) {
1365 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1367 if ($search_note_private) {
1370 if ($search_birthday_dtstart !=
'') {
1371 $sql .=
" AND t.birthday >= '".$db->idate($search_birthday_dtstart).
"'";
1373 if ($search_birthday_dtend !=
'') {
1374 $sql .=
" AND t.birthday <= '".$db->idate($search_birthday_dtend).
"'";
1376 if (count($search_roles) > 0) {
1377 $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)).
"))";
1380 $extrafieldsobjectkey = $contactstatic->table_element;
1381 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1383 $parameters = array(
'socid' =>
$object->id);
1384 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
1385 $sql .= $hookmanager->resPrint;
1386 if ($sortfield ==
"t.name") {
1387 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1389 $sql .=
" ORDER BY $sortfield $sortorder";
1392 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1393 $result = $db->query($sql);
1398 $num = $db->num_rows($result);
1402 print
'<tr class="liste_titre">';
1405 print
'<td class="liste_titre" align="right">';
1406 print $form->showFilterButtons();
1409 foreach ($contactstatic->fields as $key => $val) {
1411 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1412 $align .= ($align ?
' ' :
'').
'center';
1414 if (in_array($val[
'type'], array(
'timestamp'))) {
1415 $align .= ($align ?
' ' :
'').
'nowrap';
1417 if ($key ==
'status' || $key ==
'statut') {
1418 $align .= ($align ?
' ' :
'').
'center';
1420 if (!empty($arrayfields[
't.'.$key][
'checked']) || !empty($arrayfields[
'sc.'.$key][
'checked'])) {
1421 print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'">';
1422 if (in_array($key, array(
'statut'))) {
1423 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');
1424 } elseif (in_array($key, array(
'role'))) {
1425 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1426 } elseif (in_array($key, array(
'birthday'))) {
1427 print
'<div class="nowrap">';
1428 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1430 print
'<div class="nowrap">';
1431 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1434 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.(!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'').
'">';
1439 if ($showuserlogin) {
1440 print
'<td class="liste_titre"></td>';
1443 $extrafieldsobjectkey = $contactstatic->table_element;
1444 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1447 $parameters = array(
'arrayfields' => $arrayfields);
1448 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1449 print $hookmanager->resPrint;
1452 print
'<td class="liste_titre" align="right">';
1453 print $form->showFilterButtons();
1461 print
'<tr class="liste_titre">';
1464 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1466 foreach ($contactstatic->fields as $key => $val) {
1468 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1469 $align .= ($align ?
' ' :
'').
'center';
1471 if (in_array($val[
'type'], array(
'timestamp'))) {
1472 $align .= ($align ?
' ' :
'').
'nowrap';
1474 if ($key ==
'status' || $key ==
'statut') {
1475 $align .= ($align ?
' ' :
'').
'center';
1477 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
1478 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1480 if ($key ==
'role') {
1481 $align .= ($align ?
' ' :
'').
'left';
1483 if (!empty($arrayfields[
'sc.'.$key][
'checked'])) {
1484 print
getTitleFieldOfList($arrayfields[
'sc.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1487 if ($showuserlogin) {
1488 print
'<th class="wrapcolumntitle liste_titre">'.$langs->trans(
"DolibarrLogin").
'</th>';
1491 $extrafieldsobjectkey = $contactstatic->table_element;
1492 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1494 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1495 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
1496 print $hookmanager->resPrint;
1499 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1505 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1509 $obj = $db->fetch_object($result);
1511 $contactstatic->id = $obj->rowid;
1512 $contactstatic->ref = $obj->rowid;
1513 $contactstatic->statut = $obj->statut;
1514 $contactstatic->lastname = $obj->lastname;
1515 $contactstatic->firstname = $obj->firstname;
1516 $contactstatic->civility_id = $obj->civility_id;
1517 $contactstatic->civility_code = $obj->civility_id;
1518 $contactstatic->poste = $obj->poste;
1519 $contactstatic->address = $obj->address;
1520 $contactstatic->zip = $obj->zip;
1521 $contactstatic->town = $obj->town;
1522 $contactstatic->phone_pro = $obj->phone_pro;
1523 $contactstatic->phone_mobile = $obj->phone_mobile;
1524 $contactstatic->phone_perso = $obj->phone_perso;
1525 $contactstatic->email = $obj->email;
1526 $contactstatic->socialnetworks = $obj->socialnetworks;
1527 $contactstatic->photo = $obj->photo;
1528 $contactstatic->fk_soc = $obj->fk_soc;
1529 $contactstatic->entity = $obj->entity;
1531 $country_code =
getCountry($obj->country_id,
'2');
1532 $contactstatic->country_code = $country_code;
1534 $contactstatic->setGenderFromCivility();
1535 $contactstatic->fetch_optionals();
1537 $resultRole = $contactstatic->fetchRoles();
1538 if ($resultRole < 0) {
1542 if (is_array($contactstatic->array_options)) {
1543 foreach ($contactstatic->array_options as $key => $val) {
1548 print
'<tr class="oddeven">';
1552 print
'<td class="nowrap center">';
1555 if (isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1556 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.
$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1557 print
img_object($langs->trans(
"Event"),
"action");
1558 print
'</a> ';
1562 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1563 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.
newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1569 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1570 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).
'">';
1579 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1581 print $contactstatic->id;
1586 if (!empty($arrayfields[
't.name'][
'checked'])) {
1587 print
'<td class="tdoverflowmax150">';
1588 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0, 1);
1589 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage='.urlencode($backtopage));
1594 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1595 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->poste).
'">';
1603 if (!empty($arrayfields[
't.address'][
'checked'])) {
1604 $addresstoshow = $contactstatic->getBannerAddress(
'contact',
$object);
1605 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($addresstoshow).
'">';
1606 print $addresstoshow;
1611 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1612 print
'<td class="center">';
1618 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1619 print
'<td class="tdoverflowmax150">';
1620 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1625 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1626 print
'<td class="nowraponall">';
1632 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1633 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1636 if ($showuserlogin) {
1637 print
'<td class="tdoverflowmax125">';
1638 $tmpuser =
new User($db);
1640 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1641 if ($resfetch > 0) {
1642 print $tmpuser->getNomUrl(-1,
'', 0, 0, 24, 1);
1648 $extrafieldsobjectkey = $contactstatic->table_element;
1649 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1653 print
'<td class="nowrap center">';
1656 if (isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1657 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.
$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1658 print
img_object($langs->trans(
"Event"),
"action");
1659 print
'</a> ';
1663 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1664 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.
newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1670 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1671 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).
'">';
1684 $colspan = 1 + ($showuserlogin ? 1 : 0);
1685 foreach ($arrayfields as $key => $val) {
1686 if (!empty($val[
'checked'])) {
1690 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1693 $colspan = 1 + ($showuserlogin ? 1 : 0);
1694 foreach ($arrayfields as $key => $val) {
1695 if (!empty($val[
'checked'])) {
1699 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1701 print
"\n</table>\n";
1704 print
'</form>'.
"\n";
1754function show_actions_done($conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1756 global $user, $conf, $hookmanager;
1758 global $param, $massactionbutton;
1760 $start_year =
GETPOSTINT(
'dateevent_startyear');
1761 $start_month =
GETPOSTINT(
'dateevent_startmonth');
1762 $start_day =
GETPOSTINT(
'dateevent_startday');
1764 $end_month =
GETPOSTINT(
'dateevent_endmonth');
1769 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1770 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1772 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1773 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1775 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1779 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
1782 if (!is_object($filterobj) && !is_object($objcon)) {
1792 $sortfield_list = explode(
',', $sortfield);
1793 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1794 $sortfield_new_list = array();
1795 foreach ($sortfield_list as $sortfield_value) {
1796 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1798 $sortfield_new = implode(
',', $sortfield_new_list);
1802 if (isModEnabled(
'agenda')) {
1804 $hookmanager->initHooks(array(
'agendadao'));
1806 $sql =
"SELECT a.id, a.label as label,";
1807 $sql .=
" a.datep as dp,";
1808 $sql .=
" a.datep2 as dp2,";
1809 $sql .=
" a.percent as percent, 'action' as type,";
1810 $sql .=
" a.fk_element, a.elementtype,";
1811 $sql .=
" a.fk_contact,";
1812 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1813 $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";
1814 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1815 $sql .=
", sp.lastname, sp.firstname";
1816 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1818 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1820 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1821 $sql .=
", m.lastname, m.firstname";
1822 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1824 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1826 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1828 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1830 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1832 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1833 if (!empty($filterobj->fields[
'ref'])) {
1835 } elseif (!empty($filterobj->fields[
'label'])) {
1836 $sql .=
", o.label";
1841 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1842 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
1843 if (!empty($hookmanager->resPrint)) {
1844 $sql .= $hookmanager->resPrint;
1847 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
1851 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
1856 $force_filter_contact =
false;
1857 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
1858 $force_filter_contact =
true;
1860 if (is_object($objcon) && $objcon->id > 0) {
1861 $force_filter_contact =
true;
1865 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1866 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
1867 if (!empty($hookmanager->resPrint)) {
1868 $sql .= $hookmanager->resPrint;
1870 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1871 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
1872 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1873 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
1874 $sql .=
" ON er.resource_type = 'dolresource'";
1875 $sql .=
" AND er.element_id = a.id";
1876 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
1877 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1879 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1880 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
1881 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1882 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
1883 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1884 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
1885 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1886 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
1887 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1888 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
1889 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1890 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
1891 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
1892 && ((!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'])))
1893 && $filterobj->table_element && $filterobj->element) {
1894 $sql .=
", ".MAIN_DB_PREFIX.$filterobj->table_element.
" as o";
1897 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1898 if (!$force_filter_contact) {
1899 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
1900 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
1901 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1903 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
1904 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
1905 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1906 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1907 if ($filterobj->id) {
1908 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1910 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
1911 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
1912 if ($filterobj->id) {
1913 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1915 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1916 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1917 if ($filterobj->id) {
1918 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1920 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
1921 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
1922 if ($filterobj->id) {
1923 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1925 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
1926 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice_supplier'";
1927 if ($filterobj->id) {
1928 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1930 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1931 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1932 if ($filterobj->id) {
1933 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1935 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1936 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1937 if ($filterobj->id) {
1938 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1940 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1941 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1942 if ($filterobj->id) {
1943 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1945 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1946 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1947 if ($filterobj->id) {
1948 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1950 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
1951 && ((!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'])))
1952 && $filterobj->table_element && $filterobj->element) {
1954 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ?
"@".$module :
"").
"'";
1955 if ($filterobj->id) {
1956 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1958 } elseif (is_object($filterobj)) {
1959 return 'Bad value for $filterobj';
1962 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
1963 $sql .=
" AND (u.rowid = ". ((int) $filterobj->id).
' OR ';
1964 $sql .=
" EXISTS (SELECT r.rowid FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
1965 $sql .=
" AND r.element_type = '".$db->escape($filterobj->table_element).
"' AND r.fk_element = ".((int) $filterobj->id).
')';
1968 if (is_object($objcon) && $objcon->id > 0) {
1969 $sql .=
" AND EXISTS (SELECT r.rowid FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
1970 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id).
')';
1974 if (!empty($tms_start) && !empty($tms_end)) {
1975 $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).
"'))";
1976 } elseif (empty($tms_start) && !empty($tms_end)) {
1977 $sql .=
" AND ((a.datep <= '".$db->idate($tms_end).
"') OR (a.datep2 <= '".$db->idate($tms_end).
"'))";
1978 } elseif (!empty($tms_start) && empty($tms_end)) {
1979 $sql .=
" AND ((a.datep >= '".$db->idate($tms_start).
"') OR (a.datep2 >= '".$db->idate($tms_start).
"'))";
1982 if (is_array($actioncode) && !empty($actioncode)) {
1984 foreach ($actioncode as $key => $code) {
1985 if ((
string) $code ==
'-1') {
1991 if (!empty($code)) {
1996 } elseif (!empty($actioncode) && $actioncode !=
'-1') {
2003 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
2004 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
2005 if (!empty($hookmanager->resPrint)) {
2006 $sql .= $hookmanager->resPrint;
2009 if (is_array($actioncode)) {
2010 foreach ($actioncode as $code) {
2012 if (!empty($sql2)) {
2014 $sql = $sql.
" UNION ".$sql2;
2015 } elseif (empty($sql)) {
2023 if (!empty($sql) && !empty($sql2)) {
2024 $sql = $sql.
" UNION ".$sql2;
2025 } elseif (empty($sql) && !empty($sql2)) {
2037 $sql .= $db->order($sortfield_new, $sortorder);
2039 $sql .= $db->plimit($limit + 1, $offset);
2042 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
2044 $resql = $db->query($sql);
2047 $num = $db->num_rows($resql);
2049 $imaxinloop = ($limit ? min($num, $limit) : $num);
2050 while ($i < $imaxinloop) {
2051 $obj = $db->fetch_object($resql);
2053 if ($obj->type ==
'action') {
2055 $contactaction->id = $obj->id;
2056 $result = $contactaction->fetchResources();
2059 setEventMessage(
"company.lib::show_actions_done Error fetch resource",
'errors');
2065 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
2069 $histo[$numaction] = array(
2070 'type' => $obj->type,
2071 'tododone' => $tododone,
2073 'datestart' => $db->jdate($obj->dp),
2074 'dateend' => $db->jdate($obj->dp2),
2075 'note' => $obj->label,
2076 'percent' => $obj->percent,
2078 'userid' => $obj->user_id,
2079 'login' => $obj->user_login,
2080 'userfirstname' => $obj->user_firstname,
2081 'userlastname' => $obj->user_lastname,
2082 'userphoto' => $obj->user_photo,
2084 'contact_id' => $obj->fk_contact,
2085 'socpeopleassigned' => $contactaction->socpeopleassigned,
2086 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
2087 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
2088 'fk_element' => $obj->fk_element,
2089 'elementtype' => $obj->elementtype,
2091 'acode' => $obj->acode,
2092 'alabel' => $obj->alabel,
2093 'libelle' => $obj->alabel,
2094 'apicto' => $obj->apicto
2097 $histo[$numaction] = array(
2098 'type' => $obj->type,
2099 'tododone' =>
'done',
2101 'datestart' => $db->jdate($obj->dp),
2102 'dateend' => $db->jdate($obj->dp2),
2103 'note' => $obj->label,
2104 'percent' => $obj->percent,
2105 'acode' => $obj->acode,
2107 'userid' => $obj->user_id,
2108 'login' => $obj->user_login,
2109 'userfirstname' => $obj->user_firstname,
2110 'userlastname' => $obj->user_lastname,
2111 'userphoto' => $obj->user_photo
2123 '@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,fk_element:string,elementtype:string,contact_id:string,lastname:string,firstname:string,contact_photo:string,socpeaopleassigned:int[],login:string,userfirstname:string,userlastname:string,userphoto:string}> $histo';
2125 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
2126 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
2128 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
2129 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2130 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2131 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2136 $userstatic =
new User($db);
2137 $userlinkcache = array();
2138 $contactstatic =
new Contact($db);
2139 $elementlinkcache = array();
2141 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2142 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2143 if ($objcon && get_class($objcon) ==
'Contact' &&
2144 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
2145 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
2147 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
2149 if ($filterobj && get_class($filterobj) ==
'Societe') {
2150 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
2152 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
2157 $out .=
'<div class="div-table-responsive-no-min">';
2158 $out .=
'<table class="noborder centpercent">';
2160 $out .=
'<tr class="liste_titre">';
2164 $out .=
'<th class="liste_titre width50 middle">';
2165 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2166 $out .= $searchpicto;
2171 $out .=
'<td class="liste_titre"></td>';
2175 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="'.(isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'').
'"></td>';
2177 $out .=
'<td class="liste_titre center">';
2178 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
2181 $out .=
'<td class="liste_titre"></td>';
2183 $out .=
'<td class="liste_titre">';
2184 $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 minwidth100 maxwidth150', 1);
2187 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'"></td>';
2188 $out .=
'<td class="liste_titre"></td>';
2189 $out .=
'<td class="liste_titre"></td>';
2190 $out .=
'<td class="liste_titre"></td>';
2193 $out .=
'<td class="liste_titre" align="middle">';
2194 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2195 $out .= $searchpicto;
2200 $out .=
'<tr class="liste_titre">';
2203 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2205 if ($donetodo && $filterobj !==
null) {
2207 if (get_class($filterobj) ==
'Societe') {
2208 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
2210 if (get_class($filterobj) ==
'User') {
2211 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&userid='.$filterobj->id.
'&status=done">';
2213 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2214 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2215 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2217 if (get_class($filterobj) ==
'Societe') {
2220 if (get_class($filterobj) ==
'User') {
2225 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2226 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2229 $out .=
getTitleFieldOfList(
"Label", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2230 $out .=
getTitleFieldOfList(
"RelatedObjects", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2231 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2232 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2235 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2239 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
2241 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
2243 foreach ($histo as $key => $value) {
2244 $actionstatic->fetch($histo[$key][
'id']);
2246 $actionstatic->type_picto = $histo[$key][
'apicto'] ??
'';
2247 $actionstatic->type_code = $histo[$key][
'acode'];
2249 $out .=
'<tr class="oddeven">';
2253 $out .=
'<td></td>';
2258 $out .=
'<td class="nowrap">';
2263 $out .=
'<td class="nowraponall">';
2264 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2265 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2266 $out .= $histo[$key][
'id'];
2269 $out .= $actionstatic->getNomUrl(1, -1);
2274 $out .=
'<td class="center nowraponall">';
2275 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
2276 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
2277 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
2278 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
2279 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2280 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
2282 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
2286 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2289 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2292 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2295 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2304 $out .=
'<td class="tdoverflowmax125">';
2305 if ($histo[$key][
'userid'] > 0) {
2306 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2307 $link = $userlinkcache[$histo[$key][
'userid']];
2309 $userstatic->fetch($histo[$key][
'userid']);
2310 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2311 $userlinkcache[$histo[$key][
'userid']] = $link;
2318 $labeltype = $actionstatic->type_code;
2320 $labeltype =
'AC_OTH';
2322 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2323 $labeltype = $langs->trans(
"Message");
2325 if (!empty($arraylist[$labeltype])) {
2326 $labeltype = $arraylist[$labeltype];
2328 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
2329 $labeltype .=
' - '.$arraylist[$actionstatic->code];
2332 $out .=
'<td class="tdoverflowmax125" title="'.$labeltype.
'">';
2333 $out .= $actionstatic->getTypePicto();
2340 $out .=
'<td class="tdoverflowmax300"';
2341 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2342 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2344 $libelle = $histo[$key][
'note'];
2345 $actionstatic->id = $histo[$key][
'id'];
2346 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2349 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2350 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2351 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2352 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2353 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2359 $out .=
'<td class="tdoverflowmax200 nowraponall">';
2360 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2361 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2362 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2364 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2365 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2367 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2368 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2375 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2376 $out .=
'<td class="valignmiddle">';
2378 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2379 $result = $contact->fetch($cid);
2386 $out .= $contact->getNomUrl(-3,
'', 10,
'', -1, 0,
'paddingright');
2387 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2388 if (!empty($contact->phone_pro)) {
2389 $out .=
'('.dol_print_phone($contact->phone_pro).
')';
2392 $out .=
'<div class="paddingright"></div>';
2396 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2397 $contactstatic->lastname = $histo[$key][
'lastname'];
2398 $contactstatic->firstname = $histo[$key][
'firstname'];
2399 $contactstatic->id = $histo[$key][
'contact_id'];
2400 $contactstatic->photo = $histo[$key][
'contact_photo'];
2401 $out .=
'<td width="120">'.$contactstatic->getNomUrl(-1,
'', 10).
'</td>';
2403 $out .=
'<td> </td>';
2407 $out .=
'<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']).
'</td>';
2411 $out .=
'<td></td>';
2416 if (empty($histo)) {
2418 $out .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2421 $out .=
"</table>\n";