Add: onglet contact sur les fiches d'interventions

This commit is contained in:
Regis Houssin
2007-06-21 19:49:24 +00:00
parent 6802dc1206
commit 46244193b3
9 changed files with 423 additions and 38 deletions

View File

@@ -151,9 +151,8 @@ if (isset($mesg)) print $mesg;
$id = $_GET["propalid"]; $id = $_GET["propalid"];
if ($id > 0) if ($id > 0)
{ {
$langs->trans("PropalCard");
$propal = New Propal($db); $propal = New Propal($db);
if ( $propal->fetch($_GET['propalid'], $user->societe_id) > 0) if ( $propal->fetch($_GET['propalid']) > 0)
{ {
$soc = new Societe($db, $propal->socid); $soc = new Societe($db, $propal->socid);
$soc->fetch($propal->socid); $soc->fetch($propal->socid);
@@ -164,7 +163,7 @@ if ($id > 0)
/* /*
* Facture synthese pour rappel * Propal synthese pour rappel
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@@ -192,7 +191,7 @@ if ($id > 0)
* Ajouter une ligne de contact * Ajouter une ligne de contact
* Non affich<63> en mode modification de ligne * Non affich<63> en mode modification de ligne
*/ */
if ($_GET["action"] != 'editline' && $user->rights->facture->creer) if ($_GET["action"] != 'editline' && $user->rights->propale->creer)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>'; print '<td>'.$langs->trans("Source").'</td>';
@@ -357,8 +356,8 @@ if ($id > 0)
} }
else else
{ {
// Contrat non trouv // Propale non trouv<EFBFBD>e
print "Contrat inexistant ou acc<63>s refus<75>"; print "Propale inexistante ou acc<63>s refus<75>";
} }
} }

View File

@@ -53,28 +53,23 @@ $pagenext = $page + 1;
// S<>curit<69> acc<63>s client // S<>curit<69> acc<63>s client
$user->getrights('facture'); $user->getrights('facture');
$user->getrights('propale');
if (!$user->rights->propale->lire) accessforbidden(); if (isset($_GET["socid"]))
$socid='';
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
if ($user->societe_id > 0)
{ {
$action = ''; $objectid=$_GET["socid"];
$socid = $user->societe_id; $module='societe';
$dbtable='';
} }
if ($_GET['propalid'] > 0) else if (isset($_GET["propalid"]) && $_GET["propalid"] > 0)
{ {
$propal = new Propal($db); $objectid=$_GET["propalid"];
$result=$propal->fetch($_GET['propalid']); $module='propale';
if (! $result > 0) $dbtable='propal';
{
dolibarr_print_error($db,$propal->error);
exit;
}
if ($user->societe_id > 0 && $propal->socid <> $user->societe_id)
accessforbidden();
} }
// S<>curit<69> d'acc<63>s client et commerciaux
$socid = restrictedArea($user, $module, $objectid, $dbtable);
/******************************************************************************/ /******************************************************************************/

View File

