diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 0447129381c..13d1fe73b8d 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -98,6 +98,13 @@ if ($id > 0 || ! empty($ref))
$ret=$object->fetch($id, $ref);
$object->fetch_thirdparty();
}
+else
+{
+ $langs->load("errors");
+ setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
+ Header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php');
+ exit;
+}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index c2b2a74f66c..8bea9fa2471 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -47,6 +47,20 @@ $result = restrictedArea($user, 'propal', $id);
$object = new Propal($db);
+// Load object
+if ($id > 0 || ! empty($ref))
+{
+ $ret=$object->fetch($id, $ref);
+ $object->fetch_thirdparty();
+}
+else
+{
+ $langs->load("errors");
+ setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
+ Header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php');
+ exit;
+}
+
/*
* Ajout d'un nouveau contact
@@ -54,9 +68,7 @@ $object = new Propal($db);
if ($action == 'addcontact' && $user->rights->propale->creer)
{
- $result = $object->fetch($id);
-
- if ($result > 0 && $id > 0)
+ if ($object->id > 0)
{
$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
@@ -72,11 +84,11 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
- $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
+ setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
}
else
{
- $mesg = ''.$object->error.'
';
+ setEventMessage($object->error, 'errors');
}
}
}
@@ -84,20 +96,15 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
// Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
- if ($object->fetch($id) > 0)
+ if ($object->id > 0)
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
- else
- {
- dol_print_error($db);
- }
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
- $object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
@@ -113,7 +120,6 @@ 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);
}
@@ -129,94 +135,75 @@ $form = new Form($db);
$formcompany= new FormCompany($db);
$formother = new FormOther($db);
-
-/* *************************************************************************** */
-/* */
-/* Mode vue et edition */
-/* */
-/* *************************************************************************** */
-dol_htmloutput_mesg($mesg);
-
-if ($id > 0 || ! empty($ref))
-{
- if ($object->fetch($id,$ref) > 0)
- {
- $soc = new Societe($db);
- $soc->fetch($object->socid);
-
- $head = propal_prepare_head($object);
- dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
-
- /*
- * Propal synthese pour rappel
- */
- print '';
-
- $linkback=''.$langs->trans("BackToList").'';
-
- // Ref
- print '| '.$langs->trans('Ref').' | ';
- print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
- print ' |
';
-
- // Ref client
- print '';
- print '| ';
- print $langs->trans('RefCustomer').' | ';
- print ' | ';
- print ' ';
- print ' | ';
- print $object->ref_client;
- print ' | ';
- print '
';
-
- // Customer
- if (is_null($object->client)) $object->fetch_thirdparty();
- print "| ".$langs->trans("Company")." | ";
- print ''.$object->client->getNomUrl(1).' |
';
-
- // Delivery address
- if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
- {
- print '| ';
- print '';
- print ' | ';
-
- 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 ' |
';
- }
-
- print "
";
-
- print '';
-
- print '
';
-
- // Contacts lines (modules that overwrite templates must declare this into descriptor)
- $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
- foreach($dirtpls as $reldir)
- {
- $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
- if ($res) break;
- }
-
- }
- else
- {
- print "ErrorRecordNotFound";
- }
+if ($object->id > 0)
+{
+ $head = propal_prepare_head($object);
+ dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
+
+ /*
+ * Propal synthese pour rappel
+ */
+ print '';
+
+ $linkback=''.$langs->trans("BackToList").'';
+
+ // Ref
+ print '| '.$langs->trans('Ref').' | ';
+ print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
+ print ' |
';
+
+ // Ref client
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer').' | ';
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print $object->ref_client;
+ print ' | ';
+ print '
';
+
+ // Customer
+ print "| ".$langs->trans("Company")." | ";
+ print ''.$object->client->getNomUrl(1).' |
';
+
+ // Delivery address
+ if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
+ {
+ print '| ';
+ print '';
+ print ' | ';
+
+ 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 ' |
';
+ }
+
+ print "
";
+
+ print '';
+
+ print '
';
+
+ // Contacts lines (modules that overwrite templates must declare this into descriptor)
+ $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
+ foreach($dirtpls as $reldir)
+ {
+ $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
+ if ($res) break;
+ }
}
llxFooter();