<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.
 */

class DRMCrdsForm extends acCouchdbObjectForm {

    private $drm = null;
    private $crds = null;

    public function __construct(acCouchdbJson $object, $options = array(), $CSRFSecret = null) {
        $this->drm = $object;
        $this->crds = $this->drm->getAllCrdsByRegimeAndByGenre();

        parent::__construct($this->drm, $options, $CSRFSecret);
    }

    public function configure() {

        foreach ($this->crds as $regime => $crdAllGenre) {
            foreach ($crdAllGenre as $genre => $crds) {
                foreach ($crds as $key => $crd) {
                    $keyWidgetsSuffixe = '_' . $regime . '_' . $key;
                    if ($crd->stock_debut) 
                        $this->setWidget('stock_debut' . $keyWidgetsSuffixe, new sfWidgetFormInputHidden());
                    else
                        $this->setWidget('stock_debut' . $keyWidgetsSuffixe, new sfWidgetFormInput());                        
                    $this->setWidget('entrees_achats' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('entrees_retours' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('entrees_excedents' . $keyWidgetsSuffixe, new sfWidgetFormInput());

                    $this->setWidget('sorties_utilisations' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('sorties_destructions' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('sorties_manquants' . $keyWidgetsSuffixe, new sfWidgetFormInput());

                    $this->widgetSchema->setLabel('stock_debut' . $keyWidgetsSuffixe, 'Début de mois');
                    $this->widgetSchema->setLabel('entrees_achats' . $keyWidgetsSuffixe, 'Achats');
                    $this->widgetSchema->setLabel('entrees_retours' . $keyWidgetsSuffixe, 'Retours');
                    $this->widgetSchema->setLabel('entrees_excedents' . $keyWidgetsSuffixe, 'Excédents');

                    $this->widgetSchema->setLabel('sorties_utilisations' . $keyWidgetsSuffixe, 'Utilisations');
                    $this->widgetSchema->setLabel('sorties_destructions' . $keyWidgetsSuffixe, 'Destructions');
                    $this->widgetSchema->setLabel('sorties_manquants' . $keyWidgetsSuffixe, 'Manquants');

                    $this->setValidator('stock_debut' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('entrees_achats' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('entrees_retours' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('entrees_excedents' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));

                    $this->setValidator('sorties_utilisations' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('sorties_destructions' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('sorties_manquants' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                }
            }
        }

        $this->widgetSchema->setNameFormat('drmCrds[%s]');
    }

    protected function doUpdateObject($values) {
        parent::doUpdateObject($values);<commit_msg>Les stocks négatifs sont aurotisés dans les CRD<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.
 */

class DRMCrdsForm extends acCouchdbObjectForm {

    private $drm = null;
    private $crds = null;

    public function __construct(acCouchdbJson $object, $options = array(), $CSRFSecret = null) {
        $this->drm = $object;
        $this->crds = $this->drm->getAllCrdsByRegimeAndByGenre();

        parent::__construct($this->drm, $options, $CSRFSecret);
    }

    public function configure() {

        foreach ($this->crds as $regime => $crdAllGenre) {
            foreach ($crdAllGenre as $genre => $crds) {
                foreach ($crds as $key => $crd) {
                    $keyWidgetsSuffixe = '_' . $regime . '_' . $key;
                    if ($crd->stock_debut)
                        $this->setWidget('stock_debut' . $keyWidgetsSuffixe, new sfWidgetFormInputHidden());
                    else
                        $this->setWidget('stock_debut' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('entrees_achats' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('entrees_retours' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('entrees_excedents' . $keyWidgetsSuffixe, new sfWidgetFormInput());

                    $this->setWidget('sorties_utilisations' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('sorties_destructions' . $keyWidgetsSuffixe, new sfWidgetFormInput());
                    $this->setWidget('sorties_manquants' . $keyWidgetsSuffixe, new sfWidgetFormInput());

                    $this->widgetSchema->setLabel('stock_debut' . $keyWidgetsSuffixe, 'Début de mois');
                    $this->widgetSchema->setLabel('entrees_achats' . $keyWidgetsSuffixe, 'Achats');
                    $this->widgetSchema->setLabel('entrees_retours' . $keyWidgetsSuffixe, 'Retours');
                    $this->widgetSchema->setLabel('entrees_excedents' . $keyWidgetsSuffixe, 'Excédents');

                    $this->widgetSchema->setLabel('sorties_utilisations' . $keyWidgetsSuffixe, 'Utilisations');
                    $this->widgetSchema->setLabel('sorties_destructions' . $keyWidgetsSuffixe, 'Destructions');
                    $this->widgetSchema->setLabel('sorties_manquants' . $keyWidgetsSuffixe, 'Manquants');

                    $this->setValidator('stock_debut' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false)));
                    $this->setValidator('entrees_achats' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('entrees_retours' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('entrees_excedents' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));

                    $this->setValidator('sorties_utilisations' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('sorties_destructions' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                    $this->setValidator('sorties_manquants' . $keyWidgetsSuffixe, new sfValidatorInteger(array('required' => false, 'min' => 0)));
                }
            }
        }

        $this->widgetSchema->setNameFormat('drmCrds[%s]');
    }

    protected function doUpdateObject($values) {
        parent::doUpdateObject($values);
{'fraction_non_alphanumeric': 0.1368897166422775, 'fraction_numerical': 0.0017294133297858188, 'mean_word_length': 2.7552447552447554, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 112, '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': '7588453', 'n_tokens_mistral': 2248, 'n_tokens_neox': 2139, 'n_words': 374}