*
* 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
@@ -32,56 +33,56 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$langs->load("bills");
$langs->load("companies");
-$facid = GETPOST('facid');
-$id = GETPOST('facid');
-$ref= GETPOST('ref');
+$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
+$ref = GETPOST('ref');
+$socid=GETPOST('socid','int');
+$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'facture', $facid);
+$result = restrictedArea($user, 'facture', $id);
+
+$object = new Facture($db);
/*
* Ajout d'un nouveau contact
*/
-if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer)
+if ($action == 'addcontact' && $user->rights->facture->creer)
{
- $result = 0;
- $facture = new Facture($db);
- $result = $facture->fetch($facid);
+ $result = $object->fetch($id);
- if ($result > 0 && $facid > 0)
+ if ($result > 0 && $id > 0)
{
- $result = $facture->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
+ $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
- Header("Location: contact.php?facid=".$facture->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
- if ($facture->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
}
else
{
- $mesg = ''.$facture->error.'
';
+ $mesg = ''.$object->error.'
';
}
}
}
// bascule du statut d'un contact
-if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer)
+else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
- $facture = new Facture($db);
- if ($facture->fetch($facid))
+ if ($object->fetch($id))
{
- $result=$facture->swapContactStatus(GETPOST('ligne'));
+ $result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
@@ -90,15 +91,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer)
}
// Efface un contact
-if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer)
+else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
- $facture = new Facture($db);
- $facture->fetch($facid);
- $result = $facture->delete_contact($_GET["lineid"]);
+ $object->fetch($id);
+ $result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
- Header("Location: contact.php?facid=".$facture->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
@@ -128,12 +128,11 @@ dol_htmloutput_mesg($mesg);
if ($id > 0 || ! empty($ref))
{
- $facture = new Facture($db);
- if ($facture->fetch($id, $ref) > 0)
+ if ($object->fetch($id, $ref) > 0)
{
- $facture->fetch_thirdparty();
+ $object->fetch_thirdparty();
- $head = facture_prepare_head($facture);
+ $head = facture_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), 0, 'bill');
@@ -147,7 +146,7 @@ if ($id > 0 || ! empty($ref))
print '';
$morehtmlref='';
$discount=new DiscountAbsolute($db);
- $result=$discount->fetch(0,$facture->id);
+ $result=$discount->fetch(0,$object->id);
if ($result > 0)
{
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
@@ -156,198 +155,20 @@ if ($id > 0 || ! empty($ref))
{
dol_print_error('',$discount->error);
}
- print $form->showrefnav($facture,'ref','',1,'facnumber','ref',$morehtmlref);
+ print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print ' ';
// Customer
print "".$langs->trans("Company")." ";
- print ''.$facture->client->getNomUrl(1,'compta').' ';
+ print ''.$object->client->getNomUrl(1,'compta').' ';
print "";
print '';
-
- /*
- * Lignes de contacts
- */
- echo '';
-
- /*
- * Ajouter une ligne de contact
- * Non affiche en mode modification de ligne
- */
- if ($_GET["action"] != 'editline' && $user->rights->facture->creer)
- {
- print '';
- print ''.$langs->trans("Source").' ';
- print ''.$langs->trans("Company").' ';
- print ''.$langs->trans("Contacts").' ';
- print ''.$langs->trans("ContactType").' ';
- print ' ';
- print " \n";
-
- $var = false;
-
- print '';
-
- print '";
-
- print ' ';
- }
-
- // List of linked contacts
- print '';
- print ''.$langs->trans("Source").' ';
- print ''.$langs->trans("Company").' ';
- print ''.$langs->trans("Contacts").' ';
- print ''.$langs->trans("ContactType").' ';
- print ''.$langs->trans("Status").' ';
- print ' ';
- print " \n";
-
- $companystatic = new Societe($db);
- $var = true;
-
- foreach(array('internal','external') as $source)
- {
- $tab = $facture->liste_contact(-1,$source);
- $num=count($tab);
-
- $i = 0;
- while ($i < $num)
- {
- $var = !$var;
-
- print '';
-
- // Source
- print '';
- if ($tab[$i]['source']=='internal') print $langs->trans("User");
- if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
- print ' ';
-
- // Third party
- print '';
- if ($tab[$i]['socid'] > 0)
- {
- $companystatic->fetch($tab[$i]['socid']);
- print $companystatic->getNomUrl(1);
- }
- if ($tab[$i]['socid'] < 0)
- {
- print $mysoc->name;
- }
- if (! $tab[$i]['socid'])
- {
- print ' ';
- }
- print ' ';
-
- // Contact
- print '';
- if ($tab[$i]['source']=='internal')
- {
- $userstatic->id=$tab[$i]['id'];
- $userstatic->lastname=$tab[$i]['lastname'];
- $userstatic->firstname=$tab[$i]['firstname'];
- print $userstatic->getNomUrl(1);
- }
- if ($tab[$i]['source']=='external')
- {
- $contactstatic->id=$tab[$i]['id'];
- $contactstatic->lastname=$tab[$i]['lastname'];
- $contactstatic->firstname=$tab[$i]['firstname'];
- print $contactstatic->getNomUrl(1);
- }
- print ' ';
-
- // Type of contact
- print ''.$tab[$i]['libelle'].' ';
-
- // Status
- print '';
- // Activate/Unactivate contact
- if ($facture->statut >= 0) print '';
- print $contactstatic->LibStatut($tab[$i]['status'],3);
- if ($facture->statut >= 0) print ' ';
- print ' ';
-
- // Icon update et delete
- print '';
- if ($user->rights->facture->creer)
- {
- print ' ';
- print '';
- print img_delete();
- print ' ';
- }
- print ' ';
-
- print " \n";
-
- $i ++;
- }
- }
- print "
";
+ print ' ';
+
+ // Contacts lines
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
}
else
{
@@ -356,7 +177,7 @@ if ($id > 0 || ! empty($ref))
}
}
-$db->close();
llxFooter();
+$db->close();
?>
\ No newline at end of file
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index ea22971c1bf..dd05eede948 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -1,6 +1,7 @@
* Copyright (C) 2004-2008 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
*
* 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
@@ -27,64 +28,42 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
-$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
-
-if (!$user->rights->facture->lire)
- accessforbidden();
-
$langs->load("companies");
$langs->load("bills");
+$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
+$ref=GETPOST('ref','alpha');
+$socid=GETPOST('socid','int');
+$action=GETPOST('action','alpha');
+
// Security check
-if ($user->societe_id > 0)
-{
- unset($_GET["action"]);
- $socid = $user->societe_id;
-}
+$socid=0;
+if ($user->societe_id) $socid=$user->societe_id;
+$result=restrictedArea($user,'facture',$id,'');
-
-$fac = new Facture($db);
-$fac->fetch($_GET["facid"]);
+$object = new Facture($db);
+$object->fetch($id);
/******************************************************************************/
/* Actions */
/******************************************************************************/
-if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
+if ($action == 'setnote_public' && $user->rights->facture->creer)
{
- $db->begin();
-
- $res=$fac->update_note_public($_POST["note_public"],$user);
- if ($res < 0)
- {
- $mesg=''.$fac->error.'
';
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
+ $object->fetch($id);
+ $result=$object->update_note_public(GETPOST('note_public','alpha'));
+ if ($result < 0) dol_print_error($db,$object->error);
}
-if ($_POST["action"] == 'update' && $user->rights->facture->creer)
+else if ($action == 'setnote' && $user->rights->facture->creer)
{
- $db->begin();
-
- $res=$fac->update_note($_POST["note"],$user);
- if ($res < 0)
- {
- $mesg=''.$fac->error.'
';
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
+ $object->fetch($id);
+ $result=$object->update_note(GETPOST('note','alpha'));
+ if ($result < 0) dol_print_error($db,$object->error);
}
-
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
@@ -93,28 +72,26 @@ llxHeader();
$form = new Form($db);
-$id = $_GET['facid'];
-$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
- $fac = new Facture($db);
- $fac->fetch($id,$ref);
+ $object = new Facture($db);
+ $object->fetch($id,$ref);
$soc = new Societe($db);
- $soc->fetch($fac->socid);
+ $soc->fetch($object->socid);
- $head = facture_prepare_head($fac);
+ $head = facture_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), 0, 'bill');
print '';
// Ref
- print ''.$langs->trans('Ref').' ';
+ print ''.$langs->trans('Ref').' ';
print '';
$morehtmlref='';
$discount=new DiscountAbsolute($db);
- $result=$discount->fetch(0,$fac->id);
+ $result=$discount->fetch(0,$object->id);
if ($result > 0)
{
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
@@ -123,72 +100,22 @@ if ($id > 0 || ! empty($ref))
{
dol_print_error('',$discount->error);
}
- print $form->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref);
+ print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print ' ';
// Company
print ''.$langs->trans("Company").' ';
print ''.$soc->getNomUrl(1,'compta').' ';
- // Note publique
- print ''.$langs->trans("NotePublic").' : ';
- print '';
- if ($_GET["action"] == 'edit')
- {
- print '';
- }
- else
- {
- print ($fac->note_public?nl2br($fac->note_public):" ");
- }
- print " ";
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
- // Note priv�e
- if (! $user->societe_id)
- {
- print ''.$langs->trans("NotePrivate").' : ';
- print '';
- if ($_GET["action"] == 'edit')
- {
- print '';
- print ' ';
- print ' ';
- print ''.$fac->note." ";
- print ' ';
- print ' ';
- }
- else
- {
- print ($fac->note?nl2br($fac->note):" ");
- }
- print " ";
- }
-
- print "
";
-
-
- /*
- * Actions
- */
- print '';
- print '";
+ print "";
+ print '';
}
-$db->close();
llxFooter();
+$db->close();
?>
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 95c93afc309..6e1e06f6279 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -545,7 +545,7 @@ class FormCompany
}
// We call a page after a small delay when a new input has been selected
- $javaScript = "window.location=\'./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;";
+ $javaScript = "window.location=\'".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;";
$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\');"'; // When we select with mouse
$htmloption.= 'onKeyUp="if (event.keyCode== 13) { ac_delay(\''.$javaScript.'\',\'500\'); }"'; // When we select with keyboard
@@ -571,7 +571,7 @@ class FormCompany
}
else
{
- $javaScript = "window.location='./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
+ $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
print '';
$num = $this->db->num_rows($resql);
$i = 0;
diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php
index 165475daf33..e31b708f09b 100644
--- a/htdocs/core/lib/fichinter.lib.php
+++ b/htdocs/core/lib/fichinter.lib.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2007 Rodolphe Quiedeville
+/* Copyright (C) 2006-2007 Laurent Destailleur
+ * Copyright (C) 2007 Rodolphe Quiedeville
+ * Copyright (C) 2012 Regis Houssin
*
* 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
@@ -41,11 +42,14 @@ function fichinter_prepare_head($object)
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
- $head[$h][1] = $langs->trans('InterventionContact');
- $head[$h][2] = 'contact';
- $h++;
+
+ if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ {
+ $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('InterventionContact');
+ $head[$h][2] = 'contact';
+ $h++;
+ }
if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
{
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index b8651d753cc..b6dd10249e3 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -39,11 +39,14 @@ function facture_prepare_head($object)
$head[$h][1] = $langs->trans('CardBill');
$head[$h][2] = 'compta';
$h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
- $head[$h][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
- $h++;
+
+ if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ {
+ $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
+ $h++;
+ }
if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
{
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 41274b6f28e..8cc3d939a00 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -67,11 +67,14 @@ function commande_prepare_head($object)
$head[$h][2] = 'preview';
$h++;
}
-
- $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
- $head[$h][1] = $langs->trans('ContactsAddresses');
- $head[$h][2] = 'contact';
- $h++;
+
+ if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ {
+ $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('ContactsAddresses');
+ $head[$h][2] = 'contact';
+ $h++;
+ }
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php
index e9fc602ed29..cdf78841356 100644
--- a/htdocs/fichinter/contact.php
+++ b/htdocs/fichinter/contact.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2007-2009 Laurent Destailleur
* Copyright (C) 2012 Juanjo Menent
*
@@ -33,12 +33,14 @@ $langs->load("interventions");
$langs->load("sendings");
$langs->load("companies");
-$fichinterid = GETPOST('id','int');
+$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
+$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
+
+$object = new Fichinter($db);
/*
@@ -47,42 +49,38 @@ $result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
if ($action == 'addcontact' && $user->rights->ficheinter->creer)
{
+ $result = $object->fetch($id);
- $result = 0;
- $fichinter = new Fichinter($db);
- $result = $fichinter->fetch($fichinterid);
-
- if ($result > 0 && $fichinterid > 0)
+ if ($result > 0 && $id > 0)
{
- $result = $fichinter->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha'));
+ $result = $object->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha'));
}
if ($result >= 0)
{
- Header("Location: contact.php?id=".$fichinter->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
- if ($fichinter->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
}
else
{
- $mesg = ''.$fichinter->error.'
';
+ $mesg = ''.$object->error.'
';
}
}
}
// bascule du statut d'un contact
-if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
+else if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
{
- $fichinter = new Fichinter($db);
- if ($fichinter->fetch($fichinterid))
+ if ($object->fetch($id))
{
- $result=$fichinter->swapContactStatus(GETPOST('ligne','int'));
+ $result=$object->swapContactStatus(GETPOST('ligne','int'));
}
else
{
@@ -91,15 +89,14 @@ if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
}
// Efface un contact
-if ($action == 'deleteline' && $user->rights->ficheinter->creer)
+else if ($action == 'deletecontact' && $user->rights->ficheinter->creer)
{
- $fichinter = new Fichinter($db);
- $fichinter->fetch($fichinterid);
- $result = $fichinter->delete_contact(GETPOST('lineid','int'));
+ $object->fetch($id);
+ $result = $object->delete_contact(GETPOST('lineid','int'));
if ($result >= 0)
{
- Header("Location: contact.php?id=".$fichinter->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
@@ -128,16 +125,15 @@ $userstatic=new User($db);
dol_htmloutput_mesg($mesg);
-if ($fichinterid > 0)
+if ($id > 0)
{
- $fichinter = new Fichinter($db);
- if ($fichinter->fetch($fichinterid) > 0)
+ if ($object->fetch($id) > 0)
{
$soc = new Societe($db);
- $soc->fetch($fichinter->socid);
+ $soc->fetch($object->socid);
- $head = fichinter_prepare_head($fichinter);
+ $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention');
@@ -148,199 +144,23 @@ if ($fichinterid > 0)
// Ref
print ''.$langs->trans("Ref").' ';
- print $fichinter->ref;
+ print $object->ref;
print " ";
// Customer
- if ( is_null($fichinter->client) )
- $fichinter->fetch_thirdparty();
+ if ( is_null($object->client) )
+ $object->fetch_thirdparty();
print "".$langs->trans("Company")." ";
- print ''.$fichinter->client->getNomUrl(1).' ';
+ print ''.$object->client->getNomUrl(1).' ';
print "";
print '';
- /*
- * Lignes de contacts
- */
- echo '';
-
- /*
- * Ajouter une ligne de contact
- * Non affiche en mode modification de ligne
- */
- if ($action != 'editline' && $user->rights->ficheinter->creer)
- {
- print '';
- print ''.$langs->trans("Source").' ';
- print ''.$langs->trans("Company").' ';
- print ''.$langs->trans("Contacts").' ';
- print ''.$langs->trans("ContactType").' ';
- print ' ';
- print " \n";
-
- $var = false;
-
- print '';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
-
- // Ligne ajout pour contact interne
- print "";
-
- print '';
- print img_object('','user').' '.$langs->trans("Users");
- print ' ';
-
- print '';
- print $conf->global->MAIN_INFO_SOCIETE_NOM;
- print ' ';
-
- print '';
- //$userAlreadySelected = $fichinter->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
- $form->select_users($user->id,'contactid',0,$userAlreadySelected);
- print ' ';
- print '';
- $formcompany->selectTypeContact($fichinter, '', 'type','internal');
- print ' ';
- print ' ';
- print ' ';
-
- print ' ';
-
- print '';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
-
- // Ligne ajout pour contact externe
- $var=!$var;
- print "";
-
- print '';
- print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
- print ' ';
-
- print '';
- $selectedCompany = GETPOST('newcompany','int')?GETPOST('newcompany','int'):$fichinter->client->id;
- $selectedCompany = $formcompany->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany');
- print ' ';
-
- print '';
- $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
- if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
- print ' ';
- print '';
- $formcompany->selectTypeContact($fichinter, '', 'type','external');
- print ' ';
- print ' ';
- print ' ';
-
- print " ";
-
- print ' ';
- }
-
- // Liste des contacts li�s
- print '';
- print ''.$langs->trans("Source").' ';
- print ''.$langs->trans("Company").' ';
- print ''.$langs->trans("Contacts").' ';
- print ''.$langs->trans("ContactType").' ';
- print ''.$langs->trans("Status").' ';
- print ' ';
- print " \n";
-
- $companystatic = new Societe($db);
- $var = true;
-
- foreach(array('internal','external') as $source)
- {
- $tab = $fichinter->liste_contact(-1,$source);
- $num=count($tab);
-
- $i = 0;
- while ($i < $num)
- {
- $var = !$var;
-
- print '';
-
- // Source
- print '';
- if ($tab[$i]['source']=='internal') print $langs->trans("User");
- if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
- print ' ';
-
- // Societe
- print '';
- if ($tab[$i]['socid'] > 0)
- {
- $companystatic->fetch($tab[$i]['socid']);
- print $companystatic->getNomUrl(1);
- }
- if ($tab[$i]['socid'] < 0)
- {
- print $conf->global->MAIN_INFO_SOCIETE_NOM;
- }
- if (! $tab[$i]['socid'])
- {
- print ' ';
- }
- print ' ';
-
- // Contact
- print '';
- if ($tab[$i]['source']=='internal')
- {
- $userstatic->id=$tab[$i]['id'];
- $userstatic->lastname=$tab[$i]['lastname'];
- $userstatic->firstname=$tab[$i]['firstname'];
- print $userstatic->getNomUrl(1);
- }
- if ($tab[$i]['source']=='external')
- {
- $contactstatic->id=$tab[$i]['id'];
- $contactstatic->lastname=$tab[$i]['lastname'];
- $contactstatic->firstname=$tab[$i]['firstname'];
- print $contactstatic->getNomUrl(1);
- }
- print ' ';
-
- // Type de contact
- print ''.$tab[$i]['libelle'].' ';
-
- // Statut
- print '';
- // Activation desativation du contact
- if ($fichinter->statut >= 0) print '';
- print $contactstatic->LibStatut($tab[$i]['status'],3);
- if ($fichinter->statut >= 0) print ' ';
- print ' ';
-
- // Icon update et delete
- print '';
- if ($fichinter->statut < 5 && $user->rights->ficheinter->creer)
- {
- print ' ';
- print '';
- print img_delete();
- print ' ';
- }
- print ' ';
-
- print " \n";
-
- $i ++;
- }
- }
- print "
";
+ print ' ';
+
+ // Contacts lines
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
}
else
{
@@ -348,7 +168,7 @@ if ($fichinterid > 0)
}
}
-$db->close();
llxFooter();
+$db->close();
?>
\ No newline at end of file
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index e3dc490bc6b..06b899644c4 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -621,6 +621,66 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
$action='presend';
}
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+{
+ if ($action == 'addcontact' && $user->rights->ficheinter->creer)
+ {
+ $result = $object->fetch($id);
+
+ if ($result > 0 && $id > 0)
+ {
+ $result = $object->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha'));
+ }
+
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else
+ {
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
+ }
+ else
+ {
+ $mesg = ''.$object->error.'
';
+ }
+ }
+ }
+
+ // bascule du statut d'un contact
+ else if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
+ {
+ if ($object->fetch($id))
+ {
+ $result=$object->swapContactStatus(GETPOST('ligne','int'));
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+
+ // Efface un contact
+ else if ($action == 'deletecontact' && $user->rights->ficheinter->creer)
+ {
+ $object->fetch($id);
+ $result = $object->delete_contact(GETPOST('lineid','int'));
+
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else {
+ dol_print_error($db);
+ }
+ }
+}
+
/*
* View
@@ -856,10 +916,23 @@ else if ($id > 0 || ! empty($ref))
print ''.$langs->trans("Status").' '.$object->getLibStatut(4).' ';
print " ";
+
+ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ {
+ require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+ $formcompany= new FormCompany($db);
+
+ $blocname = 'contacts';
+ $title = $langs->trans('ContactsAddresses');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
+ }
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
- include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
+ $blocname = 'notes';
+ $title = $langs->trans('Notes');
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php
index 3c3154594f1..ce17cc34faf 100644
--- a/htdocs/fichinter/note.php
+++ b/htdocs/fichinter/note.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2011-2012 Juanjo Menent
+/* Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2011-2012 Juanjo Menent
*
* 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
@@ -29,58 +29,35 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/fichinter.lib.php");
$langs->load('companies');
$langs->load("interventions");
-$fichinterid = GETPOST('id','int');
+$id = GETPOST('id','int');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
+$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
+
+$object = new Fichinter($db);
/******************************************************************************/
/* Actions */
/******************************************************************************/
-if ($action == 'update_public' && $user->rights->ficheinter->creer)
+if ($action == 'setnote_public' && $user->rights->ficheinter->creer)
{
- $fichinter = new Fichinter($db);
- $fichinter->fetch($fichinterid);
-
- $db->begin();
-
- $res=$fichinter->update_note_public(GETPOST('note_public','alpha'),$user);
- if ($res < 0)
- {
- $mesg=''.$fichinter->error.'
';
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
+ $object->fetch($id);
+ $result=$object->update_note_public(GETPOST('note_public','alpha'));
+ if ($result < 0) dol_print_error($db,$object->error);
}
-if ($action == 'update' && $user->rights->ficheinter->creer)
+else if ($action == 'setnote' && $user->rights->ficheinter->creer)
{
- $fichinter = new Fichinter($db);
- $fichinter->fetch($fichinterid);
-
- $db->begin();
-
- $res=$fichinter->update_note(GETPOST('note_private','alpha'),$user);
- if ($res < 0)
- {
- $mesg=''.$fichinter->error.'
';
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
+ $object->fetch($id);
+ $result=$object->update_note(GETPOST('note','alpha'));
+ if ($result < 0) dol_print_error($db,$object->error);
}
-
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
@@ -89,82 +66,34 @@ llxHeader();
$form = new Form($db);
-if ($fichinterid)
+if ($id > 0)
{
if ($mesg) print $mesg;
- $fichinter = new Fichinter($db);
- if ( $fichinter->fetch($fichinterid) )
+ if ($object->fetch($id))
{
$societe = new Societe($db);
- if ( $societe->fetch($fichinter->socid) )
+ if ($societe->fetch($object->socid))
{
- $head = fichinter_prepare_head($fichinter);
+ $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention');
print '";
-
- print '';
-
- /*
- * Actions
- */
-
- print '';
}
}
}
-$db->close();
+
llxFooter();
+$db->close();
?>