multiprix.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  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 3 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/comm/multiprix.php
  21. * \ingroup societe
  22. * \brief Onglet choix du niveau de prix
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  27. // Load translation files required by the page
  28. $langs->loadLangs(array('orders', 'companies'));
  29. $id = GETPOST('id','int');
  30. $_socid = GETPOST("id",'int');
  31. // Security check
  32. if ($user->societe_id > 0)
  33. {
  34. $_socid = $user->societe_id;
  35. }
  36. /*
  37. * Actions
  38. */
  39. if ($_POST["action"] == 'setpricelevel')
  40. {
  41. $soc = new Societe($db);
  42. $soc->fetch($id);
  43. $soc->set_price_level($_POST["price_level"],$user);
  44. header("Location: multiprix.php?id=".$id);
  45. exit;
  46. }
  47. /*
  48. * View
  49. */
  50. llxHeader();
  51. $userstatic=new User($db);
  52. if ($_socid > 0)
  53. {
  54. // On recupere les donnees societes par l'objet
  55. $objsoc = new Societe($db);
  56. $objsoc->id=$_socid;
  57. $objsoc->fetch($_socid,$to);
  58. if ($errmesg)
  59. {
  60. print '<div class="error">'.$errmesg.'</div><br>';
  61. }
  62. /*
  63. * Affichage onglets
  64. */
  65. $head = societe_prepare_head($objsoc);
  66. $tabchoice='';
  67. if ($objsoc->client == 1) $tabchoice='customer';
  68. if ($objsoc->client == 2) $tabchoice='prospect';
  69. print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
  70. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  71. print '<input type="hidden" name="action" value="setpricelevel">';
  72. dol_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company');
  73. print '<table width="100%" border="0">';
  74. print '<tr><td class="tdtop">';
  75. print '<table class="border" width="100%">';
  76. print '<tr><td colspan="2" width="25%">';
  77. print $langs->trans("PriceLevel").'</td><td colspan="2">'.$objsoc->price_level."</td></tr>";
  78. print '<tr><td colspan="2">';
  79. print $langs->trans("NewValue").'</td><td colspan="2">';
  80. print '<select name="price_level" class="flat">';
  81. for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
  82. {
  83. print '<option value="'.$i.'"' ;
  84. if($i == $objsoc->price_level)
  85. print 'selected';
  86. print '>'.$i;
  87. $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i;
  88. if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
  89. print '</option>';
  90. }
  91. print '</select>';
  92. print '</td></tr>';
  93. print "</table>";
  94. print "</td>\n";
  95. print "</td></tr>";
  96. print "</table>";
  97. dol_fiche_end();
  98. print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
  99. print "</form>";
  100. print '<br><br>';
  101. /*
  102. * List historic of multiprices
  103. */
  104. $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login";
  105. $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u";
  106. $sql .= " WHERE rc.fk_soc =". $objsoc->id;
  107. $sql .= " AND u.rowid = rc.fk_user_author";
  108. $sql .= " ORDER BY rc.datec DESC";
  109. $resql=$db->query($sql);
  110. if ($resql)
  111. {
  112. print '<table class="noborder" width="100%">';
  113. $tag = !$tag;
  114. print '<tr class="liste_titre">';
  115. print '<td>'.$langs->trans("Date").'</td>';
  116. print '<td>'.$langs->trans("PriceLevel").'</td>';
  117. print '<td align="right">'.$langs->trans("User").'</td>';
  118. print '</tr>';
  119. $i = 0 ;
  120. $num = $db->num_rows($resql);
  121. while ($i < $num )
  122. {
  123. $obj = $db->fetch_object($resql);
  124. $tag = !$tag;
  125. print '<tr '.$bc[$tag].'>';
  126. print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
  127. print '<td>'.$obj->price_level.' </td>';
  128. $userstatic->id=$obj->uid;
  129. $userstatic->lastname=$obj->login;
  130. print '<td align="right">'.$userstatic->getNomUrl(1).'</td>';
  131. print '</tr>';
  132. $i++;
  133. }
  134. $db->free($resql);
  135. print "</table>";
  136. }
  137. else
  138. {
  139. dol_print_error($db);
  140. }
  141. }
  142. // End of page
  143. llxFooter();
  144. $db->close();