diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 7e6c61ca60f..d673588e88f 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -151,9 +151,8 @@ if (isset($mesg)) print $mesg; $id = $_GET["propalid"]; if ($id > 0) { - $langs->trans("PropalCard"); $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->fetch($propal->socid); @@ -164,7 +163,7 @@ if ($id > 0) /* - * Facture synthese pour rappel + * Propal synthese pour rappel */ print ''; @@ -192,7 +191,7 @@ if ($id > 0) * Ajouter une ligne de contact * Non affiché en mode modification de ligne */ - if ($_GET["action"] != 'editline' && $user->rights->facture->creer) + if ($_GET["action"] != 'editline' && $user->rights->propale->creer) { print ''; print ''; @@ -357,8 +356,8 @@ if ($id > 0) } else { - // Contrat non trouv - print "Contrat inexistant ou accés refusé"; + // Propale non trouvée + print "Propale inexistante ou accès refusé"; } } diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 0490af4b989..9087143cb66 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -53,28 +53,23 @@ $pagenext = $page + 1; // Sécurité accés client $user->getrights('facture'); -$user->getrights('propale'); -if (!$user->rights->propale->lire) accessforbidden(); -$socid=''; -if ($_GET["socid"]) { $socid=$_GET["socid"]; } -if ($user->societe_id > 0) + +if (isset($_GET["socid"])) { - $action = ''; - $socid = $user->societe_id; + $objectid=$_GET["socid"]; + $module='societe'; + $dbtable=''; } -if ($_GET['propalid'] > 0) +else if (isset($_GET["propalid"]) && $_GET["propalid"] > 0) { - $propal = new Propal($db); - $result=$propal->fetch($_GET['propalid']); - if (! $result > 0) - { - dolibarr_print_error($db,$propal->error); - exit; - } - if ($user->societe_id > 0 && $propal->socid <> $user->societe_id) - accessforbidden(); + $objectid=$_GET["propalid"]; + $module='propale'; + $dbtable='propal'; } +// Sécurité d'accès client et commerciaux +$socid = restrictedArea($user, $module, $objectid, $dbtable); + /******************************************************************************/ diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php new file mode 100644 index 00000000000..f6c018664e0 --- /dev/null +++ b/htdocs/fichinter/contact.php @@ -0,0 +1,366 @@ + + * + * 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é d'accè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 = '
'.$fichinter->error.'
'; + } +} +// 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 '
'.$langs->trans("Source").'
'; + + // Ref + print '"; + + // Customer + if ( is_null($fichinter->client) ) + $fichinter->fetch_client(); + + print ""; + print ''; + print "
'.$langs->trans("Ref").''; + print $fichinter->ref_url; + print "
".$langs->trans("Company")."'.$fichinter->client->getNomUrl(1).'
"; + + print ''; + + /* + * Lignes de contacts + */ + echo '
'; + + /* + * Ajouter une ligne de contact + * Non affiché en mode modification de ligne + */ + if ($_GET["action"] != 'editline' && $user->rights->ficheinter->creer) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var = false; + + print ''; + print ''; + print ''; + print ''; + + // Ligne ajout pour contact interne + print ""; + + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Ligne ajout pour contact externe + $var=!$var; + print ""; + + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ""; + + print ''; + } + + // Liste des contacts liés + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\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 ''; + + // Source + print ''; + + // Societe + print ''; + + // Contact + print ''; + + // Type de contact + print ''; + + // Statut + print ''; + + // Icon update et delete + print ''; + + print "\n"; + + $i ++; + } + } + print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").' 
'; + print $langs->trans("Internal"); + print ''; + print $conf->global->MAIN_INFO_SOCIETE_NOM; + print ''; + $html->select_users($user->id,'contactid'); + print ''; + $fichinter->selectTypeContact($fichinter, '', 'type','internal'); + print '
'; + print $langs->trans("External"); + print ''; + $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$fichinter->client->id; + $selectedCompany = $fichinter->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany'); + print ''; + $html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid'); + print ''; + $fichinter->selectTypeContact($fichinter, '', 'type','external'); + print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; + if ($tab[$i]['source']=='internal') print $langs->trans("Internal"); + if ($tab[$i]['source']=='external') print $langs->trans("External"); + print ''; + if ($tab[$i]['socid'] > 0) + { + print ''; + print img_object($langs->trans("ShowCompany"),"company").' '.$societe->get_nom($tab[$i]['socid']); + print ''; + } + if ($tab[$i]['socid'] < 0) + { + print $conf->global->MAIN_INFO_SOCIETE_NOM; + } + if (! $tab[$i]['socid']) + { + print ' '; + } + print ''; + if ($tab[$i]['source']=='internal') + { + print ''; + print img_object($langs->trans("ShowUser"),"user").' '.$tab[$i]['nom'].''; + } + if ($tab[$i]['source']=='external') + { + print ''; + print img_object($langs->trans("ShowContact"),"contact").' '.$tab[$i]['nom'].''; + } + print ''.$tab[$i]['libelle'].''; + // Activation desativation du contact + if ($fichinter->statut >= 0) print ''; + print $contactstatic->LibStatut($tab[$i]['status'],3); + if ($fichinter->statut >= 0) print ''; + print ''; + if ($fichinter->statut < 5 && $user->rights->ficheinter->creer) + { + print ' '; + print ''; + print img_delete(); + print ''; + } + print '
"; + } + else + { + // Fiche intervention non trouvée + print "Fiche intervention inexistante ou accès refusé"; + } +} + +$db->close(); + +llxFooter('$Date$'); +?> \ No newline at end of file diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 5d6e0532e6c..cf36c93f2f6 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -36,12 +36,12 @@ require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php"); class Fichinter extends CommonObject { var $db; - var $element='ficheinter'; + var $element='fichinter'; var $id; - var $socid; // Id client - var $client; // Objet societe client (à charger par fetch_client) + var $socid; // Id client + var $client; // Objet societe client (à charger par fetch_client) var $author; var $ref; @@ -175,10 +175,11 @@ class Fichinter extends CommonObject $this->duree = $obj->duree; $this->ref = $obj->ref; $this->note = $obj->note; - $this->socid = $obj->fk_soc; - $this->societe_id = $obj->fk_soc; // A virer, obsolete + $this->socid = $obj->fk_soc; $this->projet_id = $obj->fk_projet; $this->statut = $obj->fk_statut; + + $this->ref_url = ''.$this->ref.''; $this->db->free($resql); return 1; diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 7552911e411..573f90e2b6c 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -3,10 +3,16 @@ Intervention=Intervention Interventions=Interventions InterventionCard=Intervention card NewIntervention=New intervention -EditIntervention=Editer intervention AddIntervention=Add intervention ListOfInterventions=List of interventions +EditIntervention=Editer intervention LastInterventions=Last %s interventions AllInterventions=All interventions CreateDaftIntervention=Create draft -CustomerDoesNotHavePrefix=Customer does not have a prefix \ No newline at end of file +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 \ No newline at end of file diff --git a/htdocs/langs/fr_FR/interventions.lang b/htdocs/langs/fr_FR/interventions.lang index 03e9b19cd8e..be43d1fab64 100644 --- a/htdocs/langs/fr_FR/interventions.lang +++ b/htdocs/langs/fr_FR/interventions.lang @@ -9,4 +9,10 @@ EditIntervention=Editer LastInterventions=Les %s dernières interventions AllInterventions=Toutes les interventions CreateDaftIntervention=Créer brouillon -CustomerDoesNotHavePrefix=Le client n'a pas de préfixe de défini \ No newline at end of file +CustomerDoesNotHavePrefix=Le client n'a pas de pré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 \ No newline at end of file diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php index 09d7b4726e7..b1b9f2147f1 100644 --- a/htdocs/lib/fichinter.lib.php +++ b/htdocs/lib/fichinter.lib.php @@ -38,13 +38,15 @@ function fichinter_prepare_head($fichinter) $h = 0; $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][2] = 'card'; - $h++; - } + $head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$fichinter->id; + $head[$h][1] = $langs->trans("Card"); + $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; } diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 786d457fe0f..07c6c029b8f 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -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 (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 diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 53dc8ad5b03..8251c495440 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -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_tarif_client ADD FOREIGN KEY (fk_client) REFERENCES llx_societe (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); \ No newline at end of file