ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilPaymentCoupons Class Reference
+ Collaboration diagram for ilPaymentCoupons:

Public Member Functions

 __construct ($user_obj, $a_vendor_view=false)
 
 getCoupons ()
 
 setId ($a_id)
 
 getId ()
 
 setCouponUser ($a_user_id)
 
 getCouponUser ()
 
 setTitle ($a_title)
 
 getTitle ()
 
 setDescription ($a_description)
 
 getDescription ()
 
 setType ($a_type)
 
 getType ()
 
 setValue ($a_value)
 
 getValue ()
 
 setFromDate ($a_from)
 
 getFromDate ()
 
 setTillDate ($a_till)
 
 getTillDate ()
 
 setFromDateEnabled ($a_from_date_enabled=0)
 
 getFromDateEnabled ()
 
 setTillDateEnabled ($a_till_date_enabled=0)
 
 getTillDateEnabled ()
 
 setChangeDate ($a_date)
 
 getChangeDate ()
 
 setUses ($a_uses)
 
 getUses ()
 
 setSearchTitleType ($a_title_type)
 
 getSearchTitleType ()
 
 setSearchTitleValue ($a_title_value)
 
 getSearchTitleValue ()
 
 setSearchType ($a_type)
 
 getSearchType ()
 
 setSearchFromDay ($a_day)
 
 getSearchFromDay ()
 
 setSearchFromMonth ($a_month)
 
 getSearchFromMonth ()
 
 setSearchFromYear ($a_year)
 
 getSearchFromYear ()
 
 setSearchTillDay ($a_day)
 
 getSearchTillDay ()
 
 setSearchTillMonth ($a_month)
 
 getSearchTillMonth ()
 
 setSearchTillYear ($a_year)
 
 getSearchTillYear ()
 
 setSearchFromDateEnabled ($a_from_enabled)
 
 getSearchFromDateEnabled ()
 
 setSearchTillDateEnabled ($a_till_enabled)
 
 getSearchTillDateEnabled ()
 
 setCurrentCoupon ($coupon=array())
 
 getCurrentCoupon ()
 
 add ()
 
 update ()
 
 delete ()
 
 getCouponById ($a_coupon_id)
 
 getCouponBonus ($a_item_price)
 
 getObjectsByCouponId ($a_coupon_id)
 
 getCodesByCouponId ($a_coupon_id)
 
 getUsedCouponsByCouponId ($a_coupon_id)
 
 getCouponByCode ($a_coupon_code)
 
 checkCouponValidity ()
 
 deleteCode ($a_code_id)
 
 deleteAllCodesByCouponId ($a_coupon_id)
 
 getCode ($a_code_id)
 
 addCode ($a_code, $a_coupon_id)
 
 addCouponForBookingId ($a_booking_id)
 
 addTracking ()
 
 isObjectAssignedToCoupon ($a_ref_id)
 Checks if an object is assigned to the current coupon. More...
 
 assignObjectToCoupon ($a_ref_id)
 Assigns an object to the current coupon. More...
 
 unassignObjectFromCoupon ($a_ref_id)
 Unassigns an object from the current coupon. More...
 
 deleteCouponByCouponId ($a_pc_pk)
 deletes all coupon relevant data and tracking More...
 

Static Public Member Functions

static _lookupTitle ($a_coupon_id)
 

Private Member Functions

 getVendorIds ()
 

Private Attributes

 $db = null
 
 $user_obj = null
 
 $vendor_view = false
 
 $coupons = array()
 
 $current_coupon = array()
 
 $codes = array()
 
 $used_codes = array()
 
 $objects = array()
 
 $id = null
 
 $coupon_user = null
 
 $title = null
 
 $description = null
 
 $type = null
 
 $value = null
 
 $from = null
 
 $till = null
 
 $from_date_enabled = null
 
 $till_date_enabled = null
 
 $change_date = null
 
 $uses = null
 
 $search_title_type = null
 
 $search_title_value = null
 
 $search_type = null
 
 $search_from_day = null
 
 $search_from_month = null
 
 $search_from_year = null
 
 $search_till_day = null
 
 $search_till_month = null
 
 $search_till_year = null
 
 $search_from_enabled = null
 
 $search_till_enabled = null
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 14 of file class.ilPaymentCoupons.php.

Constructor & Destructor Documentation

◆ __construct()

ilPaymentCoupons::__construct (   $user_obj,
  $a_vendor_view = false 
)

Definition at line 53 of file class.ilPaymentCoupons.php.

54 {
55 global $ilDB;
56
57 $this->db = $ilDB;
58 $this->vendor_view = $a_vendor_view;
59 $this->user_obj = $user_obj;
60
61 $this->COUPON_VALID = 0;
62 $this->COUPON_OUT_OF_DATE = 1;
63 $this->COUPON_TOO_MUCH_USED = 2;
64 $this->COUPON_NOT_FOUND = 3;
65 }
global $ilDB

References $ilDB, and $user_obj.

Member Function Documentation

◆ _lookupTitle()

static ilPaymentCoupons::_lookupTitle (   $a_coupon_id)
static

Definition at line 940 of file class.ilPaymentCoupons.php.

941 {
942 global $ilDB;
943
944 $res = $ilDB->queryF('SELECT pc_title FROM payment_coupons WHERE pc_pk = %s',
945 array('integer'), array($a_coupon_id));
946
947 $row = $ilDB->fetchAssoc($res);
948 return $row['pc_title'];
949 }

References $ilDB, $res, and $row.

Referenced by ilPaymentCouponGUI\deleteCoupon().

+ Here is the caller graph for this function:

◆ add()

ilPaymentCoupons::add ( )

Definition at line 421 of file class.ilPaymentCoupons.php.

