35 global $db, $langs, $conf, $user;
40 $head[$tab][0] = DOL_URL_ROOT.
'/contact/card.php?id='.$object->id;
41 $head[$tab][1] = $langs->trans(
"Contact");
42 $head[$tab][2] =
'card';
49 $head[$tab][0] = DOL_URL_ROOT.
'/contact/ldap.php?id='.$object->id;
50 $head[$tab][1] = $langs->trans(
"LDAPCard");
51 $head[$tab][2] =
'ldap';
55 $head[$tab][0] = DOL_URL_ROOT.
'/contact/perso.php?id='.$object->id;
56 $head[$tab][1] = $langs->trans(
"PersonalInformations");
57 $head[$tab][2] =
'perso';
60 if (isModEnabled(
'project') && $user->hasRight(
'project',
'lire')) {
63 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
64 $cachekey =
'count_projects_contact_'.$object->id;
67 if (!is_null($dataretrieved)) {
68 $nbProject = $dataretrieved;
70 $sql =
'SELECT COUNT(n.rowid) as nb';
71 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as n';
72 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'element_contact as cc ON (n.rowid = cc.element_id)';
73 $sql .=
" WHERE cc.fk_socpeople = ".((int) $object->id);
74 $sql .=
" AND cc.fk_c_type_contact IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_type_contact WHERE element='project' AND source='external')";
75 $sql .=
" AND n.entity IN (".getEntity(
'project').
")";
77 $resql = $db->query($sql);
79 $obj = $db->fetch_object($resql);
80 $nbProject = $obj->nb;
86 $head[$tab][0] = DOL_URL_ROOT.
'/contact/project.php?id='.$object->id;
87 $head[$tab][1] = $langs->trans(
"Projects");
89 $head[$tab][1] .=
'<span class="badge marginleftonlyshort">'.$nbProject.
'</span>';
91 $head[$tab][2] =
'project';
96 if (isModEnabled(
'commande') || isModEnabled(
"propal") || isModEnabled(
'facture') || isModEnabled(
'ficheinter') || isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
97 $head[$tab][0] = DOL_URL_ROOT.
'/contact/consumption.php?id='.$object->id;
98 $head[$tab][1] = $langs->trans(
"Referers");
99 $head[$tab][2] =
'consumption';
111 $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1);
112 $head[$tab][0] = DOL_URL_ROOT.
'/contact/note.php?id='.$object->id;
113 $head[$tab][1] = $langs->trans(
"Note");
115 $head[$tab][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
117 $head[$tab][2] =
'note';
121 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
122 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
124 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
125 $nbLinks =
Link::count($db, $object->element, $object->id);
126 $head[$tab][0] = DOL_URL_ROOT.
'/contact/document.php?id='.$object->id;
127 $head[$tab][1] = $langs->trans(
"Documents");
128 if (($nbFiles + $nbLinks) > 0) {
129 $head[$tab][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
131 $head[$tab][2] =
'documents';
135 $head[$tab][0] = DOL_URL_ROOT.
'/contact/agenda.php?id='.$object->id;
136 $head[$tab][1] = $langs->trans(
"Events");
137 if (isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
138 $head[$tab][1] .=
'/';
139 $head[$tab][1] .= $langs->trans(
"Agenda");
141 $head[$tab][2] =
'agenda';
176 if (isModEnabled(
'project') && $user->hasRight(
'projet',
'lire')) {
177 $langs->load(
"projects");
180 if (isModEnabled(
'project') && $user->hasRight(
'projet',
'creer') && empty($nocreatelink)) {
181 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'AddProject'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/projet/card.php?socid='.$object->id.
'&action=create&backtopage='.urlencode($backtopage));
185 print
load_fiche_titre($langs->trans(
"ProjectsHavingThisContact"), $newcardbutton.$morehtmlright,
'');
186 print
'<div class="div-table-responsive">';
187 print
"\n".
'<table class="noborder" width=100%>';
189 $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';
190 $sql .=
', cls.code as opp_status_code, ctc.libelle as type_label';
191 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as p';
192 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_lead_status as cls on p.fk_opp_status = cls.rowid';
193 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'element_contact as cc ON (p.rowid = cc.element_id)';
194 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
195 $sql .=
" WHERE cc.fk_socpeople = ".((int) $object->id);
196 $sql .=
" AND ctc.element='project' AND ctc.source='external'";
197 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
198 $sql .=
" ORDER BY p.dateo DESC";
200 $result = $db->query($sql);
202 $num = $db->num_rows($result);
204 print
'<tr class="liste_titre">';
205 print
'<td>'.$langs->trans(
"Ref").
'</td>';
206 print
'<td>'.$langs->trans(
"Name").
'</td>';
207 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
208 print
'<td class="center">'.$langs->trans(
"DateStart").
'</td>';
209 print
'<td class="center">'.$langs->trans(
"DateEnd").
'</td>';
210 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
211 print
'<td class="center">'.$langs->trans(
"OpportunityStatusShort").
'</td>';
212 print
'<td class="right">'.$langs->trans(
"OpportunityProbabilityShort").
'</td>';
213 print
'<td class="right">'.$langs->trans(
"Status").
'</td>';
217 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
219 $projecttmp =
new Project($db);
224 $obj = $db->fetch_object($result);
225 $projecttmp->fetch($obj->id);
228 $userAccess = $projecttmp->restrictedProjectArea($user);
230 if ($user->hasRight(
'projet',
'lire') && $userAccess > 0) {
231 print
'<tr class="oddeven">';
235 print $projecttmp->getNomUrl(1);
239 print
'<td>'.dol_escape_htmltag($obj->title).
'</td>';
240 print
'<td>'.dol_escape_htmltag($obj->type_label).
'</td>';
242 print
'<td class="center">'.dol_print_date($db->jdate($obj->do),
"day").
'</td>';
244 print
'<td class="center">'.dol_print_date($db->jdate($obj->de),
"day").
'</td>';
246 print
'<td class="right">';
247 if ($obj->opp_status_code) {
248 print
price($obj->opp_amount, 1,
'', 1, -1, -1,
'');
252 print
'<td class="center">';
253 if ($obj->opp_status_code) {
254 print $langs->trans(
"OppStatus".$obj->opp_status_code);
258 print
'<td class="right">';
259 if ($obj->opp_percent) {
260 print
price($obj->opp_percent, 1,
'', 1, 0).
'%';
264 print
'<td class="right">'.$projecttmp->getLibStatut(5).
'</td>';
271 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage projects.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.