New: sharing code of contact and note tabs
This commit is contained in:
parent
ffa3e2af09
commit
281c6b7f2a
@ -199,12 +199,10 @@ if ($id > 0 || ! empty($ref))
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Lignes de contacts
|
||||
*/
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Contacts lines
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||
|
||||
}
|
||||
|
||||
@ -148,17 +148,6 @@ if ($id > 0 || ! empty($ref))
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
if ($user->rights->propale->creer && $action <> 'edit')
|
||||
{
|
||||
print '<a class="butAction" href="note.php?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ else if ($action == 'swapstatut' && $user->rights->commande->creer)
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
else if ($action == 'deleteline' && $user->rights->commande->creer)
|
||||
else if ($action == 'deletecontact' && $user->rights->commande->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact($_GET["lineid"]);
|
||||
@ -199,187 +199,11 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Lignes de contacts
|
||||
*/
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
print '<br>';
|
||||
|
||||
// Contacts lines
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||
|
||||
/*
|
||||
* Ajouter une ligne de contact
|
||||
* Non affiche en mode modification de ligne
|
||||
*/
|
||||
if ($action != 'editline' && $user->rights->commande->creer)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$var = false;
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="internal">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
// Ligne ajout pour contact interne
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print img_object('','user').' '.$langs->trans("Users");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
print $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
//$userAlreadySelected = $object->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type
|
||||
$form->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formcompany->selectTypeContact($object, '', 'type','internal');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="external">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
// Ligne ajout pour contact externe
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->client->id;
|
||||
$selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany');
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
|
||||
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formcompany->selectTypeContact($object, '', 'type','external');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
|
||||
if (! $nbofcontacts) print ' disabled="disabled"';
|
||||
print '></td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
print '<tr><td colspan="7"> </td></tr>';
|
||||
}
|
||||
|
||||
// List of linked contacts
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print "</tr>\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 '<tr '.$bc[$var].' valign="top">';
|
||||
|
||||
// Source
|
||||
print '<td align="left">';
|
||||
if ($tab[$i]['source']=='internal') print $langs->trans("User");
|
||||
if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
|
||||
print '</td>';
|
||||
|
||||
// Societe
|
||||
print '<td align="left">';
|
||||
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 '</td>';
|
||||
|
||||
// Contact
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
|
||||
// Type de contact
|
||||
print '<td>'.$tab[$i]['libelle'].'</td>';
|
||||
|
||||
// Statut
|
||||
print '<td align="center">';
|
||||
// Activation desativation du contact
|
||||
if ($object->statut >= 0) print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=swapstatut&ligne='.$tab[$i]['rowid'].'">';
|
||||
print $contactstatic->LibStatut($tab[$i]['status'],3);
|
||||
if ($object->statut >= 0) print '</a>';
|
||||
print '</td>';
|
||||
|
||||
// Icon update et delete
|
||||
print '<td align="center" nowrap="nowrap" colspan="2">';
|
||||
if ($object->statut < 5 && $user->rights->commande->creer)
|
||||
{
|
||||
print ' ';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1191,6 +1191,66 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
if ($action == 'addcontact' && $user->rights->commande->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 = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$object->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bascule du statut d'un contact
|
||||
else if ($action == 'swapstatut' && $user->rights->commande->creer)
|
||||
{
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$result=$object->swapContactStatus(GETPOST('ligne'));
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
else if ($action == 'deletecontact' && $user->rights->commande->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
|
||||
@ -1951,9 +2011,21 @@ else
|
||||
print '</table><br>';
|
||||
print "\n";
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
|
||||
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))
|
||||
{
|
||||
$blocname = 'notes';
|
||||
$title = $langs->trans('Notes');
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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,25 +27,24 @@ require("../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php');
|
||||
require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php");
|
||||
|
||||
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
|
||||
|
||||
if (!$user->rights->commande->lire) accessforbidden();
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("bills");
|
||||
$langs->load("orders");
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
$ref=GETPOST('ref','alpha');
|
||||
$socid=GETPOST('socid','int');
|
||||
$action=GETPOST('action','alpha');
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
$comid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,'commande',$comid,'');
|
||||
$result=restrictedArea($user,'commande',$id,'');
|
||||
|
||||
|
||||
$id = $_GET['id'];
|
||||
$ref= $_GET['ref'];
|
||||
$commande = new Commande($db);
|
||||
if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
|
||||
$object = new Commande($db);
|
||||
if (! $object->fetch($id, $ref) > 0)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
@ -55,25 +54,19 @@ if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_POST["action"] == 'update' && $user->rights->commande->creer)
|
||||
if ($action == 'setnote_public' && $user->rights->commande->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$resPrivateNote=$commande->update_note($_POST["note"]);
|
||||
$resPublicNote=$commande->update_note_public($_POST["note_public"]);
|
||||
|
||||
if ($resPrivateNote < 0 || $resPublicNote < 0)
|
||||
{
|
||||
$mesg='<div class="error">'.$commande->error.'</div>';
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
else if ($action == 'setnote' && $user->rights->commande->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->update_note(GETPOST('note','alpha'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -86,17 +79,17 @@ $form = new Form($db);
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socid);
|
||||
$soc->fetch($object->socid);
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
$head = commande_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="18%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $form->showrefnav($commande,'ref','',1,'ref','ref');
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $form->showrefnav($object,'ref','',1,'ref','ref');
|
||||
print "</td></tr>";
|
||||
|
||||
// Ref commande client
|
||||
@ -106,7 +99,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
print $commande->ref_client;
|
||||
print $object->ref_client;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -114,64 +107,14 @@ if ($id > 0 || ! empty($ref))
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td></tr>';
|
||||
|
||||
// Note publique
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<textarea name="note_public" cols="80" rows="'.ROWS_4.'">'.$commande->note_public."</textarea><br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($commande->note_public?nl2br($commande->note_public):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
|
||||
|
||||
// Note private
|
||||
if (! $user->societe_id)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<textarea name="note" cols="80" rows="'.ROWS_8.'">'.$commande->note."</textarea><br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($commande->note?nl2br($commande->note):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<br><center>';
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans('Save').'">';
|
||||
print '</center>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->commande->creer && $_GET["action"] <> 'edit')
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"note.php?id=".$commande->id."&action=edit\">".$langs->trans('Modify')."</a>";
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
@ -498,7 +498,9 @@ else if ($id)
|
||||
print "</table><br>";
|
||||
|
||||
// Notes
|
||||
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');
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
@ -1506,6 +1506,65 @@ else if ($action == 'builddoc') // En get ou en post
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
if ($action == 'addcontact' && $user->rights->facture->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 = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$object->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bascule du statut d'un contact
|
||||
else if ($action == 'swapstatut' && $user->rights->facture->creer)
|
||||
{
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$result=$object->swapContactStatus(GETPOST('ligne'));
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
else if ($action == 'deletecontact' && $user->rights->facture->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -2738,9 +2797,22 @@ else
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3392,7 +3464,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
||||
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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 = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$facture->error.'</div>';
|
||||
$mesg = '<div class="error">'.$object->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 '<td colspan="3">';
|
||||
$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 '</td></tr>';
|
||||
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">'.$facture->client->getNomUrl(1,'compta').'</td></tr>';
|
||||
print '<td colspan="3">'.$object->client->getNomUrl(1,'compta').'</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Lignes de contacts
|
||||
*/
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
|
||||
/*
|
||||
* Ajouter une ligne de contact
|
||||
* Non affiche en mode modification de ligne
|
||||
*/
|
||||
if ($_GET["action"] != 'editline' && $user->rights->facture->creer)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td colspan="3"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$var = false;
|
||||
|
||||
print '<form action="contact.php?facid='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="internal">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
// Line to add an internal contact
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print img_object('','user').' '.$langs->trans("Users");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
print $mysoc->name;
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
// Ge get ids of alreadey selected users
|
||||
//$userAlreadySelected = $facture->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 '</td>';
|
||||
print '<td>';
|
||||
$formcompany->selectTypeContact($facture, '', 'type','internal');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<form action="contact.php?facid='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="external">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
// Line to add an external contact
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
|
||||
print '</td>';
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id;
|
||||
$selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany');
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
$nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
|
||||
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formcompany->selectTypeContact($facture, '', 'type','external');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'"';
|
||||
if (! $nbofcontacts) print ' disabled="disabled"';
|
||||
print '></td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
print '<tr><td colspan="6"> </td></tr>';
|
||||
}
|
||||
|
||||
// List of linked contacts
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print "</tr>\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 '<tr '.$bc[$var].' valign="top">';
|
||||
|
||||
// Source
|
||||
print '<td align="left">';
|
||||
if ($tab[$i]['source']=='internal') print $langs->trans("User");
|
||||
if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
|
||||
print '</td>';
|
||||
|
||||
// Third party
|
||||
print '<td align="left">';
|
||||
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 '</td>';
|
||||
|
||||
// Contact
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
|
||||
// Type of contact
|
||||
print '<td>'.$tab[$i]['libelle'].'</td>';
|
||||
|
||||
// Status
|
||||
print '<td align="center">';
|
||||
// Activate/Unactivate contact
|
||||
if ($facture->statut >= 0) print '<a href="contact.php?facid='.$facture->id.'&action=swapstatut&ligne='.$tab[$i]['rowid'].'">';
|
||||
print $contactstatic->LibStatut($tab[$i]['status'],3);
|
||||
if ($facture->statut >= 0) print '</a>';
|
||||
print '</td>';
|
||||
|
||||
// Icon update et delete
|
||||
print '<td align="center" nowrap>';
|
||||
if ($user->rights->facture->creer)
|
||||
{
|
||||
print ' ';
|
||||
print '<a href="contact.php?facid='.$facture->id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
print '<br>';
|
||||
|
||||
// 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();
|
||||
?>
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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='<div class="error">'.$fac->error.'</div>';
|
||||
$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='<div class="error">'.$fac->error.'</div>';
|
||||
$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 '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
|
||||
print '<tr><td width="25%">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">';
|
||||
$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 '</td></tr>';
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>';
|
||||
|
||||
// Note publique
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="note.php?facid='.$fac->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update_public">';
|
||||
print '<textarea name="note_public" cols="80" rows="8">'.$fac->note_public."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($fac->note_public?nl2br($fac->note_public):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
|
||||
|
||||
// Note priv<69>e
|
||||
if (! $user->societe_id)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="note.php?facid='.$fac->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<textarea name="note" cols="80" rows="8">'.$fac->note."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($fac->note?nl2br($fac->note):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
print '</div>';
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->facture->creer && $_GET["action"] <> 'edit')
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"note.php?facid=$fac->id&action=edit\">".$langs->trans('Modify')."</a>";
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
@ -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 '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'" onChange="'.$javaScript.'">';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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))
|
||||
{
|
||||
|
||||
@ -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))
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
/* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
@ -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 = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$fichinter->error.'</div>';
|
||||
$mesg = '<div class="error">'.$object->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $fichinter->ref;
|
||||
print $object->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
// Customer
|
||||
if ( is_null($fichinter->client) )
|
||||
$fichinter->fetch_thirdparty();
|
||||
if ( is_null($object->client) )
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">'.$fichinter->client->getNomUrl(1).'</td></tr>';
|
||||
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Lignes de contacts
|
||||
*/
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
|
||||
/*
|
||||
* Ajouter une ligne de contact
|
||||
* Non affiche en mode modification de ligne
|
||||
*/
|
||||
if ($action != 'editline' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td colspan="3"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$var = false;
|
||||
|
||||
print '<form action="contact.php?id='.$fichinterid.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="internal">';
|
||||
print '<input type="hidden" name="id" value="'.$fichinterid.'">';
|
||||
|
||||
// Ligne ajout pour contact interne
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print img_object('','user').' '.$langs->trans("Users");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
print $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
//$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 '</td>';
|
||||
print '<td>';
|
||||
$formcompany->selectTypeContact($fichinter, '', 'type','internal');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<form action="contact.php?id='.$fichinterid.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="external">';
|
||||
print '<input type="hidden" name="id" value="'.$fichinterid.'">';
|
||||
|
||||
// Ligne ajout pour contact externe
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td nowrap="nowrap">';
|
||||
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$selectedCompany = GETPOST('newcompany','int')?GETPOST('newcompany','int'):$fichinter->client->id;
|
||||
$selectedCompany = $formcompany->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany');
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
|
||||
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formcompany->selectTypeContact($fichinter, '', 'type','external');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
|
||||
if (! $nbofcontacts) print ' disabled="disabled"';
|
||||
print '></td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
print '<tr><td colspan="6"> </td></tr>';
|
||||
}
|
||||
|
||||
// Liste des contacts li<6C>s
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print "</tr>\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 '<tr '.$bc[$var].' valign="top">';
|
||||
|
||||
// Source
|
||||
print '<td align="left">';
|
||||
if ($tab[$i]['source']=='internal') print $langs->trans("User");
|
||||
if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
|
||||
print '</td>';
|
||||
|
||||
// Societe
|
||||
print '<td align="left">';
|
||||
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 '</td>';
|
||||
|
||||
// Contact
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
|
||||
// Type de contact
|
||||
print '<td>'.$tab[$i]['libelle'].'</td>';
|
||||
|
||||
// Statut
|
||||
print '<td align="center">';
|
||||
// Activation desativation du contact
|
||||
if ($fichinter->statut >= 0) print '<a href="contact.php?id='.$fichinter->id.'&action=swapstatut&ligne='.$tab[$i]['rowid'].'">';
|
||||
print $contactstatic->LibStatut($tab[$i]['status'],3);
|
||||
if ($fichinter->statut >= 0) print '</a>';
|
||||
print '</td>';
|
||||
|
||||
// Icon update et delete
|
||||
print '<td align="center" nowrap>';
|
||||
if ($fichinter->statut < 5 && $user->rights->ficheinter->creer)
|
||||
{
|
||||
print ' ';
|
||||
print '<a href="contact.php?id='.$fichinter->id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
print '<br>';
|
||||
|
||||
// Contacts lines
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -348,7 +168,7 @@ if ($fichinterid > 0)
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
@ -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 = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$object->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
/* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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='<div class="error">'.$fichinter->error.'</div>';
|
||||
$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='<div class="error">'.$fichinter->error.'</div>';
|
||||
$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 '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$fichinter->ref.'</td></tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'.$object->ref.'</td></tr>';
|
||||
|
||||
// Soci<EFBFBD>t<EFBFBD>
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
|
||||
|
||||
// Note publique
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<form method="post" action="note.php?id='.$fichinter->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update_public">';
|
||||
print '<textarea name="note_public" cols="80" rows="8">'.$fichinter->note_public."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($fichinter->note_public?nl2br($fichinter->note_public):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
// Note priv<69>e
|
||||
if (! $user->societe_id)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<form method="post" action="note.php?id='.$fichinter->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<textarea name="note_private" cols="80" rows="8">'.$fichinter->note_private."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($fichinter->note_private?nl2br($fichinter->note_private):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
if ($user->rights->ficheinter->creer && $action <> 'edit')
|
||||
{
|
||||
print '<a class="butAction" href="note.php?id='.$fichinter->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user