422 {
423 $next_id = $this->db->nextId('payment_coupons');
424
425 $statement = $this->db->manipulateF('
426 INSERT INTO payment_coupons
427 ( pc_pk,
428 usr_id,
429 pc_title,
430 pc_description,
431 pc_type,
432 pc_value,
433 pc_from,
434 pc_till,
435 pc_from_enabled,
436 pc_till_enabled,
437 pc_uses,
438 pc_last_change_usr_id,
439 pc_last_changed
440 )
441 VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
442 array( 'integer',
443 'integer',
444 'text',
445 'text',
446 'text',
447 'float',
448 'date',
449 'date',
450 'integer',
451 'integer',
452 'integer',
453 'integer',
454 'timestamp'),
455 array( $next_id,
456 $this->getCouponUser(),
457 $this->getTitle(),
458 $this->getDescription(),
459 $this->getType(),
460 $this->getValue(),
461 $this->getFromDate(),
462 $this->getTillDate(),
463 $this->getFromDateEnabled(),
464 $this->getTillDateEnabled(),
465 $this->getUses(),
466 $this->getCouponUser(),
467 $this->getChangeDate() )
468 );
469
470 return $next_id;
471 }

References getChangeDate(), getCouponUser(), getDescription(), getFromDate(), getFromDateEnabled(), getTillDate(), getTillDateEnabled(), getTitle(), getType(), getUses(), and getValue().

+ Here is the call graph for this function:

◆ addCode()

ilPaymentCoupons::addCode (   $a_code,
  $a_coupon_id 
)

Definition at line 765 of file class.ilPaymentCoupons.php.

766 {
767 if ($a_code && $a_coupon_id)
768 {
769 $next_id = $this->db->nextId('payment_coupons_codes');
770 $statement = $this->db->manipulateF('
771 INSERT INTO payment_coupons_codes
772 ( pcc_pk,
773 pcc_pc_fk,
774 pcc_code
775 )
776 VALUES (%s,%s,%s)',
777 array('integer','integer', 'text'),
778 array($next_id, $a_coupon_id, $a_code));
779
780 return $next_id;
781 }
782 return false;
783 }

◆ addCouponForBookingId()

ilPaymentCoupons::addCouponForBookingId (   $a_booking_id)

Definition at line 785 of file class.ilPaymentCoupons.php.

786 {
788
789 if ($a_booking_id && is_array($current_coupon))
790 {
791 $statement = $this->db->manipulateF('
792 INSERT INTO payment_statistic_coup
793 ( psc_ps_fk,
794 psc_pc_fk,
795 psc_pcc_fk
796 ) VALUES(%s,%s,%s)',
797 array('integer', 'integer', 'integer'),
798 array($a_booking_id, $current_coupon['pc_pk'], $current_coupon['pcc_pk']));
799 }
800 return false;
801 }

References $current_coupon, and getCurrentCoupon().

+ Here is the call graph for this function:

◆ addTracking()

ilPaymentCoupons::addTracking ( )

Definition at line 803 of file class.ilPaymentCoupons.php.

804 {
806
807 if (is_array($current_coupon))
808 {
809 $next_id = $this->db->nextId('payment_coupons_track');
810 $statement = $this->db->manipulateF('
811 INSERT INTO payment_coupons_track
812 ( pct_pk,
813 pct_pcc_fk ,
814 usr_id,
815 pct_date
816 )
817 VALUES (%s, %s, %s, %s)',
818 array('integer','integer', 'integer', 'timestamp'),
819 array($next_id, $current_coupon['pcc_pk'], $this->user_obj->getId(), date("Y-m-d H:i:s")));
820
821 return $next_id;
822 }
823 return false;
824 }

References $current_coupon, and getCurrentCoupon().

+ Here is the call graph for this function:

◆ assignObjectToCoupon()

ilPaymentCoupons::assignObjectToCoupon (   $a_ref_id)

Assigns an object to the current coupon.

@access public

Returns
bool

Definition at line 856 of file class.ilPaymentCoupons.php.

857 {
858 if ($a_ref_id && is_numeric($this->getId()))
859 {
860 $statement = $this->db->manipulateF('
861 INSERT INTO payment_coupons_obj
862 ( pco_pc_fk,
863 ref_id
864 ) VALUES(%s, %s)',
865 array('integer', 'integer'),
866 array($this->getId(), $a_ref_id));
867
868 return true;
869 }
870 return false;
871 }

References getId().

+ Here is the call graph for this function:

◆ checkCouponValidity()

ilPaymentCoupons::checkCouponValidity ( )

Definition at line 672 of file class.ilPaymentCoupons.php.

673 {
674 $coupon = $this->getCurrentCoupon();
675
676 if (empty($coupon)) return $this->COUPON_NOT_FOUND;
677
678 $current_date = date("Y-m-d");
679 if ($coupon["pc_from"] != "0000-00-00" && $coupon["pc_from_enabled"] == '1' &&
680 $coupon["pc_till"] != "0000-00-00" && $coupon["pc_till_enabled"] == '1'
681 )
682 {
683 if (! ($coupon["pc_from"] <= $current_date && $current_date <= $coupon["pc_till"]))
684 {
685 return $this->COUPON_OUT_OF_DATE;
686 }
687 }
688 else if ($coupon["pc_from"] != "0000-00-00" && $coupon["pc_from_enabled"] == '1')
689 {
690 if ($coupon["pc_from"] > $current_date)
691 {
692 return $this->COUPON_OUT_OF_DATE;
693 }
694 }
695 else if ($coupon["pc_till"] != "0000-00-00" && $coupon["pc_till_enabled"] == '1')
696 {
697 if ($coupon["pc_till"] < $current_date)
698 {
699 return $this->COUPON_OUT_OF_DATE;
700 }
701 }
702
703 if (is_numeric($coupon["pc_uses"]) && $coupon["pc_uses"] > 0)
704 {
705 $res = $this->db->queryf('
706 SELECT COUNT(*) used_coupons
707 FROM payment_coupons_track
708 WHERE pct_pcc_fk = %s',
709 array('integer'),
710 array($coupon['pcc_pk']));
711
712 $row = $this->db->fetchObject($res);
713
714 if ($row->used_coupons >= $coupon["pc_uses"]) return $this->COUPON_TOO_MUCH_USED;
715 }
716
717 return $this->COUPON_VALID;
718 }

References $res, $row, and getCurrentCoupon().

+ Here is the call graph for this function:

◆ delete()

ilPaymentCoupons::delete ( )

