<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LoadJobsCommand
 *
 * @author TruongLD
 */

namespace Vietland\StoreBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use JMS\JobQueueBundle\Entity\Job;
use Symfony\Component\Console\Input\InputOption;
use Vietland\UserBundle\Document\UserLog;
use Vietland\StoreBundle\Document\Jobqueue;
use Symfony\Component\Process\Process;

class LoadJobsCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('crm:loadbill')
             ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path script')
             ->setDescription('Process the bill');
    }

    protected function processCommand($path)
    {
        $dm = $this->getContainer()->get('doctrine_mongodb')->getManager();
        $jobs = $dm->createQueryBuilder('VietlandStoreBundle:Jobqueue')
                ->field('status')->notEqual(true)
                ->sort('_id', 'asc')
                ->getQuery()
                ->execute();
        // find user status is disabled
        $users = $dm->getRepository('VietlandUserBundle:User')->findBy(array('status' => false));
        $list_userid = array();

        //send monthly birthday email
        // $now = new \DateTime(date('Y-m-d'));
        // $current_date = $now->format('Y-m-d');

        //     $month = date("m",strtotime($current_date ));
        //     $start = new \DateTime("".$month."/01/2015");
        //     $end = new \DateTime("".$month."/31/2015");

        // //var_dump($start);

        //         $function = "function() { var dob = this.dob, start = new Date('" . $start->format('Y-m-d') . "'), end = new Date('" . $end->format('Y-m-d') . ' 23:59:59' . "'), rt = false;
        //         if(typeof this.dob != 'undefined'){
        //             dob.setFullYear('" . $start->format('Y') . "');
        //             if(start.getTime() <= dob.getTime() && dob.getTime() <= end.getTime()) rt = true;
        //         };
        //         return rt;
        //         }";
        // $usersDOB = $dm->createQueryBuilder('VietlandUserBundle:User')->field('dob')->exists(true)->where($function)->sort('id', 'desc')->getQuery()->execute();
        //         //$num = count($usersDOB);
        //         //var_dump($num);
        
        // foreach($usersDOB as $user){
        //     $test= $this->addSubToDisableEnableList($user->getEmail(),$user->getFirstname(),$user->getMiddlename(),$user->getLastname(),$user->getPoint(),$user->getLevel(),$user->getNextLevel(),$user->getDob());
        // }
        // end send monthly email
        
        //send birthday email
        $now = new \DateTime(date('Y-m-d'));
        $current_date = $now->format('Y-m-d');

        $month = date("m",strtotime($current_date ));
        $day = date("d",strtotime($current_date )) + 1;
        //$bday = new \DateTime("".$month."/".$day."/2015");
        //     $end = new \DateTime("".$month."/31/2015");
        //var_dump($current_date);
          
        $function = "function() { var dob = this.dob, day=".$day.", month= ".$month." , rt = false;
        if(typeof this.dob != 'undefined'){

            
            if( day == dob.getDate() && month == (dob.getMonth() + 1) ) rt = true;
        };
        return rt;
        }";
        $usersBirthDay = $dm->createQueryBuilder('VietlandUserBundle:User')->field('dob')->exists(true)->where($function)->sort('id', 'desc')->getQuery()->execute();

        
        foreach($usersBirthDay as $user){
            $test= $this->addSubToBirthDayList($user->getEmail(),$user->getName(),$user->getDob());
             // var_dump($test);
             //    die();  
        }
                //         $num = count($usersBirthDay);
                // var_dump($num);
                // die();  
        //end birthday email
        
        if(!empty($users)){<commit_msg>add new filter sending email for tbf<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LoadJobsCommand
 *
 * @author TruongLD
 */

namespace Vietland\StoreBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use JMS\JobQueueBundle\Entity\Job;
use Symfony\Component\Console\Input\InputOption;
use Vietland\UserBundle\Document\UserLog;
use Vietland\StoreBundle\Document\Jobqueue;
use Symfony\Component\Process\Process;

class LoadJobsCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('crm:loadbill')
             ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path script')
             ->setDescription('Process the bill');
    }

    protected function processCommand($path)
    {
        $dm = $this->getContainer()->get('doctrine_mongodb')->getManager();
        $jobs = $dm->createQueryBuilder('VietlandStoreBundle:Jobqueue')
                ->field('status')->notEqual(true)
                ->sort('_id', 'asc')
                ->getQuery()
                ->execute();
        // find user status is disabled
        $users = $dm->getRepository('VietlandUserBundle:User')->findBy(array('status' => false));
        $list_userid = array();

        //send monthly birthday email
        // $now = new \DateTime(date('Y-m-d'));
        // $current_date = $now->format('Y-m-d');

        //     $month = date("m",strtotime($current_date ));
        //     $start = new \DateTime("".$month."/01/2015");
        //     $end = new \DateTime("".$month."/31/2015");

        // //var_dump($start);

        //         $function = "function() { var dob = this.dob, start = new Date('" . $start->format('Y-m-d') . "'), end = new Date('" . $end->format('Y-m-d') . ' 23:59:59' . "'), rt = false;
        //         if(typeof this.dob != 'undefined'){
        //             dob.setFullYear('" . $start->format('Y') . "');
        //             if(start.getTime() <= dob.getTime() && dob.getTime() <= end.getTime()) rt = true;
        //         };
        //         return rt;
        //         }";
        // $usersDOB = $dm->createQueryBuilder('VietlandUserBundle:User')->field('dob')->exists(true)->where($function)->sort('id', 'desc')->getQuery()->execute();
        //         //$num = count($usersDOB);
        //         //var_dump($num);
        
        // foreach($usersDOB as $user){
        //     $test= $this->addSubToDisableEnableList($user->getEmail(),$user->getFirstname(),$user->getMiddlename(),$user->getLastname(),$user->getPoint(),$user->getLevel(),$user->getNextLevel(),$user->getDob());
        // }
        // end send monthly email
        
        //send birthday email
        $now = new \DateTime(date('Y-m-d'));
        $current_date = $now->format('Y-m-d');

        $month = date("m",strtotime($current_date ));
        $day = date("d",strtotime($current_date )) + 1;
        //$bday = new \DateTime("".$month."/".$day."/2015");
        //     $end = new \DateTime("".$month."/31/2015");
        //var_dump($current_date);
          
        $function = "function() { var dob = this.dob, day=".$day.", month= ".$month." , rt = false;
        if(typeof this.dob != 'undefined'){

            
            if( day == dob.getDate() && month == (dob.getMonth() + 1) ) rt = true;
        };
        return rt;
        }";
        $usersBirthDay = $dm->createQueryBuilder('VietlandUserBundle:User')->field('dob')->exists(true)->where($function)->sort('id', 'desc')->getQuery()->execute();

        
        foreach($usersBirthDay as $user){
            
            $email = $user->getEmail();
            if(strpos($email,'<EMAIL>') == false){
                $test= $this->addSubToBirthDayList($user->getEmail(),$user->getName(),$user->getDob());
            }
             // var_dump($test);
             //    die();  
        }
                //         $num = count($usersBirthDay);
                // var_dump($num);
                // die();  
        //end birthday email
        
        if(!empty($users)){
{'fraction_non_alphanumeric': 0.18760938046902345, 'fraction_numerical': 0.007000350017500875, 'mean_word_length': 2.2249811888638074, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2008614', 'n_tokens_mistral': 2628, 'n_tokens_neox': 2544, 'n_words': 435}