44 global $db, $langs, $conf, $user;
50 $head[$h][0] = DOL_URL_ROOT.
'/societe/card.php?socid='.$object->id;
51 $head[$h][1] = $langs->trans(
"ThirdParty");
52 $head[$h][2] =
'card';
55 if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
56 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->hasRight(
'societe',
'contact',
'lire')) {
60 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
61 $cachekey =
'count_contacts_thirdparty_'.$object->id;
64 if (!is_null($dataretrieved)) {
65 $nbContact = $dataretrieved;
67 $sql =
"SELECT COUNT(p.rowid) as nb";
68 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as p";
70 $parameters = array(
'contacttab' =>
true);
71 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
72 $sql .= $hookmanager->resPrint;
73 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
74 $sql .=
" AND p.entity IN (".getEntity($object->element).
")";
76 $parameters = array(
'contacttab' =>
true);
77 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
78 $sql .= $hookmanager->resPrint;
79 $resql = $db->query($sql);
81 $obj = $db->fetch_object($resql);
82 $nbContact = $obj->nb;
88 $head[$h][0] = DOL_URL_ROOT.
'/societe/contact.php?socid='.$object->id;
89 $head[$h][1] = $langs->trans(
'ContactsAddresses');
91 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
93 $head[$h][2] =
'contact';
97 $head[$h][0] = DOL_URL_ROOT.
'/societe/societecontact.php?socid='.$object->id;
98 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
99 $head[$h][1] = $langs->trans(
"ContactsAddresses");
100 if ($nbContact > 0) {
101 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
103 $head[$h][2] =
'contact';
107 if ($object->client == 1 || $object->client == 2 || $object->client == 3) {
108 $head[$h][0] = DOL_URL_ROOT.
'/comm/card.php?socid='.$object->id;
110 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) {
111 $head[$h][1] .= $langs->trans(
"Prospect");
113 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) {
114 $head[$h][1] .=
' | ';
116 if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) {
117 $head[$h][1] .= $langs->trans(
"Customer");
119 $head[$h][2] =
'customer';
122 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
123 $langs->load(
"products");
125 $head[$h][0] = DOL_URL_ROOT.
'/societe/price.php?socid='.$object->id;
126 $head[$h][1] = $langs->trans(
"CustomerPrices");
127 $head[$h][2] =
'price';
131 $supplier_module_enabled = 0;
132 if (isModEnabled(
'supplier_proposal') || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
133 $supplier_module_enabled = 1;
135 if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
136 $head[$h][0] = DOL_URL_ROOT.
'/fourn/card.php?socid='.$object->id;
137 $head[$h][1] = $langs->trans(
"Supplier");
138 $head[$h][2] =
'supplier';
142 if (isModEnabled(
'project') && (!empty($user->rights->projet->lire))) {
145 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
146 $cachekey =
'count_projects_thirdparty_'.$object->id;
149 if (!is_null($dataretrieved)) {
150 $nbProject = $dataretrieved;
152 $sql =
"SELECT COUNT(n.rowid) as nb";
153 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as n";
154 $sql .=
" WHERE fk_soc = ".((int) $object->id);
155 $sql .=
" AND entity IN (".getEntity(
'project').
")";
156 $resql = $db->query($sql);
158 $obj = $db->fetch_object($resql);
159 $nbProject = $obj->nb;
165 $head[$h][0] = DOL_URL_ROOT.
'/societe/project.php?socid='.$object->id;
166 $head[$h][1] = $langs->trans(
"Projects");
167 if ($nbProject > 0) {
168 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbProject.
'</span>';
170 $head[$h][2] =
'project';
175 if (isModEnabled(
'resource') && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) {
176 $head[$h][0] = DOL_URL_ROOT.
'/resource/element_resource.php?element=societe&element_id='.$object->id;
177 $head[$h][1] = $langs->trans(
"Resources");
178 $head[$h][2] =
'resources';
183 if ((isModEnabled(
'commande') || isModEnabled(
'propal') || isModEnabled(
'facture') || isModEnabled(
'ficheinter') || isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice"))
184 && empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) {
185 $head[$h][0] = DOL_URL_ROOT.
'/societe/consumption.php?socid='.$object->id;
186 $head[$h][1] = $langs->trans(
"Referers");
187 $head[$h][2] =
'consumption';
192 if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) {
194 $foundonexternalonlinesystem = 0;
195 $langs->load(
"bills");
197 $title = $langs->trans(
"PaymentModes");
199 if (isModEnabled(
'stripe')) {
204 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
208 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
210 $stripecu = $societeaccount->getCustomerAccount($object->id,
'stripe', $servicestatus);
212 $foundonexternalonlinesystem++;
216 $sql =
"SELECT COUNT(n.rowid) as nb";
217 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_rib as n";
218 $sql .=
" WHERE n.fk_soc = ".((int) $object->id);
219 if (!isModEnabled(
'stripe')) {
220 $sql .=
" AND n.stripe_card_ref IS NULL";
222 $sql .=
" AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".((int) $servicestatus).
"))";
225 $resql = $db->query($sql);
227 $obj = $db->fetch_object($resql);
228 $nbBankAccount = $obj->nb;
235 $head[$h][0] = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.urlencode($object->id);
236 $head[$h][1] = $title;
237 if ($foundonexternalonlinesystem) {
238 $head[$h][1] .=
'<span class="badge marginleftonlyshort">...</span>';
239 } elseif ($nbBankAccount > 0) {
240 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbBankAccount.
'</span>';
242 $head[$h][2] =
'rib';
246 if (isModEnabled(
'website') && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && ($user->hasRight(
'societe',
'lire'))) {
247 $head[$h][0] = DOL_URL_ROOT.
'/societe/website.php?id='.urlencode($object->id);
248 $head[$h][1] = $langs->trans(
"WebSiteAccounts");
250 $sql =
"SELECT COUNT(n.rowid) as nb";
251 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as n";
252 $sql .=
" WHERE fk_soc = ".((int) $object->id).
' AND fk_website > 0';
253 $resql = $db->query($sql);
255 $obj = $db->fetch_object($resql);
261 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
263 $head[$h][2] =
'website';
268 if (!empty($user->rights->partnership->read)) {
269 $langs->load(
"partnership");
270 $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
271 $head[$h][0] = DOL_URL_ROOT.
'/partnership/partnership_list.php?socid='.$object->id;
272 $head[$h][1] = $langs->trans(
"Partnerships");
274 $sql =
"SELECT COUNT(n.rowid) as nb";
275 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership as n";
276 $sql .=
" WHERE fk_soc = ".((int) $object->id);
277 $resql = $db->query($sql);
279 $obj = $db->fetch_object($resql);
285 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
287 $head[$h][2] =
'partnerships';
288 if ($nbPartnership > 0) {
289 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbPartnership.
'</span>';
301 if ($user->socid == 0) {
303 if (isModEnabled(
'notification')) {
306 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
307 $cachekey =
'count_notifications_thirdparty_'.$object->id;
309 if (!is_null($dataretrieved)) {
310 $nbNotif = $dataretrieved;
312 $sql =
"SELECT COUNT(n.rowid) as nb";
313 $sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def as n";
314 $sql .=
" WHERE fk_soc = ".((int) $object->id);
315 $resql = $db->query($sql);
317 $obj = $db->fetch_object($resql);
325 $head[$h][0] = DOL_URL_ROOT.
'/societe/notify/card.php?socid='.urlencode($object->id);
326 $head[$h][1] = $langs->trans(
"Notifications");
328 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNotif.
'</span>';
330 $head[$h][2] =
'notify';
336 if (!empty($object->note_private)) {
339 if (!empty($object->note_public)) {
342 $head[$h][0] = DOL_URL_ROOT.
'/societe/note.php?id='.urlencode($object->id);
343 $head[$h][1] = $langs->trans(
"Notes");
345 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
347 $head[$h][2] =
'note';
353 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
354 $cachekey =
'count_attached_thirdparty_'.$object->id;
356 if (!is_null($dataretrieved)) {
357 $totalAttached = $dataretrieved;
359 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
360 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
361 $upload_dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id;
362 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
363 $nbLinks =
Link::count($db, $object->element, $object->id);
364 $totalAttached = $nbFiles + $nbLinks;
368 $head[$h][0] = DOL_URL_ROOT.
'/societe/document.php?socid='.$object->id;
369 $head[$h][1] = $langs->trans(
"Documents");
370 if (($totalAttached) > 0) {
371 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
373 $head[$h][2] =
'document';
377 $head[$h][0] = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id;
378 $head[$h][1] = $langs->trans(
"Events");
379 if (isModEnabled(
'agenda')&& ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
382 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
383 $cachekey =
'count_events_thirdparty_'.$object->id;
385 if (!is_null($dataretrieved)) {
386 $nbEvent = $dataretrieved;
388 $sql =
"SELECT COUNT(id) as nb";
389 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
390 $sql .=
" WHERE fk_soc = ".((int) $object->id);
391 $resql = $db->query($sql);
393 $obj = $db->fetch_object($resql);
396 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
402 $head[$h][1] .= $langs->trans(
"Agenda");
404 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
407 $head[$h][2] =
'agenda';
940function show_contacts($conf, $langs, $db, $object, $backtopage =
'', $showuserlogin = 0)
942 global $user, $conf, $extrafields, $hookmanager;
945 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
947 $form =
new Form($db);
949 $optioncss =
GETPOST(
'optioncss',
'alpha');
950 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
951 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
952 $page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
954 $search_status =
GETPOST(
"search_status",
'int');
955 if ($search_status ==
'') {
959 $search_rowid =
GETPOST(
"search_rowid",
'int');
960 $search_name =
GETPOST(
"search_name",
'alpha');
961 $search_address =
GETPOST(
"search_address",
'alpha');
962 $search_poste =
GETPOST(
"search_poste",
'alpha');
963 $search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
964 $search_roles =
GETPOST(
"search_roles",
'array');
965 $search_birthday_dtstart =
GETPOST(
"search_birthday_dtstart",
'alpha');
966 $search_birthday_dtend =
GETPOST(
"search_birthday_dtend",
'alpha');
968 if ($search_birthday_dtstart !=
'' || $search_birthday_dtend !=
'') {
969 $search_birthday_dtstart =
dol_mktime(0, 0, 0,
GETPOST(
'search_birthday_dtstartmonth',
'int'),
GETPOST(
'search_birthday_dtstartday',
'int'),
GETPOST(
'search_birthday_dtstartyear',
'int'));
970 $search_birthday_dtend =
dol_mktime(23, 59, 59,
GETPOST(
'search_birthday_dtendmonth',
'int'),
GETPOST(
'search_birthday_dtendday',
'int'),
GETPOST(
'search_birthday_dtendyear',
'int'));
974 $searchAddressPhoneDBFields = array(
1002 $sortfield =
"t.lastname";
1005 if (isModEnabled(
'clicktodial')) {
1006 $user->fetch_clicktodial();
1010 $contactstatic =
new Contact($db);
1012 $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1014 $contactstatic->fields = array(
1015 'rowid' =>array(
'type'=>
'integer',
'label'=>
"TechnicalID",
'enabled'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0),
'visible'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0),
'position'=>1),
1016 'name' =>array(
'type'=>
'varchar(128)',
'label'=>
'Name',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>1,
'index'=>1,
'position'=>10,
'searchall'=>1),
1017 'poste' =>array(
'type'=>
'varchar(128)',
'label'=>
'PostOrFunction',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>2,
'index'=>1,
'position'=>20),
1018 'address' =>array(
'type'=>
'varchar(128)',
'label'=>
'Address',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>3,
'index'=>1,
'position'=>30),
1019 'note_private' =>array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'visible'=>3,
'position'=>35),
1020 'role' =>array(
'type'=>
'checkbox',
'label'=>
'Role',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>4,
'index'=>1,
'position'=>40),
1021 'birthday' =>array(
'type'=>
'date',
'label'=>
'Birthday',
'enabled'=>1,
'visible'=>-1,
'notnull'=> 0,
'position'=>45),
1022 '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))),
1026 $arrayfields = array(
1027 't.rowid'=>array(
'label'=>
"TechnicalID",
'checked'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0),
'enabled'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0),
'position'=>1),
1028 't.name'=>array(
'label'=>
"Name",
'checked'=>1,
'position'=>10),
1029 't.poste'=>array(
'label'=>
"PostOrFunction",
'checked'=>1,
'position'=>20),
1030 '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),
1031 't.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'position'=>35),
1032 'sc.role'=>array(
'label'=>
"ContactByDefaultFor",
'checked'=>1,
'position'=>40),
1033 't.birthday'=>array(
'label'=>
"Birthday",
'checked'=>0,
'position'=>45),
1034 't.statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>50,
'class'=>
'center'),
1037 if (!empty($extrafields->attributes[$contactstatic->table_element][
'label']) && is_array($extrafields->attributes[$contactstatic->table_element][
'label']) && count($extrafields->attributes[$contactstatic->table_element][
'label'])) {
1038 foreach ($extrafields->attributes[$contactstatic->table_element][
'label'] as $key => $val) {
1039 if (!empty($extrafields->attributes[$contactstatic->table_element][
'list'][$key])) {
1040 $arrayfields[
"ef.".$key] = array(
1041 'label'=>$extrafields->attributes[$contactstatic->table_element][
'label'][$key],
1042 'checked'=>((
dol_eval($extrafields->attributes[$contactstatic->table_element][
'list'][$key], 1, 1,
'1') < 0) ? 0 : 1),
1043 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element][
'pos'][$key],
1044 'enabled' => (abs((
int)
dol_eval($extrafields->attributes[$contactstatic->table_element][
'list'][$key], 1)) != 3 &&
dol_eval($extrafields->attributes[$contactstatic->table_element][
'perms'][$key], 1, 1,
'1'))
1052 foreach ($arrayfields as $key => $val) {
1053 $queryName =
'search_'.substr($key, 2);
1054 if (
GETPOST($queryName,
'alpha')) {
1055 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1058 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1061 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1063 $search_status =
'';
1065 $search_roles = array();
1066 $search_address =
'';
1068 $search_note_private =
'';
1069 $search_birthday_dtstart =
'';
1070 $search_birthday_dtend =
'';
1072 $search_array_options = array();
1074 foreach ($contactstatic->fields as $key => $val) {
1079 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1082 $newcardbutton =
'';
1083 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1084 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1085 $newcardbutton .=
dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?socid='.$object->id.
'&action=create&backtopage='.urlencode($backtopage));
1090 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1093 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
1094 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1095 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1096 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1097 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1098 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1099 print
'<input type="hidden" name="page" value="'.$page.
'">';
1101 $arrayofmassactions = array();
1104 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1105 $selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
1106 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1108 print
'<div class="div-table-responsive">';
1109 print
"\n".
'<table class="tagtable liste">'.
"\n";
1111 $param =
"socid=".urlencode($object->id);
1112 if ($search_rowid !=
'') {
1113 $param .=
'&search_rowid='.urlencode($search_rowid);
1115 if ($search_status !=
'') {
1116 $param .=
'&search_status='.urlencode($search_status);
1118 if (count($search_roles) > 0) {
1119 $param .= implode(
'&search_roles[]=', $search_roles);
1121 if ($search_name !=
'') {
1122 $param .=
'&search_name='.urlencode($search_name);
1124 if ($search_poste !=
'') {
1125 $param .=
'&search_poste='.urlencode($search_poste);
1127 if ($search_address !=
'') {
1128 $param .=
'&search_address='.urlencode($search_address);
1130 if ($search_note_private !=
'') {
1131 $param .=
'&search_note_private='.urlencode($search_note_private);
1133 if ($search_birthday_dtstart !=
'') {
1134 $param .=
'&search_birthday_dtstart='.urlencode($search_birthday_dtstart);
1136 if ($search_birthday_dtend !=
'') {
1137 $param .=
'&search_birthday_dtend='.urlencode($search_birthday_dtend);
1139 if ($optioncss !=
'') {
1140 $param .=
'&optioncss='.urlencode($optioncss);
1144 $extrafieldsobjectkey = $contactstatic->table_element;
1145 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1147 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1148 $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,";
1149 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1150 $sql .=
" t.note_private";
1151 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as t";
1152 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1153 $sql .=
" WHERE t.fk_soc = ".((int) $object->id);
1154 $sql .=
" AND t.entity IN (".getEntity($object->element).
")";
1155 $sql .=
" AND ((t.fk_user_creat = ".((int) $user->id).
" AND t.priv = 1) OR t.priv = 0)";
1156 if ($search_rowid) {
1159 if ($search_status !=
'' && $search_status !=
'-1') {
1160 $sql .=
" AND t.statut = ".((int) $search_status);
1163 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1165 if ($search_poste) {
1168 if ($search_address) {
1169 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1171 if ($search_note_private) {
1174 if ($search_birthday_dtstart !=
'') {
1175 $sql .=
" AND t.birthday >= '".$db->idate($search_birthday_dtstart).
"'";
1177 if ($search_birthday_dtend !=
'') {
1178 $sql .=
" AND t.birthday <= '".$db->idate($search_birthday_dtend).
"'";
1180 if (count($search_roles) > 0) {
1181 $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)).
"))";
1184 $extrafieldsobjectkey = $contactstatic->table_element;
1185 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1187 $parameters = array(
'socid' => $object->id);
1188 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1189 $sql .= $hookmanager->resPrint;
1190 if ($sortfield ==
"t.name") {
1191 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1193 $sql .=
" ORDER BY $sortfield $sortorder";
1196 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1197 $result = $db->query($sql);
1202 $num = $db->num_rows($result);
1206 print
'<tr class="liste_titre">';
1209 print
'<td class="liste_titre" align="right">';
1210 print $form->showFilterButtons();
1213 foreach ($contactstatic->fields as $key => $val) {
1215 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1216 $align .= ($align ?
' ' :
'').
'center';
1218 if (in_array($val[
'type'], array(
'timestamp'))) {
1219 $align .= ($align ?
' ' :
'').
'nowrap';
1221 if ($key ==
'status' || $key ==
'statut') {
1222 $align .= ($align ?
' ' :
'').
'center';
1224 if (!empty($arrayfields[
't.'.$key][
'checked']) || !empty($arrayfields[
'sc.'.$key][
'checked'])) {
1225 print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'">';
1226 if (in_array($key, array(
'statut'))) {
1227 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');
1228 } elseif (in_array($key, array(
'role'))) {
1229 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1230 } elseif (in_array($key, array(
'birthday'))) {
1231 print
'<div class="nowrap">';
1232 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1234 print
'<div class="nowrap">';
1235 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1238 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.(!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'').
'">';
1243 if ($showuserlogin) {
1244 print
'<td class="liste_titre"></td>';
1247 $extrafieldsobjectkey = $contactstatic->table_element;
1248 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1251 $parameters = array(
'arrayfields'=>$arrayfields);
1252 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1253 print $hookmanager->resPrint;
1256 print
'<td class="liste_titre" align="right">';
1257 print $form->showFilterButtons();
1265 print
'<tr class="liste_titre">';
1268 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1270 foreach ($contactstatic->fields as $key => $val) {
1272 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1273 $align .= ($align ?
' ' :
'').
'center';
1275 if (in_array($val[
'type'], array(
'timestamp'))) {
1276 $align .= ($align ?
' ' :
'').
'nowrap';
1278 if ($key ==
'status' || $key ==
'statut') {
1279 $align .= ($align ?
' ' :
'').
'center';
1281 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
1282 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1284 if ($key ==
'role') {
1285 $align .= ($align ?
' ' :
'').
'left';
1287 if (!empty($arrayfields[
'sc.'.$key][
'checked'])) {
1288 print
getTitleFieldOfList($arrayfields[
'sc.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1291 if ($showuserlogin) {
1292 print
'<th class="wrapcolumntitle liste_titre">'.$langs->trans(
"DolibarrLogin").
'</th>';
1295 $extrafieldsobjectkey = $contactstatic->table_element;
1296 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1298 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1299 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1300 print $hookmanager->resPrint;
1303 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1309 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1313 $obj = $db->fetch_object($result);
1315 $contactstatic->id = $obj->rowid;
1316 $contactstatic->ref = $obj->rowid;
1317 $contactstatic->statut = $obj->statut;
1318 $contactstatic->lastname = $obj->lastname;
1319 $contactstatic->firstname = $obj->firstname;
1320 $contactstatic->civility_id = $obj->civility_id;
1321 $contactstatic->civility_code = $obj->civility_id;
1322 $contactstatic->poste = $obj->poste;
1323 $contactstatic->address = $obj->address;
1324 $contactstatic->zip = $obj->zip;
1325 $contactstatic->town = $obj->town;
1326 $contactstatic->phone_pro = $obj->phone_pro;
1327 $contactstatic->phone_mobile = $obj->phone_mobile;
1328 $contactstatic->phone_perso = $obj->phone_perso;
1329 $contactstatic->email = $obj->email;
1330 $contactstatic->socialnetworks = $obj->socialnetworks;
1331 $contactstatic->photo = $obj->photo;
1332 $contactstatic->fk_soc = $obj->fk_soc;
1333 $contactstatic->entity = $obj->entity;
1335 $country_code =
getCountry($obj->country_id, 2);
1336 $contactstatic->country_code = $country_code;
1338 $contactstatic->setGenderFromCivility();
1339 $contactstatic->fetch_optionals();
1341 $resultRole = $contactstatic->fetchRoles();
1342 if ($resultRole < 0) {
1346 if (is_array($contactstatic->array_options)) {
1347 foreach ($contactstatic->array_options as $key => $val) {
1352 print
'<tr class="oddeven">';
1356 print
'<td class="nowrap center">';
1359 if (isModEnabled(
'agenda')&& $user->hasRight(
'agenda',
'myactions',
'create')) {
1360 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1361 print
img_object($langs->trans(
"Event"),
"action");
1362 print
'</a> ';
1366 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1367 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1376 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1378 print $contactstatic->id;
1383 if (!empty($arrayfields[
't.name'][
'checked'])) {
1384 print
'<td class="tdoverflowmax150">';
1385 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0, 1);
1386 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage='.urlencode($backtopage));
1391 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1392 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->poste).
'">';
1400 if (!empty($arrayfields[
't.address'][
'checked'])) {
1401 $addresstoshow = $contactstatic->getBannerAddress(
'contact', $object);
1402 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag(
dol_string_nohtmltag($addresstoshow)).
'">';
1403 print $addresstoshow;
1408 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1410 if ($obj->note_private) {
1417 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1419 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1424 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1425 print
'<td class="nowraponall">';
1431 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1432 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1435 if ($showuserlogin) {
1436 print
'<td class="tdoverflowmax125">';
1437 $tmpuser=
new User($db);
1438 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1439 if ($resfetch > 0) {
1440 print $tmpuser->getNomUrl(1,
'', 0, 0, 24, 1);
1446 $extrafieldsobjectkey = $contactstatic->table_element;
1447 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1451 print
'<td class="nowrap center">';
1454 if (isModEnabled(
'agenda')&& $user->hasRight(
'agenda',
'myactions',
'create')) {
1455 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1456 print
img_object($langs->trans(
"Event"),
"action");
1457 print
'</a> ';
1461 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1462 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1475 $colspan = 1 + ($showuserlogin ? 1 : 0);
1476 foreach ($arrayfields as $key => $val) {
1477 if (!empty($val[
'checked'])) {
1481 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1484 $colspan = 1 + ($showuserlogin ? 1 : 0);
1485 foreach ($arrayfields as $key => $val) {
1486 if (!empty($val[
'checked'])) {
1490 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1492 print
"\n</table>\n";
1495 print
'</form>'.
"\n";
1544function show_actions_done($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1546 global $user, $conf, $hookmanager;
1548 global $param, $massactionbutton;
1550 $start_year =
GETPOST(
'dateevent_startyear',
'int');
1551 $start_month =
GETPOST(
'dateevent_startmonth',
'int');
1552 $start_day =
GETPOST(
'dateevent_startday',
'int');
1553 $end_year =
GETPOST(
'dateevent_endyear',
'int');
1554 $end_month =
GETPOST(
'dateevent_endmonth',
'int');
1555 $end_day =
GETPOST(
'dateevent_endday',
'int');
1559 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1560 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1562 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1563 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1565 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1572 if (!is_object($filterobj) && !is_object($objcon)) {
1582 $sortfield_list = explode(
',', $sortfield);
1583 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1584 $sortfield_new_list = array();
1585 foreach ($sortfield_list as $sortfield_value) {
1586 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1588 $sortfield_new = implode(
',', $sortfield_new_list);
1592 if (isModEnabled(
'agenda')) {
1594 $hookmanager->initHooks(array(
'agendadao'));
1597 if (is_object($objcon) && $objcon->id > 0) {
1598 $sql =
"SELECT DISTINCT a.id, a.label as label,";
1600 $sql =
"SELECT a.id, a.label as label,";
1602 $sql .=
" a.datep as dp,";
1603 $sql .=
" a.datep2 as dp2,";
1604 $sql .=
" a.percent as percent, 'action' as type,";
1605 $sql .=
" a.fk_element, a.elementtype,";
1606 $sql .=
" a.fk_contact,";
1607 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1608 $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";
1609 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1610 $sql .=
", sp.lastname, sp.firstname";
1611 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1613 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1615 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1616 $sql .=
", m.lastname, m.firstname";
1617 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1619 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1621 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1623 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1625 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1627 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1628 if (!empty($filterobj->fields[
'ref'])) {
1630 } elseif (!empty($filterobj->fields[
'label'])) {
1631 $sql .=
", o.label";
1636 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1637 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
1638 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1640 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1641 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
1642 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
1644 $force_filter_contact =
false;
1645 if (is_object($objcon) && $objcon->id > 0) {
1646 $force_filter_contact =
true;
1647 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
1648 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
1652 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1653 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
1654 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1656 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1657 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
1658 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1659 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
1660 $sql .=
" ON er.resource_type = 'dolresource'";
1661 $sql .=
" AND er.element_id = a.id";
1662 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
1663 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1665 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1666 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
1667 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1668 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
1669 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1670 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
1671 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1672 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
1673 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1674 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
1675 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1676 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
1677 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && (!empty($filterobj->fields[
'ref']) && is_array($filterobj->fields[
'ref']) || $filterobj->fields[
'label'] && is_array($filterobj->fields[
'label'])) && $filterobj->table_element && $filterobj->element) {
1678 $sql .=
", ".MAIN_DB_PREFIX.$filterobj->table_element.
" as o";
1681 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1682 if ($force_filter_contact ===
false) {
1683 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
1684 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
1685 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1687 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
1688 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
1689 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1690 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1691 if ($filterobj->id) {
1692 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1694 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
1695 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
1696 if ($filterobj->id) {
1697 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1699 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1700 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1701 if ($filterobj->id) {
1702 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1704 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
1705 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
1706 if ($filterobj->id) {
1707 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1709 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1710 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1711 if ($filterobj->id) {
1712 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1714 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1715 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1716 if ($filterobj->id) {
1717 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1719 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1720 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1721 if ($filterobj->id) {
1722 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1724 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1725 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1726 if ($filterobj->id) {
1727 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1729 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && (!empty($filterobj->fields[
'ref']) && is_array($filterobj->fields[
'ref']) || $filterobj->fields[
'label'] && is_array($filterobj->fields[
'label'])) && $filterobj->table_element && $filterobj->element) {
1731 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ?
"@".$module :
"").
"'";
1732 if ($filterobj->id) {
1733 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1738 if (!empty($tms_start) && !empty($tms_end)) {
1739 $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).
"'))";
1740 } elseif (empty($tms_start) && !empty($tms_end)) {
1741 $sql .=
" AND ((a.datep <= '".$db->idate($tms_end).
"') OR (a.datep2 <= '".$db->idate($tms_end).
"'))";
1742 } elseif (!empty($tms_start) && empty($tms_end)) {
1743 $sql .=
" AND ((a.datep >= '".$db->idate($tms_start).
"') OR (a.datep2 >= '".$db->idate($tms_start).
"'))";
1746 if (is_array($actioncode) && !empty($actioncode)) {
1748 foreach ($actioncode as $key => $code) {
1752 if (!empty($code)) {
1760 } elseif (!empty($actioncode)) {
1767 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
1768 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
1769 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1771 if (is_array($actioncode)) {
1772 foreach ($actioncode as $code) {
1774 if (!empty($sql2)) {
1776 $sql = $sql.
" UNION ".$sql2;
1777 } elseif (empty($sql)) {
1785 if (!empty($sql) && !empty($sql2)) {
1786 $sql = $sql.
" UNION ".$sql2;
1787 } elseif (empty($sql) && !empty($sql2)) {
1795 $sql .= $db->order($sortfield_new, $sortorder);
1797 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
1799 $resql = $db->query($sql);
1802 $num = $db->num_rows($resql);
1805 $obj = $db->fetch_object($resql);
1807 if ($obj->type ==
'action') {
1809 $contactaction->id = $obj->id;
1810 $result = $contactaction->fetchResources();
1813 setEventMessage(
"company.lib::show_actions_done Error fetch ressource",
'errors');
1819 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
1823 $histo[$numaction] = array(
1825 'tododone'=>$tododone,
1827 'datestart'=>$db->jdate($obj->dp),
1828 'dateend'=>$db->jdate($obj->dp2),
1829 'note'=>$obj->label,
1830 'percent'=>$obj->percent,
1832 'userid'=>$obj->user_id,
1833 'login'=>$obj->user_login,
1834 'userfirstname'=>$obj->user_firstname,
1835 'userlastname'=>$obj->user_lastname,
1836 'userphoto'=>$obj->user_photo,
1838 'contact_id'=>$obj->fk_contact,
1839 'socpeopleassigned' => $contactaction->socpeopleassigned,
1840 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
1841 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
1842 'fk_element'=>$obj->fk_element,
1843 'elementtype'=>$obj->elementtype,
1845 'acode'=>$obj->acode,
1846 'alabel'=>$obj->alabel,
1847 'libelle'=>$obj->alabel,
1848 'apicto'=>$obj->apicto
1851 $histo[$numaction] = array(
1855 'datestart'=>$db->jdate($obj->dp),
1856 'dateend'=>$db->jdate($obj->dp2),
1857 'note'=>$obj->label,
1858 'percent'=>$obj->percent,
1859 'acode'=>$obj->acode,
1861 'userid'=>$obj->user_id,
1862 'login'=>$obj->user_login,
1863 'userfirstname'=>$obj->user_firstname,
1864 'userlastname'=>$obj->user_lastname,
1865 'userphoto'=>$obj->user_photo
1877 if (isModEnabled(
'agenda')|| (isModEnabled(
'mailing') && !empty($objcon->email))) {
1878 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1880 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1881 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1882 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1883 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1888 $userstatic =
new User($db);
1889 $userlinkcache = array();
1890 $contactstatic =
new Contact($db);
1891 $elementlinkcache = array();
1893 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1894 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1895 if ($objcon && get_class($objcon) ==
'Contact' &&
1896 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
1897 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
1899 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
1901 if ($filterobj && get_class($filterobj) ==
'Societe') {
1902 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
1907 $out .=
'<div class="div-table-responsive-no-min">';
1908 $out .=
'<table class="noborder centpercent">';
1910 $out .=
'<tr class="liste_titre">';
1914 $out .=
'<th class="liste_titre width50 middle">';
1915 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
1916 $out .= $searchpicto;
1921 $out .=
'<td class="liste_titre"></td>';
1924 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="'.(isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'').
'"></td>';
1925 $out .=
'<td class="liste_titre"></td>';
1926 $out .=
'<td class="liste_titre">';
1927 $out .=
$formactions->select_type_actions($actioncode,
"actioncode",
'', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, (empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 0 : 1), 1,
'minwidth100 maxwidth150');
1929 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'"></td>';
1930 $out .=
'<td class="liste_titre center">';
1931 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
1933 $out .=
'<td class="liste_titre"></td>';
1934 $out .=
'<td class="liste_titre"></td>';
1935 $out .=
'<td class="liste_titre"></td>';
1938 $out .=
'<td class="liste_titre" align="middle">';
1939 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
1940 $out .= $searchpicto;
1945 $out .=
'<tr class="liste_titre">';
1948 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
1952 if (get_class($filterobj) ==
'Societe') {
1953 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
1955 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
1956 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
1957 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
1959 if (get_class($filterobj) ==
'Societe') {
1964 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
1967 $out .=
getTitleFieldOfList(
"Label", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
1968 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
1969 $out .=
getTitleFieldOfList(
"RelatedObjects", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
1970 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
1971 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
1974 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
1978 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
1980 $arraylist = $caction->liste_array(1,
'code',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
1982 foreach ($histo as $key => $value) {
1983 $actionstatic->fetch($histo[$key][
'id']);
1985 $actionstatic->type_picto = $histo[$key][
'apicto'];
1986 $actionstatic->type_code = $histo[$key][
'acode'];
1988 $out .=
'<tr class="oddeven">';
1992 $out .=
'<td></td>';
1997 $out .=
'<td class="nowrap">';
2002 $out .=
'<td class="nowraponall">';
2003 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2004 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2005 $out .= $histo[$key][
'id'];
2008 $out .= $actionstatic->getNomUrl(1, -1);
2013 $out .=
'<td class="tdoverflowmax150">';
2017 if ($histo[$key][
'userid'] > 0) {
2018 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2019 $link = $userlinkcache[$histo[$key][
'userid']];
2021 $userstatic->fetch($histo[$key][
'userid']);
2022 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2023 $userlinkcache[$histo[$key][
'userid']] = $link;
2030 $labeltype = $actionstatic->type_code;
2031 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
2032 $labeltype =
'AC_OTH';
2034 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2035 $labeltype = $langs->trans(
"Message");
2037 if (!empty($arraylist[$labeltype])) {
2038 $labeltype = $arraylist[$labeltype];
2040 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
2041 $labeltype .=
' - '.$arraylist[$actionstatic->code];
2044 $out .=
'<td class="tdoverflowmax150" title="'.$labeltype.
'">';
2045 $out .= $actionstatic->getTypePicto();
2050 $out .=
'<td class="tdoverflowmax300"';
2051 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2052 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2053 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
2055 $libelle = $histo[$key][
'note'];
2056 $actionstatic->id = $histo[$key][
'id'];
2057 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2060 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2061 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2062 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2063 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2064 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2070 $out .=
'<td class="center nowraponall">';
2071 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
2072 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
2073 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
2074 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
2075 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2076 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
2078 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
2082 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2085 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2088 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2091 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2103 $out .=
'<td class="nowraponall">';
2104 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2105 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2106 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2108 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2109 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2111 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2112 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2121 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2122 $out .=
'<td class="valignmiddle">';
2124 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2125 $result = $contact->fetch($cid);
2132 $out .= $contact->getNomUrl(-3,
'', 10,
'', -1, 0,
'paddingright');
2133 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2134 if (!empty($contact->phone_pro)) {
2135 $out .=
'('.dol_print_phone($contact->phone_pro).
')';
2138 $out .=
'<div class="paddingright"></div>';
2142 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2143 $contactstatic->lastname = $histo[$key][
'lastname'];
2144 $contactstatic->firstname = $histo[$key][
'firstname'];
2145 $contactstatic->id = $histo[$key][
'contact_id'];
2146 $contactstatic->photo = $histo[$key][
'contact_photo'];
2147 $out .=
'<td width="120">'.$contactstatic->getNomUrl(-1,
'', 10).
'</td>';
2149 $out .=
'<td> </td>';
2153 $out .=
'<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']).
'</td>';
2157 $out .=
'<td></td>';
2163 if (empty($histo)) {
2165 $out .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2168 $out .=
"</table>\n";