2005-09-03 02:09:55 +02:00
|
|
|
<?php
|
2012-03-18 11:13:01 +01:00
|
|
|
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
|
|
|
|
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
|
2012-12-30 15:11:07 +01:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
2005-09-03 02:09:55 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-09-03 02:09:55 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-01 01:45:11 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-09-03 02:09:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2011-08-27 17:14:31 +02:00
|
|
|
* \file htdocs/contrat/contact.php
|
|
|
|
|
* \ingroup contrat
|
|
|
|
|
* \brief Onglet de gestion des contacts des contrats
|
|
|
|
|
*/
|
2005-09-03 02:09:55 +02:00
|
|
|
|
2010-03-27 15:50:05 +01:00
|
|
|
require ("../main.inc.php");
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
2005-09-03 02:09:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
$langs->load("contracts");
|
|
|
|
|
$langs->load("companies");
|
|
|
|
|
|
2012-03-18 11:13:01 +01:00
|
|
|
$action=GETPOST('action','alpha');
|
|
|
|
|
$confirm=GETPOST('confirm','alpha');
|
|
|
|
|
$socid = GETPOST('socid','int');
|
|
|
|
|
$id = GETPOST('id','int');
|
|
|
|
|
$ref=GETPOST('ref','alpha');
|
2006-03-13 14:29:27 +01:00
|
|
|
|
2008-02-24 14:18:40 +01:00
|
|
|
// Security check
|
2008-02-25 21:03:21 +01:00
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
2012-03-18 11:13:01 +01:00
|
|
|
$result=restrictedArea($user,'contrat',$id);
|
|
|
|
|
|
|
|
|
|
$object = new Contrat($db);
|
2008-02-24 14:18:40 +01:00
|
|
|
|
2006-03-13 14:29:27 +01:00
|
|
|
|
2005-09-03 02:09:55 +02:00
|
|
|
/*
|
|
|
|
|
* Ajout d'un nouveau contact
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($action == 'addcontact' && $user->rights->contrat->creer)
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
$result = $object->fetch($id);
|
2005-09-03 02:09:55 +02:00
|
|
|
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($result > 0 && $id > 0)
|
2005-09-17 18:58:58 +02:00
|
|
|
{
|
2012-03-18 14:06:55 +01:00
|
|
|
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
|
2012-12-29 13:12:45 +01:00
|
|
|
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
|
2005-09-17 18:58:58 +02:00
|
|
|
}
|
2009-02-16 23:37:30 +01:00
|
|
|
|
2005-09-03 02:09:55 +02:00
|
|
|
if ($result >= 0)
|
|
|
|
|
{
|
2012-08-31 05:58:38 +02:00
|
|
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
2005-09-03 02:09:55 +02:00
|
|
|
exit;
|
2007-10-31 13:55:01 +01:00
|
|
|
}
|
|
|
|
|
else
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
2007-10-31 13:55:01 +01:00
|
|
|
{
|
|
|
|
|
$langs->load("errors");
|
|
|
|
|
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
$mesg = '<div class="error">'.$object->error.'</div>';
|
2007-10-31 13:55:01 +01:00
|
|
|
}
|
2005-09-03 02:09:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
2005-09-17 18:58:58 +02:00
|
|
|
|
2005-09-03 02:09:55 +02:00
|
|
|
// bascule du statut d'un contact
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($action == 'swapstatut' && $user->rights->contrat->creer)
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($object->fetch($id))
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
$result=$object->swapContactStatus(GETPOST('ligne'));
|
2007-05-04 23:19:15 +02:00
|
|
|
}
|
|
|
|
|
else
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
dol_print_error($db,$object->error);
|
2005-09-03 02:09:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-17 18:58:58 +02:00
|
|
|
// Efface un contact
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($action == 'deletecontact' && $user->rights->contrat->creer)
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
$object->fetch($id);
|
|
|
|
|
$result = $object->delete_contact($_GET["lineid"]);
|
2005-09-03 02:09:55 +02:00
|
|
|
|
|
|
|
|
if ($result >= 0)
|
|
|
|
|
{
|
2012-08-31 05:58:38 +02:00
|
|
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
2005-09-03 02:09:55 +02:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-02-18 13:26:55 +01:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
2005-09-03 02:09:55 +02:00
|
|
|
|
|
|
|
|
llxHeader('', $langs->trans("ContractCard"), "Contrat");
|
|
|
|
|
|
2011-11-08 10:18:45 +01:00
|
|
|
$form = new Form($db);
|
2009-02-18 13:26:55 +01:00
|
|
|
$formcompany= new FormCompany($db);
|
2007-05-04 23:19:15 +02:00
|
|
|
$contactstatic=new Contact($db);
|
2011-02-09 19:27:56 +01:00
|
|
|
$userstatic=new User($db);
|
2007-05-04 23:19:15 +02:00
|
|
|
|
2011-08-14 05:13:50 +02:00
|
|
|
dol_htmloutput_mesg($mesg);
|
2005-09-03 02:09:55 +02:00
|
|
|
|
|
|
|
|
/* *************************************************************************** */
|
|
|
|
|
/* */
|
|
|
|
|
/* Mode vue et edition */
|
|
|
|
|
/* */
|
|
|
|
|
/* *************************************************************************** */
|
2012-03-18 11:13:01 +01:00
|
|
|
|
|
|
|
|
if ($id > 0 || ! empty($ref))
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
if ($object->fetch($id, $ref) > 0)
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2012-03-18 11:13:01 +01:00
|
|
|
dol_htmloutput_mesg($mesg);
|
2005-09-03 02:09:55 +02:00
|
|
|
|
2012-03-18 11:13:01 +01:00
|
|
|
$object->fetch_thirdparty();
|
2006-06-22 02:35:29 +02:00
|
|
|
|
2012-03-18 11:13:01 +01:00
|
|
|
$head = contract_prepare_head($object);
|
2009-02-16 23:37:30 +01:00
|
|
|
|
2006-02-17 00:25:41 +01:00
|
|
|
$hselected=1;
|
2005-09-03 02:09:55 +02:00
|
|
|
|
2009-08-05 20:22:40 +02:00
|
|
|
dol_fiche_head($head, $hselected, $langs->trans("Contract"), 0, 'contract');
|
2005-09-03 02:09:55 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Contrat
|
|
|
|
|
*/
|
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
2012-07-28 20:59:57 +02:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/liste.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
|
|
|
|
|
2005-09-03 02:09:55 +02:00
|
|
|
// Reference du contrat
|
2005-09-17 04:09:36 +02:00
|
|
|
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
2012-07-28 20:59:57 +02:00
|
|
|
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
|
2005-09-03 02:09:55 +02:00
|
|
|
print "</td></tr>";
|
|
|
|
|
|
|
|
|
|
// Customer
|
|
|
|
|
print "<tr><td>".$langs->trans("Customer")."</td>";
|
2012-03-18 11:13:01 +01:00
|
|
|
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
2006-06-22 02:35:29 +02:00
|
|
|
|
|
|
|
|
// Ligne info remises tiers
|
|
|
|
|
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
2013-06-16 21:31:21 +02:00
|
|
|
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
|
2006-06-22 02:35:29 +02:00
|
|
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
2012-03-18 11:13:01 +01:00
|
|
|
$absolute_discount=$object->thirdparty->getAvailableDiscounts();
|
2006-06-22 02:35:29 +02:00
|
|
|
print '. ';
|
2011-11-23 14:55:36 +01:00
|
|
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency));
|
2006-06-22 02:35:29 +02:00
|
|
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
|
|
|
|
print '.';
|
|
|
|
|
print '</td></tr>';
|
2005-09-03 02:09:55 +02:00
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
2005-09-17 04:06:06 +02:00
|
|
|
print '</div>';
|
2013-06-16 21:31:21 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
print '<br>';
|
2013-06-16 21:31:21 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// Contacts lines
|
2012-08-23 02:04:35 +02:00
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php';
|
2005-09-03 02:09:55 +02:00
|
|
|
|
2005-09-17 18:58:58 +02:00
|
|
|
}
|
|
|
|
|
else
|
2005-09-03 02:09:55 +02:00
|
|
|
{
|
2009-02-18 13:26:55 +01:00
|
|
|
print "ErrorRecordNotFound";
|
2005-09-03 02:09:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-03-18 11:13:01 +01:00
|
|
|
$db->close();
|
2005-09-03 02:09:55 +02:00
|
|
|
?>
|