diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index ffb71c6b284..3604d56edc1 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1044,6 +1044,67 @@ else if ($action == 'down' && $user->rights->propale->creer)
exit;
}
+if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+{
+ if ($action == 'addcontact' && $user->rights->propale->creer)
+ {
+ $result = $object->fetch($id);
+
+ if ($result > 0 && $id > 0)
+ {
+ $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
+ }
+
+ 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->propale->creer)
+ {
+ if ($object->fetch($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)
+ {
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+}
+
/*
* View
@@ -1479,9 +1540,21 @@ if ($id > 0 || ! empty($ref))
print ' ';
+ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
+ {
+ 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/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index 54081f5bc21..ae741698641 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -93,7 +93,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer)
}
// Efface un contact
-else if ($action == 'deleteline' && $user->rights->propale->creer)
+else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
@@ -126,8 +126,6 @@ llxHeader('', $langs->trans("Proposal"), "Propal");
$form = new Form($db);
$formcompany= new FormCompany($db);
$formother = new FormOther($db);
-$contactstatic=new Contact($db);
-$userstatic=new User($db);
/* *************************************************************************** */
@@ -205,185 +203,10 @@ if ($id > 0 || ! empty($ref))
/*
* Lignes de contacts
*/
- print '';
-
- /*
- * Ajouter une ligne de contact
- * Non affiche en mode modification de ligne
- */
- if ($action != 'editline' && $user->rights->propale->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 ' ';
- }
-
-
- // Liste des contacts lies
- 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 = $object->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 ($object->statut >= 0) print '';
- print $contactstatic->LibStatut($tab[$i]['status'],3);
- if ($object->statut >= 0) print ' ';
- print ' ';
-
- // Icon update et delete
- print '';
- if ($user->rights->propale->creer)
- {
- print ' ';
- print 'id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
- print img_delete();
- print ' ';
- }
- print ' ';
-
- print " \n";
-
- $i ++;
- }
- }
- print "
";
+ print ' ';
+
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
+
}
else
{
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 80ab342df3f..8bc2d5f7eea 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -32,54 +32,33 @@ $langs->load('propal');
$langs->load('compta');
$langs->load('bills');
-$id = isset($_GET["id"])?$_GET["id"]:'';
+$id = GETPOST('id','int');
+$ref=GETPOST('ref','alpha');
+$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal');
+$object = new Propal($db);
/******************************************************************************/
/* Actions */
/******************************************************************************/
-if ($_POST["action"] == 'update_public' && $user->rights->propale->creer)
-{
- $propal = new Propal($db);
- $propal->fetch($_GET["id"]);
-
- $db->begin();
-
- $res=$propal->update_note_public($_POST["note_public"],$user);
- if ($res < 0)
- {
- $mesg=''.$propal->error.'
';
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
-}
-
-if ($_POST['action'] == 'update' && $user->rights->propale->creer)
-{
- $propal = new Propal($db);
- $propal->fetch($_GET["id"]);
-
- $db->begin();
-
- $res=$propal->update_note($_POST["note"],$user);
- if ($res < 0)
- {
- $mesg=''.$propal->error.'
';
- $db->rollback();
- }
- else
- {
- $db->commit();
- }
+if ($action == 'setnote_public' && $user->rights->propale->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note_public(GETPOST('note_public','alpha'));
+ if ($result < 0) dol_print_error($db,$object->error);
+}
+
+else if ($action == 'setnote' && $user->rights->propale->creer)
+{
+ $object->fetch($id);
+ $result=$object->update_note(GETPOST('note','alpha'));
+ if ($result < 0) dol_print_error($db,$object->error);
}
@@ -92,21 +71,18 @@ llxHeader();
$form = new Form($db);
-$id = $_GET["id"];
-$ref= $_GET["ref"];
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg;
$now=gmmktime();
- $propal = new Propal($db);
- if ($propal->fetch($id, $ref))
+ if ($object->fetch($id, $ref))
{
$societe = new Societe($db);
- if ( $societe->fetch($propal->socid) )
+ if ( $societe->fetch($object->socid) )
{
- $head = propal_prepare_head($propal);
+ $head = propal_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal');
print '';
@@ -115,7 +91,7 @@ if ($id > 0 || ! empty($ref))
// Ref
print ''.$langs->trans('Ref').' ';
- print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
+ print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print ' ';
// Ref client
@@ -125,15 +101,15 @@ if ($id > 0 || ! empty($ref))
print '';
print '
';
print '';
- print $propal->ref_client;
+ print $object->ref_client;
print ' ';
print '';
// Customer
- if ( is_null($propal->client) )
- $propal->fetch_thirdparty();
+ if ( is_null($object->client) )
+ $object->fetch_thirdparty();
print "".$langs->trans("Company")." ";
- print ''.$propal->client->getNomUrl(1).' ';
+ print ''.$object->client->getNomUrl(1).' ';
// Ligne info remises tiers
print ''.$langs->trans('Discounts').' ';
@@ -148,17 +124,17 @@ if ($id > 0 || ! empty($ref))
// Date
print ' '.$langs->trans('Date').' ';
- print dol_print_date($propal->date,'daytext');
+ print dol_print_date($object->date,'daytext');
print ' ';
print ' ';
// Date fin propal
print '';
print ''.$langs->trans('DateEndPropal').' ';
- if ($propal->fin_validite)
+ if ($object->fin_validite)
{
- print dol_print_date($propal->fin_validite,'daytext');
- if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
+ print dol_print_date($object->fin_validite,'daytext');
+ if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
@@ -166,45 +142,8 @@ if ($id > 0 || ! empty($ref))
}
print ' ';
print ' ';
-
- // Note publique
- print ''.$langs->trans("NotePublic").' : ';
- print '';
- if ($_GET["action"] == 'edit')
- {
- print '';
- }
- else
- {
- print ($propal->note_public?nl2br($propal->note_public):" ");
- }
- print " ";
-
- // Note privee
- if (! $user->societe_id)
- {
- print ''.$langs->trans("NotePrivate").' : ';
- print '';
- if ($_GET["action"] == 'edit')
- {
- print '';
- print ' ';
- print ' ';
- print ''.$propal->note." ";
- print ' ';
- print ' ';
- }
- else
- {
- print ($propal->note?nl2br($propal->note):" ");
- }
- print " ";
- }
+
+ include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
print "";
@@ -215,15 +154,16 @@ if ($id > 0 || ! empty($ref))
*/
print '';
}
}
}
-$db->close();
+
llxFooter();
+$db->close();
?>
diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php
index 9b86b373925..3ef03979045 100644
--- a/htdocs/core/lib/propal.lib.php
+++ b/htdocs/core/lib/propal.lib.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2010 Regis Houssin
+ * 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
@@ -62,11 +62,14 @@ function propal_prepare_head($object)
$head[$h][2] = 'preview';
$h++;
}
-
- $head[$h][0] = DOL_URL_ROOT.'/comm/propal/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.'/comm/propal/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/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php
new file mode 100644
index 00000000000..ff902336521
--- /dev/null
+++ b/htdocs/core/tpl/bloc_showhide.tpl.php
@@ -0,0 +1,62 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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
+ * along with this program. If not, see .
+ *
+ */
+
+// Hide by default
+$hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false);
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php
new file mode 100644
index 00000000000..16a3e1a40d7
--- /dev/null
+++ b/htdocs/core/tpl/contacts.tpl.php
@@ -0,0 +1,168 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (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
+ * along with this program. If not, see .
+ *
+ */
+
+$module = $object->element;
+if ($module == 'propal') $module = 'propale';
+else if ($module == 'fichinter') { $module = 'ficheinter'; }
+
+$companystatic=new Societe($db);
+$contactstatic=new Contact($db);
+$userstatic=new User($db);
+
+?>
+
+
+
+
+rights->$module->creer) { ?>
+
+ trans("Source"); ?>
+ trans("Company"); ?>
+ trans("Contacts"); ?>
+ trans("ContactType"); ?>
+
+
+
+
+
+ id; ?>" method="POST">
+
+
+
+
+
+ >
+ trans("Users"); ?>
+ global->MAIN_INFO_SOCIETE_NOM; ?>
+ select_users($user->id,'contactid',0,$userAlreadySelected); ?>
+ selectTypeContact($object, '', 'type','internal'); ?>
+ ">
+
+
+
+ id; ?>" method="POST">
+
+
+
+
+
+
+
+ >
+ trans("ThirdPartyContacts"); ?>
+
+ socid; ?>
+ selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?>
+
+
+ select_contacts($selectedCompany, '', 'contactid'); ?>
+ trans("NoContactDefined"); ?>
+
+
+ selectTypeContact($object, '', 'type','external'); ?>
+
+
+ ">
+
+
+
+
+
+
+
+
+
+
+ trans("Source"); ?>
+ trans("Company"); ?>
+ trans("Contacts"); ?>
+ trans("ContactType"); ?>
+ trans("Status"); ?>
+
+
+
+
+
+ liste_contact(-1,$source);
+ $num=count($tab);
+
+ $i = 0;
+ while ($i < $num) {
+ $var = !$var;
+ ?>
+
+ valign="top">
+
+ trans("User"); ?>
+ trans("ThirdPartyContact"); ?>
+
+
+ 0)
+ {
+ $companystatic->fetch($tab[$i]['socid']);
+ echo $companystatic->getNomUrl(1);
+ }
+ if ($tab[$i]['socid'] < 0)
+ {
+ echo $conf->global->MAIN_INFO_SOCIETE_NOM;
+ }
+ if (! $tab[$i]['socid'])
+ {
+ echo ' ';
+ }
+ ?>
+
+
+ id=$tab[$i]['id'];
+ $userstatic->lastname=$tab[$i]['lastname'];
+ $userstatic->firstname=$tab[$i]['firstname'];
+ echo $userstatic->getNomUrl(1);
+ }
+ if ($tab[$i]['source']=='external')
+ {
+ $contactstatic->id=$tab[$i]['id'];
+ $contactstatic->lastname=$tab[$i]['lastname'];
+ $contactstatic->firstname=$tab[$i]['firstname'];
+ echo $contactstatic->getNomUrl(1);
+ }
+ ?>
+
+
+
+ statut >= 0) echo ''; ?>
+ LibStatut($tab[$i]['status'],3); ?>
+ statut >= 0) echo ' '; ?>
+
+
+ rights->$module->creer) { ?>
+ id.'&action=deletecontact&lineid='.$tab[$i]['rowid']; ?>">
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php
index 9975de606dd..3f78504c025 100644
--- a/htdocs/core/tpl/notes.tpl.php
+++ b/htdocs/core/tpl/notes.tpl.php
@@ -16,7 +16,6 @@
*
*/
-$hide = $object->extraparams['notes']['showhide'];
$module = $object->element;
$note_public = 'note_public';
$note_private = 'note';
@@ -25,38 +24,7 @@ else if ($module == 'fichinter') { $module = 'ficheinter'; $note_private = 'note
?>
-
-
-
-
-
-
-trans('Notes'); ?>
-
-
+
editfieldkey("NotePublic",$note_public,$object->note_public,$object,$user->rights->$module->creer,'textarea'); ?>
@@ -71,7 +39,4 @@ $(document).ready(function() {
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file