customer_and_coupon Class Reference

Recup liaison entre customer et coupon. More...

List of all members.

Public Member Functions

Public Attributes


Detailed Description

Recup liaison entre customer et coupon.

TODO Purge des coupon deja consommé par le client

Definition at line 17 of file page.customer_and_coupon.php.


Member Function Documentation

customer_and_coupon::customer_and_coupon ( customer_id  ) 

Definition at line 27 of file page.customer_and_coupon.php.

00027                                             {
00028     global $page;
00029     $this->customer_id=(int)$customer_id;
00030     $this->list_coupon=array();
00031   }

customer_and_coupon::init (  ) 

Construit objet list des customers associé à ce produits.

Parameters:
@a int id produit

ne fournis que les coupons non utilise et dont les dates corresponde, specifique au client en cours

Definition at line 39 of file page.customer_and_coupon.php.

00039                  {
00040     global $page;
00041 
00043 //     $check_user_query = tep_db_query( $sql = 'SELECT dc.coupons_description, dc.coupons_discount_amount, dc2u.coupons_id  FROM '.TABLE_DISCOUNT_COUPONS.' dc, '.TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS.' dc2u WHERE dc.coupons_id=dc2u.coupons_id and  dc2u.customers_id='.(int)$this->customer_id.' AND in_out=\'I\' AND ( coupons_date_start <= CURDATE() OR coupons_date_start IS NULL )  AND ( coupons_date_end >= CURDATE() OR coupons_date_end IS NULL ) AND  coupons_number_available < 1 ' );
00044     $check_user_query = tep_db_query( $sql = 'SELECT dc.coupons_description, dc.coupons_discount_amount, dc2u.coupons_id, dc.coupons_max_use   FROM '.TABLE_DISCOUNT_COUPONS.' dc, '.TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS.' dc2u WHERE dc.coupons_id=dc2u.coupons_id and  dc2u.customers_id='.(int)$this->customer_id.' AND in_out=\'I\'  AND coupons_number_available >= 1 AND ( coupons_date_start <= NOW() OR ( coupons_date_start IS NULL OR  coupons_date_start = \'1000-01-01 00:00:00\' ) ) AND ( coupons_date_end >= NOW() OR ( coupons_date_end IS NULL OR  coupons_date_end = \'1000-01-01 00:00:00\' ) )' );
00045 
00046     if( tep_db_num_rows( $check_user_query ) > 0 )
00047       while($v = tep_db_fetch_array( $check_user_query ) ) {
00048 
00049 
00050        $check_use_query = tep_db_query($sql = "SELECT COUNT(*) AS cnt
00051                                               FROM ".TABLE_ORDERS." AS o
00052                                               INNER JOIN ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o
00053                                                 ON dc2o.orders_id=o.orders_id
00054                                                 AND o.customers_id = '".(int)$this->customer_id."'
00055                                                 AND dc2o.coupons_id='".tep_db_input( $v['coupons_id'] )."'");
00056       $use = tep_db_fetch_array( $check_use_query );
00057       //show error message if coupons_max_use is equal to the number of times this customer has used the code
00058       if( $v['coupons_max_use'] > $use['cnt'] )  $this->list_coupon[] = $v;
00059       }
00060 
00061     return $this->list_coupon;
00062   }


Member Data Documentation

customer_and_coupon::$list_coupon

LA liste des coupon dspo pour le customer.

Definition at line 22 of file page.customer_and_coupon.php.


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