<commit_before><?php

class FacturationMassiveForm extends acCouchdbForm {

    public function configure() {
        $this->setWidget('date_facturation'   , new sfWidgetFormInput(array('default' => date('d/m/Y'))));
        $this->widgetSchema->setLabel('date_facturation'  , 'Date de facturation');
        $this->setValidator('date_facturation' , new sfValidatorDate(array('date_output' => 'Y-m-d', 'date_format' => '~(?P<day>\d{2})/(?P<month>\d{2})/(?P<year>\d{4})~', 'required' => true)));

        if(!$this->getOption("uniqueTemplateFactureName")){
          $modeles = $this->getModeles();
          $this->setWidget('modele'   , new sfWidgetFormChoice(array('choices' => $modeles)));
          $this->setWidget('libelle'   , new sfWidgetFormInput());
          $this->setWidget('requete'   , new sfWidgetFormInput());
          $this->widgetSchema->setLabel('modele'  , 'Template de facture');
          $this->widgetSchema->setLabel('libelle'  , 'Libellé');
          $this->widgetSchema->setLabel('requete'  , 'Requête');
          $this->setValidator('requete' , new sfValidatorString(array("required" => true)));
          $this->setValidator('modele' , new sfValidatorChoice(array('choices' => array_keys($modeles), 'multiple' => false, 'required' => true)));
          $this->setValidator('libelle' , new sfValidatorString(array("required" => true)));
        }
        $this->widgetSchema->setNameFormat('facturation_massive[%s]');
    }

    public function updateDocument() {
        $this->getDocument()->libelle = $this->getValue('libelle');
        $this->getDocument()->arguments->add('requete', $this->getValue('requete'));
        if(!$this->getOption("uniqueTemplateFactureName")){
          $this->getDocument()->arguments->add('modele', $this->getValue('modele'));
        }else{
          $this->getDocument()->arguments->add('modele', $this->getOption("uniqueTemplateFactureName"));
        }
        $this->getDocument()->arguments->add('date_facturation', $this->getValue('date_facturation'));
    }

    public function getModeles() {

        return self::getModelesByObject($this->getOption("modeles"));
    }

    public static function getModelesByObject($modeles) {
        $choices = [];

        foreach ($modeles as $templateFacture) {<commit_msg>1er template par défaut facturation<commit_after><?php

class FacturationMassiveForm extends acCouchdbForm {

    public function configure() {
        $this->setWidget('date_facturation'   , new sfWidgetFormInput(array('default' => date('d/m/Y'))));
        $this->widgetSchema->setLabel('date_facturation'  , 'Date de facturation');
        $this->setValidator('date_facturation' , new sfValidatorDate(array('date_output' => 'Y-m-d', 'date_format' => '~(?P<day>\d{2})/(?P<month>\d{2})/(?P<year>\d{4})~', 'required' => true)));

        if(!$this->getOption("uniqueTemplateFactureName")){
          $modeles = $this->getModeles();
          $this->setWidget('modele'   , new sfWidgetFormChoice(array('choices' => $modeles)));
          $this->setWidget('libelle'   , new sfWidgetFormInput());
          $this->setWidget('requete'   , new sfWidgetFormInput());
          $this->widgetSchema->setLabel('modele'  , 'Template de facture');
          $this->widgetSchema->setLabel('libelle'  , 'Libellé');
          $this->widgetSchema->setLabel('requete'  , 'Requête');
          $this->setValidator('requete' , new sfValidatorString(array("required" => true)));
          $this->setValidator('modele' , new sfValidatorChoice(array('choices' => array_keys($modeles), 'multiple' => false, 'required' => true)));
          $this->setValidator('libelle' , new sfValidatorString(array("required" => true)));
        }
        $this->widgetSchema->setNameFormat('facturation_massive[%s]');
    }

    public function updateDocument() {
        $this->getDocument()->libelle = $this->getValue('libelle');
        $this->getDocument()->arguments->add('requete', $this->getValue('requete'));
        if(!$this->getOption("uniqueTemplateFactureName")){
          $this->getDocument()->arguments->add('modele', $this->getValue('modele'));
        }else{
          $this->getDocument()->arguments->add('modele', $this->getOption("uniqueTemplateFactureName"));
        }
        $this->getDocument()->arguments->add('date_facturation', $this->getValue('date_facturation'));
    }

    public function getModeles() {

        return self::getModelesByObject($this->getOption("modeles"));
    }

    public static function getModelesByObject($modeles) {
        $choices = [];

        if ($modeles === null) {
            $modeles = [];
        }

        foreach ($modeles as $templateFacture) {
{'fraction_non_alphanumeric': 0.18920077137347333, 'fraction_numerical': 0.0014998928647953717, 'mean_word_length': 3.7975334018499485, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 111, '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': '2973662', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1365, 'n_words': 190}