Definition at line 522 of file class.ilPaymentCoupons.php.

523 {
524 if ($this->getId())
525 {
526 $statement = $this->db->manipulateF('
527 DELETE FROM payment_coupons WHERE pc_pk = %s',
528 array('integer'),
529 array($this->getId()));
530
531 return true;
532 }
533 return false;
534 }

References getId().

+ Here is the call graph for this function:

◆ deleteAllCodesByCouponId()

ilPaymentCoupons::deleteAllCodesByCouponId (   $a_coupon_id)

Definition at line 733 of file class.ilPaymentCoupons.php.

734 {
735 if ($a_coupon_id)
736 {
737 $statement = $this->db->manipulateF('
738 DELETE FROM payment_coupons_codes WHERE pcc_pc_fk = %s',
739 array('integer'),array($a_coupon_id));
740
741 return true;
742 }
743 return false;
744 }

◆ deleteCode()

ilPaymentCoupons::deleteCode (   $a_code_id)

Definition at line 720 of file class.ilPaymentCoupons.php.

721 {
722 if ($a_code_id)
723 {
724 $statement = $this->db->manipulateF('
725 DELETE FROM payment_coupons_codes WHERE pcc_pk = %s',
726 array('integer'), array($a_code_id));
727
728 return true;
729 }
730 return false;
731 }

◆ deleteCouponByCouponId()

ilPaymentCoupons::deleteCouponByCouponId (   $a_pc_pk)

deletes all coupon relevant data and tracking

Parameters
integer$a_pc_pk

Definition at line 899 of file class.ilPaymentCoupons.php.

