2
0
forked from Wavyzz/dolibarr

Fix: use better method for avoid warnings

This commit is contained in:
Regis Houssin
2012-08-25 19:08:06 +02:00
parent f322ec50ed
commit 4dd8119a9e
2 changed files with 94 additions and 100 deletions

View File

@@ -98,6 +98,13 @@ if ($id > 0 || ! empty($ref))
$ret=$object->fetch($id, $ref); $ret=$object->fetch($id, $ref);
$object->fetch_thirdparty(); $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 // 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'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';

View File

@@ -47,6 +47,20 @@ $result = restrictedArea($user, 'propal', $id);
$object = new Propal($db); $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 * Ajout d'un nouveau contact
@@ -54,9 +68,7 @@ $object = new Propal($db);
if ($action == 'addcontact' && $user->rights->propale->creer) if ($action == 'addcontact' && $user->rights->propale->creer)
{ {
$result = $object->fetch($id); if ($object->id > 0)
if ($result > 0 && $id > 0)
{ {
$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); $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') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
} }
else else
{ {
$mesg = '<div class="error">'.$object->error.'</div>'; setEventMessage($object->error, 'errors');
} }
} }
} }
@@ -84,20 +96,15 @@ if ($action == 'addcontact' && $user->rights->propale->creer)
// Bascule du statut d'un contact // Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer) else if ($action == 'swapstatut' && $user->rights->propale->creer)
{ {
if ($object->fetch($id) > 0) if ($object->id > 0)
{ {
$result=$object->swapContactStatus(GETPOST('ligne')); $result=$object->swapContactStatus(GETPOST('ligne'));
} }
else
{
dol_print_error($db);
}
} }
// Efface un contact // Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer) else if ($action == 'deletecontact' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0)
@@ -113,7 +120,6 @@ else if ($action == 'deletecontact' && $user->rights->propale->creer)
else if ($action == 'setaddress' && $user->rights->propale->creer) else if ($action == 'setaddress' && $user->rights->propale->creer)
{ {
$object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']); $result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@@ -129,94 +135,75 @@ $form = new Form($db);
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$formother = new FormOther($db); $formother = new FormOther($db);
if ($object->id > 0)
/* *************************************************************************** */ {
/* */ $head = propal_prepare_head($object);
/* Mode vue et edition */ dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
/* */
/* *************************************************************************** */ /*
dol_htmloutput_mesg($mesg); * Propal synthese pour rappel
*/
if ($id > 0 || ! empty($ref)) print '<table class="border" width="100%">';
{
if ($object->fetch($id,$ref) > 0) $linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
{
$soc = new Societe($db); // Ref
$soc->fetch($object->socid); print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
$head = propal_prepare_head($object); print '</td></tr>';
dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
// Ref client
/* print '<tr><td>';
* Propal synthese pour rappel print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
*/ print $langs->trans('RefCustomer').'</td><td align="left">';
print '<table class="border" width="100%">'; print '</td>';
print '</tr></table>';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; print '</td><td colspan="3">';
print $object->ref_client;
// Ref print '</td>';
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'; print '</tr>';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>'; // Customer
print "<tr><td>".$langs->trans("Company")."</td>";
// Ref client print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; // Delivery address
print $langs->trans('RefCustomer').'</td><td align="left">'; if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
print '</td>'; {
print '</tr></table>'; print '<tr><td>';
print '</td><td colspan="3">'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $object->ref_client; print $langs->trans('DeliveryAddress');
print '</td>'; print '</td>';
print '</tr>';
if ($action != 'editdelivery_address' && ! empty($object->brouillon))
// Customer 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>';
if (is_null($object->client)) $object->fetch_thirdparty(); print '</tr></table>';
print "<tr><td>".$langs->trans("Company")."</td>"; print '</td><td colspan="3">';
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
if ($action == 'editdelivery_address')
// Delivery address {
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
{ }
print '<tr><td>'; else
print '<table class="nobordernopadding" width="100%"><tr><td>'; {
print $langs->trans('DeliveryAddress'); $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
print '</td>'; }
print '</td></tr>';
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">'; print "</table>";
if ($action == 'editdelivery_address') print '</div>';
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); print '<br>';
}
else // Contacts lines (modules that overwrite templates must declare this into descriptor)
{ $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id); foreach($dirtpls as $reldir)
} {
print '</td></tr>'; $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
} if ($res) break;
}
print "</table>";
print '</div>';
print '<br>';
// 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";
}
} }
llxFooter(); llxFooter();