<commit_before><?php

class DRMExportDB2Task extends sfBaseTask
{

  protected function configure()
  {

    $this->addArguments(array(
        new sfCommandArgument('path', sfCommandArgument::REQUIRED, "Chemin ou générer les fichiers"),
    ));
    $this->addOptions(array(
        new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'declaration'),
        new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
        new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'default'),
        new sfCommandOption('periode_max', null, sfCommandOption::PARAMETER_REQUIRED, 'limit on a max periode', null),
        new sfCommandOption('file_origine', null, sfCommandOption::PARAMETER_REQUIRED, "fichier origine tel que généré précédemment", null),
        // add your own options here
    ));

    $this->namespace        = 'drm';
    $this->name             = 'export-db2';
    $this->briefDescription = '';
    $this->detailedDescription = <<<EOF
The [DRMExportDB2|INFO] task does things.
Call it with:

    [php symfony DRMExportDB2|INFO]
EOF;
  }

    protected function execute($arguments = array(), $options = array())
    {
        // initialize the database connection
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'])->getConnection();

        $date = date('YmdHis');
        $export = new ExportMouvementsDRMDB2();

        if (isset($options['file_origine'])) {
          $csv = file($options['file_origine']);
          return $export->setFacture($csv);
        }

        $csv = $export->export(MouvementfactureFacturationView::getInstance()->getMouvementsAll(0), $options['periode_max']);

        $noLignes = true;
        foreach($csv as $file => $lignes) {
            if(count($lignes)) {
                $noLignes = false;
                break;
            }
        }

        if($noLignes) {
            return;
        }

        $origineFilename = null;
        foreach($csv as $file => $lignes) {
            $fileName = $arguments['path']."/".$date."_".preg_replace("/.+\./", "", $file);
            file_put_contents($fileName, implode("\r\n", $lignes));
            if($file == "09.ORIGINES") {
                $origineFilename = $fileName;
            }
        }
        $export->setFacture(explode("\r\n", file_get_contents($origineFilename)));
    }
}<commit_msg>Ajout l'option de date min<commit_after><?php

class DRMExportDB2Task extends sfBaseTask
{

  protected function configure()
  {

    $this->addArguments(array(
        new sfCommandArgument('path', sfCommandArgument::REQUIRED, "Chemin ou générer les fichiers"),
    ));
    $this->addOptions(array(
        new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'declaration'),
        new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
        new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'default'),
        new sfCommandOption('periode_max', null, sfCommandOption::PARAMETER_REQUIRED, 'limit on a max periode', null),
        new sfCommandOption('periode_min', null, sfCommandOption::PARAMETER_REQUIRED, 'limit on a min periode', null),
        new sfCommandOption('file_origine', null, sfCommandOption::PARAMETER_REQUIRED, "fichier origine tel que généré précédemment", null),
        // add your own options here
    ));

    $this->namespace        = 'drm';
    $this->name             = 'export-db2';
    $this->briefDescription = '';
    $this->detailedDescription = <<<EOF
The [DRMExportDB2|INFO] task does things.
Call it with:

    [php symfony DRMExportDB2|INFO]
EOF;
  }

    protected function execute($arguments = array(), $options = array())
    {
        // initialize the database connection
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'])->getConnection();

        $date = date('YmdHis');
        $export = new ExportMouvementsDRMDB2();

        if (isset($options['file_origine'])) {
          $csv = file($options['file_origine']);
          return $export->setFacture($csv);
        }

        $csv = $export->export(MouvementfactureFacturationView::getInstance()->getMouvementsAll(0), $options['periode_max'], $options['periode_min']);

        $noLignes = true;
        foreach($csv as $file => $lignes) {
            if(count($lignes)) {
                $noLignes = false;
                break;
            }
        }

        if($noLignes) {
            return;
        }

        $origineFilename = null;
        foreach($csv as $file => $lignes) {
            $fileName = $arguments['path']."/".$date."_".preg_replace("/.+\./", "", $file);
            file_put_contents($fileName, implode("\r\n", $lignes));
            if($file == "09.ORIGINES") {
                $origineFilename = $fileName;
            }
        }
        $export->setFacture(explode("\r\n", file_get_contents($origineFilename)));
    }
}
{'fraction_non_alphanumeric': 0.14479984677264893, 'fraction_numerical': 0.0030645470216433632, 'mean_word_length': 2.93815987933635, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, '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': '3943667', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1529, 'n_words': 305}