diff --git a/htdocs/contact/project.php b/htdocs/contact/project.php
index 2a5888f02f5..b05709f019a 100644
--- a/htdocs/contact/project.php
+++ b/htdocs/contact/project.php
@@ -40,8 +40,8 @@ $hookmanager->initHooks(array('projectcontact'));
$parameters = array('id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
/*
@@ -50,67 +50,66 @@ if($reshook < 0) {
$form = new Form($db);
-if($id) {
- require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
+if ($id) {
+ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
- $object = new Contact($db);
+ $object = new Contact($db);
- $result = $object->fetch($id);
- if(empty($object->thirdparty)) {
- $object->fetch_thirdparty();
- }
- $socid = $object->thirdparty->id;
- $title = $langs->trans("Projects");
- if(! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
- $title = $object->name." - ".$title;
- }
- llxHeader('', $title);
+ $result = $object->fetch($id);
+ if (empty($object->thirdparty)) {
+ $object->fetch_thirdparty();
+ }
+ $socid = $object->thirdparty->id;
+ $title = $langs->trans("Projects");
+ if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name." - ".$title;
+ }
+ llxHeader('', $title);
- if(! empty($conf->notification->enabled)) {
- $langs->load("mails");
- }
- $head = contact_prepare_head($object);
+ if (! empty($conf->notification->enabled)) {
+ $langs->load("mails");
+ }
+ $head = contact_prepare_head($object);
- print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
+ print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
- $morehtmlref = '
';
- if(empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
- $object->thirdparty->fetch($socid);
- // Thirdparty
- $morehtmlref .= $langs->trans('ThirdParty').' : ';
- if($object->thirdparty->id > 0) {
- $morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
- }
- else {
- $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
- }
- }
- $morehtmlref .= '
';
+ $morehtmlref = '';
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
+ $object->thirdparty->fetch($socid);
+ // Thirdparty
+ $morehtmlref .= $langs->trans('ThirdParty').' : ';
+ if ($object->thirdparty->id > 0) {
+ $morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
+ } else {
+ $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
+ }
+ $morehtmlref .= '
';
- dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
+ dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
- print '';
+ print '
';
- print '
';
- print '
';
+ print '';
+ print '';
-// Civility
- print '| '.$langs->trans("UserTitle").' | ';
- print $object->getCivilityLabel();
- print ' |
';
+ // Civility
+ print '| '.$langs->trans("UserTitle").' | ';
+ print $object->getCivilityLabel();
+ print ' |
';
- print '
';
+ print '
';
- print '
';
+ print '
';
- print dol_get_fiche_end();
- print '
';
+ print dol_get_fiche_end();
+ print '
';
- // Projects list
- $result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
+ // Projects list
+ $result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
}
// End of page
diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php
index a97a59a3da3..2e512fa7182 100644
--- a/htdocs/core/lib/contact.lib.php
+++ b/htdocs/core/lib/contact.lib.php
@@ -57,7 +57,7 @@ function contact_prepare_head(Contact $object)
$head[$tab][2] = 'perso';
$tab++;
- if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
+ if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
$nbProject = 0;
// Enable caching of thirdrparty count projects
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
@@ -67,12 +67,12 @@ function contact_prepare_head(Contact $object)
if (!is_null($dataretrieved)) {
$nbProject = $dataretrieved;
} else {
- $sql = 'SELECT COUNT(n.rowid) as nb';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as n';
- $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (n.rowid = cc.element_id)';
- $sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
- $sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE element="project" AND source="external")';
- $sql .= ' AND n.entity IN ('.getEntity('project').')';
+ $sql = 'SELECT COUNT(n.rowid) as nb';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as n';
+ $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (n.rowid = cc.element_id)';
+ $sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
+ $sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE element="project" AND source="external")';
+ $sql .= ' AND n.entity IN ('.getEntity('project').')';
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
@@ -184,15 +184,15 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
print "\n".'';
$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';
- $sql .= ', cls.code as opp_status_code, ctc.libelle';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls on p.fk_opp_status = cls.rowid';
- $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)';
- $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
- $sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
- $sql .= ' AND ctc.element="project" AND ctc.source="external"';
- $sql .= ' AND p.entity IN ('.getEntity('project').')';
- $sql .= ' ORDER BY p.dateo DESC';
+ $sql .= ', cls.code as opp_status_code, ctc.libelle';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls on p.fk_opp_status = cls.rowid';
+ $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)';
+ $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
+ $sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
+ $sql .= ' AND ctc.element="project" AND ctc.source="external"';
+ $sql .= ' AND p.entity IN ('.getEntity('project').')';
+ $sql .= ' ORDER BY p.dateo DESC';
$result = $db->query($sql);
if ($result) {
@@ -201,7 +201,6 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
print '';
print '| '.$langs->trans("Ref").' | ';
print ''.$langs->trans("Name").' | ';
- print ''.$langs->trans("ContactType").' | ';
print ''.$langs->trans("DateStart").' | ';
print ''.$langs->trans("DateEnd").' | ';
print ''.$langs->trans("OpportunityAmountShort").' | ';
@@ -234,7 +233,6 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
// Label
print ''.$obj->title.' | ';
- print ''.$obj->libelle.' | ';
// Date start
print ''.dol_print_date($db->jdate($obj->do), "day").' | ';
// Date end
@@ -278,4 +276,4 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
}
return $i;
-}
\ No newline at end of file
+}