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 :

Enregistrer un formulaire avec x input en une seule fois


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 Enregistrer un formulaire avec x input en une seule fois
    Je voudrais enregistrer en un seul passage tous mes informations dans une vue NEW.

    Voici la 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
     
    <?php 
    $oForm=new plugin_form($this->oSaisir);
    $oForm2=new plugin_form($this->tActivite);
    $oForm->setMessage($this->tMessage);
    ?>
    <div class="container col-md-11 col-md-offset-1" >
     
    		<form class="form-horizontal" action="" method="POST" >
    			<h3 class="text-center ">Nouvelle saisie</h3>
    			<div class="form-group">
    				<div class="col-sm-offset-4 col-sm-4 ">
    					<?php echo $oForm->getInputText('exercer_date',array('class'=>'text-center form-control sandbox-container','placeholder'=> 'JJ/MM/AAAA','autocomplete'=>'off','data-provide' =>'datepicker')) ?>
    				</div>
    			</div>
     
    			<?php foreach($this->tActivite as $key => $oActivite):?>
    				<div class="form-group">
    					<div class="col-sm-offset-2 col-sm-4">
    						<!--<?php //echo $oForm2->getInputText($sActivite,array('class'=>'text-center form-control'))?>-->
    						<?php echo $oActivite;?>
    						<input type="hidden" name="<?php echo $oActivite;?>" value=<?php echo $key;?>>
     
    					</div>
     
    					<div class="col-sm-2"><?php echo $oForm->getInputText('resultat_activite',array('class'=>'form-control','autocomplete'=>'off')) ?>
    					</div>
    				</div>
    			<?php endforeach;?>
     
    			<input type="hidden" name="users_id" value="<?php echo _root::getAuth()->getAccount()->id ?>"/>
     
    		<?php echo $oForm->getToken('token',$this->token)?>
     
    			<div class="form-group">
    			    <div class="col-sm-offset-7 col-sm-5">
    					<input type="submit" class="btn btn-success" value="Ajouter" /> <a class="btn btn-link" href="<?php echo $this->getLink('saisir::list')?>">Annuler</a>
    				</div>
    			</div>
    		</form>
    </div>
    Voici le main avec la methode NEW:
    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
     
    public function _new(){
    		$tMessage=$this->processSave();
    		$oSaisir=new row_saisir;
     
    		$agent=_root::getAuth()->getAccount()->id;
    		$oService = model_rattacher::getInstance()->findByIdService($agent);
    		$var=$oService->rattacher_service_id;
     
    		$oView=new _view('saisir::new');
    		$oView->oSaisir = $oSaisir;
    		$tActivite = model_activite::getInstance()->getSelect2($var);
    		$oView->tActivite =$tActivite;
     
    				$oView->tJoinmodel_users = model_users::getInstance()->getSelect();		
    				$oView->tJoinmodel_activite = model_activite::getInstance()->getSelect2($var);
     
     
    		$oPluginXsrf=new plugin_xsrf();
    		$oView->token=$oPluginXsrf->getToken();
    		$oView->tMessage=$tMessage;
     
    		$this->oLayout->add('main',$oView);
    	}
    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
     
    private function processSave(){
    		if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
    			return null;
    		}
     
    		$oPluginXsrf=new plugin_xsrf();
    		if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
    			return array('token'=>$oPluginXsrf->getMessage() );
    		}
     
    		$iId=_root::getParam('id',null);
    		if($iId==null){
    			$oSaisir=new row_saisir;	
    		}else{
    			$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id',null) );
    		}
     
    		$tId=model_saisir::getInstance()->getIdTab();
    		$tColumn=array('users_id','activite_id','exercer_date','resultat_activite');
     
    		foreach($tColumn as $sColumn){
    			if (_root::getParam($sColumn,null) == null) {
    				continue;
    			} else if (in_array($sColumn,$tId)) {
    				continue;
    			}
     
    			$oSaisir->$sColumn=_root::getParam($sColumn,null) ;
    		}
     
     
    		if($oSaisir->isValid()){
    			$agent=_root::getAuth()->getAccount()->id;
    			$oService = model_rattacher::getInstance()->findByIdService($agent);
    			$var=$oService->rattacher_service_id;
    			$tActivite = model_activite::getInstance()->getSelect2($var);
     
    			foreach($tActivite as $key => $oActivite) {
    				$oSaisir = new row_saisir;
    				$oSaisir->activite_id=$key;
    				$oSaisir->resultat_activite=$resultat_activite;
    				$oSaisir->save();
    			}
    			//une fois enregistre on redirige (vers la page liste)
    			_root::redirect('saisir::list');
     
    		} else {
    			return $oSaisir->getListError();
    		}
     
    	}
    Ca ne marche pas pourquoi?

  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
    Bonjour,
    Premièrement il faudrait renommer la variable oSaisir au sein de la boucle en effet ça créé une ambiguité entre le oSaisir du new et ceux de la boucle

    ensuite on peut ajouter du debug en modifiant ainsi:
    Code php : 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
     
    private function processSave(){
    		if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
    			return null;
    		}
     
    		$oPluginXsrf=new plugin_xsrf();
    		if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
    			return array('token'=>$oPluginXsrf->getMessage() );
    		}
     
    		$iId=_root::getParam('id',null);
    		if($iId==null){
    			$oSaisir=new row_saisir;	
    		}else{
    			$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id',null) );
    		}
     
    		$tId=model_saisir::getInstance()->getIdTab();
    		$tColumn=array('users_id','activite_id','exercer_date','resultat_activite');
     
    		foreach($tColumn as $sColumn){
    			if (_root::getParam($sColumn,null) == null) {
    				continue;
    			} else if (in_array($sColumn,$tId)) {
    				continue;
    			}
     
    			$oSaisir->$sColumn=_root::getParam($sColumn,null) ;
    		}
     
     
    		if($oSaisir->isValid()){
    			$agent=_root::getAuth()->getAccount()->id;
    			$oService = model_rattacher::getInstance()->findByIdService($agent);
    			$var=$oService->rattacher_service_id;
    			$tActivite = model_activite::getInstance()->getSelect2($var);
     
    			//ajout verification du tableau d activite avant de boucler dessus
    			if($tActivite){
    				foreach($tActivite as $key => $oActivite) {
    					//renommage de la variable oSaisirLoop
    					$oSaisirLoop = new row_saisir;
    					$oSaisirLoop->activite_id=$key;
    					$oSaisirLoop->resultat_activite=$resultat_activite;
    					$oSaisirLoop->save();
     
    					//on ajoute le debug des objets oSaisir de cette boucle
    					plugin_debug::addSpy('oSaisirLoop'.$key,print_r($oSaisirLoop,1));
    					plugin_debug::addSpy('oSaisirLoop'.$key.'Check',$oSaisirLoop->getListError());
    				}
    			}
     
    			//ajout debug
    			plugin_debug::addSpy('tActivite',$tActivite);
    			return;
     
    			//une fois enregistre on redirige (vers la page liste)
    			_root::redirect('saisir::list');
     
    		} else {
    			plugin_debug::addSpy('checkError',$oSaisir->getListError());
     
    			return $oSaisir->getListError();
    		}
     
    	}

    Si vous pouvez poster ce qui est affiché via le bouton "spy variables" de la barre de debug pour voir ce qu'il en est.
    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
    Citation Envoyé par imikado Voir le message
    Bonjour,
    Premièrement il faudrait renommer la variable oSaisir au sein de la boucle en effet ça créé une ambiguité entre le oSaisir du new et ceux de la boucle

    ensuite on peut ajouter du debug en modifiant ainsi:
    Code php : 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
     
    private function processSave(){
    		if(!_root::getRequest()->isPost() ){ //si ce n'est pas une requete POST on ne soumet pas
    			return null;
    		}
     
    		$oPluginXsrf=new plugin_xsrf();
    		if(!$oPluginXsrf->checkToken( _root::getParam('token') ) ){ //on verifie que le token est valide
    			return array('token'=>$oPluginXsrf->getMessage() );
    		}
     
    		$iId=_root::getParam('id',null);
    		if($iId==null){
    			$oSaisir=new row_saisir;	
    		}else{
    			$oSaisir=model_saisir::getInstance()->findById( _root::getParam('id',null) );
    		}
     
    		$tId=model_saisir::getInstance()->getIdTab();
    		$tColumn=array('users_id','activite_id','exercer_date','resultat_activite');
     
    		foreach($tColumn as $sColumn){
    			if (_root::getParam($sColumn,null) == null) {
    				continue;
    			} else if (in_array($sColumn,$tId)) {
    				continue;
    			}
     
    			$oSaisir->$sColumn=_root::getParam($sColumn,null) ;
    		}
     
     
    		if($oSaisir->isValid()){
    			$agent=_root::getAuth()->getAccount()->id;
    			$oService = model_rattacher::getInstance()->findByIdService($agent);
    			$var=$oService->rattacher_service_id;
    			$tActivite = model_activite::getInstance()->getSelect2($var);
     
    			//ajout verification du tableau d activite avant de boucler dessus
    			if($tActivite){
    				foreach($tActivite as $key => $oActivite) {
    					//renommage de la variable oSaisirLoop
    					$oSaisirLoop = new row_saisir;
    					$oSaisirLoop->activite_id=$key;
    					$oSaisirLoop->resultat_activite=$resultat_activite;
    					$oSaisirLoop->save();
     
    					//on ajoute le debug des objets oSaisir de cette boucle
    					plugin_debug::addSpy('oSaisirLoop'.$key,print_r($oSaisirLoop,1));
    					plugin_debug::addSpy('oSaisirLoop'.$key.'Check',$oSaisirLoop->getListError());
    				}
    			}
     
    			//ajout debug
    			plugin_debug::addSpy('tActivite',$tActivite);
    			return;
     
    			//une fois enregistre on redirige (vers la page liste)
    			_root::redirect('saisir::list');
     
    		} else {
    			plugin_debug::addSpy('checkError',$oSaisir->getListError());
     
    			return $oSaisir->getListError();
    		}
     
    	}

    Si vous pouvez poster ce qui est affiché via le bouton "spy variables" de la barre de debug pour voir ce qu'il en est.
    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
     
     
    Undefined variable: resultat_activite
    #0 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php(201): exception_error_handler(8, 'Undefined varia...', 'C:\\xampp\\htdocs...', 201, Array)
    #1 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php(77): module_saisir->processSave()
    #2 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\lib\framework\class_root.php(263): module_saisir->_new()
    #3 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\public\index.php(47): _root->run()
    #4 {main}
     
    Detail:
    #0 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php (201)
    exception_error_handler( , 'Undefined variable: resultat_activite' , 'C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php' , , Array ( [oPluginXsrf] => plugin_xsrf Object ( [sSalt:plugin_xsrf:private] => fdsfA34T679hjfdsAfef [iLifetime:plugin_xsrf:private] => 360 [sMsg:plugin_xsrf:private] => [bUseSession:plugin_xsrf:private] => 0 [sSessionVar:plugin_xsrf:private] => xsrfTokenArray ) [iId] => [oSaisir] => row_saisir Object ( [sClassModel:protected] => model_saisir [_bChooseUpdate:abstract_row:private] => [_tProperty:protected] => Array ( [users_id] => 11 [exercer_date] => 05/01/2016 ) [_tPropertyToUpdate:protected] => Array ( [0] => users_id [1] => exercer_date ) ) [tId] => Array ( [0] => saisir_id ) [tColumn] => Array ( [0] => users_id [1] => activite_id [2] => exercer_date [3] => resultat_activite ) [sColumn] => resultat_activite [agent] => 11 [oService] => row_rattacher Object ( [sClassModel:protected] => model_rattacher [_bChooseUpdate:abstract_row:private] => 1 [_tProperty:protected] => Array ( [rattacher_id] => 8 [rattacher_users_id] => 11 [rattacher_service_id] => 36 [rattacher_date_debut] => 19/09/2016 [rattacher_date_fin] => 19/09/2016 ) [_tPropertyToUpdate:protected] => ) [var] => 36 [tActivite] => Array ( [52] => TRAIT_PI [53] => DECL_RESS [54] => RECLA_N2 [55] => REV_PIFSI [56] => OPI [57] => MAJ_DOSS [62] => OBSERVATIONS [63] => DSH / requêtes DSH [64] => ARCHIVAGE [65] => COURRIER NOTAIRE [66] => COURRIER ENTRANT / SORTANT [67] => MUTATIONS [68] => INSTANCIER SCAPIN /TRAITEMENT [69] => LM2a [70] => REIMPUTATION INVAL et IJ [71] => SUIVI PLANIR [72] => Veille réglementaire [73] => supervision [74] => traitement dossier ue [75] => traitement dossier récupération sur succession ) [key] => 52 [oActivite] => TRAIT_PI [oSaisirLoop] => row_saisir Object ( [sClassModel:protected] => model_saisir [_bChooseUpdate:abstract_row:private] => [_tProperty:protected] => Array ( [activite_id] => 52 ) [_tPropertyToUpdate:protected] => Array ( [0] => activite_id ) ) ) )
    #1 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php (77)
    module_saisir -> processSave( )
    #2 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\lib\framework\class_root.php (263)
    module_saisir -> _new( )
    #3 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\public\index.php (47)
    _root -> run( )
    #4 {main}
     
    Fichier : C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php ligne 201
     
    Message : Undefined variable: resultat_activite
    183	
    184	            $oSaisir->$sColumn=_root::getParam($sColumn,null) ;
    185	        }
    186	        
    187	        
    188	        if($oSaisir->isValid()){
    189	            $agent=_root::getAuth()->getAccount()->id;
    190	            $oService = model_rattacher::getInstance()->findByIdService($agent);
    191	            $var=$oService->rattacher_service_id;
    192	            $tActivite = model_activite::getInstance()->getSelect2($var);
    193	
    194	        
    195	            //ajout verification du tableau d activite avant de boucler dessus
    196	            if($tActivite){
    197	                foreach($tActivite as $key => $oActivite) {
    198	                    //renommage de la variable oSaisirLoop
    199	                    $oSaisirLoop = new row_saisir;
    200	                    $oSaisirLoop->activite_id=$key;
    201	                    $oSaisirLoop->resultat_activite=$resultat_activite;
    202	                    $oSaisirLoop->save();
    203	 
    204	                    //on ajoute le debug des objets oSaisir de cette boucle
    205	                    plugin_debug::addSpy('oSaisirLoop'.$key,print_r($oSaisirLoop,1));
    206	                    plugin_debug::addSpy('oSaisirLoop'.$key.'Check',$oSaisirLoop->getListError());
    207	                }
    208	            }
    209	 
    210	            //ajout debug
    211	            plugin_debug::addSpy('tActivite',$tActivite);
    212	            return;
    213	 
    214	            //une fois enregistre on redirige (vers la page liste)
    215	            _root::redirect('saisir::list');
    216	 
    217	        } else {
    218	            plugin_debug::addSpy('checkError',$oSaisir->getListError());
    Navigation
    Module:saisir Action:new
    $_GET
    Array
    (
    [:nav] => saisir::new
    )
    $_POST
    Array
    (
    [exercer_date] => 05/01/2016
    [TRAIT_PI] => 52
    [resultat_activite] =>
    [DECL_RESS] => 53
    [RECLA_N2] => 54
    [REV_PIFSI] => 55
    [OPI] => 56
    [MAJ_DOSS] => 57
    [OBSERVATIONS] => 62
    [DSH_/_requêtes_DSH] => 63
    [ARCHIVAGE] => 64
    [COURRIER_NOTAIRE] => 65
    [COURRIER_ENTRANT_/_SORTANT] => 66
    [MUTATIONS] => 67
    [INSTANCIER_SCAPIN_/TRAITEMENT] => 68
    [LM2a] => 69
    [REIMPUTATION_INVAL_et_IJ] => 70
    [SUIVI_PLANIR] => 71
    [Veille_réglementaire] => 72
    [supervision] => 73
    [traitement_dossier_ue] => 74
    [traitement_dossier_récupération_sur_succession] => 75
    [users_id] => 11
    [token] => 1474529532####67fd4d3a5a206a0e42a9a602e132f2f54b8503d7
    )

  4. #4
    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
    Citation Envoyé par viny1976 Voir le message
    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
     
     
    Undefined variable: resultat_activite
    #0 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php(201): exception_error_handler(8, 'Undefined varia...', 'C:\\xampp\\htdocs...', 201, Array)
    #1 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php(77): module_saisir->processSave()
    #2 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\lib\framework\class_root.php(263): module_saisir->_new()
    #3 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\public\index.php(47): _root->run()
    #4 {main}
     
    Detail:
    #0 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php (201)
    exception_error_handler( , 'Undefined variable: resultat_activite' , 'C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php' , , Array ( [oPluginXsrf] => plugin_xsrf Object ( [sSalt:plugin_xsrf:private] => fdsfA34T679hjfdsAfef [iLifetime:plugin_xsrf:private] => 360 [sMsg:plugin_xsrf:private] => [bUseSession:plugin_xsrf:private] => 0 [sSessionVar:plugin_xsrf:private] => xsrfTokenArray ) [iId] => [oSaisir] => row_saisir Object ( [sClassModel:protected] => model_saisir [_bChooseUpdate:abstract_row:private] => [_tProperty:protected] => Array ( [users_id] => 11 [exercer_date] => 05/01/2016 ) [_tPropertyToUpdate:protected] => Array ( [0] => users_id [1] => exercer_date ) ) [tId] => Array ( [0] => saisir_id ) [tColumn] => Array ( [0] => users_id [1] => activite_id [2] => exercer_date [3] => resultat_activite ) [sColumn] => resultat_activite [agent] => 11 [oService] => row_rattacher Object ( [sClassModel:protected] => model_rattacher [_bChooseUpdate:abstract_row:private] => 1 [_tProperty:protected] => Array ( [rattacher_id] => 8 [rattacher_users_id] => 11 [rattacher_service_id] => 36 [rattacher_date_debut] => 19/09/2016 [rattacher_date_fin] => 19/09/2016 ) [_tPropertyToUpdate:protected] => ) [var] => 36 [tActivite] => Array ( [52] => TRAIT_PI [53] => DECL_RESS [54] => RECLA_N2 [55] => REV_PIFSI [56] => OPI [57] => MAJ_DOSS [62] => OBSERVATIONS [63] => DSH / requêtes DSH [64] => ARCHIVAGE [65] => COURRIER NOTAIRE [66] => COURRIER ENTRANT / SORTANT [67] => MUTATIONS [68] => INSTANCIER SCAPIN /TRAITEMENT [69] => LM2a [70] => REIMPUTATION INVAL et IJ [71] => SUIVI PLANIR [72] => Veille réglementaire [73] => supervision [74] => traitement dossier ue [75] => traitement dossier récupération sur succession ) [key] => 52 [oActivite] => TRAIT_PI [oSaisirLoop] => row_saisir Object ( [sClassModel:protected] => model_saisir [_bChooseUpdate:abstract_row:private] => [_tProperty:protected] => Array ( [activite_id] => 52 ) [_tPropertyToUpdate:protected] => Array ( [0] => activite_id ) ) ) )
    #1 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php (77)
    module_saisir -> processSave( )
    #2 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\lib\framework\class_root.php (263)
    module_saisir -> _new( )
    #3 C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\public\index.php (47)
    _root -> run( )
    #4 {main}
     
    Fichier : C:\xampp\htdocs\9-mkFramework\mkframework_v4_126_1_r311\data\genere\cellule_statistiques\module\saisir\main.php ligne 201
     
    Message : Undefined variable: resultat_activite
    183	
    184	            $oSaisir->$sColumn=_root::getParam($sColumn,null) ;
    185	        }
    186	        
    187	        
    188	        if($oSaisir->isValid()){
    189	            $agent=_root::getAuth()->getAccount()->id;
    190	            $oService = model_rattacher::getInstance()->findByIdService($agent);
    191	            $var=$oService->rattacher_service_id;
    192	            $tActivite = model_activite::getInstance()->getSelect2($var);
    193	
    194	        
    195	            //ajout verification du tableau d activite avant de boucler dessus
    196	            if($tActivite){
    197	                foreach($tActivite as $key => $oActivite) {
    198	                    //renommage de la variable oSaisirLoop
    199	                    $oSaisirLoop = new row_saisir;
    200	                    $oSaisirLoop->activite_id=$key;
    201	                    $oSaisirLoop->resultat_activite=$resultat_activite;
    202	                    $oSaisirLoop->save();
    203	 
    204	                    //on ajoute le debug des objets oSaisir de cette boucle
    205	                    plugin_debug::addSpy('oSaisirLoop'.$key,print_r($oSaisirLoop,1));
    206	                    plugin_debug::addSpy('oSaisirLoop'.$key.'Check',$oSaisirLoop->getListError());
    207	                }
    208	            }
    209	 
    210	            //ajout debug
    211	            plugin_debug::addSpy('tActivite',$tActivite);
    212	            return;
    213	 
    214	            //une fois enregistre on redirige (vers la page liste)
    215	            _root::redirect('saisir::list');
    216	 
    217	        } else {
    218	            plugin_debug::addSpy('checkError',$oSaisir->getListError());
    Navigation
    Module:saisir Action:new
    $_GET
    Array
    (
    [:nav] => saisir::new
    )
    $_POST
    Array
    (
    [exercer_date] => 05/01/2016
    [TRAIT_PI] => 52
    [resultat_activite] =>
    [DECL_RESS] => 53
    [RECLA_N2] => 54
    [REV_PIFSI] => 55
    [OPI] => 56
    [MAJ_DOSS] => 57
    [OBSERVATIONS] => 62
    [DSH_/_requêtes_DSH] => 63
    [ARCHIVAGE] => 64
    [COURRIER_NOTAIRE] => 65
    [COURRIER_ENTRANT_/_SORTANT] => 66
    [MUTATIONS] => 67
    [INSTANCIER_SCAPIN_/TRAITEMENT] => 68
    [LM2a] => 69
    [REIMPUTATION_INVAL_et_IJ] => 70
    [SUIVI_PLANIR] => 71
    [Veille_réglementaire] => 72
    [supervision] => 73
    [traitement_dossier_ue] => 74
    [traitement_dossier_récupération_sur_succession] => 75
    [users_id] => 11
    [token] => 1474529532####67fd4d3a5a206a0e42a9a602e132f2f54b8503d7
    )
    J'ai réussi
    Voilà la partie que j'ai modifié :
    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
     
    $i=1;
    			//ajout verification du tableau d activite avant de boucler dessus
    			if($tActivite){
    				foreach($tActivite as $key => $oActivite) {
    						//renommage de la variable oSaisirLoop
    						$oSaisirLoop = new row_saisir;
    							if ($_POST['resultat_activite'.$i] != '') {	
    								$oSaisirLoop->users_id = $agent;
    								$oSaisirLoop->activite_id=$key;
    								$oSaisirLoop->exercer_date=$_POST['exercer_date'];
    								$oSaisirLoop->resultat_activite=$_POST['resultat_activite'.$i];
    								$oSaisirLoop->save();
     
    							}
    					$i++;
    				}
    			}
    Merci pour tes conseils.

  5. #5
    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
    Citation Envoyé par viny1976 Voir le message
    J'ai réussi
    Voilà la partie que j'ai modifié :
    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
     
    $i=1;
    			//ajout verification du tableau d activite avant de boucler dessus
    			if($tActivite){
    				foreach($tActivite as $key => $oActivite) {
    						//renommage de la variable oSaisirLoop
    						$oSaisirLoop = new row_saisir;
    							if ($_POST['resultat_activite'.$i] != '') {	
    								$oSaisirLoop->users_id = $agent;
    								$oSaisirLoop->activite_id=$key;
    								$oSaisirLoop->exercer_date=$_POST['exercer_date'];
    								$oSaisirLoop->resultat_activite=$_POST['resultat_activite'.$i];
    								$oSaisirLoop->save();
     
    							}
    					$i++;
    				}
    			}
    Merci pour tes conseils.
    Question :
    Est ce que si je ne mets pas la variable $i il reconnaîtra à chaque fois $_POST[resultat_activite]?
    Je pose la question car en l'état si j'applique la même logique à l'action édit il ne reconnaît pas la variable.

  6. #6
    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
    Bonjour,

    Je me suis réjouis un peu trop tôt.
    Dans ma méthode new j'enregistre bien en une seule fois plusieurs champs.
    Par contre je n'arrive pas dans la méthode edit à afficher les données.

    Un petit coup de main la communauté du MkFramework....

    Merci

  7. #7
    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
    Je n'avais pas bien compris la première fois le soucis, j'ai l'impression que le module CRUD multi-ligne pourrait répondre à votre soucis:

    http://mkframework.com/tutoriaux.html#crudmulti
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

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

Discussions similaires

  1. [XL-2003] fonction mscomm1.input utilisable une seule fois?
    Par Elfstat dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 12/04/2009, 14h02
  2. Réponses: 3
    Dernier message: 14/08/2006, 22h27
  3. Réponses: 19
    Dernier message: 26/01/2006, 09h44
  4. ouvrir un formulaire avec le rslt d'une requête
    Par 973thom dans le forum Access
    Réponses: 4
    Dernier message: 09/09/2005, 17h51
  5. Formulaire avec liste basée sur une autre table
    Par sabotage dans le forum Langage SQL
    Réponses: 6
    Dernier message: 10/08/2005, 14h43

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