How to add columns in credit view - AwoRewards


  • Default avatar
    benjamin2    
     10 years ago
    0

    Hello,

    I want to add columns on credit view.

    The first one will display the friends' usernames. So I've tried alone.
    I've edited the /components/com_aworewards/views/credit/tmpl/default.php file, I've added 2 lines that I've found in /components/com_aworewards/views/referral/tmpl/default.php file. This one : th class="sectiontableheader">
    <?php
     
    echo JHTML::_('grid.sort''COM_AWOREWARDS_USERNAME''u2.username'$this->lists['order_Dir'], $this->lists['order'] ); 
    ?>

    and this one :
    <?php
     
    echo $row->r_username
    ?>
     
    Ok so now I've a new column named "username" but it's empty.
    I've certainly something more to do but I can't find. Could you help me please.

    The second column that I need must display the date when the sponsors have used the coupon. Do you think it's possible ?

    Thanks
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    In order to display the referral, you would have to query for it. The sql for the credit screen can be found in
    www/administrator/components/com_aworewards/helpers/estore/hikashop/helper.php
    function sqlCredit

    You would need to left join , something like this
    LEFT JOIN #__users u2 ON u2.id=h.referral_id


    And add u2.username as r_username in the select, then it should work.

    For the second column, the usage of coupons in awocoupon is stored in #__awocoupon_history. So you can query for it there, but remember coupons can generally be used more than once. So if this is the case with the coupons, then you would have to account for it.
  • Default avatar
    benjamin2    
     10 years ago
    0

    Hello,

    I'm not able to make it working. I've tried to put your code like this :
    static function sqlCredit($where,$orderby) {
    $sql = 'SELECT h.*,u.username,c.coupon_code,r.rule_name,CONCAT(o.order_id," (",o.order_number,")") AS order_number,r.id AS rrule_id,p.amount_paid,u2.username AS r_username
    FROM #__aworewards h
    JOIN #__users u ON u.id=h.user_id
    LEFT JOIN #__aworewards_rule r ON r.id=h.rule_id AND r.estore=h.estore
    LEFT JOIN #__awocoupon c ON c.id=h.coupon_id AND c.estore=h.estore
    LEFT JOIN #__hikashop_order o ON o.order_id=h.item_id AND h.rule_type="order"
    LEFT JOIN #__aworewards_payment p ON p.id=h.payment_id
    LEFT JOIN #__users u2 ON u2.id=h.referral_id
    WHERE h.estore="hikashop"
    '. $where.'
    '.$orderby;
    return $sql;
    I probably don't put your code on the right place.
    Could you help me please ?
  • Your avatar
    seyi    
     10 years ago
    0

    Actually looking at it, that will give you the sponsor's user name if the friend was receiving the discount.


    To get the friend, if the sponsor is receiving the discount, and if it is an order, then something like this:
    LEFT JOIN #__hikashop_user hu2 ON hu2.user_id=o.order_user_id
    LEFT JOIN #__users u2 ON u2.id=hu2.user_cms_id

  • Default avatar
    benjamin2    
     10 years ago
    0

    Hello,

    Ok it works perfectly.Thanks.
    Do you think you can give me the same code with #__awocoupon_history, I want to know when the coupon is used by the sponsor ?
    regards,
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    You can join by the history table
    LEFT JOIN #__awocoupon_history hh ON hh.coupon_id=c.id


    And then call hh.timestamp in the select part
  • Default avatar
    benjamin2    
     10 years ago
    0

    Hello,

    It doesn't work, I put your code like this :
    static function sqlCredit($where,$orderby) { 
            $sql = 'SELECT h.*,u.username,c.coupon_code,r.rule_name,CONCAT(o.order_id," (",o.order_number,")") AS order_number,r.id AS rrule_id,p.amount_paid,u2.username AS r_username,hh.timestamp
                      FROM #__aworewards h
                      JOIN #__users u ON u.id=h.user_id
                      LEFT JOIN #__aworewards_rule r ON r.id=h.rule_id AND r.estore=h.estore
                      LEFT JOIN #__awocoupon c ON c.id=h.coupon_id AND c.estore=h.estore
                      LEFT JOIN #__hikashop_order o ON o.order_id=h.item_id AND h.rule_type="order"
                      LEFT JOIN #__aworewards_payment p ON p.id=h.payment_id
                      LEFT JOIN #__hikashop_user hu2 ON hu2.user_id=o.order_user_id
                      LEFT JOIN #__users u2 ON u2.id=hu2.user_cms_id
                      LEFT JOIN #__awocoupon_history hh ON hh.coupon_id=c.id
                     WHERE h.estore="hikashop"
                    '. $where.' 
                    '.$orderby;
            return $sql;


    And I have added in /components/com_aworewards/views/credit/tmpl/default.php file the 2 lines that I've found in /administrator/components/com_awocoupon/views/history
    This one :
    <th class="title"><?php echo JHTML::_('grid.sort''COM_AWOCOUPON_RPT_ORDER_DATE''_created_on'$this->lists['order_Dir'], $this->lists['order'] ); ?></th>

    and this one
    <td align="center"><?php echo !empty($row->_created_on) ? date('Y-m-d',strtotime($row->_created_on)) : ' '?></td>


    Do you think it's correct ?
  • Your avatar
    seyi    
     10 years ago
    0

    You will need to display row->timestamp, not row->created_on.
  • Default avatar
    benjamin2    
     10 years ago
    0

    Thank you, it works perfectly
  • Default avatar
    benjamin2    
     9 years ago
    0

    Hello,

    I've found a bug, the order date display 01/01/1970 and when the sponsor use the coupon, it display the right date (I'm not really sure I don't try it on few days).
    I've a table with 2 columns that displaying dates : one is the referral's order date and the other is when the coupon is used by the sponsor.
    Maybe a conflict between these 2 columns.

    Thanks for your help.
  • Default avatar
    benjamin2    
     9 years ago
    0

    I've tried with my demo website and it display the date when the coupon is used in both columns.
    Could you help me please
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    Yes there are 2 timestamp columns in the sql. Change ",hh.timestamp" to ",hh.timestamp AS coupon_use_date"

    Then on the template page for the coupon date column, use $row->coupon_use_date instead of $row->timestamp
  • Default avatar
    benjamin2    
     9 years ago
    0

    Hello,
    It's ok, it works.
    Thank you Seyi