facturestatcommon.class.php 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class FactureStatCommon
  3. {
  4. public $db;
  5. const HUF = 'HUF';
  6. const EUR = 'EUR';
  7. const CASH = 'LIQ';
  8. const CARD = 'CB';
  9. /**
  10. *
  11. */
  12. public function __construct()
  13. {
  14. global $db;
  15. $this->db = $db;
  16. }
  17. /**
  18. * Generate entity SQL condition to query from facture table
  19. *
  20. * @param int $entity Entity ID
  21. *
  22. * @return string SQL condition
  23. */
  24. public function getEntitySql(int $entity): string
  25. {
  26. return ($entity > 0) ? " AND f.entity={$entity}" : '';
  27. }
  28. /**
  29. * Generate facture payment mode SQL condition
  30. */
  31. public function getPaymentCodeSql(string $paymentCode): string
  32. {
  33. return "
  34. AND f.fk_mode_reglement=(
  35. SELECT p.id
  36. FROM ".MAIN_DB_PREFIX."c_paiement AS p
  37. WHERE p.entity=f.entity
  38. AND p.code ILIKE '{$paymentCode}'
  39. AND p.active=1
  40. ) ";
  41. }
  42. }