Jump to content

Display children's birthdates by month on the dashboard


Recommended Posts

Hello,

I use Prestashop 1.6.1.24.

On the account creation form, I added fields to know the names of customers'children and their dates of birth (they can enter 4 children with 4 dates of birth).
The informations are added in ps_customer table.

I would like to display on the dashboard the list of customers who have a child celebrating his or her birthday in the current month. Do you think it's possible ?

The first problem I have is that the dates of birth are registred as text in ps_customer table. Perhaps I have made something wrong in the creation of these fields :

in override/classes/customer.php, I added :
public $child1;
public $birth_child1;    
public $child2;
public $birth_child2;
public $child3;
public $birth_child3;
public $child4;
public $birth_child4;

and after :

public static $definition = array(
        'table' => 'customer',
        'primary' => 'id_customer',
        'fields' => array(
            'secure_key' =>       array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false),
            'lastname' =>          array('type' => self::TYPE_STRING, 'validate' => 'isCustomerName', 'required' => true, 'size' => 32),
            'firstname' =>          array('type' => self::TYPE_STRING, 'validate' => 'isCustomerName', 'required' => true, 'size' => 32),
            'email' =>                 array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
            'passwd' =>             array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),

I insert :

            'child1' =>                     array('type' => self::TYPE_STRING, 'required' => false, 'size' => 32),
            'birth_child1' =>          array('type' => self::TYPE_DATE, 'required' => false),
            'child2' =>                     array('type' => self::TYPE_STRING, 'required' => false, 'size' => 32),
            'birth_child2' =>           array('type' => self::TYPE_DATE, 'required' => false),
            'child3' =>                     array('type' => self::TYPE_STRING, 'required' => false, 'size' => 32),
            'birth_child3' =>          array('type' => self::TYPE_DATE, 'required' => false),
            'child4' =>                     array('type' => self::TYPE_STRING, 'required' => false, 'size' => 32),
            'birth_child4' =>          array('type' => self::TYPE_DATE, 'required' => false),

The dates of birth in ps-customer are entered with type : varchar(10) and not date.

So, I don't know how to sort these dates by month and display a table on dashboard with the dates of birth of the current month. Can you help me please ?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...