36 global $db, $langs,
$conf, $user;
41 $head[$tab][0] = DOL_URL_ROOT.
'/contact/card.php?id='.
$object->id;
42 $head[$tab][1] = $langs->trans(
"Contact");
43 $head[$tab][2] =
'card';
50 $head[$tab][0] = DOL_URL_ROOT.
'/contact/ldap.php?id='.
$object->id;
51 $head[$tab][1] = $langs->trans(
"LDAPCard");
52 $head[$tab][2] =
'ldap';
56 $head[$tab][0] = DOL_URL_ROOT.
'/contact/perso.php?id='.
$object->id;
57 $head[$tab][1] = $langs->trans(
"PersonalInformations");
58 $head[$tab][2] =
'perso';
61 if (isModEnabled(
'project') && $user->hasRight(
'project',
'lire')) {
64 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
65 $cachekey =
'count_projects_contact_'.$object->id;
68 if (!is_null($dataretrieved)) {
69 $nbProject = $dataretrieved;
71 $sql =
'SELECT COUNT(n.rowid) as nb';
72 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as n';
73 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'element_contact as cc ON (n.rowid = cc.element_id)';
74 $sql .=
" WHERE cc.fk_socpeople = ".((int)
$object->id);
75 $sql .=
" AND cc.fk_c_type_contact IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_type_contact WHERE element='project' AND source='external')";
76 $sql .=
" AND n.entity IN (".getEntity(
'project').
")";
78 $resql = $db->query($sql);
80 $obj = $db->fetch_object($resql);
81 $nbProject = $obj->nb;
87 $head[$tab][0] = DOL_URL_ROOT.
'/contact/project.php?id='.
$object->id;
88 $head[$tab][1] = $langs->trans(
"Projects");
90 $head[$tab][1] .=
'<span class="badge marginleftonlyshort">'.$nbProject.
'</span>';
92 $head[$tab][2] =
'project';
97 if (isModEnabled(
'order') || isModEnabled(
"propal") || isModEnabled(
'invoice') || isModEnabled(
'intervention') || isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
98 $head[$tab][0] = DOL_URL_ROOT.
'/contact/consumption.php?id='.
$object->id;
99 $head[$tab][1] = $langs->trans(
"Referers");
100 $head[$tab][2] =
'consumption';
112 $nbNote = (empty(
$object->note_private) ? 0 : 1) + (empty(
$object->note_public) ? 0 : 1);
113 $head[$tab][0] = DOL_URL_ROOT.
'/contact/note.php?id='.
$object->id;
114 $head[$tab][1] = $langs->trans(
"Note");
116 $head[$tab][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
118 $head[$tab][2] =
'note';
122 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
123 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
125 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
127 $head[$tab][0] = DOL_URL_ROOT.
'/contact/document.php?id='.
$object->id;
128 $head[$tab][1] = $langs->trans(
"Documents");
129 if (($nbFiles + $nbLinks) > 0) {
130 $head[$tab][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
132 $head[$tab][2] =
'documents';
136 $head[$tab][0] = DOL_URL_ROOT.
'/contact/agenda.php?id='.
$object->id;
137 $head[$tab][1] = $langs->trans(
"Events");
138 if (isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
139 $head[$tab][1] .=
'/';
140 $head[$tab][1] .= $langs->trans(
"Agenda");
142 $head[$tab][2] =
'agenda';
177 if (isModEnabled(
'project') && $user->hasRight(
'projet',
'lire')) {
178 $langs->load(
"projects");
181 if (isModEnabled(
'project') && $user->hasRight(
'projet',
'creer') && empty($nocreatelink)) {
182 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'AddProject'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/projet/card.php?socid='.
$object->id.
'&action=create&backtopage='.urlencode($backtopage));
186 print
load_fiche_titre($langs->trans(
"ProjectsHavingThisContact"), $newcardbutton.$morehtmlright,
'');
187 print
'<div class="div-table-responsive">';
188 print
"\n".
'<table class="noborder" width=100%>';
190 $sql =
'SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_modification, p.budget_amount';
191 $sql .=
', cls.code as opp_status_code, ctc.libelle as type_label';
192 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as p';
193 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_lead_status as cls on p.fk_opp_status = cls.rowid';
194 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'element_contact as cc ON (p.rowid = cc.element_id)';
195 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
196 $sql .=
" WHERE cc.fk_socpeople = ".((int)
$object->id);
197 $sql .=
" AND ctc.element='project' AND ctc.source='external'";
198 $sql .=
" AND p.entity IN (".getEntity(
'project').
")";
199 $sql .=
" ORDER BY p.dateo DESC";
201 $result = $db->query($sql);
203 $num = $db->num_rows($result);
205 print
'<tr class="liste_titre">';
206 print
'<td>'.$langs->trans(
"Ref").
'</td>';
207 print
'<td>'.$langs->trans(
"Name").
'</td>';
208 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
209 print
'<td class="center">'.$langs->trans(
"DateStart").
'</td>';
210 print
'<td class="center">'.$langs->trans(
"DateEnd").
'</td>';
211 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
212 print
'<td class="center">'.$langs->trans(
"OpportunityStatusShort").
'</td>';
213 print
'<td class="right">'.$langs->trans(
"OpportunityProbabilityShort").
'</td>';
214 print
'<td class="right">'.$langs->trans(
"Status").
'</td>';
218 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
220 $projecttmp =
new Project($db);
225 $obj = $db->fetch_object($result);
226 $projecttmp->fetch($obj->id);
229 $userAccess = $projecttmp->restrictedProjectArea($user);
231 if ($user->hasRight(
'projet',
'lire') && $userAccess > 0) {
232 print
'<tr class="oddeven">';
236 print $projecttmp->getNomUrl(1);
240 print
'<td>'.dol_escape_htmltag($obj->title).
'</td>';
241 print
'<td>'.dol_escape_htmltag($obj->type_label).
'</td>';
243 print
'<td class="center">'.dol_print_date($db->jdate($obj->do),
"day").
'</td>';
245 print
'<td class="center">'.dol_print_date($db->jdate($obj->de),
"day").
'</td>';
247 print
'<td class="right">';
248 if ($obj->opp_status_code) {
249 print
price($obj->opp_amount, 1,
'', 1, -1, -1,
'');
253 print
'<td class="center">';
254 if ($obj->opp_status_code) {
255 print $langs->trans(
"OppStatus".$obj->opp_status_code);
259 print
'<td class="right">';
260 if ($obj->opp_percent) {
261 print
price($obj->opp_percent, 1,
'', 1, 0).
'%';
265 print
'<td class="right">'.$projecttmp->getLibStatut(5).
'</td>';
272 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage projects.
dol_dir_list($utf8_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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.