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'";
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' => (!
getDolGlobalInt(
'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'),
1231 if (!empty($extrafields->attributes[$contactstatic->table_element][
'label']) && is_array($extrafields->attributes[$contactstatic->table_element][
'label']) && count($extrafields->attributes[$contactstatic->table_element][
'label'])) {
1232 foreach ($extrafields->attributes[$contactstatic->table_element][
'label'] as $key => $val) {
1233 if (!empty($extrafields->attributes[$contactstatic->table_element][
'list'][$key])) {
1234 $arrayfields[
"ef.".$key] = array(
1235 'label' => $extrafields->attributes[$contactstatic->table_element][
'label'][$key],
1236 'checked' => (((
int)
dol_eval($extrafields->attributes[$contactstatic->table_element][
'list'][$key], 1, 1,
'1') < 0) ? 0 : 1),
1237 'position' => 1000 + $extrafields->attributes[$contactstatic->table_element][
'pos'][$key],
1238 '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'))
1246 foreach ($arrayfields as $key => $val) {
1247 $queryName =
'search_'.substr($key, 2);
1248 if (
GETPOST($queryName,
'alpha')) {
1249 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1252 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1255 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1257 $search_status =
'';
1259 $search_roles = array();
1260 $search_address =
'';
1262 $search_note_private =
'';
1263 $search_birthday_dtstart =
'';
1264 $search_birthday_dtend =
'';
1266 $search_array_options = array();
1268 foreach ($contactstatic->fields as $key => $val) {
1273 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1276 $newcardbutton =
'';
1277 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1278 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1279 $newcardbutton .=
dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?socid='.
$object->id.
'&action=create&backtopage='.urlencode($backtopage));
1284 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1287 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
1288 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1289 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1290 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1291 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1292 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1293 print
'<input type="hidden" name="page" value="'.$page.
'">';
1295 $arrayofmassactions = array();
1298 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1299 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1300 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1301 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1303 print
'<div class="div-table-responsive">';
1304 print
"\n".
'<table class="tagtable liste">'.
"\n";
1306 $param =
"socid=".urlencode((
string) (
$object->id));
1307 if ($search_rowid !=
'') {
1308 $param .=
'&search_rowid='.urlencode((
string) ($search_rowid));
1310 if ($search_status !=
'') {
1311 $param .=
'&search_status='.urlencode((
string) ($search_status));
1313 if (count($search_roles) > 0) {
1314 $param .= implode(
'&search_roles[]=', $search_roles);
1316 if ($search_name !=
'') {
1317 $param .=
'&search_name='.urlencode($search_name);
1319 if ($search_poste !=
'') {
1320 $param .=
'&search_poste='.urlencode($search_poste);
1322 if ($search_address !=
'') {
1323 $param .=
'&search_address='.urlencode($search_address);
1325 if ($search_note_private !=
'') {
1326 $param .=
'&search_note_private='.urlencode($search_note_private);
1328 if ($search_birthday_dtstart !=
'') {
1329 $param .=
'&search_birthday_dtstart='.urlencode($search_birthday_dtstart);
1331 if ($search_birthday_dtend !=
'') {
1332 $param .=
'&search_birthday_dtend='.urlencode($search_birthday_dtend);
1334 if ($optioncss !=
'') {
1335 $param .=
'&optioncss='.urlencode($optioncss);
1339 $extrafieldsobjectkey = $contactstatic->table_element;
1340 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1342 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1343 $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,";
1344 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1345 $sql .=
" t.note_private";
1346 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as t";
1347 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1348 $sql .=
" WHERE t.fk_soc = ".((int)
$object->id);
1349 $sql .=
" AND t.entity IN (" .getEntity(
'socpeople') .
")";
1350 $sql .=
" AND ((t.fk_user_creat = ".((int) $user->id).
" AND t.priv = 1) OR t.priv = 0)";
1351 if ($search_rowid) {
1354 if ($search_status !=
'' && $search_status !=
'-1') {
1355 $sql .=
" AND t.statut = ".((int) $search_status);
1358 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1360 if ($search_poste) {
1363 if ($search_address) {
1364 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1366 if ($search_note_private) {
1369 if ($search_birthday_dtstart !=
'') {
1370 $sql .=
" AND t.birthday >= '".$db->idate($search_birthday_dtstart).
"'";
1372 if ($search_birthday_dtend !=
'') {
1373 $sql .=
" AND t.birthday <= '".$db->idate($search_birthday_dtend).
"'";
1375 if (count($search_roles) > 0) {
1376 $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)).
"))";
1379 $extrafieldsobjectkey = $contactstatic->table_element;
1380 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1382 $parameters = array(
'socid' =>
$object->id);
1383 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
1384 $sql .= $hookmanager->resPrint;
1385 if ($sortfield ==
"t.name") {
1386 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1388 $sql .=
" ORDER BY $sortfield $sortorder";
1391 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1392 $result = $db->query($sql);
1397 $num = $db->num_rows($result);
1401 print
'<tr class="liste_titre">';
1404 print
'<td class="liste_titre" align="right">';
1405 print $form->showFilterButtons();
1408 foreach ($contactstatic->fields as $key => $val) {
1410 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1411 $align .= ($align ?
' ' :
'').
'center';
1413 if (in_array($val[
'type'], array(
'timestamp'))) {
1414 $align .= ($align ?
' ' :
'').
'nowrap';
1416 if ($key ==
'status' || $key ==
'statut') {
1417 $align .= ($align ?
' ' :
'').
'center';
1419 if (!empty($arrayfields[
't.'.$key][
'checked']) || !empty($arrayfields[
'sc.'.$key][
'checked'])) {
1420 print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'">';
1421 if (in_array($key, array(
'statut'))) {
1422 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');
1423 } elseif (in_array($key, array(
'role'))) {
1424 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1425 } elseif (in_array($key, array(
'birthday'))) {
1426 print
'<div class="nowrap">';
1427 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1429 print
'<div class="nowrap">';
1430 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1433 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.(!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'').
'">';
1438 if ($showuserlogin) {
1439 print
'<td class="liste_titre"></td>';
1442 $extrafieldsobjectkey = $contactstatic->table_element;
1443 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1446 $parameters = array(
'arrayfields' => $arrayfields);
1447 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1448 print $hookmanager->resPrint;
1451 print
'<td class="liste_titre" align="right">';
1452 print $form->showFilterButtons();
1460 print
'<tr class="liste_titre">';
1463 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1465 foreach ($contactstatic->fields as $key => $val) {
1467 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1468 $align .= ($align ?
' ' :
'').
'center';
1470 if (in_array($val[
'type'], array(
'timestamp'))) {
1471 $align .= ($align ?
' ' :
'').
'nowrap';
1473 if ($key ==
'status' || $key ==
'statut') {
1474 $align .= ($align ?
' ' :
'').
'center';
1476 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
1477 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1479 if ($key ==
'role') {
1480 $align .= ($align ?
' ' :
'').
'left';
1482 if (!empty($arrayfields[
'sc.'.$key][
'checked'])) {
1483 print
getTitleFieldOfList($arrayfields[
'sc.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1486 if ($showuserlogin) {
1487 print
'<th class="wrapcolumntitle liste_titre">'.$langs->trans(
"DolibarrLogin").
'</th>';
1490 $extrafieldsobjectkey = $contactstatic->table_element;
1491 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1493 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
1494 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
1495 print $hookmanager->resPrint;
1498 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1504 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1508 $obj = $db->fetch_object($result);
1510 $contactstatic->id = $obj->rowid;
1511 $contactstatic->ref = $obj->rowid;
1512 $contactstatic->statut = $obj->statut;
1513 $contactstatic->lastname = $obj->lastname;
1514 $contactstatic->firstname = $obj->firstname;
1515 $contactstatic->civility_id = $obj->civility_id;
1516 $contactstatic->civility_code = $obj->civility_id;
1517 $contactstatic->poste = $obj->poste;
1518 $contactstatic->address = $obj->address;
1519 $contactstatic->zip = $obj->zip;
1520 $contactstatic->town = $obj->town;
1521 $contactstatic->phone_pro = $obj->phone_pro;
1522 $contactstatic->phone_mobile = $obj->phone_mobile;
1523 $contactstatic->phone_perso = $obj->phone_perso;
1524 $contactstatic->email = $obj->email;
1525 $contactstatic->socialnetworks = $obj->socialnetworks;
1526 $contactstatic->photo = $obj->photo;
1527 $contactstatic->fk_soc = $obj->fk_soc;
1528 $contactstatic->entity = $obj->entity;
1530 $country_code =
getCountry($obj->country_id, 2);
1531 $contactstatic->country_code = $country_code;
1533 $contactstatic->setGenderFromCivility();
1534 $contactstatic->fetch_optionals();
1536 $resultRole = $contactstatic->fetchRoles();
1537 if ($resultRole < 0) {
1541 if (is_array($contactstatic->array_options)) {
1542 foreach ($contactstatic->array_options as $key => $val) {
1547 print
'<tr class="oddeven">';
1551 print
'<td class="nowrap center">';
1554 if (isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1555 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.
$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1556 print
img_object($langs->trans(
"Event"),
"action");
1557 print
'</a> ';
1561 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1562 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.
newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1568 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1569 print
'<a class="marginleftonly right" href="'.DOL_URL_ROOT.
'/societe/contact.php?action=delete&token='.
newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1578 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1580 print $contactstatic->id;
1585 if (!empty($arrayfields[
't.name'][
'checked'])) {
1586 print
'<td class="tdoverflowmax150">';
1587 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0, 1);
1588 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage='.urlencode($backtopage));
1593 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1594 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->poste).
'">';
1602 if (!empty($arrayfields[
't.address'][
'checked'])) {
1603 $addresstoshow = $contactstatic->getBannerAddress(
'contact',
$object);
1604 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($addresstoshow).
'">';
1605 print $addresstoshow;
1610 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1611 print
'<td class="center">';
1617 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1618 print
'<td class="tdoverflowmax150">';
1619 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1624 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1625 print
'<td class="nowraponall">';
1631 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1632 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1635 if ($showuserlogin) {
1636 print
'<td class="tdoverflowmax125">';
1637 $tmpuser =
new User($db);
1639 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1640 if ($resfetch > 0) {
1641 print $tmpuser->getNomUrl(-1,
'', 0, 0, 24, 1);
1647 $extrafieldsobjectkey = $contactstatic->table_element;
1648 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1652 print
'<td class="nowrap center">';
1655 if (isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
1656 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.
$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1657 print
img_object($langs->trans(
"Event"),
"action");
1658 print
'</a> ';
1662 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1663 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.
newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1669 if ($user->hasRight(
'societe',
'contact',
'delete')) {
1670 print
'<a class="marginleftonly right" href="'.DOL_URL_ROOT.
'/societe/contact.php?action=delete&token='.
newToken().
'&id='.$obj->rowid.
'&socid='.urlencode($obj->fk_soc).
'">';
1683 $colspan = 1 + ($showuserlogin ? 1 : 0);
1684 foreach ($arrayfields as $key => $val) {
1685 if (!empty($val[
'checked'])) {
1689 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1692 $colspan = 1 + ($showuserlogin ? 1 : 0);
1693 foreach ($arrayfields as $key => $val) {
1694 if (!empty($val[
'checked'])) {
1698 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1700 print
"\n</table>\n";
1703 print
'</form>'.
"\n";
1752function show_actions_done($conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1754 global $user, $conf, $hookmanager;
1756 global $param, $massactionbutton;
1758 $start_year =
GETPOSTINT(
'dateevent_startyear');
1759 $start_month =
GETPOSTINT(
'dateevent_startmonth');
1760 $start_day =
GETPOSTINT(
'dateevent_startday');
1762 $end_month =
GETPOSTINT(
'dateevent_endmonth');
1767 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1768 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1770 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1771 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1773 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1777 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
1780 if (!is_object($filterobj) && !is_object($objcon)) {
1790 $sortfield_list = explode(
',', $sortfield);
1791 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1792 $sortfield_new_list = array();
1793 foreach ($sortfield_list as $sortfield_value) {
1794 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1796 $sortfield_new = implode(
',', $sortfield_new_list);
1800 if (isModEnabled(
'agenda')) {
1802 $hookmanager->initHooks(array(
'agendadao'));
1804 $sql =
"SELECT a.id, a.label as label,";
1805 $sql .=
" a.datep as dp,";
1806 $sql .=
" a.datep2 as dp2,";
1807 $sql .=
" a.percent as percent, 'action' as type,";
1808 $sql .=
" a.fk_element, a.elementtype,";
1809 $sql .=
" a.fk_contact,";
1810 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1811 $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";
1812 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1813 $sql .=
", sp.lastname, sp.firstname";
1814 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1816 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1818 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1819 $sql .=
", m.lastname, m.firstname";
1820 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1822 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1824 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1826 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1828 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1830 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1831 if (!empty($filterobj->fields[
'ref'])) {
1833 } elseif (!empty($filterobj->fields[
'label'])) {
1834 $sql .=
", o.label";
1839 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1840 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
1841 if (!empty($hookmanager->resPrint)) {
1842 $sql .= $hookmanager->resPrint;
1845 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1847 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
1849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
1854 $force_filter_contact =
false;
1855 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
1856 $force_filter_contact =
true;
1858 if (is_object($objcon) && $objcon->id > 0) {
1859 $force_filter_contact =
true;
1863 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1864 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
1865 if (!empty($hookmanager->resPrint)) {
1866 $sql .= $hookmanager->resPrint;
1868 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1869 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
1870 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1871 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
1872 $sql .=
" ON er.resource_type = 'dolresource'";
1873 $sql .=
" AND er.element_id = a.id";
1874 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
1875 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1877 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1878 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
1879 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1880 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
1881 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1882 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
1883 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1884 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
1885 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1886 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
1887 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1888 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
1889 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
1890 && ((!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'])))
1891 && $filterobj->table_element && $filterobj->element) {
1892 $sql .=
", ".MAIN_DB_PREFIX.$filterobj->table_element.
" as o";
1895 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1897 if ($force_filter_contact ===
false) {
1898 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
1899 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
1900 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1902 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
1903 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
1904 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1905 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1906 if ($filterobj->id) {
1907 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1909 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
1910 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
1911 if ($filterobj->id) {
1912 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1914 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1915 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1916 if ($filterobj->id) {
1917 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1919 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
1920 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
1921 if ($filterobj->id) {
1922 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1924 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1925 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1926 if ($filterobj->id) {
1927 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1929 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1930 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1931 if ($filterobj->id) {
1932 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1934 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1935 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1936 if ($filterobj->id) {
1937 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1939 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1940 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1941 if ($filterobj->id) {
1942 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1944 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
1945 && ((!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'])))
1946 && $filterobj->table_element && $filterobj->element) {
1948 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ?
"@".$module :
"").
"'";
1949 if ($filterobj->id) {
1950 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1952 } elseif (is_object($filterobj)) {
1953 return 'Bad value for $filterobj';
1956 if (is_object($filterobj) && $filterobj->id > 0 && get_class($filterobj) ==
'User') {
1957 $sql .=
" AND (u.rowid = ". ((int) $filterobj->id).
' OR ';
1958 $sql .=
" EXISTS (SELECT r.rowid FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
1959 $sql .=
" AND r.element_type = '".$db->escape($filterobj->table_element).
"' AND r.fk_element = ".((int) $filterobj->id).
')';
1962 if (is_object($objcon) && $objcon->id > 0) {
1963 $sql .=
" AND EXISTS (SELECT r.rowid FROM ".MAIN_DB_PREFIX.
"actioncomm_resources as r WHERE a.id = r.fk_actioncomm";
1964 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id).
')';
1968 if (!empty($tms_start) && !empty($tms_end)) {
1969 $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).
"'))";
1970 } elseif (empty($tms_start) && !empty($tms_end)) {
1971 $sql .=
" AND ((a.datep <= '".$db->idate($tms_end).
"') OR (a.datep2 <= '".$db->idate($tms_end).
"'))";
1972 } elseif (!empty($tms_start) && empty($tms_end)) {
1973 $sql .=
" AND ((a.datep >= '".$db->idate($tms_start).
"') OR (a.datep2 >= '".$db->idate($tms_start).
"'))";
1976 if (is_array($actioncode) && !empty($actioncode)) {
1978 foreach ($actioncode as $key => $code) {
1982 if (!empty($code)) {
1987 } elseif (!empty($actioncode)) {
1994 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
1995 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
1996 if (!empty($hookmanager->resPrint)) {
1997 $sql .= $hookmanager->resPrint;
2000 if (is_array($actioncode)) {
2001 foreach ($actioncode as $code) {
2003 if (!empty($sql2)) {
2005 $sql = $sql.
" UNION ".$sql2;
2006 } elseif (empty($sql)) {
2014 if (!empty($sql) && !empty($sql2)) {
2015 $sql = $sql.
" UNION ".$sql2;
2016 } elseif (empty($sql) && !empty($sql2)) {
2028 $sql .= $db->order($sortfield_new, $sortorder);
2030 $sql .= $db->plimit($limit + 1, $offset);
2033 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
2035 $resql = $db->query($sql);
2038 $num = $db->num_rows($resql);
2040 $imaxinloop = ($limit ? min($num, $limit) : $num);
2041 while ($i < $imaxinloop) {
2042 $obj = $db->fetch_object($resql);
2044 if ($obj->type ==
'action') {
2046 $contactaction->id = $obj->id;
2047 $result = $contactaction->fetchResources();
2050 setEventMessage(
"company.lib::show_actions_done Error fetch resource",
'errors');
2056 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
2060 $histo[$numaction] = array(
2061 'type' => $obj->type,
2062 'tododone' => $tododone,
2064 'datestart' => $db->jdate($obj->dp),
2065 'dateend' => $db->jdate($obj->dp2),
2066 'note' => $obj->label,
2067 'percent' => $obj->percent,
2069 'userid' => $obj->user_id,
2070 'login' => $obj->user_login,
2071 'userfirstname' => $obj->user_firstname,
2072 'userlastname' => $obj->user_lastname,
2073 'userphoto' => $obj->user_photo,
2075 'contact_id' => $obj->fk_contact,
2076 'socpeopleassigned' => $contactaction->socpeopleassigned,
2077 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
2078 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
2079 'fk_element' => $obj->fk_element,
2080 'elementtype' => $obj->elementtype,
2082 'acode' => $obj->acode,
2083 'alabel' => $obj->alabel,
2084 'libelle' => $obj->alabel,
2085 'apicto' => $obj->apicto
2088 $histo[$numaction] = array(
2089 'type' => $obj->type,
2090 'tododone' =>
'done',
2092 'datestart' => $db->jdate($obj->dp),
2093 'dateend' => $db->jdate($obj->dp2),
2094 'note' => $obj->label,
2095 'percent' => $obj->percent,
2096 'acode' => $obj->acode,
2098 'userid' => $obj->user_id,
2099 'login' => $obj->user_login,
2100 'userfirstname' => $obj->user_firstname,
2101 'userlastname' => $obj->user_lastname,
2102 'userphoto' => $obj->user_photo
2114 '@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';
2116 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
2117 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
2119 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
2120 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2121 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2122 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2127 $userstatic =
new User($db);
2128 $userlinkcache = array();
2129 $contactstatic =
new Contact($db);
2130 $elementlinkcache = array();
2132 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2133 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2134 if ($objcon && get_class($objcon) ==
'Contact' &&
2135 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
2136 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
2138 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
2140 if ($filterobj && get_class($filterobj) ==
'Societe') {
2141 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
2143 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
2148 $out .=
'<div class="div-table-responsive-no-min">';
2149 $out .=
'<table class="noborder centpercent">';
2151 $out .=
'<tr class="liste_titre">';
2155 $out .=
'<th class="liste_titre width50 middle">';
2156 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2157 $out .= $searchpicto;
2162 $out .=
'<td class="liste_titre"></td>';
2166 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="'.(isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'').
'"></td>';
2168 $out .=
'<td class="liste_titre center">';
2169 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
2172 $out .=
'<td class="liste_titre"></td>';
2174 $out .=
'<td class="liste_titre">';
2175 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'',
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, (
getDolGlobalString(
'AGENDA_USE_MULTISELECT_TYPE') ? 1 : 0), 1,
'combolargeelem minwidth100 maxwidth150');
2177 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'"></td>';
2178 $out .=
'<td class="liste_titre"></td>';
2179 $out .=
'<td class="liste_titre"></td>';
2180 $out .=
'<td class="liste_titre"></td>';
2183 $out .=
'<td class="liste_titre" align="middle">';
2184 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2185 $out .= $searchpicto;
2190 $out .=
'<tr class="liste_titre">';
2193 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2197 if (get_class($filterobj) ==
'Societe') {
2198 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
2200 if (get_class($filterobj) ==
'User') {
2201 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&userid='.$filterobj->id.
'&status=done">';
2203 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2204 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2205 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2207 if (get_class($filterobj) ==
'Societe') {
2210 if (get_class($filterobj) ==
'User') {
2215 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2216 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2219 $out .=
getTitleFieldOfList(
"Label", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2220 $out .=
getTitleFieldOfList(
"RelatedObjects", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2221 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2222 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2225 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2229 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
2231 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
2233 foreach ($histo as $key => $value) {
2234 $actionstatic->fetch($histo[$key][
'id']);
2236 $actionstatic->type_picto = $histo[$key][
'apicto'] ??
'';
2237 $actionstatic->type_code = $histo[$key][
'acode'];
2239 $out .=
'<tr class="oddeven">';
2243 $out .=
'<td></td>';
2248 $out .=
'<td class="nowrap">';
2253 $out .=
'<td class="nowraponall">';
2254 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2255 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2256 $out .= $histo[$key][
'id'];
2259 $out .= $actionstatic->getNomUrl(1, -1);
2264 $out .=
'<td class="center nowraponall">';
2265 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
2266 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
2267 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
2268 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
2269 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2270 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
2272 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
2276 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2279 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2282 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2285 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2294 $out .=
'<td class="tdoverflowmax125">';
2295 if ($histo[$key][
'userid'] > 0) {
2296 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2297 $link = $userlinkcache[$histo[$key][
'userid']];
2299 $userstatic->fetch($histo[$key][
'userid']);
2300 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2301 $userlinkcache[$histo[$key][
'userid']] = $link;
2308 $labeltype = $actionstatic->type_code;
2310 $labeltype =
'AC_OTH';
2312 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2313 $labeltype = $langs->trans(
"Message");
2315 if (!empty($arraylist[$labeltype])) {
2316 $labeltype = $arraylist[$labeltype];
2318 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
2319 $labeltype .=
' - '.$arraylist[$actionstatic->code];
2322 $out .=
'<td class="tdoverflowmax125" title="'.$labeltype.
'">';
2323 $out .= $actionstatic->getTypePicto();
2330 $out .=
'<td class="tdoverflowmax300"';
2331 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2332 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2334 $libelle = $histo[$key][
'note'];
2335 $actionstatic->id = $histo[$key][
'id'];
2336 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2339 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2340 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2341 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2342 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2343 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2349 $out .=
'<td class="tdoverflowmax200 nowraponall">';
2350 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2351 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2352 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2354 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2355 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2357 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2358 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2365 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2366 $out .=
'<td class="valignmiddle">';
2368 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2369 $result = $contact->fetch($cid);
2376 $out .= $contact->getNomUrl(-3,
'', 10,
'', -1, 0,
'paddingright');
2377 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2378 if (!empty($contact->phone_pro)) {
2379 $out .=
'('.dol_print_phone($contact->phone_pro).
')';
2382 $out .=
'<div class="paddingright"></div>';
2386 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2387 $contactstatic->lastname = $histo[$key][
'lastname'];
2388 $contactstatic->firstname = $histo[$key][
'firstname'];
2389 $contactstatic->id = $histo[$key][
'contact_id'];
2390 $contactstatic->photo = $histo[$key][
'contact_photo'];
2391 $out .=
'<td width="120">'.$contactstatic->getNomUrl(-1,
'', 10).
'</td>';
2393 $out .=
'<td> </td>';
2397 $out .=
'<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']).
'</td>';
2401 $out .=
'<td></td>';
2406 if (empty($histo)) {
2408 $out .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2411 $out .=
"</table>\n";