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->rights->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 entity IN (".getEntity($object->element).
")";
76 $parameters = array(
'contacttab' =>
true);
77 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
78 $sql .= $hookmanager->resPrint;
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;
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';
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");
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);
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) {
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')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->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';
430 global $langs, $conf, $user;
434 $head[$h][0] = DOL_URL_ROOT.
'/societe/card.php?socid='.$object->id;
435 $head[$h][1] = $langs->trans(
"ThirdParty");
436 $head[$h][2] =
'company';
439 $head[$h][0] =
'commerciaux.php?socid='.$object->id;
440 $head[$h][1] = $langs->trans(
"SalesRepresentative");
441 $head[$h][2] =
'salesrepresentative';
456 global $langs, $conf, $user, $db;
459 $extrafields->fetch_name_optionals_label(
'societe');
460 $extrafields->fetch_name_optionals_label(
'socpeople');
465 $head[$h][0] = DOL_URL_ROOT.
'/societe/admin/societe.php';
466 $head[$h][1] = $langs->trans(
"Miscellaneous");
467 $head[$h][2] =
'general';
476 $head[$h][0] = DOL_URL_ROOT.
'/societe/admin/societe_extrafields.php';
477 $head[$h][1] = $langs->trans(
"ExtraFieldsThirdParties");
478 $nbExtrafields = $extrafields->attributes[
'societe'][
'count'];
479 if ($nbExtrafields > 0) {
480 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
482 $head[$h][2] =
'attributes';
485 $head[$h][0] = DOL_URL_ROOT.
'/societe/admin/contact_extrafields.php';
486 $head[$h][1] = $langs->trans(
"ExtraFieldsContacts");
487 $nbExtrafields = $extrafields->attributes[
'socpeople'][
'count'];
488 if ($nbExtrafields > 0) {
489 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
491 $head[$h][2] =
'attributes_contacts';
516 function getCountry($searchkey, $withcode =
'', $dbtouse = 0, $outputlangs =
'', $entconv = 1, $searchlabel =
'')
523 if (empty($searchkey) && empty($searchlabel)) {
524 if ($withcode ===
'all') {
525 return array(
'id'=>
'',
'code'=>
'',
'label'=>
'');
530 if (!is_object($dbtouse)) {
533 if (!is_object($outputlangs)) {
534 $outputlangs = $langs;
537 $sql =
"SELECT rowid, code, label FROM ".MAIN_DB_PREFIX.
"c_country";
538 if (is_numeric($searchkey)) {
539 $sql .=
" WHERE rowid = ".((int) $searchkey);
540 } elseif (!empty($searchkey)) {
541 $sql .=
" WHERE code = '".$db->escape($searchkey).
"'";
543 $sql .=
" WHERE label = '".$db->escape($searchlabel).
"'";
546 $resql = $dbtouse->query($sql);
548 $obj = $dbtouse->fetch_object(
$resql);
550 $label = ((!empty($obj->label) && $obj->label !=
'-') ? $obj->label :
'');
551 if (is_object($outputlangs)) {
552 $outputlangs->load(
"dict");
554 $label = ($obj->code && ($outputlangs->trans(
"Country".$obj->code) !=
"Country".$obj->code)) ? $outputlangs->trans(
"Country".$obj->code) : $label;
556 $label = ($obj->code && ($outputlangs->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv(
"Country".$obj->code) : $label;
559 if ($withcode == 1) {
560 $result = $label ?
"$obj->code - $label" :
"$obj->code";
561 } elseif ($withcode == 2) {
562 $result = $obj->code;
563 } elseif ($withcode == 3) {
564 $result = $obj->rowid;
565 } elseif ($withcode ===
'all') {
566 $result = array(
'id'=>$obj->rowid,
'code'=>$obj->code,
'label'=>$label);
571 $result =
'NotDefined';
596 function getState($id, $withcode =
'', $dbtouse = 0, $withregion = 0, $outputlangs =
'', $entconv = 1)
600 if (!is_object($dbtouse)) {
604 $sql =
"SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM";
605 $sql .=
" ".MAIN_DB_PREFIX.
"c_departements as d, ".MAIN_DB_PREFIX.
"c_regions as r,".MAIN_DB_PREFIX.
"c_country as c";
606 $sql .=
" WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".((int) $id);
607 $sql .=
" AND d.active = 1 AND r.active = 1 AND c.active = 1";
608 $sql .=
" ORDER BY c.code, d.code_departement";
610 dol_syslog(
"Company.lib::getState", LOG_DEBUG);
611 $resql = $dbtouse->query($sql);
613 $obj = $dbtouse->fetch_object(
$resql);
615 $label = ((!empty($obj->name) && $obj->name !=
'-') ? $obj->name :
'');
616 if (is_object($outputlangs)) {
617 $outputlangs->load(
"dict");
619 $label = ($obj->code && ($outputlangs->trans(
"State".$obj->code) !=
"State".$obj->code)) ? $outputlangs->trans(
"State".$obj->code) : $label;
621 $label = ($obj->code && ($outputlangs->transnoentitiesnoconv(
"State".$obj->code) !=
"State".$obj->code)) ? $outputlangs->transnoentitiesnoconv(
"State".$obj->code) : $label;
625 if ($withcode == 1) {
626 if ($withregion == 1) {
627 return $label = $obj->region_name.
' - '.$obj->code.
' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
629 return $label = $obj->code.
' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
631 } elseif ($withcode == 2) {
632 if ($withregion == 1) {
633 return $label = $obj->region_name.
' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
635 return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name !=
'-' ? $obj->name :
''));
637 } elseif ($withcode ===
'all') {
638 if ($withregion == 1) {
639 return array(
'id'=>$obj->id,
'code'=>$obj->code,
'label'=>$label,
'region_code'=>$obj->region_code,
'region'=>$obj->region_name);
641 return array(
'id'=>$obj->id,
'code'=>$obj->code,
'label'=>$label);
644 if ($withregion == 1) {
645 return $label = $obj->region_name.
' - '.$label;
651 return $langs->transnoentitiesnoconv(
"NotDefined");
670 if (empty($outputlangs)) {
671 $outputlangs = $langs;
674 $outputlangs->load(
"dict");
677 if ($outputlangs->trans(
"Currency".$code_iso) !=
"Currency".$code_iso) {
678 return ($withcode ? $code_iso.
' - ' :
'').$outputlangs->trans(
"Currency".$code_iso);
682 $sql =
"SELECT label FROM ".MAIN_DB_PREFIX.
"c_currencies";
683 $sql .=
" WHERE code_iso='".$db->escape($code_iso).
"'";
685 $resql = $db->query($sql);
687 $num = $db->num_rows(
$resql);
690 $obj = $db->fetch_object(
$resql);
691 $label = ($obj->label !=
'-' ? $obj->label :
'');
693 return ($label == $code_iso) ?
"$code_iso" :
"$code_iso - $label";
701 return 'ErrorWhenReadingCurrencyLabel';
718 $sql =
"SELECT libelle FROM ".MAIN_DB_PREFIX.
"c_forme_juridique";
719 $sql .=
" WHERE code='".$db->escape($code).
"'";
721 dol_syslog(
"Company.lib::getFormeJuridiqueLabel", LOG_DEBUG);
722 $resql = $db->query($sql);
724 $num = $db->num_rows(
$resql);
727 $obj = $db->fetch_object(
$resql);
728 $label = ($obj->libelle !=
'-' ? $obj->libelle :
'');
731 return $langs->trans(
"NotDefined");
748 $country_code_in_EEC = array();
750 if (!empty($conf->cache[
'country_code_in_EEC'])) {
752 $country_code_in_EEC = $conf->cache[
'country_code_in_EEC'];
754 $sql =
"SELECT cc.code FROM ".MAIN_DB_PREFIX.
"c_country as cc";
755 $sql .=
" WHERE cc.eec = 1";
757 $resql = $db->query($sql);
759 $num = $db->num_rows(
$resql);
762 $objp = $db->fetch_object(
$resql);
763 $country_code_in_EEC[] = $objp->code;
769 $conf->cache[
'country_code_in_EEC'] = $country_code_in_EEC;
771 return $country_code_in_EEC;
782 if (empty($object->country_code)) {
789 return in_array($object->country_code, $country_code_in_EEC);
805 function show_projects($conf, $langs, $db, $object, $backtopage =
'', $nocreatelink = 0, $morehtmlright =
'')
807 global $user, $action, $hookmanager;
811 if (
isModEnabled(
'project') && $user->hasRight(
'projet',
'lire')) {
812 $langs->load(
"projects");
815 if (
isModEnabled(
'project') && $user->hasRight(
'projet',
'creer') && empty($nocreatelink)) {
816 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'AddProject'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/projet/card.php?socid='.$object->id.
'&action=create&backtopage='.urlencode($backtopage));
820 print
load_fiche_titre($langs->trans(
"ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright,
'');
822 print
'<div class="div-table-responsive">'.
"\n";
823 print
'<table class="noborder centpercent">';
825 $sql =
"SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount";
826 $sql .=
", cls.code as opp_status_code";
827 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
828 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls on p.fk_opp_status = cls.rowid";
829 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
830 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
831 $sql .=
" ORDER BY p.dateo DESC";
833 $result = $db->query($sql);
835 $num = $db->num_rows($result);
837 print
'<tr class="liste_titre">';
838 print
'<td>'.$langs->trans(
"Ref").
'</td>';
839 print
'<td>'.$langs->trans(
"Name").
'</td>';
840 print
'<td class="center">'.$langs->trans(
"DateStart").
'</td>';
841 print
'<td class="center">'.$langs->trans(
"DateEnd").
'</td>';
842 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
843 print
'<td class="center">'.$langs->trans(
"OpportunityStatusShort").
'</td>';
844 print
'<td class="right">'.$langs->trans(
"OpportunityProbabilityShort").
'</td>';
845 print
'<td class="right">'.$langs->trans(
"Status").
'</td>';
849 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
851 $projecttmp =
new Project($db);
856 $obj = $db->fetch_object($result);
857 $projecttmp->fetch($obj->id);
860 $userAccess = $projecttmp->restrictedProjectArea($user);
862 if ($user->rights->projet->lire && $userAccess > 0) {
863 print
'<tr class="oddeven">';
866 print
'<td class="nowraponall">';
867 print $projecttmp->getNomUrl(1);
871 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).
'">'.
dol_escape_htmltag($obj->title).
'</td>';
873 print
'<td class="center">'.dol_print_date($db->jdate($obj->do),
"day").
'</td>';
875 print
'<td class="center">'.dol_print_date($db->jdate($obj->de),
"day").
'</td>';
877 print
'<td class="right">';
878 if ($obj->opp_status_code) {
879 print
'<span class="amount">'.price($obj->opp_amount, 1,
'', 1, -1, -1,
'').
'</span>';
883 print
'<td class="center">';
884 if ($obj->opp_status_code) {
885 print $langs->trans(
"OppStatus".$obj->opp_status_code);
889 print
'<td class="right">';
890 if ($obj->opp_percent) {
891 print
price($obj->opp_percent, 1,
'', 1, 0).
'%';
895 print
'<td class="right">'.$projecttmp->getLibStatut(5).
'</td>';
902 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
909 $parameters = array(
'sql'=>$sql,
'function'=>
'show_projects');
910 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
911 print $hookmanager->resPrint;
934 function show_contacts($conf, $langs, $db, $object, $backtopage =
'', $showuserlogin = 0)
936 global $user, $conf, $extrafields, $hookmanager;
939 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
943 $optioncss =
GETPOST(
'optioncss',
'alpha');
944 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
945 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
948 $search_status =
GETPOST(
"search_status",
'int');
949 if ($search_status ==
'') {
953 $search_rowid =
GETPOST(
"search_rowid",
'int');
954 $search_name =
GETPOST(
"search_name",
'alpha');
955 $search_address =
GETPOST(
"search_address",
'alpha');
956 $search_poste =
GETPOST(
"search_poste",
'alpha');
957 $search_note_private =
GETPOST(
'search_note_private',
'alphanohtml');
958 $search_roles =
GETPOST(
"search_roles",
'array');
962 $searchAddressPhoneDBFields = array(
990 $sortfield =
"t.lastname";
994 $user->fetch_clicktodial();
998 $contactstatic =
new Contact($db);
1000 $extrafields->fetch_name_optionals_label($contactstatic->table_element);
1002 $contactstatic->fields = array(
1003 '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),
1004 'name' =>array(
'type'=>
'varchar(128)',
'label'=>
'Name',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>1,
'index'=>1,
'position'=>10,
'searchall'=>1),
1005 'poste' =>array(
'type'=>
'varchar(128)',
'label'=>
'PostOrFunction',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>2,
'index'=>1,
'position'=>20),
1006 'address' =>array(
'type'=>
'varchar(128)',
'label'=>
'Address',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>3,
'index'=>1,
'position'=>30),
1007 'note_private' =>array(
'type'=>
'text',
'label'=>
'NotePrivate',
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'visible'=>3,
'position'=>35),
1008 'role' =>array(
'type'=>
'checkbox',
'label'=>
'Role',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>4,
'index'=>1,
'position'=>40),
1009 '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))),
1013 $arrayfields = array(
1014 '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),
1015 't.name'=>array(
'label'=>
"Name",
'checked'=>1,
'position'=>10),
1016 't.poste'=>array(
'label'=>
"PostOrFunction",
'checked'=>1,
'position'=>20),
1017 '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),
1018 't.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'position'=>35),
1019 'sc.role'=>array(
'label'=>
"ContactByDefaultFor",
'checked'=>1,
'position'=>40),
1020 't.statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>50,
'class'=>
'center'),
1023 if (!empty($extrafields->attributes[$contactstatic->table_element][
'label']) && is_array($extrafields->attributes[$contactstatic->table_element][
'label']) && count($extrafields->attributes[$contactstatic->table_element][
'label'])) {
1024 foreach ($extrafields->attributes[$contactstatic->table_element][
'label'] as $key => $val) {
1025 if (!empty($extrafields->attributes[$contactstatic->table_element][
'list'][$key])) {
1026 $arrayfields[
"ef.".$key] = array(
1027 'label'=>$extrafields->attributes[$contactstatic->table_element][
'label'][$key],
1028 'checked'=>(($extrafields->attributes[$contactstatic->table_element][
'list'][$key] < 0) ? 0 : 1),
1029 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element][
'pos'][$key],
1030 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element][
'list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element][
'perms'][$key]));
1037 foreach ($arrayfields as $key => $val) {
1038 $queryName =
'search_'.substr($key, 2);
1039 if (
GETPOST($queryName,
'alpha')) {
1040 $search[substr($key, 2)] =
GETPOST($queryName,
'alpha');
1043 $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element,
'',
'search_');
1046 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1048 $search_status =
'';
1050 $search_roles = array();
1051 $search_address =
'';
1053 $search_note_private =
'';
1055 $search_array_options = array();
1057 foreach ($contactstatic->fields as $key => $val) {
1062 $contactstatic->fields =
dol_sort_array($contactstatic->fields,
'position');
1065 $newcardbutton =
'';
1066 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1067 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
1068 $newcardbutton .=
dolGetButtonTitle($addcontact,
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/contact/card.php?socid='.$object->id.
'&action=create&backtopage='.urlencode($backtopage));
1073 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"ContactsForCompany") : $langs->trans(
"ContactsAddressesForCompany"));
1076 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" name="formfilter">';
1077 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1078 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1079 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1080 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1081 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1082 print
'<input type="hidden" name="page" value="'.$page.
'">';
1084 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1085 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1088 print
'<div class="div-table-responsive">';
1089 print
"\n".
'<table class="tagtable liste">'.
"\n";
1091 $param =
"socid=".urlencode($object->id);
1092 if ($search_rowid !=
'') {
1093 $param .=
'&search_rowid='.urlencode($search_rowid);
1095 if ($search_status !=
'') {
1096 $param .=
'&search_status='.urlencode($search_status);
1098 if (count($search_roles) > 0) {
1099 $param .= implode(
'&search_roles[]=', $search_roles);
1101 if ($search_name !=
'') {
1102 $param .=
'&search_name='.urlencode($search_name);
1104 if ($search_poste !=
'') {
1105 $param .=
'&search_poste='.urlencode($search_poste);
1107 if ($search_address !=
'') {
1108 $param .=
'&search_address='.urlencode($search_address);
1110 if ($search_note_private !=
'') {
1111 $param .=
'&search_note_private='.urlencode($search_note_private);
1113 if ($optioncss !=
'') {
1114 $param .=
'&optioncss='.urlencode($optioncss);
1118 $extrafieldsobjectkey = $contactstatic->table_element;
1119 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1121 $sql =
"SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo, t.fk_soc,";
1122 $sql .=
" t.civility as civility_id, t.address, t.zip, t.town";
1123 $sql .=
", t.note_private";
1124 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as t";
1125 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
1126 $sql .=
" WHERE t.fk_soc = ".((int) $object->id);
1127 $sql .=
" AND t.entity IN (".getEntity($object->element).
")";
1128 $sql .=
" AND ((t.fk_user_creat = ".((int) $user->id).
" AND t.priv = 1) OR t.priv = 0)";
1129 if ($search_rowid) {
1132 if ($search_status !=
'' && $search_status !=
'-1') {
1133 $sql .=
" AND t.statut = ".((int) $search_status);
1136 $sql .=
natural_search(array(
't.lastname',
't.firstname'), $search_name);
1138 if ($search_poste) {
1141 if ($search_address) {
1142 $sql .=
natural_search($searchAddressPhoneDBFields, $search_address);
1144 if ($search_note_private) {
1147 if (count($search_roles) > 0) {
1148 $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)).
"))";
1151 $extrafieldsobjectkey = $contactstatic->table_element;
1152 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1154 $parameters = array(
'socid' => $object->id);
1155 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
1156 $sql .= $hookmanager->resPrint;
1157 if ($sortfield ==
"t.name") {
1158 $sql .=
" ORDER BY t.lastname $sortorder, t.firstname $sortorder";
1160 $sql .=
" ORDER BY $sortfield $sortorder";
1163 dol_syslog(
'core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
1164 $result = $db->query($sql);
1169 $num = $db->num_rows($result);
1173 print
'<tr class="liste_titre">';
1174 foreach ($contactstatic->fields as $key => $val) {
1176 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1177 $align .= ($align ?
' ' :
'').
'center';
1179 if (in_array($val[
'type'], array(
'timestamp'))) {
1180 $align .= ($align ?
' ' :
'').
'nowrap';
1182 if ($key ==
'status' || $key ==
'statut') {
1183 $align .= ($align ?
' ' :
'').
'center';
1185 if (!empty($arrayfields[
't.'.$key][
'checked']) || !empty($arrayfields[
'sc.'.$key][
'checked'])) {
1186 print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'">';
1187 if (in_array($key, array(
'statut'))) {
1188 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');
1189 } elseif (in_array($key, array(
'role'))) {
1190 print $formcompany->showRoles(
"search_roles", $contactstatic,
'edit', $search_roles,
'minwidth200 maxwidth300');
1192 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.(!empty($search[$key]) ?
dol_escape_htmltag($search[$key]) :
'').
'">';
1197 if ($showuserlogin) {
1198 print
'<td class="liste_titre"></td>';
1201 $extrafieldsobjectkey = $contactstatic->table_element;
1202 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1205 $parameters = array(
'arrayfields'=>$arrayfields);
1206 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $contactstatic);
1207 print $hookmanager->resPrint;
1209 print
'<td class="liste_titre" align="right">';
1210 print
$form->showFilterButtons();
1217 print
'<tr class="liste_titre">';
1218 foreach ($contactstatic->fields as $key => $val) {
1220 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
1221 $align .= ($align ?
' ' :
'').
'center';
1223 if (in_array($val[
'type'], array(
'timestamp'))) {
1224 $align .= ($align ?
' ' :
'').
'nowrap';
1226 if ($key ==
'status' || $key ==
'statut') {
1227 $align .= ($align ?
' ' :
'').
'center';
1229 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
1230 print
getTitleFieldOfList($val[
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1232 if ($key ==
'role') {
1233 $align .= ($align ?
' ' :
'').
'left';
1235 if (!empty($arrayfields[
'sc.'.$key][
'checked'])) {
1236 print
getTitleFieldOfList($arrayfields[
'sc.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
'',
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
1239 if ($showuserlogin) {
1240 print
'<th class="wrapcolumntitle liste_titre">'.$langs->trans(
"DolibarrLogin").
'</th>';
1243 $extrafieldsobjectkey = $contactstatic->table_element;
1244 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1246 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1247 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1248 print $hookmanager->resPrint;
1249 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
1254 if ($num || (
GETPOST(
'button_search') ||
GETPOST(
'button_search.x') ||
GETPOST(
'button_search_x'))) {
1258 $obj = $db->fetch_object($result);
1260 $contactstatic->id = $obj->rowid;
1261 $contactstatic->ref = $obj->rowid;
1262 $contactstatic->statut = $obj->statut;
1263 $contactstatic->lastname = $obj->lastname;
1264 $contactstatic->firstname = $obj->firstname;
1265 $contactstatic->civility_id = $obj->civility_id;
1266 $contactstatic->civility_code = $obj->civility_id;
1267 $contactstatic->poste = $obj->poste;
1268 $contactstatic->address = $obj->address;
1269 $contactstatic->zip = $obj->zip;
1270 $contactstatic->town = $obj->town;
1271 $contactstatic->phone_pro = $obj->phone_pro;
1272 $contactstatic->phone_mobile = $obj->phone_mobile;
1273 $contactstatic->phone_perso = $obj->phone_perso;
1274 $contactstatic->email = $obj->email;
1275 $contactstatic->socialnetworks = $obj->socialnetworks;
1276 $contactstatic->photo = $obj->photo;
1277 $contactstatic->fk_soc = $obj->fk_soc;
1278 $contactstatic->entity = $obj->entity;
1280 $country_code =
getCountry($obj->country_id, 2);
1281 $contactstatic->country_code = $country_code;
1283 $contactstatic->setGenderFromCivility();
1284 $contactstatic->fetch_optionals();
1286 $resultRole = $contactstatic->fetchRoles();
1287 if ($resultRole < 0) {
1291 if (is_array($contactstatic->array_options)) {
1292 foreach ($contactstatic->array_options as $key => $val) {
1297 print
'<tr class="oddeven">';
1300 if (!empty($arrayfields[
't.rowid'][
'checked'])) {
1302 print $contactstatic->id;
1307 if (!empty($arrayfields[
't.name'][
'checked'])) {
1309 print
$form->showphoto(
'contact', $contactstatic, 0, 0, 0,
'photorefnoborder valignmiddle marginrightonly',
'small', 1, 0, 1);
1310 print $contactstatic->getNomUrl(0,
'', 0,
'&backtopage='.urlencode($backtopage));
1315 if (!empty($arrayfields[
't.poste'][
'checked'])) {
1324 if (!empty($arrayfields[
't.address'][
'checked'])) {
1326 print $contactstatic->getBannerAddress(
'contact', $object);
1331 if (!empty($arrayfields[
't.note_private'][
'checked'])) {
1333 if ($obj->note_private) {
1340 if (!empty($arrayfields[
'sc.role'][
'checked'])) {
1342 print $formcompany->showRoles(
"roles", $contactstatic,
'view');
1347 if (!empty($arrayfields[
't.statut'][
'checked'])) {
1348 print
'<td class="center">'.$contactstatic->getLibStatut(5).
'</td>';
1351 if ($showuserlogin) {
1353 $tmpuser=
new User($db);
1354 $resfetch = $tmpuser->fetch(0,
'',
'', 0, -1,
'', $contactstatic->id);
1355 if ($resfetch > 0) {
1356 print $tmpuser->getNomUrl(1,
'', 0, 0, 24, 1);
1362 $extrafieldsobjectkey = $contactstatic->table_element;
1363 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1366 print
'<td align="right">';
1369 if (
isModEnabled(
'agenda')&& $user->hasRight(
'agenda',
'myactions',
'create')) {
1370 print
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.
'&socid='.$object->id.
'&backtopage='.urlencode($backtopage).
'">';
1371 print
img_object($langs->trans(
"Event"),
"action");
1372 print
'</a> ';
1376 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1377 print
'<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.
'/contact/card.php?action=edit&token='.
newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($backtopage).
'">';
1389 $colspan = 1 + ($showuserlogin ? 1 : 0);
1390 foreach ($arrayfields as $key => $val) {
1391 if (!empty($val[
'checked'])) {
1395 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
1398 $colspan = 1 + ($showuserlogin ? 1 : 0);
1399 foreach ($arrayfields as $key => $val) {
1400 if (!empty($val[
'checked'])) {
1404 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1406 print
"\n</table>\n";
1409 print
'</form>'.
"\n";
1427 function show_actions_todo($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'')
1429 global $user, $conf;
1431 $out =
show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode,
'todo');
1458 function show_actions_done($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC', $module =
'')
1460 global $user, $conf;
1462 global $param, $massactionbutton;
1464 $start_year =
GETPOST(
'dateevent_startyear',
'int');
1465 $start_month =
GETPOST(
'dateevent_startmonth',
'int');
1466 $start_day =
GETPOST(
'dateevent_startday',
'int');
1467 $end_year =
GETPOST(
'dateevent_endyear',
'int');
1468 $end_month =
GETPOST(
'dateevent_endmonth',
'int');
1469 $end_day =
GETPOST(
'dateevent_endday',
'int');
1473 if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
1474 $tms_start =
dol_mktime(0, 0, 0, $start_month, $start_day, $start_year,
'tzuserrel');
1476 if (!empty($end_year) && !empty($end_month) && !empty($end_day)) {
1477 $tms_end =
dol_mktime(23, 59, 59, $end_month, $end_day, $end_year,
'tzuserrel');
1479 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
1486 if (!is_object($filterobj) && !is_object($objcon)) {
1496 $sortfield_list = explode(
',', $sortfield);
1497 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
1498 $sortfield_new_list = array();
1499 foreach ($sortfield_list as $sortfield_value) {
1500 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
1502 $sortfield_new = implode(
',', $sortfield_new_list);
1507 require_once DOL_DOCUMENT_ROOT .
'/core/class/hookmanager.class.php';
1510 $hookmanager->initHooks(array(
'agendadao'));
1513 if (is_object($objcon) && $objcon->id > 0) {
1514 $sql =
"SELECT DISTINCT a.id, a.label as label,";
1516 $sql =
"SELECT a.id, a.label as label,";
1518 $sql .=
" a.datep as dp,";
1519 $sql .=
" a.datep2 as dp2,";
1520 $sql .=
" a.percent as percent, 'action' as type,";
1521 $sql .=
" a.fk_element, a.elementtype,";
1522 $sql .=
" a.fk_contact,";
1523 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
1524 $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";
1525 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1526 $sql .=
", sp.lastname, sp.firstname";
1527 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1529 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1531 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1532 $sql .=
", m.lastname, m.firstname";
1533 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1535 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1537 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1539 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1541 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1543 } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields[
'rowid']) && $filterobj->table_element && $filterobj->element) {
1544 if (!empty($filterobj->fields[
'ref'])) {
1546 } elseif (!empty($filterobj->fields[
'label'])) {
1547 $sql .=
", o.label";
1552 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1553 $reshook = $hookmanager->executeHooks(
'showActionsDoneListSelect', $parameters);
1554 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1556 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
1557 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
1558 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
1560 $force_filter_contact =
false;
1561 if (is_object($objcon) && $objcon->id > 0) {
1562 $force_filter_contact =
true;
1563 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
1564 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
1568 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon);
1569 $reshook = $hookmanager->executeHooks(
'showActionsDoneListFrom', $parameters);
1570 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1572 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur'))) {
1573 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
1574 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1575 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
1576 $sql .=
" ON er.resource_type = 'dolresource'";
1577 $sql .=
" AND er.element_id = a.id";
1578 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
1579 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project') {
1581 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1582 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
1583 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1584 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
1585 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1586 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
1587 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1588 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
1589 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1590 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
1591 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1592 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
1593 } 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) {
1594 $sql .=
", ".MAIN_DB_PREFIX.$filterobj->table_element.
" as o";
1597 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
1598 if ($force_filter_contact ===
false) {
1599 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
1600 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
1601 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
1603 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
1604 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
1605 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
1606 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
1607 if ($filterobj->id) {
1608 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1610 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
1611 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
1612 if ($filterobj->id) {
1613 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1615 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
1616 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
1617 if ($filterobj->id) {
1618 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1620 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
1621 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
1622 if ($filterobj->id) {
1623 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1625 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
1626 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
1627 if ($filterobj->id) {
1628 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1630 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
1631 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
1632 if ($filterobj->id) {
1633 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1635 } 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) {
1637 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ?
"@".$module :
"").
"'";
1638 if ($filterobj->id) {
1639 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
1644 if (!empty($tms_start) && !empty($tms_end)) {
1645 $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).
"'))";
1646 } elseif (empty($tms_start) && !empty($tms_end)) {
1647 $sql .=
" AND ((a.datep <= '".$db->idate($tms_end).
"') OR (a.datep2 <= '".$db->idate($tms_end).
"'))";
1648 } elseif (!empty($tms_start) && empty($tms_end)) {
1649 $sql .=
" AND ((a.datep >= '".$db->idate($tms_start).
"') OR (a.datep2 >= '".$db->idate($tms_start).
"'))";
1652 if (is_array($actioncode) && !empty($actioncode)) {
1654 foreach ($actioncode as $key => $code) {
1658 if (!empty($code)) {
1666 } elseif (!empty($actioncode)) {
1673 $parameters = array(
'sql' => &$sql,
'filterobj' => $filterobj,
'objcon' => $objcon,
'module' => $module);
1674 $reshook = $hookmanager->executeHooks(
'showActionsDoneListWhere', $parameters);
1675 if (!empty($hookmanager->resPrint)) $sql.= $hookmanager->resPrint;
1677 if (is_array($actioncode)) {
1678 foreach ($actioncode as $code) {
1680 if (!empty($sql2)) {
1682 $sql = $sql.
" UNION ".$sql2;
1683 } elseif (empty($sql)) {
1691 if (!empty($sql) && !empty($sql2)) {
1692 $sql = $sql.
" UNION ".$sql2;
1693 } elseif (empty($sql) && !empty($sql2)) {
1701 $sql .= $db->order($sortfield_new, $sortorder);
1703 dol_syslog(
"company.lib::show_actions_done", LOG_DEBUG);
1705 $resql = $db->query($sql);
1708 $num = $db->num_rows(
$resql);
1711 $obj = $db->fetch_object(
$resql);
1713 if ($obj->type ==
'action') {
1715 $contactaction->id = $obj->id;
1716 $result = $contactaction->fetchResources();
1719 setEventMessage(
"company.lib::show_actions_done Error fetch ressource",
'errors');
1725 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) {
1729 $histo[$numaction] = array(
1731 'tododone'=>$tododone,
1733 'datestart'=>$db->jdate($obj->dp),
1734 'dateend'=>$db->jdate($obj->dp2),
1735 'note'=>$obj->label,
1736 'percent'=>$obj->percent,
1738 'userid'=>$obj->user_id,
1739 'login'=>$obj->user_login,
1740 'userfirstname'=>$obj->user_firstname,
1741 'userlastname'=>$obj->user_lastname,
1742 'userphoto'=>$obj->user_photo,
1744 'contact_id'=>$obj->fk_contact,
1745 'socpeopleassigned' => $contactaction->socpeopleassigned,
1746 'lastname' => empty($obj->lastname) ?
'' : $obj->lastname,
1747 'firstname' => empty($obj->firstname) ?
'' : $obj->firstname,
1748 'fk_element'=>$obj->fk_element,
1749 'elementtype'=>$obj->elementtype,
1751 'acode'=>$obj->acode,
1752 'alabel'=>$obj->alabel,
1753 'libelle'=>$obj->alabel,
1754 'apicto'=>$obj->apicto
1757 $histo[$numaction] = array(
1761 'datestart'=>$db->jdate($obj->dp),
1762 'dateend'=>$db->jdate($obj->dp2),
1763 'note'=>$obj->label,
1764 'percent'=>$obj->percent,
1765 'acode'=>$obj->acode,
1767 'userid'=>$obj->user_id,
1768 'login'=>$obj->user_login,
1769 'userfirstname'=>$obj->user_firstname,
1770 'userlastname'=>$obj->user_lastname,
1771 'userphoto'=>$obj->user_photo
1784 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1786 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1787 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1788 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1789 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1794 $userstatic =
new User($db);
1795 $userlinkcache = array();
1796 $contactstatic =
new Contact($db);
1797 $elementlinkcache = array();
1799 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1800 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1801 if ($objcon && get_class($objcon) ==
'Contact' &&
1802 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
1803 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
1805 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
1807 if ($filterobj && get_class($filterobj) ==
'Societe') {
1808 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
1813 $out .=
'<div class="div-table-responsive-no-min">';
1814 $out .=
'<table class="noborder centpercent">';
1816 $out .=
'<tr class="liste_titre">';
1818 $out .=
'<td class="liste_titre"></td>';
1821 $out .=
'<td class="liste_titre"><input type="text" class="width50" name="search_rowid" value="'.(isset($filters[
'search_rowid']) ? $filters[
'search_rowid'] :
'').
'"></td>';
1822 $out .=
'<td class="liste_titre"></td>';
1823 $out .=
'<td class="liste_titre">';
1824 $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');
1826 $out .=
'<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'"></td>';
1827 $out .=
'<td class="liste_titre center">';
1828 $out .=
$form->selectDateToDate($tms_start, $tms_end,
'dateevent', 1);
1830 $out .=
'<td class="liste_titre"></td>';
1831 $out .=
'<td class="liste_titre"></td>';
1832 $out .=
'<td class="liste_titre"></td>';
1834 $out .=
'<td class="liste_titre" align="middle">';
1835 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
1836 $out .= $searchpicto;
1840 $out .=
'<tr class="liste_titre">';
1843 if (get_class($filterobj) ==
'Societe') {
1844 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
1846 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
1847 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
1848 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
1850 if (get_class($filterobj) ==
'Societe') {
1855 $out .=
getTitleFieldOfList(
"Ref", 0, $_SERVER[
"PHP_SELF"],
'a.id',
'', $param,
'', $sortfield, $sortorder);
1858 $out .=
getTitleFieldOfList(
"Label", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
1859 $out .=
getTitleFieldOfList(
"Date", 0, $_SERVER[
"PHP_SELF"],
'a.datep,a.id',
'', $param,
'', $sortfield, $sortorder,
'center ');
1860 $out .=
getTitleFieldOfList(
"RelatedObjects", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
1861 $out .=
getTitleFieldOfList(
"ActionOnContact", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'tdoverflowmax125 ', 0,
'', 0);
1862 $out .=
getTitleFieldOfList(
"Status", 0, $_SERVER[
"PHP_SELF"],
'a.percent',
'', $param,
'', $sortfield, $sortorder,
'center ');
1863 $out .=
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch ');
1866 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
1868 $arraylist = $caction->liste_array(1,
'code',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
1870 foreach ($histo as $key => $value) {
1871 $actionstatic->fetch($histo[$key][
'id']);
1873 $actionstatic->type_picto = $histo[$key][
'apicto'];
1874 $actionstatic->type_code = $histo[$key][
'acode'];
1876 $out .=
'<tr class="oddeven">';
1880 $out .=
'<td class="nowrap">';
1885 $out .=
'<td class="nowraponall">';
1886 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
1887 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
1888 $out .= $histo[$key][
'id'];
1891 $out .= $actionstatic->getNomUrl(1, -1);
1896 $out .=
'<td class="tdoverflowmax150">';
1900 if ($histo[$key][
'userid'] > 0) {
1901 if (isset($userlinkcache[$histo[$key][
'userid']])) {
1902 $link = $userlinkcache[$histo[$key][
'userid']];
1904 $userstatic->fetch($histo[$key][
'userid']);
1905 $link = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
1906 $userlinkcache[$histo[$key][
'userid']] = $link;
1913 $labeltype = $actionstatic->type_code;
1914 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
1915 $labeltype =
'AC_OTH';
1917 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
1918 $labeltype = $langs->trans(
"Message");
1920 if (!empty($arraylist[$labeltype])) {
1921 $labeltype = $arraylist[$labeltype];
1923 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
1924 $labeltype .=
' - '.$arraylist[$actionstatic->code];
1927 $out .=
'<td class="tdoverflowmax150" title="'.$labeltype.
'">';
1928 $out .= $actionstatic->getTypePicto();
1933 $out .=
'<td class="tdoverflowmax300"';
1934 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
1935 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
1936 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
1938 $libelle = $histo[$key][
'note'];
1939 $actionstatic->id = $histo[$key][
'id'];
1940 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
1943 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
1944 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
1945 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
1946 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
1947 $out .=
' title="'.dol_escape_htmltag($libelle).
'">';
1953 $out .=
'<td class="center nowraponall">';
1954 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
1955 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
1956 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
1957 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
1958 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
1959 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
1961 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
1965 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
1968 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
1971 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
1974 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
1986 $out .=
'<td class="nowraponall">';
1987 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
1988 if (isset($elementlinkcache[$histo[$key][
'elementtype']]) && isset($elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
1989 $link = $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
1991 if (!isset($elementlinkcache[$histo[$key][
'elementtype']])) {
1992 $elementlinkcache[$histo[$key][
'elementtype']] = array();
1994 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
1995 $elementlinkcache[$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
2004 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
2005 $out .=
'<td class="valignmiddle">';
2007 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $value) {
2008 $result = $contact->fetch($cid);
2015 $out .= $contact->getNomUrl(-3,
'', 10,
'', -1, 0,
'paddingright');
2016 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
2017 if (!empty($contact->phone_pro)) {
2018 $out .=
'('.dol_print_phone($contact->phone_pro).
')';
2021 $out .=
'<div class="paddingright"></div>';
2025 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
2026 $contactstatic->lastname = $histo[$key][
'lastname'];
2027 $contactstatic->firstname = $histo[$key][
'firstname'];
2028 $contactstatic->id = $histo[$key][
'contact_id'];
2029 $contactstatic->photo = $histo[$key][
'contact_photo'];
2030 $out .=
'<td width="120">'.$contactstatic->getNomUrl(-1,
'', 10).
'</td>';
2032 $out .=
'<td> </td>';
2036 $out .=
'<td class="nowrap center">'.$actionstatic->LibStatut($histo[$key][
'percent'], 2, 0, $histo[$key][
'datestart']).
'</td>';
2039 $out .=
'<td></td>';
2044 if (empty($histo)) {
2046 $out .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2049 $out .=
"</table>\n";
2077 $sql =
"SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas";
2078 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
2079 $sql .=
" WHERE s.parent = ".((int) $object->id);
2080 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
2081 $sql .=
" ORDER BY s.nom";
2083 $result = $db->query($sql);
2084 $num = $db->num_rows($result);
2087 $socstatic =
new Societe($db);
2091 print
"\n".
'<div class="div-table-responsive-no-min">'.
"\n";
2092 print
'<table class="noborder centpercent">'.
"\n";
2094 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Company").
'</td>';
2095 print
'<td>'.$langs->trans(
"Address").
'</td><td>'.$langs->trans(
"Zip").
'</td>';
2096 print
'<td>'.$langs->trans(
"Town").
'</td><td>'.$langs->trans(
"CustomerCode").
'</td>';
2097 print
"<td> </td>";
2103 $obj = $db->fetch_object($result);
2105 $socstatic->id = $obj->rowid;
2106 $socstatic->name = $obj->name;
2107 $socstatic->name_alias = $obj->name_alias;
2108 $socstatic->email = $obj->email;
2109 $socstatic->code_client = $obj->code_client;
2110 $socstatic->code_fournisseur = $obj->code_client;
2111 $socstatic->code_compta = $obj->code_compta;
2112 $socstatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
2113 $socstatic->email = $obj->email;
2114 $socstatic->canvas = $obj->canvas;
2115 $socstatic->client = $obj->client;
2116 $socstatic->fournisseur = $obj->fournisseur;
2118 print
'<tr class="oddeven">';
2120 print
'<td class="tdoverflowmax150">';
2121 print $socstatic->getNomUrl(1);
2124 print
'<td class="tdoverflowmax400" title="'.dol_escape_htmltag($obj->address).
'">'.
dol_escape_htmltag($obj->address).
'</td>';
2125 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">'.$obj->zip.
'</td>';
2126 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->town).
'">'.$obj->town.
'</td>';
2127 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->code_client).
'">'.$obj->code_client.
'</td>';
2129 print
'<td class="center">';
2130 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.((int) $obj->rowid).
'&action=edit&token='.
newToken().
'">';
2137 print
"\n</table>\n";
2138 print
'</div>'.
"\n";
2158 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
2159 if ($actioncode ==
'AC_NON_AUTO') {
2160 $sql .=
" $sqlANDOR c.type != 'systemauto'";
2161 } elseif ($actioncode ==
'AC_ALL_AUTO') {
2162 $sql .=
" $sqlANDOR c.type = 'systemauto'";
2164 if ($actioncode ==
'AC_OTH') {
2165 $sql .=
" $sqlANDOR c.type != 'systemauto'";
2166 } elseif ($actioncode ==
'AC_OTH_AUTO') {
2167 $sql .=
" $sqlANDOR c.type = 'systemauto'";
2171 if ($actioncode ==
'AC_NON_AUTO') {
2172 $sql .=
" $sqlANDOR c.type != 'systemauto'";
2173 } elseif ($actioncode ==
'AC_ALL_AUTO') {
2174 $sql .=
" $sqlANDOR c.type = 'systemauto'";
2176 $sql .=
" $sqlANDOR c.code = '".$db->escape($actioncode).
"'";
2197 if ($donetodo ==
'todo') {
2198 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
2199 } elseif ($donetodo ==
'done') {
2200 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
2202 if (is_array($filters) && $filters[
'search_agenda_label']) {
2203 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
2205 if (is_array($filters) && $filters[
'search_rowid']) {
2222 global $conf, $langs, $db;
2225 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
2226 $langs->load(
"mails");
2228 $sql2 =
"SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
2229 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
2230 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
2231 $sql2 .=
", 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";
2232 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
2233 $sql2 .=
", '' as lastname, '' as firstname";
2234 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
2235 $sql2 .=
", '' as lastname, '' as firstname";
2236 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
2237 $sql2 .=
", '' as ref";
2238 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
2239 $sql2 .=
", '' as ref";
2240 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
2241 $sql2 .=
", '' as ref";
2243 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
2244 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
2245 $sql2 .=
" AND mc.statut = 1";
2246 $sql2 .=
" AND u.rowid = m.fk_user_valid";
2247 $sql2 .=
" AND mc.fk_mailing=m.rowid";
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Class to manage agenda events (actions)
Class to manage different types of events.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage projects.
Class for SocieteAccount.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='')
Show html area for list of projects.
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
show_actions_todo($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='')
Show html area with actions to do.
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
societe_prepare_head2($object)
Return array of tabs to used on page.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
getState($id, $withcode='', $dbtouse=0, $withregion=0, $outputlangs='', $entconv=1)
Return state translated from an id.
addOtherFilterSQL(&$sql, $donetodo, $now, $filters)
Add Event Type SQL.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
addEventTypeSQL(&$sql, $actioncode, $sqlANDOR="AND")
Add Event Type SQL.
societe_admin_prepare_head()
Return array head with list of tabs to view object informations.
getFormeJuridiqueLabel($code)
Retourne le nom traduit de la forme juridique.
addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
Add Mailing Event Type SQL.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.