PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/comm/propal/note.php

https://github.com/asterix14/dolibarr
PHP | 229 lines | 151 code | 37 blank | 41 comment | 30 complexity | 100b93bfab5f312d5845bc0e70d01c19 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/comm/propal/note.php
  22. * \ingroup propale
  23. * \brief Fiche d'information sur une proposition commerciale
  24. */
  25. require("../../main.inc.php");
  26. require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
  28. $langs->load('propal');
  29. $langs->load('compta');
  30. $langs->load('bills');
  31. $id = isset($_GET["id"])?$_GET["id"]:'';
  32. // Security check
  33. if ($user->societe_id) $socid=$user->societe_id;
  34. $result = restrictedArea($user, 'propale', $id, 'propal');
  35. /******************************************************************************/
  36. /* Actions */
  37. /******************************************************************************/
  38. if ($_POST["action"] == 'update_public' && $user->rights->propale->creer)
  39. {
  40. $propal = new Propal($db);
  41. $propal->fetch($_GET["id"]);
  42. $db->begin();
  43. $res=$propal->update_note_public($_POST["note_public"],$user);
  44. if ($res < 0)
  45. {
  46. $mesg='<div class="error">'.$propal->error.'</div>';
  47. $db->rollback();
  48. }
  49. else
  50. {
  51. $db->commit();
  52. }
  53. }
  54. if ($_POST['action'] == 'update' && $user->rights->propale->creer)
  55. {
  56. $propal = new Propal($db);
  57. $propal->fetch($_GET["id"]);
  58. $db->begin();
  59. $res=$propal->update_note($_POST["note"],$user);
  60. if ($res < 0)
  61. {
  62. $mesg='<div class="error">'.$propal->error.'</div>';
  63. $db->rollback();
  64. }
  65. else
  66. {
  67. $db->commit();
  68. }
  69. }
  70. /******************************************************************************/
  71. /* Affichage fiche */
  72. /******************************************************************************/
  73. llxHeader();
  74. $form = new Form($db);
  75. $id = $_GET["id"];
  76. $ref= $_GET["ref"];
  77. if ($id > 0 || ! empty($ref))
  78. {
  79. if ($mesg) print $mesg;
  80. $now=gmmktime();
  81. $propal = new Propal($db);
  82. if ($propal->fetch($id, $ref))
  83. {
  84. $societe = new Societe($db);
  85. if ( $societe->fetch($propal->socid) )
  86. {
  87. $head = propal_prepare_head($propal);
  88. dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal');
  89. print '<table class="border" width="100%">';
  90. $linkback="<a href=\"".DOL_URL_ROOT.'/comm/propal.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
  91. // Ref
  92. print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
  93. print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
  94. print '</td></tr>';
  95. // Ref client
  96. print '<tr><td>';
  97. print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
  98. print $langs->trans('RefCustomer').'</td><td align="left">';
  99. print '</td>';
  100. print '</tr></table>';
  101. print '</td><td colspan="3">';
  102. print $propal->ref_client;
  103. print '</td>';
  104. print '</tr>';
  105. // Customer
  106. if ( is_null($propal->client) )
  107. $propal->fetch_thirdparty();
  108. print "<tr><td>".$langs->trans("Company")."</td>";
  109. print '<td colspan="3">'.$propal->client->getNomUrl(1).'</td></tr>';
  110. // Ligne info remises tiers
  111. print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
  112. if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
  113. else print $langs->trans("CompanyHasNoRelativeDiscount");
  114. $absolute_discount=$societe->getAvailableDiscounts();
  115. print '. ';
  116. if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
  117. else print $langs->trans("CompanyHasNoAbsoluteDiscount");
  118. print '.';
  119. print '</td></tr>';
  120. // Date
  121. print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
  122. print dol_print_date($propal->date,'daytext');
  123. print '</td>';
  124. print '</tr>';
  125. // Date fin propal
  126. print '<tr>';
  127. print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
  128. if ($propal->fin_validite)
  129. {
  130. print dol_print_date($propal->fin_validite,'daytext');
  131. if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
  132. }
  133. else
  134. {
  135. print $langs->trans("Unknown");
  136. }
  137. print '</td>';
  138. print '</tr>';
  139. // Note publique
  140. print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
  141. print '<td valign="top" colspan="3">';
  142. if ($_GET["action"] == 'edit')
  143. {
  144. print '<form method="post" action="note.php?id='.$propal->id.'">';
  145. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  146. print '<input type="hidden" name="action" value="update_public">';
  147. print '<textarea name="note_public" cols="80" rows="8">'.$propal->note_public."</textarea><br>";
  148. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  149. print '</form>';
  150. }
  151. else
  152. {
  153. print ($propal->note_public?nl2br($propal->note_public):"&nbsp;");
  154. }
  155. print "</td></tr>";
  156. // Note privee
  157. if (! $user->societe_id)
  158. {
  159. print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
  160. print '<td valign="top" colspan="3">';
  161. if ($_GET["action"] == 'edit')
  162. {
  163. print '<form method="post" action="note.php?id='.$propal->id.'">';
  164. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  165. print '<input type="hidden" name="action" value="update">';
  166. print '<textarea name="note" cols="80" rows="8">'.$propal->note."</textarea><br>";
  167. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  168. print '</form>';
  169. }
  170. else
  171. {
  172. print ($propal->note?nl2br($propal->note):"&nbsp;");
  173. }
  174. print "</td></tr>";
  175. }
  176. print "</table>";
  177. print '</div>';
  178. /*
  179. * Actions
  180. */
  181. print '<div class="tabsAction">';
  182. if ($user->rights->propale->creer && $_GET['action'] <> 'edit')
  183. {
  184. print '<a class="butAction" href="note.php?id='.$propal->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
  185. }
  186. print '</div>';
  187. }
  188. }
  189. }
  190. $db->close();
  191. llxFooter();
  192. ?>