PageRenderTime 74ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/fichinter/contact.php

https://github.com/zeert/dolibarr
PHP | 157 lines | 86 code | 33 blank | 38 comment | 22 complexity | 04da4cde5a2b1026850d2fc20426fd48 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
  3. * Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/fichinter/contact.php
  21. * \ingroup fichinter
  22. * \brief Onglet de gestion des contacts de fiche d'intervention
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php");
  26. require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/fichinter.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
  29. $langs->load("interventions");
  30. $langs->load("sendings");
  31. $langs->load("companies");
  32. $id = GETPOST('id','int');
  33. $ref = GETPOST('ref', 'alpha');
  34. $action = GETPOST('action','alpha');
  35. // Security check
  36. if ($user->societe_id) $socid=$user->societe_id;
  37. $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
  38. $object = new Fichinter($db);
  39. $result = $object->fetch($id,$ref);
  40. /*
  41. * Ajout d'un nouveau contact
  42. */
  43. if ($action == 'addcontact' && $user->rights->ficheinter->creer)
  44. {
  45. if ($result > 0 && $id > 0)
  46. {
  47. $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
  48. $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha'));
  49. }
  50. if ($result >= 0)
  51. {
  52. Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
  53. exit;
  54. }
  55. else
  56. {
  57. if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
  58. {
  59. $langs->load("errors");
  60. $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
  61. }
  62. else
  63. {
  64. $mesg = '<div class="error">'.$object->error.'</div>';
  65. }
  66. }
  67. }
  68. // bascule du statut d'un contact
  69. else if ($action == 'swapstatut' && $user->rights->ficheinter->creer)
  70. {
  71. $result=$object->swapContactStatus(GETPOST('ligne','int'));
  72. }
  73. // Efface un contact
  74. else if ($action == 'deletecontact' && $user->rights->ficheinter->creer)
  75. {
  76. $result = $object->delete_contact(GETPOST('lineid','int'));
  77. if ($result >= 0)
  78. {
  79. Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
  80. exit;
  81. }
  82. else {
  83. dol_print_error($db);
  84. }
  85. }
  86. /*
  87. * View
  88. */
  89. $form = new Form($db);
  90. $formcompany = new FormCompany($db);
  91. $contactstatic=new Contact($db);
  92. $userstatic=new User($db);
  93. llxHeader();
  94. // Mode vue et edition
  95. dol_htmloutput_mesg($mesg);
  96. if ($id > 0 || ! empty($ref))
  97. {
  98. $soc = new Societe($db);
  99. $soc->fetch($object->socid);
  100. $head = fichinter_prepare_head($object);
  101. dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention');
  102. /*
  103. * Fiche intervention synthese pour rappel
  104. */
  105. print '<table class="border" width="100%">';
  106. $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  107. // Ref
  108. print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
  109. print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
  110. print "</td></tr>";
  111. // Customer
  112. if ( is_null($object->client) )
  113. $object->fetch_thirdparty();
  114. print "<tr><td>".$langs->trans("Company")."</td>";
  115. print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
  116. print "</table>";
  117. print '</div>';
  118. print '<br>';
  119. // Contacts lines
  120. include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
  121. }
  122. llxFooter();
  123. $db->close();
  124. ?>