900 {
901 global $ilDB;
902
903 $res = $ilDB->queryF('
904 SELECT pcc_pk
905 FROM payment_coupons_codes
906 WHERE pcc_pc_fk = %s',
907 array('integer'),array($a_pc_pk));
908
909 $code_ids = array();
910 while($row = $ilDB->fetchAssoc($res))
911 {
912 $code_ids[] = $row['pcc_pk'];
913 }
914
915 $ilDB->manipulate('
916 DELETE FROM payment_coupons_track
917 WHERE '. $ilDB->in('pct_pcc_fk', $code_ids, false, 'integer'));
918
919 $ilDB->manipulate('
920 DELETE FROM payment_statistic_coup
921 WHERE '.$ilDB->in('psc_pcc_fk', $code_ids, false, 'integer'));
922
923 $ilDB->manipulateF('
924 DELETE FROM payment_coupons
925 WHERE pc_pk = %s',
926 array('integer'),array($a_pc_pk));
927
928 $ilDB->manipulateF('
929 DELETE FROM payment_coupons_obj
930 WHERE pco_pc_fk = %s',
931 array('integer'),array($a_pc_pk));
932
933 $ilDB->manipulateF('
934 DELETE FROM payment_coupons_codes
935 WHERE pcc_pk = %s',
936 array('integer'),array($a_pc_pk));
937
938 }

References $ilDB, $res, and $row.

◆ getChangeDate()

ilPaymentCoupons::getChangeDate ( )

Definition at line 308 of file class.ilPaymentCoupons.php.

309 {
310 return $this->change_date;
311 }

References $change_date.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getCode()

ilPaymentCoupons::getCode (   $a_code_id)

Definition at line 746 of file class.ilPaymentCoupons.php.

747 {
748 $res = $this->db->queryf('
749 SELECT * FROM payment_coupons_codes
750 WHERE pcc_pk = %s',
751 array('integer'),
752 array($a_code_id));
753
754 $code = array();
755
756 while($row = $this->db->fetchObject($res))
757 {
758 $code['pcc_pk'] = $row->pcc_pk;
759 $code['pcc_pc_fk'] = $row->pcc_pc_fk;
760 $code['pcc_code'] = $row->pcc_code;
761 }
762 return $code ? $code : array();
763 }
$code
Definition: example_050.php:99

References $code, $res, and $row.

◆ getCodesByCouponId()

ilPaymentCoupons::getCodesByCouponId (   $a_coupon_id)

Definition at line 593 of file class.ilPaymentCoupons.php.

594 {
595 $this->codes = array();
596
597 $res = $this->db->queryf('
598 SELECT payment_coupons_codes.*, COUNT(pct_pcc_fk) pcc_used, pcc_pk
599 FROM payment_coupons_codes
600 LEFT JOIN payment_coupons_track ON pct_pcc_fk = pcc_pk
601 WHERE pcc_pc_fk = %s
602 GROUP BY pcc_pk, payment_coupons_codes.pcc_pc_fk ,pcc_code',
603 array('integer'),
604 array($a_coupon_id));
605
606 while($row = $this->db->fetchObject($res))
607 {
608 $this->codes[$row->pcc_pk]['pcc_pk'] = $row->pcc_pk;
609 $this->codes[$row->pcc_pk]['pcc_code'] = $row->pcc_code;
610 $this->codes[$row->pcc_pk]['pcc_used'] = $row->pcc_used;
611 }
612
613 return $this->codes;
614 }

References $codes, $res, and $row.

Referenced by getCoupons().

+ Here is the caller graph for this function:

◆ getCouponBonus()

ilPaymentCoupons::getCouponBonus (   $a_item_price)

Definition at line 559 of file class.ilPaymentCoupons.php.

560 {
561 if (is_array($coupon = $this->getCurrentCoupon()))
562 {
563 switch ($coupon["pc_type"])
564 {
565 case "fix":
566 return (float) $coupon["pc_value"];
567 case "percent":
568 return (float) $a_item_price * ($coupon["pc_value"] / 100);
569 }
570 }
571
572 return 0;
573 }

References getCurrentCoupon().

+ Here is the call graph for this function:

◆ getCouponByCode()

ilPaymentCoupons::getCouponByCode (   $a_coupon_code)

Definition at line 639 of file class.ilPaymentCoupons.php.

640 {
641 $res = $this->db->queryf('
642 SELECT * FROM payment_coupons_codes
643 INNER JOIN payment_coupons ON pc_pk = pcc_pc_fk
644 WHERE pcc_code = %s',
645 array('text'),
646 array($a_coupon_code));
647
648 $coupon = array();
649
650 if (is_object($row = $this->db->fetchObject($res)))
651 {
652 $coupon['pc_pk'] = $row->pc_pk;
653 $coupon['pc_title'] = $row->pc_title;
654 $coupon['pc_description'] = $row->pc_description;
655 $coupon['pc_type'] = $row->pc_type;
656 $coupon['pc_value'] = $row->pc_value;
657 $coupon['pc_type'] = $row->pc_type;
658 $coupon['pc_from'] = $row->pc_from;
659 $coupon['pc_till'] = $row->pc_till;
660 $coupon['pc_uses'] = $row->pc_uses;
661 $coupon['pcc_pk'] = $row->pcc_pk;
662 $coupon['pcc_code'] = $row->pcc_code;
663 $coupon['objects'] = $this->getObjectsByCouponId($row->pc_pk);
664 }
665
666 $this->setId($coupon['pc_pk']);
667 $this->setCurrentCoupon($coupon);
668
669 return $coupon ? $coupon : array();
670 }
getObjectsByCouponId($a_coupon_id)
setCurrentCoupon($coupon=array())

References $res, $row, getObjectsByCouponId(), setCurrentCoupon(), and setId().

+ Here is the call graph for this function:

◆ getCouponById()

ilPaymentCoupons::getCouponById (   $a_coupon_id)

Definition at line 536 of file class.ilPaymentCoupons.php.

537 {
538 $res = $this->db->queryf('
539 SELECT * FROM payment_coupons
540 WHERE pc_pk = %s', array('integer'), array($a_coupon_id));
541
542 while($row = $this->db->fetchObject($res))
543 {
544 $this->setId($row->pc_pk);
545 $this->setCouponUser($row->usr_id);
546 $this->setTitle($row->pc_title);
547 $this->setDescription($row->pc_description);
548 $this->setType($row->pc_type);
549 $this->setValue($row->pc_value);
550 $this->setFromDate($row->pc_from);
551 $this->setTillDate($row->pc_till);
552 $this->setFromDateEnabled($row->pc_from_enabled);
553 $this->setTillDateEnabled($row->pc_till_enabled);
554 $this->setUses($row->pc_uses);
555 $this->setChangeDate(date("Y-m-h H:i:s"));
556 }
557 }
setTillDateEnabled($a_till_date_enabled=0)
setFromDateEnabled($a_from_date_enabled=0)
setDescription($a_description)

References $res, $row, setChangeDate(), setCouponUser(), setDescription(), setFromDate(), setFromDateEnabled(), setId(), setTillDate(), setTillDateEnabled(), setTitle(), setType(), setUses(), and setValue().

+ Here is the call graph for this function:

◆ getCoupons()

ilPaymentCoupons::getCoupons ( )

Definition at line 67 of file class.ilPaymentCoupons.php.

68 {
69
70 $this->coupons = array();
71
72 $data = array();
73 $data_types = array();
74
75 $query = 'SELECT * FROM payment_coupons WHERE 1 = 1 ';
76
77 if ($_SESSION['pay_coupons']['from']['date']['d'] != '' &&
78 $_SESSION['pay_coupons']['from']['date']['m'] != '' &&
79 $_SESSION['pay_coupons']['from']['date']['y'] != '')
80 {
81
82 $from = date('Y-m-d',mktime(0, 0, 0, $_SESSION['pay_coupons']['from']['date']['m'],
83 $_SESSION['pay_coupons']['from']['date']['d'],
84 $_SESSION['pay_coupons']['from']['date']['y']));
85
86
87 $query .= 'AND pc_from >= %s ';
88 $data_types[] = 'date';
89 $data[] = $from;
90 }
91 if ($_SESSION['pay_coupons']['til']['date']['d'] != '' &&
92 $_SESSION['pay_coupons']['til']['date']['m'] != '' &&
93 $_SESSION['pay_coupons']['til']['date']['y'] != '')
94 {
95 $til = date('Y-m-d',mktime(23, 59, 59, $_SESSION['pay_coupons']['til']['date']['m'],
96 $_SESSION['pay_coupons']['til']['date']['d'],
97 $_SESSION['pay_coupons']['til']['date']['y']));
98 $query .= 'AND pc_till <= %s ';
99 $data_types[] = 'date';
100 $data[] = $til;
101 }
102
103 if ($this->getSearchTitleValue() != "")
104 {
105 if ($this->getSearchTitleType() == 0)
106 {
107 $query .= " AND pc_title LIKE %s ";
108 array_push($data, $this->getSearchTitleValue().'%');
109 array_push($data_types, 'text');
110 }
111 else if ($this->getSearchTitleType() == 1)
112 {
113 $query .= " AND pc_title LIKE %s ";
114 array_push($data, '%'.$this->getSearchTitleValue());
115 array_push($data_types,'text');
116 }
117 }
118
119 if ($this->getSearchType() != "")
120 {
121 $query .= ' AND pc_type = %s';
122 array_push($data, $this->getSearchType());
123 array_push($data_types, 'text');
124 }
125
126 $vendors = $this->getVendorIds();
127 if (is_array($vendors) &&
128 count($vendors) > 0)
129 {
130 $in = 'usr_id IN (';
131 $counter = 0;
132 foreach($vendors as $vendor)
133 {
134 array_push($data, $vendor);
135 array_push($data_types, 'integer');
136
137 if($counter > 0) $in .= ',';
138 $in .= '%s';
139 ++$counter;
140 }
141 $in .= ')';
142
143 $query .= ' AND '.$in;
144 }
145
146
147 $cnt_data = count($data);
148 $cnt_data_types = count($data_types);
149
150 if($cnt_data == 0 && $cnt_data_types == 0)
151 {
152 $res = $this->db->query($query);
153 }
154 else
155 {
156 $res= $this->db->queryf($query, $data_types, $data);
157 }
158
159 while($row = $this->db->fetchObject($res))
160 {
161 $this->coupons[$row->pc_pk]['pc_pk'] = $row->pc_pk;
162 $this->coupons[$row->pc_pk]['usr_id'] = $row->usr_id;
163 $this->coupons[$row->pc_pk]['pc_title'] = $row->pc_title;
164 $this->coupons[$row->pc_pk]['pc_description'] = $row->pc_description;
165 $this->coupons[$row->pc_pk]['pc_type'] = $row->pc_type;
166 $this->coupons[$row->pc_pk]['pc_value'] = $row->pc_value;
167 $this->coupons[$row->pc_pk]['pc_from'] = $row->pc_from;
168 $this->coupons[$row->pc_pk]['pc_till'] = $row->pc_till;
169 $this->coupons[$row->pc_pk]['pc_from_enabled'] = $row->pc_from_enabled;
170 $this->coupons[$row->pc_pk]['pc_till_enabled'] = $row->pc_till_enabled;
171 $this->coupons[$row->pc_pk]['pc_uses'] = $row->pc_uses;
172 $this->coupons[$row->pc_pk]['pc_last_change_usr_id'] = $row->pc_last_change_usr_id;
173 $this->coupons[$row->pc_pk]['pc_last_changed'] = $row->pc_last_changed;
174 $this->coupons[$row->pc_pk]['number_of_codes'] = count($this->getCodesByCouponId($row->pc_pk));
175 $this->coupons[$row->pc_pk]['usage_of_codes'] = count($this->getUsedCouponsByCouponId($row->pc_pk));
176 $this->coupons[$row->pc_pk]['objects'] = $this->getObjectsByCouponId($row->pc_pk);
177 }
178
179 return $this->coupons;
180 }
$_SESSION["AccountId"]
getUsedCouponsByCouponId($a_coupon_id)
getCodesByCouponId($a_coupon_id)
$data

References $_SESSION, $coupons, $data, $from, $in, $query, $res, $row, getCodesByCouponId(), getObjectsByCouponId(), getSearchTitleType(), getSearchTitleValue(), getSearchType(), getUsedCouponsByCouponId(), and getVendorIds().

+ Here is the call graph for this function:

◆ getCouponUser()

ilPaymentCoupons::getCouponUser ( )

Definition at line 231 of file class.ilPaymentCoupons.php.

232 {
233 return $this->coupon_user;
234 }

References $coupon_user.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getCurrentCoupon()

ilPaymentCoupons::getCurrentCoupon ( )

Definition at line 416 of file class.ilPaymentCoupons.php.

417 {
419 }

References $current_coupon.

Referenced by addCouponForBookingId(), addTracking(), checkCouponValidity(), and getCouponBonus().

+ Here is the caller graph for this function:

◆ getDescription()

ilPaymentCoupons::getDescription ( )

Definition at line 247 of file class.ilPaymentCoupons.php.

248 {
249 return $this->description;
250 }

References $description.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getFromDate()

ilPaymentCoupons::getFromDate ( )

Definition at line 271 of file class.ilPaymentCoupons.php.

272 {
273 return $this->from;
274 }

References $from.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getFromDateEnabled()

ilPaymentCoupons::getFromDateEnabled ( )

Definition at line 288 of file class.ilPaymentCoupons.php.

References $from_date_enabled.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilPaymentCoupons::getId ( )

Definition at line 223 of file class.ilPaymentCoupons.php.

224 {
225 return $this->id;
226 }

References $id.

Referenced by assignObjectToCoupon(), delete(), isObjectAssignedToCoupon(), unassignObjectFromCoupon(), and update().

+ Here is the caller graph for this function:

◆ getObjectsByCouponId()

ilPaymentCoupons::getObjectsByCouponId (   $a_coupon_id)

Definition at line 575 of file class.ilPaymentCoupons.php.

576 {
577 $this->objects = array();
578
579 $res = $this->db->queryf('
580 SELECT * FROM payment_coupons_obj
581 WHERE pco_pc_fk = %s',
582 array('integer'),
583 array($a_coupon_id));
584
585 while($row = $this->db->fetchObject($res))
586 {
587 $this->objects[] = $row->ref_id;
588 }
589
590 return $this->objects;
591 }

References $objects, $res, and $row.

Referenced by getCouponByCode(), and getCoupons().

+ Here is the caller graph for this function:

◆ getSearchFromDateEnabled()

ilPaymentCoupons::getSearchFromDateEnabled ( )

Definition at line 399 of file class.ilPaymentCoupons.php.

References $search_from_enabled.

◆ getSearchFromDay()

ilPaymentCoupons::getSearchFromDay ( )

Definition at line 350 of file class.ilPaymentCoupons.php.

References $search_from_day.

◆ getSearchFromMonth()

ilPaymentCoupons::getSearchFromMonth ( )

Definition at line 359 of file class.ilPaymentCoupons.php.

References $search_from_month.

◆ getSearchFromYear()

ilPaymentCoupons::getSearchFromYear ( )

Definition at line 367 of file class.ilPaymentCoupons.php.

References $search_from_year.

◆ getSearchTillDateEnabled()

ilPaymentCoupons::getSearchTillDateEnabled ( )

Definition at line 407 of file class.ilPaymentCoupons.php.

References $search_till_enabled.

◆ getSearchTillDay()

ilPaymentCoupons::getSearchTillDay ( )

Definition at line 375 of file class.ilPaymentCoupons.php.

References $search_till_day.

◆ getSearchTillMonth()

ilPaymentCoupons::getSearchTillMonth ( )

Definition at line 383 of file class.ilPaymentCoupons.php.

References $search_till_month.

◆ getSearchTillYear()

ilPaymentCoupons::getSearchTillYear ( )

Definition at line 391 of file class.ilPaymentCoupons.php.

References $search_till_year.

◆ getSearchTitleType()

ilPaymentCoupons::getSearchTitleType ( )

Definition at line 326 of file class.ilPaymentCoupons.php.

References $search_title_type.

Referenced by getCoupons().

+ Here is the caller graph for this function:

◆ getSearchTitleValue()

ilPaymentCoupons::getSearchTitleValue ( )

Definition at line 334 of file class.ilPaymentCoupons.php.

References $search_title_value.

Referenced by getCoupons().

+ Here is the caller graph for this function:

◆ getSearchType()

ilPaymentCoupons::getSearchType ( )

Definition at line 342 of file class.ilPaymentCoupons.php.

343 {
344 return $this->search_type;
345 }

References $search_type.

Referenced by getCoupons().

+ Here is the caller graph for this function:

◆ getTillDate()

ilPaymentCoupons::getTillDate ( )

Definition at line 279 of file class.ilPaymentCoupons.php.

280 {
281 return $this->till;
282 }

References $till.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getTillDateEnabled()

ilPaymentCoupons::getTillDateEnabled ( )

Definition at line 297 of file class.ilPaymentCoupons.php.

References $till_date_enabled.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getTitle()

ilPaymentCoupons::getTitle ( )

Definition at line 239 of file class.ilPaymentCoupons.php.

240 {
241 return $this->title;
242 }

References $title.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getType()

ilPaymentCoupons::getType ( )

Definition at line 255 of file class.ilPaymentCoupons.php.

256 {
257 return $this->type;
258 }

References $type.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getUsedCouponsByCouponId()

ilPaymentCoupons::getUsedCouponsByCouponId (   $a_coupon_id)

Definition at line 616 of file class.ilPaymentCoupons.php.

617 {
618 $this->used_codes = array();
619
620 $res = $this->db->queryf('
621 SELECT * FROM payment_coupons_track
622 INNER JOIN payment_coupons_codes ON pcc_pk = pct_pcc_fk
623 WHERE pcc_pc_fk = %s',
624 array('integer'),
625 array($a_coupon_id));
626
627 while($row = $this->db->fetchObject($res))
628 {
629 $this->used_codes[$row->pct_pk]['pct_pk'] = $row->pct_pk;
630 $this->used_codes[$row->pct_pk]['pcc_code'] = $row->pcc_code;
631 $this->used_codes[$row->pct_pk]['usr_id'] = $row->usr_id;
632 $this->used_codes[$row->pct_pk]['pct_date'] = $row->pct_date;
633 $this->used_codes[$row->pct_pk]['pct_ps_fk'] = $row->pct_ps_fk;
634 }
635
636 return $this->used_codes;
637 }

References $res, $row, and $used_codes.

Referenced by getCoupons().

+ Here is the caller graph for this function:

◆ getUses()

ilPaymentCoupons::getUses ( )

Definition at line 316 of file class.ilPaymentCoupons.php.

317 {
318 return $this->uses;
319 }

References $uses.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getValue()

ilPaymentCoupons::getValue ( )

Definition at line 263 of file class.ilPaymentCoupons.php.

264 {
265 return $this->value;
266 }

References $value.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getVendorIds()

ilPaymentCoupons::getVendorIds ( )
private

Definition at line 182 of file class.ilPaymentCoupons.php.

183 {
184 $vendors[] = $this->user_obj->getId();
185 if (ilPaymentVendors::_isVendor($this->user_obj->getId()))
186 {
187 $ptObj = new ilPaymentTrustees($this->user_obj);
188
189 if ($trustees = $ptObj->getTrustees())
190 {
191 foreach ($trustees as $trustee)
192 {
193 if ((bool) $trustee["perm_coupons"])
194 {
195 $vendors[] = $trustee["trustee_id"];
196 }
197 }
198 }
199 }
200 if ($vend = ilPaymentTrustees::_getVendorsForCouponsByTrusteeId($this->user_obj->getId()))
201 {
202 foreach ($vend as $v)
203 {
204 $vendors[] = $v;
206 {
207 foreach ($trustees as $t)
208 {
209 $vendors[] = $t;
210 }
211 }
212 }
213 }
214
215 return $vendors ? $vendors : array();
216 }
static _getVendorsForCouponsByTrusteeId($a_usr_id)
static _getTrusteesForCouponsByVendorId($a_usr_id)

References $t, ilPaymentTrustees\_getTrusteesForCouponsByVendorId(), and ilPaymentTrustees\_getVendorsForCouponsByTrusteeId().

Referenced by getCoupons().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isObjectAssignedToCoupon()

ilPaymentCoupons::isObjectAssignedToCoupon (   $a_ref_id)

Checks if an object is assigned to the current coupon.

@access public

Returns
bool

Definition at line 832 of file class.ilPaymentCoupons.php.

833 {
834 if ($a_ref_id && is_numeric($this->getId()))
835 {
836 $res = $this->db->queryf('
837 SELECT * FROM payment_coupons_obj
838 WHERE ref_id = %s
839 AND pco_pc_fk = %s',
840 array('integer', 'integer'),
841 array($a_ref_id, $this->getId()));
842
843 if ($res->numRows()) return true;
844
845 return false;
846 }
847 return false;
848 }

References $res, and getId().

+ Here is the call graph for this function:

◆ setChangeDate()

ilPaymentCoupons::setChangeDate (   $a_date)

Definition at line 301 of file class.ilPaymentCoupons.php.

302 {
303 if($a_date == '0000-00-00 00:00:00')
304 $this->change_date = NULL;
305 else
306 $this->change_date = $a_date;
307 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setCouponUser()

ilPaymentCoupons::setCouponUser (   $a_user_id)

Definition at line 227 of file class.ilPaymentCoupons.php.

228 {
229 $this->coupon_user = $a_user_id;
230 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setCurrentCoupon()

ilPaymentCoupons::setCurrentCoupon (   $coupon = array())

Definition at line 412 of file class.ilPaymentCoupons.php.

413 {
414 $this->current_coupon = $coupon;
415 }

Referenced by getCouponByCode().

+ Here is the caller graph for this function:

◆ setDescription()

ilPaymentCoupons::setDescription (   $a_description)

Definition at line 243 of file class.ilPaymentCoupons.php.

244 {
245 $this->description = $a_description;
246 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setFromDate()

ilPaymentCoupons::setFromDate (   $a_from)

Definition at line 267 of file class.ilPaymentCoupons.php.

268 {
269 $this->from = $a_from;
270 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setFromDateEnabled()

ilPaymentCoupons::setFromDateEnabled (   $a_from_date_enabled = 0)

Definition at line 283 of file class.ilPaymentCoupons.php.

284 {
285 if($a_from_date_enabled == NULL) $a_from_date_enabled = 0;
286 $this->from_date_enabled = $a_from_date_enabled;
287 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setId()

ilPaymentCoupons::setId (   $a_id)

Definition at line 219 of file class.ilPaymentCoupons.php.

220 {
221 return $this->id = $a_id;
222 }

Referenced by getCouponByCode(), and getCouponById().

+ Here is the caller graph for this function:

◆ setSearchFromDateEnabled()

ilPaymentCoupons::setSearchFromDateEnabled (   $a_from_enabled)

Definition at line 395 of file class.ilPaymentCoupons.php.

396 {
397 $this->search_from_enabled = $a_from_enabled;
398 }

◆ setSearchFromDay()

ilPaymentCoupons::setSearchFromDay (   $a_day)

Definition at line 346 of file class.ilPaymentCoupons.php.

347 {
348 $this->search_from_day = $a_day;
349 }

◆ setSearchFromMonth()

ilPaymentCoupons::setSearchFromMonth (   $a_month)

Definition at line 354 of file class.ilPaymentCoupons.php.

355 {
356
357 $this->search_from_month = $a_month;
358 }

◆ setSearchFromYear()

ilPaymentCoupons::setSearchFromYear (   $a_year)

Definition at line 363 of file class.ilPaymentCoupons.php.

364 {
365 $this->search_from_year = $a_year;
366 }

◆ setSearchTillDateEnabled()

ilPaymentCoupons::setSearchTillDateEnabled (   $a_till_enabled)

Definition at line 403 of file class.ilPaymentCoupons.php.

404 {
405 $this->search_till_enabled = $a_till_enabled;
406 }

◆ setSearchTillDay()

ilPaymentCoupons::setSearchTillDay (   $a_day)

Definition at line 371 of file class.ilPaymentCoupons.php.

372 {
373 $this->search_till_day = $a_day;
374 }

◆ setSearchTillMonth()

ilPaymentCoupons::setSearchTillMonth (   $a_month)

Definition at line 379 of file class.ilPaymentCoupons.php.

380 {
381 $this->search_till_month = $a_month;
382 }

◆ setSearchTillYear()

ilPaymentCoupons::setSearchTillYear (   $a_year)

Definition at line 387 of file class.ilPaymentCoupons.php.

388 {
389 $this->search_till_year = $a_year;
390 }

◆ setSearchTitleType()

ilPaymentCoupons::setSearchTitleType (   $a_title_type)

Definition at line 322 of file class.ilPaymentCoupons.php.

323 {
324 $this->search_title_type = $a_title_type;
325 }

◆ setSearchTitleValue()

ilPaymentCoupons::setSearchTitleValue (   $a_title_value)

Definition at line 330 of file class.ilPaymentCoupons.php.

331 {
332 $this->search_title_value = $a_title_value;
333 }

◆ setSearchType()

ilPaymentCoupons::setSearchType (   $a_type)

Definition at line 338 of file class.ilPaymentCoupons.php.

339 {
340 $this->search_type = $a_type;
341 }

◆ setTillDate()

ilPaymentCoupons::setTillDate (   $a_till)

Definition at line 275 of file class.ilPaymentCoupons.php.

276 {
277 $this->till = $a_till;
278 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setTillDateEnabled()

ilPaymentCoupons::setTillDateEnabled (   $a_till_date_enabled = 0)

Definition at line 292 of file class.ilPaymentCoupons.php.

293 {
294 if($a_till_date_enabled == NULL) $a_till_date_enabled = 0;
295 $this->till_date_enabled = $a_till_date_enabled;
296 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setTitle()

ilPaymentCoupons::setTitle (   $a_title)

Definition at line 235 of file class.ilPaymentCoupons.php.

236 {
237 $this->title = $a_title;
238 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setType()

ilPaymentCoupons::setType (   $a_type)

Definition at line 251 of file class.ilPaymentCoupons.php.

252 {
253 $this->type = $a_type;
254 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setUses()

ilPaymentCoupons::setUses (   $a_uses)

Definition at line 312 of file class.ilPaymentCoupons.php.

313 {
314 $this->uses = $a_uses;
315 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ setValue()

ilPaymentCoupons::setValue (   $a_value)

Definition at line 259 of file class.ilPaymentCoupons.php.

260 {
261 $this->value = $a_value;
262 }

Referenced by getCouponById().

+ Here is the caller graph for this function:

◆ unassignObjectFromCoupon()

ilPaymentCoupons::unassignObjectFromCoupon (   $a_ref_id)

Unassigns an object from the current coupon.

@access public

Returns
bool

Definition at line 879 of file class.ilPaymentCoupons.php.

880 {
881 if ($a_ref_id && is_numeric($this->getId()))
882 {
883 $statement = $this->db->manipulateF('
884 DELETE FROM payment_coupons_obj
885 WHERE ref_id = %s
886 AND pco_pc_fk = %s',
887 array('integer', 'integer'),
888 array($a_ref_id, $this->getId()));
889
890 return true;
891 }
892 return false;
893 }

References getId().

+ Here is the call graph for this function:

◆ update()

ilPaymentCoupons::update ( )

Definition at line 473 of file class.ilPaymentCoupons.php.

474 {
475 if ($this->getId())
476 {
477 $statement = $this->db->manipulateF('
478 UPDATE payment_coupons
479 SET pc_title = %s,
480 pc_description = %s,
481 pc_type = %s,
482 pc_value = %s,
483 pc_from = %s,
484 pc_till = %s,
485 pc_from_enabled = %s,
486 pc_till_enabled = %s,
487 pc_uses = %s,
488 pc_last_change_usr_id = %s,
489 pc_last_changed = %s
490 WHERE pc_pk = %s',
491 array( 'text',
492 'text',
493 'text',
494 'float',
495 'date',
496 'date',
497 'integer',
498 'integer',
499 'integer',
500 'integer',
501 'timestamp',
502 'integer'),
503 array( $this->getTitle(),
504 $this->getDescription(),
505 $this->getType(),
506 $this->getValue(),
507 $this->getFromDate(),
508 $this->getTillDate(),
509 $this->getFromDateEnabled(),
510 $this->getTillDateEnabled(),
511 $this->getUses(),
512 $this->getCouponUser(),
513 $this->getChangeDate(),
514 $this->getId()
515 ));
516
517 return true;
518 }
519 return false;
520 }

References getChangeDate(), getCouponUser(), getDescription(), getFromDate(), getFromDateEnabled(), getId(), getTillDate(), getTillDateEnabled(), getTitle(), getType(), getUses(), and getValue().

+ Here is the call graph for this function:

Field Documentation

◆ $change_date

ilPaymentCoupons::$change_date = null
private

Definition at line 37 of file class.ilPaymentCoupons.php.

Referenced by getChangeDate().

◆ $codes

ilPaymentCoupons::$codes = array()
private

Definition at line 23 of file class.ilPaymentCoupons.php.

Referenced by getCodesByCouponId().

◆ $coupon_user

ilPaymentCoupons::$coupon_user = null
private

Definition at line 28 of file class.ilPaymentCoupons.php.

Referenced by getCouponUser().

◆ $coupons

ilPaymentCoupons::$coupons = array()
private

Definition at line 21 of file class.ilPaymentCoupons.php.

Referenced by getCoupons().

◆ $current_coupon

ilPaymentCoupons::$current_coupon = array()
private

Definition at line 22 of file class.ilPaymentCoupons.php.

Referenced by addCouponForBookingId(), addTracking(), and getCurrentCoupon().

◆ $db

ilPaymentCoupons::$db = null
private

Definition at line 16 of file class.ilPaymentCoupons.php.

◆ $description

ilPaymentCoupons::$description = null
private

Definition at line 30 of file class.ilPaymentCoupons.php.

Referenced by getDescription().

◆ $from

ilPaymentCoupons::$from = null
private

Definition at line 33 of file class.ilPaymentCoupons.php.

Referenced by getCoupons(), and getFromDate().

◆ $from_date_enabled

ilPaymentCoupons::$from_date_enabled = null
private

Definition at line 35 of file class.ilPaymentCoupons.php.

Referenced by getFromDateEnabled().

◆ $id

ilPaymentCoupons::$id = null
private

Definition at line 27 of file class.ilPaymentCoupons.php.

Referenced by getId().

◆ $objects

ilPaymentCoupons::$objects = array()
private

Definition at line 25 of file class.ilPaymentCoupons.php.

Referenced by getObjectsByCouponId().

◆ $search_from_day

ilPaymentCoupons::$search_from_day = null
private

Definition at line 42 of file class.ilPaymentCoupons.php.

Referenced by getSearchFromDay().

◆ $search_from_enabled

ilPaymentCoupons::$search_from_enabled = null
private

Definition at line 48 of file class.ilPaymentCoupons.php.

Referenced by getSearchFromDateEnabled().

◆ $search_from_month

ilPaymentCoupons::$search_from_month = null
private

Definition at line 43 of file class.ilPaymentCoupons.php.

Referenced by getSearchFromMonth().

◆ $search_from_year

ilPaymentCoupons::$search_from_year = null
private

Definition at line 44 of file class.ilPaymentCoupons.php.

Referenced by getSearchFromYear().

◆ $search_till_day

ilPaymentCoupons::$search_till_day = null
private

Definition at line 45 of file class.ilPaymentCoupons.php.

Referenced by getSearchTillDay().

◆ $search_till_enabled

ilPaymentCoupons::$search_till_enabled = null
private

Definition at line 49 of file class.ilPaymentCoupons.php.

Referenced by getSearchTillDateEnabled().

◆ $search_till_month

ilPaymentCoupons::$search_till_month = null
private

Definition at line 46 of file class.ilPaymentCoupons.php.

Referenced by getSearchTillMonth().

◆ $search_till_year

ilPaymentCoupons::$search_till_year = null
private

Definition at line 47 of file class.ilPaymentCoupons.php.

Referenced by getSearchTillYear().

◆ $search_title_type

ilPaymentCoupons::$search_title_type = null
private

Definition at line 39 of file class.ilPaymentCoupons.php.

Referenced by getSearchTitleType().

◆ $search_title_value

ilPaymentCoupons::$search_title_value = null
private

Definition at line 40 of file class.ilPaymentCoupons.php.

Referenced by getSearchTitleValue().

◆ $search_type

ilPaymentCoupons::$search_type = null
private

Definition at line 41 of file class.ilPaymentCoupons.php.

Referenced by getSearchType().

◆ $till

ilPaymentCoupons::$till = null
private

Definition at line 34 of file class.ilPaymentCoupons.php.

Referenced by getTillDate().

◆ $till_date_enabled

ilPaymentCoupons::$till_date_enabled = null
private

Definition at line 36 of file class.ilPaymentCoupons.php.

Referenced by getTillDateEnabled().

◆ $title

ilPaymentCoupons::$title = null
private

Definition at line 29 of file class.ilPaymentCoupons.php.

Referenced by getTitle().

◆ $type

ilPaymentCoupons::$type = null
private

Definition at line 31 of file class.ilPaymentCoupons.php.

Referenced by getType().

◆ $used_codes

ilPaymentCoupons::$used_codes = array()
private

Definition at line 24 of file class.ilPaymentCoupons.php.

Referenced by getUsedCouponsByCouponId().

◆ $user_obj

ilPaymentCoupons::$user_obj = null
private

Definition at line 18 of file class.ilPaymentCoupons.php.

Referenced by __construct().

◆ $uses

ilPaymentCoupons::$uses = null
private

Definition at line 38 of file class.ilPaymentCoupons.php.

Referenced by getUses().

◆ $value

ilPaymentCoupons::$value = null
private

Definition at line 32 of file class.ilPaymentCoupons.php.

Referenced by getValue().

◆ $vendor_view

ilPaymentCoupons::$vendor_view = false
private

Definition at line 19 of file class.ilPaymentCoupons.php.


The documentation for this class was generated from the following file: