accountancysystem.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/accountancy/class/accountancysystem.class.php
  19. * \ingroup accounting
  20. * \brief File of class to manage accountancy systems
  21. */
  22. /** \class AccountancySystem
  23. * \brief Classe to manage accountancy systems
  24. */
  25. class AccountancySystem
  26. {
  27. var $db;
  28. var $error;
  29. var $rowid;
  30. var $fk_pcg_version;
  31. var $pcg_type;
  32. var $pcg_subtype;
  33. var $label;
  34. var $account_number;
  35. var $account_parent;
  36. /**
  37. * \brief Constructor of class
  38. * \param DB Database handler
  39. * \param id Id compte (0 by default)
  40. */
  41. function AccountancySystem($DB, $id=0)
  42. {
  43. $this->db = $DB;
  44. $this->id = $id ;
  45. }
  46. /**
  47. * \brief Insert accountancy system name into database
  48. * \param user User making insert
  49. * \return int <0 if KO, Id of line if OK
  50. */
  51. function create($user)
  52. {
  53. $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingsystem";
  54. $sql.= " (date_creation, fk_user_author, numero,intitule)";
  55. $sql.= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')";
  56. $resql = $this->db->query($sql);
  57. if ($resql)
  58. {
  59. $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingsystem");
  60. if ($id > 0)
  61. {
  62. $this->id = $id;
  63. $result = $this->id;
  64. }
  65. else
  66. {
  67. $result = -2;
  68. $this->error="AccountancySystem::Create Erreur $result";
  69. dol_syslog($this->error, LOG_ERR);
  70. }
  71. }
  72. else
  73. {
  74. $result = -1;
  75. $this->error="AccountancySystem::Create Erreur $result";
  76. dol_syslog($this->error, LOG_ERR);
  77. }
  78. return $result;
  79. }
  80. }
  81. ?>