From a8d12a7c482c2dab5f1a89f53727ecfa301e81a4 Mon Sep 17 00:00:00 2001
From: Grand Philippe <contact@atoo-net.com>
Date: Fri, 27 Apr 2012 11:13:59 +0200
Subject: [PATCH]     to use personal contacts.tpl within personal theme

---
 htdocs/comm/propal/contact.php | 64 +++++++++++++++++++---------------
 1 file changed, 36 insertions(+), 28 deletions(-)

diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index 46ce0ac7afe..b9406d6012b 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -2,6 +2,7 @@
 /* Copyright (C) 2005      Patrick Rouillon     <patrick@rouillon.net>
  * Copyright (C) 2005-2009 Destailleur Laurent  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012 Regis Houssin		<regis@dolibarr.fr>
+ * Copyright (C) 2011-2012 Philippe Grand       <philippe.grand@atoo-net.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -57,7 +58,7 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
 
     if ($result > 0 && $id > 0)
     {
-    	$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
+    	$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
   		$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
     }
 
@@ -110,11 +111,11 @@ else if ($action == 'deletecontact' && $user->rights->propale->creer)
 	}
 }
 
-else if ($action == 'setaddress' && $user->rights->propale->creer)
-{
-	$object->fetch($id);
-	$result=$object->setDeliveryAddress($_POST['fk_address']);
-	if ($result < 0) dol_print_error($db,$object->error);
+else if ($action == 'setaddress' && $user->rights->propale->creer)
+{
+	$object->fetch($id);
+	$result=$object->setDeliveryAddress($_POST['fk_address']);
+	if ($result < 0) dol_print_error($db,$object->error);
 }
 
 
@@ -174,27 +175,27 @@ if ($id > 0 || ! empty($ref))
 		print "<tr><td>".$langs->trans("Company")."</td>";
 		print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
 		
-		// Delivery address
-		if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
-		{
-			print '<tr><td>';
-			print '<table class="nobordernopadding" width="100%"><tr><td>';
-			print $langs->trans('DeliveryAddress');
-			print '</td>';
-		
-			if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
-			print '</tr></table>';
-			print '</td><td colspan="3">';
-		
-			if ($action == 'editdelivery_address')
-			{
-				$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
-			}
-			else
-			{
-				$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
-			}
-			print '</td></tr>';
+		// Delivery address
+		if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
+		{
+			print '<tr><td>';
+			print '<table class="nobordernopadding" width="100%"><tr><td>';
+			print $langs->trans('DeliveryAddress');
+			print '</td>';
+		
+			if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
+			print '</tr></table>';
+			print '</td><td colspan="3">';
+		
+			if ($action == 'editdelivery_address')
+			{
+				$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
+			}
+			else
+			{
+				$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
+			}
+			print '</td></tr>';
 		}
 
 		print "</table>";
@@ -204,7 +205,14 @@ if ($id > 0 || ! empty($ref))
 		print '<br>';
 		
 		// Contacts lines
-		include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
+		if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
+		{
+			include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php");
+		}
+		else
+		{
+			include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
+		}
 		
 	}
 	else
-- 
GitLab