@@ -0,0 +1,366 @@
<?php
/* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/fichinter/contact.php
\ingroup fichinter
\brief Onglet de gestion des contacts de fiche d'intervention
\version $Revision$
*/
require ("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php");
$langs->load("interventions");
$langs->load("sendings");
$langs->load("companies");
$fichinterid = isset($_GET["id"])?$_GET["id"]:'';
// S<>curit<69> d'acc<63>s client et commerciaux
$socid = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
/*
* Ajout d'un nouveau contact
*/
if ($_POST["action"] == 'addcontact' && $user->rights->ficheinter->creer)
{
$result = 0;
$fichinter = new Fichinter($db);
$result = $fichinter->fetch($_GET["id"]);
if ($result > 0 && $_GET["id"] > 0)
{
$result = $fichinter->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: contact.php?id=".$fichinter->id);
exit;
}
else
{
$mesg = '<div class="error">'.$fichinter->error.'</div>';
}
}
// modification d'un contact. On enregistre le type
if ($_POST["action"] == 'updateligne' && $user->rights->ficheinter->creer)
{
$fichinter = new Fichinter($db);
if ($fichinter->fetch($_GET["id"]))
{
$contact = $fichinter->detail_contact($_POST["elrowid"]);
$type = $_POST["type"];
$statut = $contact->statut;
$result = $fichinter->update_contact($_POST["elrowid"], $statut, $type);
if ($result >= 0)
{
$db->commit();
} else
{
dolibarr_print_error($db, "result=$result");
$db->rollback();
}
} else
{
dolibarr_print_error($db);
}
}
// bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->ficheinter->creer)
{
$fichinter = new Fichinter($db);
if ($fichinter->fetch($_GET["id"]))
{
$contact = $fichinter->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4;
$result = $fichinter->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
} else
{
dolibarr_print_error($db, "result=$result");
$db->rollback();
}
} else
{
dolibarr_print_error($db);
}
}
// Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->ficheinter->creer)
{
$fichinter = new Fichinter($db);
$fichinter->fetch($_GET["id"]);
$result = $fichinter->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
Header("Location: contact.php?id=".$fichinter->id);
exit;
}
else {
dolibarr_print_error($db);
}
}
llxHeader();
$html = new Form($db);
$contactstatic=new Contact($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
if (isset($mesg)) print $mesg;
$id = $_GET["id"];
if ($id > 0)
{
$fichinter = New Fichinter($db);
if ($fichinter->fetch($_GET['id']) > 0)
{
$soc = new Societe($db, $fichinter->socid);
$soc->fetch($fichinter->socid);
$head = fichinter_prepare_head($fichinter);
dolibarr_fiche_head($head, 'contact', $langs->trans("InterventionCard"));
/*
* Fiche intervention synthese pour rappel
*/
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $fichinter->ref_url;
print "</td></tr>";
// Customer
if ( is_null($fichinter->client) )
$fichinter->fetch_client();
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$fichinter->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 affich<63> en mode modification de ligne
*/
if ($_GET["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">&nbsp;</td>';
print "</tr>\n";
$var = false;
print '<form action="contact.php?id='.$id.'" method="post">';
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>';
print $langs->trans("Internal");
print '</td>';
print '<td colspan="1">';
print $conf->global->MAIN_INFO_SOCIETE_NOM;
print '</td>';
print '<td colspan="1">';
$html->select_users($user->id,'contactid');
print '</td>';
print '<td>';
$fichinter->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='.$id.'" method="post">';
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>';
print $langs->trans("External");
print '</td>';
print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$fichinter->client->id;
$selectedCompany = $fichinter->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany');
print '</td>';
print '<td colspan="1">';
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid');
print '</td>';
print '<td>';
$fichinter->selectTypeContact($fichinter, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
print "</form>";
print '<tr><td colspan="6">&nbsp;</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">&nbsp;</td>';
print "</tr>\n";
$societe = new Societe($db);
$var = true;
foreach(array('internal','external') as $source)
{
$tab = $fichinter->liste_contact(-1,$source);
$num=sizeof($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("Internal");
if ($tab[$i]['source']=='external') print $langs->trans("External");
print '</td>';
// Societe
print '<td align="left">';
if ($tab[$i]['socid'] > 0)
{
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$tab[$i]['socid'].'">';
print img_object($langs->trans("ShowCompany"),"company").' '.$societe->get_nom($tab[$i]['socid']);
print '</a>';
}
if ($tab[$i]['socid'] < 0)
{
print $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (! $tab[$i]['socid'])
{
print '&nbsp;';
}
print '</td>';
// Contact
print '<td>';
if ($tab[$i]['source']=='internal')
{
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$tab[$i]['id'].'">';
print img_object($langs->trans("ShowUser"),"user").' '.$tab[$i]['nom'].'</a>';
}
if ($tab[$i]['source']=='external')
{
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$tab[$i]['id'].'">';
print img_object($langs->trans("ShowContact"),"contact").' '.$tab[$i]['nom'].'</a>';
}
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.'&amp;action=swapstatut&amp;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 '&nbsp;';
print '<a href="contact.php?id='.$fichinter->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">';
print img_delete();
print '</a>';
}
print '</td>';
print "</tr>\n";
$i ++;
}
}
print "</table>";
}
else
{
// Fiche intervention non trouv<75>e
print "Fiche intervention inexistante ou acc<63>s refus<75>";
}
}
$db->close();
llxFooter('$Date$');
?>

View File

@@ -36,12 +36,12 @@ require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
class Fichinter extends CommonObject class Fichinter extends CommonObject
{ {
var $db; var $db;
var $element='ficheinter'; var $element='fichinter';
var $id; var $id;
var $socid; // Id client var $socid; // Id client
var $client; // Objet societe client (<28> charger par fetch_client) var $client; // Objet societe client (<28> charger par fetch_client)
var $author; var $author;
var $ref; var $ref;
@@ -175,10 +175,11 @@ class Fichinter extends CommonObject
$this->duree = $obj->duree; $this->duree = $obj->duree;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->note = $obj->note; $this->note = $obj->note;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->societe_id = $obj->fk_soc; // A virer, obsolete
$this->projet_id = $obj->fk_projet; $this->projet_id = $obj->fk_projet;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->ref_url = '<a href="'.DOL_URL_ROOT.'/fichinter/fiche.php?id='.$this->id.'">'.$this->ref.'</a>';
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;

View File

@@ -3,10 +3,16 @@ Intervention=Intervention
Interventions=Interventions Interventions=Interventions
InterventionCard=Intervention card InterventionCard=Intervention card
NewIntervention=New intervention NewIntervention=New intervention
EditIntervention=Editer intervention
AddIntervention=Add intervention AddIntervention=Add intervention
ListOfInterventions=List of interventions ListOfInterventions=List of interventions
EditIntervention=Editer intervention
LastInterventions=Last %s interventions LastInterventions=Last %s interventions
AllInterventions=All interventions AllInterventions=All interventions
CreateDaftIntervention=Create draft CreateDaftIntervention=Create draft
CustomerDoesNotHavePrefix=Customer does not have a prefix CustomerDoesNotHavePrefix=Customer does not have a prefix
InterventionContact=Intervention contact
##### Types de contacts #####
TypeContact_fichinter_internal_INTERREPFOLL=Representative following-up intervention
TypeContact_fichinter_internal_INTERVENING=Intervening
TypeContact_fichinter_external_BILLING=Billing customer contact
TypeContact_fichinter_external_CUSTOMER=Following-up customer contact

View File

@@ -9,4 +9,10 @@ EditIntervention=Editer
LastInterventions=Les %s derni<6E>res interventions LastInterventions=Les %s derni<6E>res interventions
AllInterventions=Toutes les interventions AllInterventions=Toutes les interventions
CreateDaftIntervention=Cr<43>er brouillon CreateDaftIntervention=Cr<43>er brouillon
CustomerDoesNotHavePrefix=Le client n'a pas de pr<70>fixe de d<>fini CustomerDoesNotHavePrefix=Le client n'a pas de pr<70>fixe de d<>fini
InterventionContact=Contact intervention
##### Types de contacts #####
TypeContact_fichinter_internal_INTERREPFOLL=Responsable suivi de l'intervention
TypeContact_fichinter_internal_INTERVENING=Intervenant
TypeContact_fichinter_external_BILLING=Contact client facturation intervention
TypeContact_fichinter_external_CUSTOMER=Contact client suivi de l'intervention

View File

@@ -38,13 +38,15 @@ function fichinter_prepare_head($fichinter)
$h = 0; $h = 0;
$head = array(); $head = array();
if ($conf->fichinter->enabled && $user->rights->ficheinter->lire) $head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$fichinter->id;
{ $head[$h][1] = $langs->trans("Card");
$head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$fichinter->id; $head[$h][2] = 'card';
$head[$h][1] = $langs->trans("Card"); $h++;
$head[$h][2] = 'card';
$h++; $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$fichinter->id;
} $head[$h][1] = $langs->trans('InterventionContact');
$head[$h][2] = 'contact';
$h++;
return $head; return $head;
} }

View File

@@ -1093,6 +1093,11 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100,'commande','external', 'BILLING', 'Contact client facturation commande', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100,'commande','external', 'BILLING', 'Contact client facturation commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101,'commande','external', 'CUSTOMER', 'Contact client suivi commande', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101,'commande','external', 'CUSTOMER', 'Contact client suivi commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (120, 'fichinter','internal', 'INTERREPFOLL', 'Responsable suivi de l\'intervention', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (121, 'fichinter','internal', 'INTERVENING', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (130, 'fichinter','external', 'BILLING', 'Contact client facturation intervention', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (131, 'fichinter','external', 'CUSTOMER', 'Contact client suivi de l\'intervention', 1);
-- --
-- Entree menu auguria -- Entree menu auguria

View File

@@ -675,3 +675,8 @@ ALTER TABLE `llx_osc_product` ADD UNIQUE KEY `fk_product` (`fk_product`);
-- V4 ALTER TABLE llx_telephonie_societe_ligne ADD FOREIGN KEY (fk_soc_facture) REFERENCES llx_societe(rowid); -- V4 ALTER TABLE llx_telephonie_societe_ligne ADD FOREIGN KEY (fk_soc_facture) REFERENCES llx_societe(rowid);
-- V4 ALTER TABLE llx_telephonie_tarif_client ADD FOREIGN KEY (fk_client) REFERENCES llx_societe (rowid); -- V4 ALTER TABLE llx_telephonie_tarif_client ADD FOREIGN KEY (fk_client) REFERENCES llx_societe (rowid);
-- fin du changement idp en rowid -- fin du changement idp en rowid
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (120, 'fichinter','internal', 'INTERREPFOLL', 'Responsable suivi de l\'intervention', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (121, 'fichinter','internal', 'INTERVENING', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (130, 'fichinter','external', 'BILLING', 'Contact client facturation intervention', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (131, 'fichinter','external', 'CUSTOMER', 'Contact client suivi de l\'intervention', 1);