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';
56 if (!
getDolGlobalString(
'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 (!
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS') && ($object->client == 2 || $object->client == 3)) {
111 $head[$h][1] .= $langs->trans(
"Prospect");
114 $head[$h][1] .=
' | ';
116 if (!
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS') && ($object->client == 1 || $object->client == 3)) {
117 $head[$h][1] .= $langs->trans(
"Customer");
119 $head[$h][2] =
'customer';
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 && $user->hasRight(
'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') && ($user->hasRight(
'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';
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"))
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';
194 $foundonexternalonlinesystem = 0;
195 $langs->load(
"bills");
197 $title = $langs->trans(
"PaymentModes");
199 if (isModEnabled(
'stripe')) {
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';
247 ((isModEnabled(
'website') &&
getDolGlobalString(
'WEBSITE_USE_WEBSITE_ACCOUNTS')) || isModEnabled(
'webportal'))
248 && $user->hasRight(
'societe',
'lire')
250 $site_filter_list = array();
251 if (isModEnabled(
'website')) {
252 $site_filter_list[] =
'dolibarr_website';
254 if (isModEnabled(
'webportal')) {
255 $site_filter_list[] =
'dolibarr_portal';
258 $head[$h][0] = DOL_URL_ROOT.
'/societe/website.php?id='.urlencode($object->id);
259 $head[$h][1] = $langs->trans(
"WebSiteAccounts");
261 $sql =
"SELECT COUNT(n.rowid) as nb";
262 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as n";
263 $sql .=
" WHERE fk_soc = ".((int) $object->id);
264 $sql .=
" AND entity IN (".getEntity(
'thirdpartyaccount').
")";
265 if (!empty($site_filter_list)) {
266 $sql .=
" AND n.site IN (".$db->sanitize(
"'".implode(
"','", $site_filter_list).
"'", 1).
")";
268 $resql = $db->query($sql);
270 $obj = $db->fetch_object($resql);
276 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
278 $head[$h][2] =
'website';
283 if ($user->hasRight(
'partnership',
'read')) {
284 $langs->load(
"partnership");
285 $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
286 $head[$h][0] = DOL_URL_ROOT.
'/partnership/partnership_list.php?socid='.$object->id;
287 $head[$h][1] = $langs->trans(
"Partnerships");
289 $sql =
"SELECT COUNT(n.rowid) as nb";
290 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership as n";
291 $sql .=
" WHERE fk_soc = ".((int) $object->id);
292 $sql .=
" AND entity IN (".getEntity(
'partnership').
")";
293 $resql = $db->query($sql);
295 $obj = $db->fetch_object($resql);
301 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
303 $head[$h][2] =
'partnerships';
304 if ($nbPartnership > 0) {
305 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbPartnership.
'</span>';
317 if ($user->socid == 0) {
319 if (isModEnabled(
'notification')) {
322 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
323 $cachekey =
'count_notifications_thirdparty_'.$object->id;
325 if (!is_null($dataretrieved)) {
326 $nbNotif = $dataretrieved;
328 $sql =
"SELECT COUNT(n.rowid) as nb";
329 $sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def as n";
330 $sql .=
" WHERE fk_soc = ".((int) $object->id);
331 $resql = $db->query($sql);
333 $obj = $db->fetch_object($resql);
341 $head[$h][0] = DOL_URL_ROOT.
'/societe/notify/card.php?socid='.urlencode($object->id);
342 $head[$h][1] = $langs->trans(
"Notifications");
344 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNotif.
'</span>';
346 $head[$h][2] =
'notify';
352 if (!empty($object->note_private)) {
355 if (!empty($object->note_public)) {
358 $head[$h][0] = DOL_URL_ROOT.
'/societe/note.php?id='.urlencode($object->id);
359 $head[$h][1] = $langs->trans(
"Notes");
361 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
363 $head[$h][2] =
'note';
369 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
370 $cachekey =
'count_attached_thirdparty_'.$object->id;
372 if (!is_null($dataretrieved)) {
373 $totalAttached = $dataretrieved;
375 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
376 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
377 $upload_dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id;
378 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
379 $nbLinks =
Link::count($db, $object->element, $object->id);
380 $totalAttached = $nbFiles + $nbLinks;
384 $head[$h][0] = DOL_URL_ROOT.
'/societe/document.php?socid='.$object->id;
385 $head[$h][1] = $langs->trans(
"Documents");
386 if (($totalAttached) > 0) {
387 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($totalAttached).
'</span>';
389 $head[$h][2] =
'document';
393 $head[$h][0] = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id;
394 $head[$h][1] = $langs->trans(
"Events");
395 if (isModEnabled(
'agenda')&& ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
398 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
399 $cachekey =
'count_events_thirdparty_'.$object->id;
401 if (!is_null($dataretrieved)) {
402 $nbEvent = $dataretrieved;
404 $sql =
"SELECT COUNT(id) as nb";
405 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
406 $sql .=
" WHERE fk_soc = ".((int) $object->id);
407 $sql .=
" AND entity IN (".getEntity(
'agenda').
")";
408 $resql = $db->query($sql);
410 $obj = $db->fetch_object($resql);
413 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
419 $head[$h][1] .= $langs->trans(
"Agenda");
421 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
424 $head[$h][2] =
'agenda';
992function show_contacts($conf, $langs, $db, $object, $backtopage =
'', $showuserlogin = 0)
994 global $user, $conf, $extrafields, $hookmanager;
997 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
999 $form =
new Form($db);
1001 $optioncss =
GETPOST(
'optioncss',
'alpha');
1002 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1003 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1004 $page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
1006 $search_status =
GETPOST(
"search_status",
'int');
1007 if ($search_status ==
'') {
1011 $search_rowid =
GETPOST(
"search_rowid",
'int');
1012 $search_name =
GETPOST(
"search_name",
'alpha');
1013 $search_address =
GETPOST(
"search_address",
'alpha');
1014 $search_poste =
GETPOST(
"search_poste",
'alpha');
1015 $search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
1016 $search_roles =
GETPOST(
"search_roles",
'array');
1017 $search_birthday_dtstart =
GETPOST(
"search_birthday_dtstart",
'alpha');
1018 $search_birthday_dtend =
GETPOST(
"search_birthday_dtend",
'alpha');
1020 if ($search_birthday_dtstart !=
'' || $search_birthday_dtend !=
'') {
1021 $search_birthday_dtstart =
dol_mktime(0, 0, 0,
GETPOST(
'search_birthday_dtstartmonth',
'int'),
GETPOST(
'search_birthday_dtstartday',
'int'),
GETPOST(
'search_birthday_dtstartyear',
'int'));
1022 $search_birthday_dtend =
dol_mktime(23, 59, 59,
GETPOST(
'search_birthday_dtendmonth',
'int'),
GETPOST(
'search_birthday_dtendday',
'int'),
GETPOST(
'search_birthday_dtendyear',
'int'));
1026 $searchAddressPhoneDBFields = array(
1054 $sortfield =
"t.lastname";
1057 if (isModEnabled(
'clicktodial')) {
1058 $user->fetch_clicktodial();
1062 $contactstatic =
new Contact($db);
1064 $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1066 $contactstatic->fields = array(
1067 'rowid' =>array(
'type'=>
'integer',
'label'=>
"TechnicalID",
'enabled'=>(
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'visible'=>(
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'position'=>1),
1068 'name' =>array(
'type'=>
'varchar(128)',
'label'=>
'Name',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>1,
'index'=>1,
'position'=>10,
'searchall'=>1),
1069 'poste' =>array(
'type'=>
'varchar(128)',
'label'=>
'PostOrFunction',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>2,
'index'=>1,
'position'=>20),
1070 'address' =>array(
'type'=>
'varchar(128)',
'label'=>
'Address',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>3,
'index'=>1,
'position'=>30),
1071 'note_private' =>array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'visible'=>3,
'position'=>35),
1072 'role' =>array(
'type'=>
'checkbox',
'label'=>
'Role',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>4,
'index'=>1,
'position'=>40),
1073 'birthday' =>array(
'type'=>
'date',
'label'=>
'Birthday',
'enabled'=>1,
'visible'=>-1,
'notnull'=> 0,
'position'=>45),
1074 '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))),
1078 $arrayfields = array(
1079 't.rowid'=>array(
'label'=>
"TechnicalID",
'checked'=>(
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'enabled'=>(
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0),
'position'=>1),
1080 't.name'=>array(
'label'=>
"Name",
'checked'=>1,
'position'=>10),
1081 't.poste'=>array(
'label'=>
"PostOrFunction",
'checked'=>1,
'position'=>20),
1082 '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),
1083 't.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'position'=>35),
1084 'sc.role'=>array(
'label'=>
"ContactByDefaultFor",
'checked'=>1,
'position'=>40),
1085 't.birthday'=>array(
'label'=>
"Birthday",
'checked'=>0,
'position'=>45),
1086 't.statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>50,
'class'=>
'center'),
1089 if (!empty($extrafields->attributes[$contactstatic->table_element][
'label']) && is_array($extrafields->attributes[$contactstatic->table_element][
'label']) && count($extrafields->attributes[$contactstatic->table_element][
'label'])) {
1090 foreach ($extrafields->attributes[$contactstatic->table_element][
'label'] as $key => $val) {
1091 if (!empty($extrafields->attributes[$contactstatic->table_element][
'list'][$key])) {
1092 $arrayfields[
"ef.".$key] = array(
1093 'label'=>$extrafields->attributes[$contactstatic->table_element][
'label'][$key],
1094 'checked'=>((
dol_eval($extrafields->attributes[$contactstatic->table_element][
'list'][$key], 1, 1,
'1') < 0) ? 0 : 1),
1095 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element][
'pos'][$key],
1096 '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'))
1104 foreach ($arrayfields as $key => $val) {
1105 $queryName =
'search_'.substr($key, 2);
1106 if (
GETPOST($queryName,
'alpha')) {
1107 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1110 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1113 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1115 $search_status =
'';
1117 $search_roles = array();
1118 $search_address =
'';
1120 $search_note_private =
'';
1121 $search_birthday_dtstart =
'';
1122 $search_birthday_dtend =
'';
1124 $search_array_options = array();
1126 foreach ($contactstatic->fields as $key => $val) {
1131 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1134 $newcardbutton =
'';
1135 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1136 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1137 $newcardbutton .=
dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?socid='.$object->id.
'&action=create&backtopage='.urlencode($backtopage));
1142 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1145 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
1146 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1147 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1148 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1149 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1150 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1151 print
'<input type="hidden" name="page" value="'.$page.
'">';
1153 $arrayofmassactions = array();
1156 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1157 $selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
1158 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1160 print
'<div class="div-table-responsive">';
1161 print
"\n".
'<table class="tagtable liste">'.
"\n";
1163 $param =
"socid=".urlencode($object->id);
1164 if ($search_rowid !=
'') {
1165 $param .=
'&search_rowid='.urlencode($search_rowid);
1167 if ($search_status !=
'') {
1168 $param .=
'&search_status='.urlencode($search_status);
1170 if (count($search_roles) > 0) {
1171 $param .= implode(
'&search_roles[]=', $search_roles);
1173 if ($search_name !=
'') {
1174 $param .=
'&search_name='.urlencode($search_name);
1176 if ($search_poste !=
'') {
1177 $param .=
'&search_poste='.urlencode($search_poste);
1179 if ($search_address !=
'') {
1180 $param .=
'&search_address='.urlencode($search_address);
1182 if ($search_note_private !=
'') {
1183 $param .=
'&search_note_private='.urlencode($search_note_private);
1185 if ($search_birthday_dtstart !=
'') {
1186 $param .=
'&search_birthday_dtstart='.urlencode($search_birthday_dtstart);
1188 if ($search_birthday_dtend !=
'') {
1189 $param .=
'&search_birthday_dtend='.urlencode($search_birthday_dtend);
1191 if ($optioncss !=
'') {
1192 $param .=
'&optioncss='.urlencode($optioncss);
1196 $extrafieldsobjectkey = $contactstatic->table_element;
1197 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1199 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste,";
1200 $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,";
1201 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town, t.birthday,";
1202 $sql .=
" t.note_private";
1203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as t";
1204 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1205 $sql .=
" WHERE t.fk_soc = ".((int) $object->id);
1206 $sql .=
" AND t.entity IN (" .getEntity(
'socpeople') .
")";
1207 $sql .=
" AND ((t.fk_user_creat = ".((int) $user->id).
" AND t.priv = 1) OR t.priv = 0)";
1208 if ($search_rowid) {
1211 if ($search_status !=
'' && $search_status !=
'-1') {
1212 $sql .=
" AND t.statut = ".((int) $search_status);
1215 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1217 if ($search_poste) {
1220 if ($search_address) {
1221 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1223 if ($search_note_private) {
1226 if ($search_birthday_dtstart !=
'') {
1227 $sql .=
" AND t.birthday >= '".$db->idate($search_birthday_dtstart).
"'";
1229 if ($search_birthday_dtend !=
'') {
1230 $sql .=
" AND t.birthday <= '".$db->idate($search_birthday_dtend).
"'";
1232 if (count($search_roles) > 0) {
1233 $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)).
"))";
1236 $extrafieldsobjectkey = $contactstatic->table_element;
1237 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1239 $parameters = array(
'socid' => $object->id);
1240 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1241 $sql .= $hookmanager->resPrint;
1242 if ($sortfield ==
"t.name") {
1243 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1245 $sql .=
" ORDER BY $sortfield $sortorder";
1248 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1249 $result = $db->query($sql);
1254 $num = $db->num_rows($result);
1258 print
'<tr class="liste_titre">';
1261 print
'<td class="liste_titre" align="right">';
1262 print $form->showFilterButtons();
1265 foreach ($contactstatic->fields as $key => $val) {
1267 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1268 $align .= ($align ?
' ' :
'').
'center';
1270 if (in_array($val[
'type'], array(
'timestamp'))) {
1271 $align .= ($align ?
' ' :
'').
'nowrap';
1273 if ($key ==
'status' || $key ==
'statut') {
1274 $align .= ($align ?
' ' :
'').
'center';
1276 if (!empty($arrayfields[
't.'.$key][
'checked']) || !empty($arrayfields[
'sc.'.$key][
'checked'])) {
1277 print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'">';
1278 if (in_array($key, array(
'statut'))) {
1279 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');
1280 } elseif (in_array($key, array(
'role'))) {
1281 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1282 } elseif (in_array($key, array(
'birthday'))) {
1283 print
'<div class="nowrap">';
1284 print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart :
'',
"search_birthday_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1286 print
'<div class="nowrap">';
1287 print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend :
'',
"search_birthday_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1290 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.(!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'').
'">';
1295 if ($showuserlogin) {
1296 print
'<td class="liste_titre"></td>';
1299 $extrafieldsobjectkey = $contactstatic->table_element;
1300 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1303 $parameters = array(
'arrayfields'=>$arrayfields);
1304 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1305 print $hookmanager->resPrint;
1308 print
'<td class="liste_titre" align="right">';
1309 print $form->showFilterButtons();
1317 print
'<tr class="liste_titre">';
1320 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1322 foreach ($contactstatic->fields as $key => $val) {
1324 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1325 $align .= ($align ?
' ' :
'').
'center';
1327 if (in_array($val[
'type'], array(
'timestamp'))) {
1328 $align .= ($align ?
' ' :
'').
'nowrap';
1330 if ($key ==
'status' || $key ==
'statut') {
1331 $align .= ($align ?
' ' :
'').
'center';
1333 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
1334 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1336 if ($key ==
'role') {
1337 $align .= ($align ?
' ' :
'').
'left';
1339 if (!empty($arrayfields[
'sc.'.$key][
'checked'])) {
1340 print
getTitleFieldOfList($arrayfields[
'sc.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1343 if ($showuserlogin) {
1344 print
'<th class="wrapcolumntitle liste_titre">'.$langs->trans(
"DolibarrLogin").
'</th>';
1347 $extrafieldsobjectkey = $contactstatic->table_element;
1348 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1350 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1351 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1352 print $hookmanager->resPrint;
1355 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
1361 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1365 $obj = $db->fetch_object($result);
1367 $contactstatic->id = $obj->rowid;
1368 $contactstatic->ref = $obj->rowid;
1369 $contactstatic->statut = $obj->statut;
1370 $contactstatic->lastname = $obj->lastname;
1371 $contactstatic->firstname = $obj->firstname;
1372 $contactstatic->civility_id = $obj->civility_id;
1373 $contactstatic->civility_code = $obj->civility_id;
1374 $contactstatic->poste = $obj->poste;
1375 $contactstatic->address = $obj->address;
1376 $contactstatic->zip = $obj->zip;
1377 $contactstatic->town = $obj->town;
1378 $contactstatic->phone_pro = $obj->phone_pro;
1379 $contactstatic->phone_mobile = $obj->phone_mobile;
1380 $contactstatic->phone_perso = $obj->phone_perso;
1381 $contactstatic->email = $obj->email;
1382 $contactstatic->socialnetworks = $obj->socialnetworks;
1383 $contactstatic->photo = $obj->photo;
1384 $contactstatic->fk_soc = $obj->fk_soc;
1385 $contactstatic->entity = $obj->entity;
1387 $country_code =
getCountry($obj->country_id, 2);
1388 $contactstatic->country_code = $country_code;
1390 $contactstatic->setGenderFromCivility();
1391 $contactstatic->fetch_optionals();
1393 $resultRole = $contactstatic->fetchRoles();
1394 if ($resultRole < 0) {
1398 if (is_array($contactstatic->array_options)) {
1399 foreach ($contactstatic->array_options as $key => $val) {
1404 print
'<tr class="oddeven">';
1408 print
'<td class="nowrap center">';
1411 if (isModEnabled(
'agenda')&& $user->hasRight(
'agenda',
'myactions',
'create')) {
1412 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1413 print
img_object($langs->trans(
"Event"),
"action");
1414 print
'</a> ';
1418 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1419 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1428 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1430 print $contactstatic->id;
1435 if (!empty($arrayfields[
't.name'][
'checked'])) {
1436 print
'<td class="tdoverflowmax150">';
1437 print $form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0, 1);
1438 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage='.urlencode($backtopage));
1443 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1444 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->poste).
'">';
1452 if (!empty($arrayfields[
't.address'][
'checked'])) {
1453 $addresstoshow = $contactstatic->getBannerAddress(
'contact', $object);
1454 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag(
dol_string_nohtmltag($addresstoshow)).
'">';
1455 print $addresstoshow;
1460 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1462 if ($obj->note_private) {
1469 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1470 print
'<td class="tdoverflowmax150">';
1471 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1476 if (!empty($arrayfields[
't.birthday'][
'checked'])) {
1477 print
'<td class="nowraponall">';
1483 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1484 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1487 if ($showuserlogin) {
1488 print
'<td class="tdoverflowmax125">';
1489 $tmpuser=
new User($db);
1490 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1491 if ($resfetch > 0) {
1492 print $tmpuser->getNomUrl(1,
'', 0, 0, 24, 1);
1498 $extrafieldsobjectkey = $contactstatic->table_element;
1499 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1503 print
'<td class="nowrap center">';
1506 if (isModEnabled(
'agenda')&& $user->hasRight(
'agenda',
'myactions',
'create')) {
1507 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1508 print
img_object($langs->trans(
"Event"),
"action");
1509 print
'</a> ';
1513 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1514 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1527 $colspan = 1 + ($showuserlogin ? 1 : 0);
1528 foreach ($arrayfields as $key => $val) {
1529 if (!empty($val[
'checked'])) {
1533 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1536 $colspan = 1 + ($showuserlogin ? 1 : 0);
1537 foreach ($arrayfields as $key => $val) {
1538 if (!empty($val[
'checked'])) {
1542 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1544 print
"\n</table>\n";
1547 print
'</form>'.
"\n";
1596function show_actions_done($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1598 global $user, $conf, $hookmanager;
1600 global $param, $massactionbutton;
1602 $start_year =
GETPOST(
'dateevent_startyear',
'int');
1603 $start_month =
GETPOST(
'dateevent_startmonth',
'int');
1604 $start_day =
GETPOST(
'dateevent_startday',
'int');
1605 $end_year =
GETPOST(
'dateevent_endyear',
'int');
1606 $end_month =
GETPOST(
'dateevent_endmonth',
'int');
1607 $end_day =
GETPOST(
'dateevent_endday',
'int');
1611 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1612 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1614 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1615 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1617 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1624 if (!is_object($filterobj) && !is_object($objcon)) {
1634 $sortfield_list = explode(
',', $sortfield);
1635 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1636 $sortfield_new_list = array();
1637 foreach ($sortfield_list as $sortfield_value) {
1638 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1640 $sortfield_new = implode(
',', $sortfield_new_list);
1644 if (isModEnabled(
'agenda')) {
1646 $hookmanager->initHooks(array(
'agendadao'));
1649 if (is_object($objcon) && $objcon->id > 0) {
1650 $sql =
"SELECT DISTINCT a.id, a.label as label,";
1652 $sql =
"SELECT a.id, a.label as label,";
1654 $sql .=
" a.datep as dp,";
1655 $sql .=
" a.datep2 as dp2,";
1656 $sql .=
" a.percent as percent, 'action' as type,";
1657 $sql .=
" a.fk_element, a.elementtype,";
1658 $sql .=
" a.fk_contact,";
1659 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1660 $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";
1661 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1662 $sql .=
", sp.lastname, sp.firstname";
1663 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1665 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1667 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1668 $sql .=
", m.lastname, m.firstname";
1669 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1671 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1673 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1675 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1677 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1679 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1680 if (!empty($filterobj->fields[
'ref'])) {
1682 } elseif (!empty($filterobj->fields[
'label'])) {
1683 $sql .=
", o.label";
1688 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1689 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
1690 if (!empty($hookmanager->resPrint)) {
1691 $sql.= $hookmanager->resPrint;
1694 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1695 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
1696 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
1698 $force_filter_contact =
false;
1699 if (is_object($objcon) && $objcon->id > 0) {
1700 $force_filter_contact =
true;
1701 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
1702 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
1706 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1707 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
1708 if (!empty($hookmanager->resPrint)) {
1709 $sql.= $hookmanager->resPrint;
1712 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1713 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
1714 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1715 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
1716 $sql .=
" ON er.resource_type = 'dolresource'";
1717 $sql .=
" AND er.element_id = a.id";
1718 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
1719 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1721 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1722 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
1723 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1724 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
1725 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1726 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
1727 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1728 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
1729 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1730 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
1731 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1732 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
1733 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
1734 && ((!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'])))
1735 && $filterobj->table_element && $filterobj->element) {
1736 $sql .=
", ".MAIN_DB_PREFIX.$filterobj->table_element.
" as o";
1737 } elseif (is_object($filterobj)) {
1738 return 'Bad value for $filterobj';
1741 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1742 if ($force_filter_contact ===
false) {
1743 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
1744 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
1745 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1747 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
1748 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
1749 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1750 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1751 if ($filterobj->id) {
1752 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1754 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
1755 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
1756 if ($filterobj->id) {
1757 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1759 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1760 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1761 if ($filterobj->id) {
1762 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1764 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
1765 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'invoice'";
1766 if ($filterobj->id) {
1767 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1769 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1770 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1771 if ($filterobj->id) {
1772 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1774 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1775 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1776 if ($filterobj->id) {
1777 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1779 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1780 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1781 if ($filterobj->id) {
1782 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1784 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1785 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1786 if ($filterobj->id) {
1787 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1789 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid'])
1790 && ((!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'])))
1791 && $filterobj->table_element && $filterobj->element) {
1793 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ?
"@".$module :
"").
"'";
1794 if ($filterobj->id) {
1795 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1797 } elseif (is_object($filterobj)) {
1798 return 'Bad value for $filterobj';
1802 if (!empty($tms_start) && !empty($tms_end)) {
1803 $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).
"'))";
1804 } elseif (empty($tms_start) && !empty($tms_end)) {
1805 $sql .=
" AND ((a.datep <= '".$db->idate($tms_end).
"') OR (a.datep2 <= '".$db->idate($tms_end).
"'))";
1806 } elseif (!empty($tms_start) && empty($tms_end)) {
1807 $sql .=
" AND ((a.datep >= '".$db->idate($tms_start).
"') OR (a.datep2 >= '".$db->idate($tms_start).
"'))";
1810 if (is_array($actioncode) && !empty($actioncode)) {
1812 foreach ($actioncode as $key => $code) {
1816 if (!empty($code)) {
1821 } elseif (!empty($actioncode)) {
1828 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
1829 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
1830 if (!empty($hookmanager->resPrint)) {
1831 $sql.= $hookmanager->resPrint;
1834 if (is_array($actioncode)) {
1835 foreach ($actioncode as $code) {
1837 if (!empty($sql2)) {
1839 $sql = $sql.
" UNION ".$sql2;
1840 } elseif (empty($sql)) {
1848 if (!empty($sql) && !empty($sql2)) {
1849 $sql = $sql.
" UNION ".$sql2;
1850 } elseif (empty($sql) && !empty($sql2)) {
1858 $sql .= $db->order($sortfield_new, $sortorder);
1860 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
1862 $resql = $db->query($sql);
1865 $num = $db->num_rows($resql);
1868 $obj = $db->fetch_object($resql);
1870 if ($obj->type ==
'action') {
1872 $contactaction->id = $obj->id;
1873 $result = $contactaction->fetchResources();
1876 setEventMessage(
"company.lib::show_actions_done Error fetch ressource",
'errors');
1882 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
1886 $histo[$numaction] = array(
1888 'tododone'=>$tododone,
1890 'datestart'=>$db->jdate($obj->dp),
1891 'dateend'=>$db->jdate($obj->dp2),
1892 'note'=>$obj->label,
1893 'percent'=>$obj->percent,
1895 'userid'=>$obj->user_id,
1896 'login'=>$obj->user_login,
1897 'userfirstname'=>$obj->user_firstname,
1898 'userlastname'=>$obj->user_lastname,
1899 'userphoto'=>$obj->user_photo,
1901 'contact_id'=>$obj->fk_contact,
1902 'socpeopleassigned' => $contactaction->socpeopleassigned,
1903 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
1904 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
1905 'fk_element'=>$obj->fk_element,
1906 'elementtype'=>$obj->elementtype,
1908 'acode'=>$obj->acode,
1909 'alabel'=>$obj->alabel,
1910 'libelle'=>$obj->alabel,
1911 'apicto'=>$obj->apicto
1914 $histo[$numaction] = array(
1918 'datestart'=>$db->jdate($obj->dp),
1919 'dateend'=>$db->jdate($obj->dp2),
1920 'note'=>$obj->label,
1921 'percent'=>$obj->percent,
1922 'acode'=>$obj->acode,
1924 'userid'=>$obj->user_id,
1925 'login'=>$obj->user_login,
1926 'userfirstname'=>$obj->user_firstname,
1927 'userlastname'=>$obj->user_lastname,
1928 'userphoto'=>$obj->user_photo
1940 if (isModEnabled(
'agenda')|| (isModEnabled(
'mailing') && !empty($objcon->email))) {
1941 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1943 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1944 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1945 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1946 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1951 $userstatic =
new User($db);
1952 $userlinkcache = array();
1953 $contactstatic =
new Contact($db);
1954 $elementlinkcache = array();
1956 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1957 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1958 if ($objcon && get_class($objcon) ==
'Contact' &&
1959 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
1960 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
1962 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
1964 if ($filterobj && get_class($filterobj) ==
'Societe') {
1965 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
1970 $out .=
'<div class="div-table-responsive-no-min">';
1971 $out .=
'<table class="noborder centpercent">';
1973 $out .=
'<tr class="liste_titre">';
1977 $out .=
'<th class="liste_titre width50 middle">';
1978 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
1979 $out .= $searchpicto;
1984 $out .=
'<td class="liste_titre"></td>';
1987 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="'.(isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'').
'"></td>';
1988 $out .=
'<td class="liste_titre"></td>';
1989 $out .=
'<td class="liste_titre">';
1992 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'"></td>';
1993 $out .=
'<td class="liste_titre center">';
1994 $out .= $form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
1996 $out .=
'<td class="liste_titre"></td>';
1997 $out .=
'<td class="liste_titre"></td>';
1998 $out .=
'<td class="liste_titre"></td>';
2001 $out .=
'<td class="liste_titre" align="middle">';
2002 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
2003 $out .= $searchpicto;
2008 $out .=
'<tr class="liste_titre">';
2011 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2015 if (get_class($filterobj) ==
'Societe') {
2016 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
2018 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
2019 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
2020 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
2022 if (get_class($filterobj) ==
'Societe') {
2027 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
2030 $out .=
getTitleFieldOfList(
"Label", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2031 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
2032 $out .=
getTitleFieldOfList(
"RelatedObjects", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
2033 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
2034 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
2037 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
2041 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
2043 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
2045 foreach ($histo as $key => $value) {
2046 $actionstatic->fetch($histo[$key][
'id']);
2048 $actionstatic->type_picto = $histo[$key][
'apicto'];
2049 $actionstatic->type_code = $histo[$key][
'acode'];
2051 $out .=
'<tr class="oddeven">';
2055 $out .=
'<td></td>';
2060 $out .=
'<td class="nowrap">';
2065 $out .=
'<td class="nowraponall">';
2066 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2067 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2068 $out .= $histo[$key][
'id'];
2071 $out .= $actionstatic->getNomUrl(1, -1);
2076 $out .=
'<td class="tdoverflowmax125">';
2077 if ($histo[$key][
'userid'] > 0) {
2078 if (isset($userlinkcache[$histo[$key][
'userid']])) {
2079 $link = $userlinkcache[$histo[$key][
'userid']];
2081 $userstatic->fetch($histo[$key][
'userid']);
2082 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
2083 $userlinkcache[$histo[$key][
'userid']] = $link;
2090 $labeltype = $actionstatic->type_code;
2092 $labeltype =
'AC_OTH';
2094 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
2095 $labeltype = $langs->trans(
"Message");
2097 if (!empty($arraylist[$labeltype])) {
2098 $labeltype = $arraylist[$labeltype];
2100 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
2101 $labeltype .=
' - '.$arraylist[$actionstatic->code];
2104 $out .=
'<td class="tdoverflowmax125" title="'.$labeltype.
'">';
2105 $out .= $actionstatic->getTypePicto();
2112 $out .=
'<td class="tdoverflowmax300"';
2113 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
2114 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2116 $libelle = $histo[$key][
'note'];
2117 $actionstatic->id = $histo[$key][
'id'];
2118 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2121 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
2122 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
2123 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
2124 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
2125 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
2131 $out .=
'<td class="center nowraponall">';
2132 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
2133 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
2134 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
2135 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
2136 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
2137 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
2139 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
2143 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2146 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2149 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
2152 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
2161 $out .=
'<td class="nowraponall">';
2162 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
2163 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
2164 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
2166 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
2167 $elementlinkcache[$histo[$key][
'elementtype']] = array();
2169 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
2170 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2177 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2178 $out .=
'<td class="valignmiddle">';
2180 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $cvalue) {
2181 $result = $contact->fetch($cid);
2188 $out .= $contact->getNomUrl(-3,
'', 10,
'', -1, 0,
'paddingright');
2189 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2190 if (!empty($contact->phone_pro)) {
2191 $out .=
'('.dol_print_phone($contact->phone_pro).
')';
2194 $out .=
'<div class="paddingright"></div>';
2198 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2199 $contactstatic->lastname = $histo[$key][
'lastname'];
2200 $contactstatic->firstname = $histo[$key][
'firstname'];
2201 $contactstatic->id = $histo[$key][
'contact_id'];
2202 $contactstatic->photo = $histo[$key][
'contact_photo'];
2203 $out .=
'<td width="120">'.$contactstatic->getNomUrl(-1,
'', 10).
'</td>';
2205 $out .=
'<td> </td>';
2209 $out .=
'<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']).
'</td>';
2213 $out .=
'<td></td>';
2219 if (empty($histo)) {
2221 $out .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2224 $out .=
"</table>\n";