IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MkFramework Discussion :

Soucis avec retraitement des dates


Sujet :

MkFramework

  1. #1
    Membre habitué
    Homme Profil pro
    Assistant statisticien
    Inscrit en
    Juillet 2009
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Réunion

    Informations professionnelles :
    Activité : Assistant statisticien
    Secteur : Santé

    Informations forums :
    Inscription : Juillet 2009
    Messages : 132
    Points : 168
    Points
    168
    Par défaut Soucis avec retraitement des dates
    Bonjour,

    Dans mon model j'ai
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    public function __construct($tRow=null)
    {
     
            //on appelle le constructeur normal de la row
            parent::__construct($tRow);
     
    		plugin_debug::addSpy('$tRow',$tRow);
     
    		//on modifie le champ date avant d'initialiser l'objet
            if ($tRow['date_du_deces']) {
                $oDate0 = new plugin_date($tRow['date_du_deces'], 'Y-m-d');
    			$this->date_du_deces = $oDate0->toString('d/m/Y');
            }
    }
    J'obtiens ce message d'erreur dans ma vue
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
     
    Undefined offset: 1
    #0 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php(383): exception_error_handler(8, 'Undefined offse...', 'C:\\xampp\\htdocs...', 383, Array)
    #1 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php(50): plugin_date->convertFromFormatToTab('07/06/2010', 'Y-m-d')
    #2 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php(37): plugin_date->loadFromFormat('07/06/2010', 'Y-m-d')
    #3 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\module\base\view\edit.php(6): plugin_date->__construct('07/06/2010', 'Y-m-d')
    #4 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_view.php(85): include('C:\\xampp\\htdocs...')
    #5 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_layout.php(158): _view->show()
    #6 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\layout\bootstrap.php(29): _layout->load('main')
    #7 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_layout.php(122): include('C:\\xampp\\htdocs...')
    #8 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\module\base\main.php(248): _layout->show()
    #9 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_root.php(262): module_base->after()
    #10 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\public\index.php(48): _root->run()
    #11 {main}
     
    Detail:
    #0 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php (383)
    exception_error_handler( , 'Undefined offset: 1' , 'C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php' , , Array ( [sDate] => 07/06/2010 [sFormat] => Y-m-d [iAnnee] => 07/06/2010 ) )
    #1 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php (50)
    plugin_date -> convertFromFormatToTab( '07/06/2010' , 'Y-m-d' )
    #2 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php (37)
    plugin_date -> loadFromFormat( '07/06/2010' , 'Y-m-d' )
    #3 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\module\base\view\edit.php (6)
    plugin_date -> __construct( '07/06/2010' , 'Y-m-d' )
    #4 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_view.php (85)
    include( 'C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\module\base\view\edit.php' )
    #5 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_layout.php (158)
    _view -> show( )
    #6 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\layout\bootstrap.php (29)
    _layout -> load( 'main' )
    #7 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_layout.php (122)
    include( 'C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\layout\bootstrap.php' )
    #8 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\module\base\main.php (248)
    _layout -> show( )
    #9 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Lib\mkframeworkLib\class_root.php (262)
    module_base -> after( )
    #10 C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\public\index.php (48)
    _root -> run( )
    #11 {main}
    Fichier : C:\xampp\htdocs\2-mkFramework\mkfPackage-1.2.0\Projects\kdc1\plugin\plugin_date.php ligne 383
     
    Message : Undefined offset: 1
     
    365	        return date($sFormat,$this->getMkTime());
    366	    }
    367	
    368	    /**
    369	    * @access public
    370	    * @return bool  retourne true/false selon que la date soit aujourd'hui
    371	    */
    372	    public function isToday(){
    373	        if($this->getFormat('Y-m-d')==date('Y-m-d')){
    374	            return true;
    375	        }
    376	        return false;
    377	    }
    378	    
    379	    
    380	    private function convertFromFormatToTab($sDate,$sFormat){
    381	        
    382	        if($sFormat=='Y-m-d'){
    383	            list($iAnnee,$iMois,$iJour)=explode('-',$sDate);
    384	        }elseif($sFormat=='d-m-Y'){
    385	            list($iJour,$iMois,$iAnnee)=explode('-',$sDate);
    386	        }elseif($sFormat=='d/m/Y'){
    387	            list($iJour,$iMois,$iAnnee)=explode('/',$sDate);
    388	        }elseif($sFormat=='Y/m/d'){
    389	            list($iAnnee,$iMois,$iJour)=explode('/',$sDate);
    390	        }elseif($sFormat=='m-d-Y'){
    391	            list($iMois,$iJour,$iAnnee)=explode('-',$sDate);
    392	        }elseif($sFormat=='y-m-d'){
    393	            list($iAnnee,$iMois,$iJour)=explode('-',$sDate);
    394	            $iAnnee=2000+intval($iAnnee);
    395	        }        
    396	
    397	        return array(
    398	                sprintf('%04d',$iAnnee),
    399	                sprintf('%02d',$iMois),
    400	                sprintf('%02d',$iJour),
    Je ne comprends pas pourquoi.
    Pourtant le champ existe bien dans ma vue
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
     
    <?php 
    $oForm=new plugin_form($this->oBase);
    $oForm->setMessage($this->tMessage);
     
    if($this->oBase->date_du_deces){
    	$dateFinDelai2ans = new plugin_Date($this->oBase->date_du_deces,'Y-m-d');
     
    	$dateFinDelai2ans->addMonth(24);
    	$dateFinDelai2ans->removeDay(1);
     
    }else{
    	$dateFinDelai2ans = '';
    }
     
    $dateReception = new plugin_Date($this->oBase->date_de_reception,'Y-m-d');
    $numDossier = $dateReception->getYear(). "		" . $dateReception->getMonth() . "		" . $this->oBase->id_base;
    ?>
    <!--
    <form class="form-horizontal" action="" method="POST" >
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_du_deces</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_du_deces',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_de_la_demande</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_de_la_demande',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_de_reception</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_de_reception',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">nir</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('nir',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">nom_de_assure_DCD</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('nom_de_assure_DCD',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">nombre_de_parts_a_payer</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('nombre_de_parts_a_payer',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_de_paiement</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_de_paiement',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">nombre_de_parts_payees</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('nombre_de_parts_payees',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">observations</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('observations',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_de_demande_de_pieces_complementaires</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_de_demande_de_pieces_complementaires',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_de_relance</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_de_relance',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_arrivee_dossier_complet</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_arrivee_dossier_complet',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_de_relance_prevue</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_de_relance_prevue',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">droits_ouverts</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('droits_ouverts',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_1er_Refus</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_1er_Refus',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_Paiement_Prevu_Le</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_Paiement_Prevu_Le',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">montantDeLaPartPayee</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('montantDeLaPartPayee',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">Regul_Fin_2ans</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('Regul_Fin_2ans',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">montantTotalKDC</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('montantTotalKDC',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">nouveau_montant_part</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('nouveau_montant_part',array('class'=>'form-control')) ?></div>
    	</div>
     
    	<div class="form-group">
    		<label class="col-sm-2 control-label">date_regul_2ans</label>
    		<div class="col-sm-10"><?php echo $oForm->getInputText('date_regul_2ans',array('class'=>'form-control')) ?></div>
    	</div>
     
     
     
     
    < ?php echo $oForm->getToken('token',$this->token)?>
     
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
    		<input type="submit" class="btn btn-success" value="Modifier" /> <a class="btn btn-link" href="< ?php echo $this->getLink('base::list')?>">Annuler</a>
    	</div>
    </div>
    </form>-->
    <div class="page-header">
    	<h1 class="title text-center">Modifier dossier</h1>
    </div>
     
    <form class="form" action="" method="POST" >
     
    	<div class="row">
    		<div class="form-group">
    			<label class="col-sm-4 col-sm-offset-4 control-label">Fin du délai 2 ans</label>
    			<div class="col-sm-4 ">
    				<input type="text" class="text-center form-control" style="font-weight:800;font-size:18px;"  value="<?= $numDossier ; ?>" disabled=true>
    			</div>
    		</div>
    	</div>
    	<br>
     
    	<div class="row">
    		<div class="form-group">
    			<label class="col-sm-2 control-label text-right">
    				Date du décès
    			</label>
    			<div class="col-sm-2">
    				<?php echo $oForm->getInputText('date_du_deces',array('class'=>'form-control text-center')) ?>
    			</div>
    Un coup de main la communauté ??

  2. #2
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Le problème vient de votre format de date d'entrée

    vous avez inscrit:
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    new plugin_date($tRow['date_du_deces'], 'Y-m-d');

    Le framework s'attend donc à construire un objet date à partir d'un string formatée YYYY-MM-DD

    sauf, qu'on voit dans la stack trace que la date reçu n'a pas ce format:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    plugin_date->loadFromFormat('07/06/2010', 'Y-m-d')
    d'où le soucis

    soit vous faite un convert dans votre requete SQL, soit vous indiquez un autre format d'entrée, ici plus d/m/Y
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  3. #3
    Membre habitué
    Homme Profil pro
    Assistant statisticien
    Inscrit en
    Juillet 2009
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Réunion

    Informations professionnelles :
    Activité : Assistant statisticien
    Secteur : Santé

    Informations forums :
    Inscription : Juillet 2009
    Messages : 132
    Points : 168
    Points
    168
    Par défaut Soucis avec retraitement des dates (suite et fin)
    Bonjour IMIKADO

    Effectivement dans l'action edit du module base je lui indiquait le format Y-m-d alors que le retraitement depuis le model était en d/m/Y.

    Parfois je manque de jugeote.

    Merci pour le conseil.

    Cordialement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Souci avec utilisation des constructeurs
    Par Khalfe dans le forum Débuter avec Java
    Réponses: 7
    Dernier message: 09/04/2020, 01h11
  2. Réponses: 3
    Dernier message: 02/04/2013, 09h31
  3. petit soucis avec la fonction date
    Par gaston11 dans le forum Débuter
    Réponses: 4
    Dernier message: 04/02/2013, 22h42
  4. souci avec lissage des ombres
    Par LastSpear dans le forum OpenGL
    Réponses: 2
    Dernier message: 28/06/2009, 14h59
  5. Gros souci avec gestion des arguments
    Par toams69 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 0
    Dernier message: 09/01/2009, 16h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo