Quick links: Content - sections - sub sections
EN FR
Quick Search Advanced search
 
Page

  [Opened] Output function on non object. Problème URGENT

Posted by foxmask on 05/12/2013 19:07

après un jForm::fill() il faut penser a un if (!$form->check())


@GitHub - Forum HaveFnuBB! powered by Jelix - Le Booster Jelix !

  [Opened] Output function on non object. Problème URGENT

Reply #1 Posted by foxmask on 05/12/2013 19:12

a partir de la ligne de code $meteo2 il faut mettre tout ce qui suit dans une autre méthode et avant meteo2 faire un redirect sur cette méthode. ainsi ça évitera qu'un utilisateur appuye sur la touche f5 et recharge la page et duplique les données. et c'est plus lisible maintenable et safe


@GitHub - Forum HaveFnuBB! powered by Jelix - Le Booster Jelix !

  [Opened] Output function on non object. Problème URGENT

Reply #2 Posted by bdecaslou on 05/12/2013 20:00

done mais le problème reste entier.

function createsave5(){
        $rep = $this->getResponse('html');
        $rep->addCssLink(jApp::config()->urlengine['basePath'].'css/mes_styles.css');
        $rep->body->assign('IMG',jApp::config()->urlengine['basePath'].'images/');
        $rep->addCssLink('http://code.jquery.com/ui/1.8.24/themes/base/jquery-ui.css');
        $rep->addJSLink('https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js');
        $rep->addJSLink('https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js');
        
        $form= jForms::fill("ProjetWeb~experiment4");
        $dt=$form->getData('Time');
        $experiment4 = jDao::createRecord('ProjetWeb~meteorologicaldata');
        $experiment4-> idExperiment =$this->param('idExperiment');
        $experiment4-> IdData =$this->param('IdData');
        $experiment4-> Time =$this->param('Time');
        $experiment4-> temperature =$this->param('temperature');
        $experiment4-> InsolationTime =$this->param('InsolationTime');
        $experiment4-> RainTime =$this->param('RainTime'); 
        $data =  jDao::get("meteorologicaldata");
        $data->insert($experiment4);
        
        $experiment =  jDao::get("experiment");
        $lastrecord = $experiment->getLastRecord();
        $id = $lastrecord->idExperiment;
        $dt2= $lastrecord->DateHourEnd;
        $duration=$lastrecord->duration;
        $record=$duration-2;
        jLog::dump($dt2);
        jLog::dump($dt);
        $aa=substr($dt, 8, 2);
        $ab=substr($dt,5, 2);
        $ac=substr($dt, 0, 4);
        $ad=substr($dt, 11, 2);
        $ae=substr($dt, 14, 2);
        $af=substr($dt, 17, 2);
        $aaa=substr($dt2, 8, 2);
        $aab=substr($dt2, 5, 2);
        $aac=substr($dt2, 0, 4);
        $aad=substr($dt2, 11, 2);
        $aae=substr($dt2,14, 2);
        $aaf=substr($dt, 17, 2);
        $j=0;
        $dt3=new JDateTime($ac,$ab,$aa,$ad,$ae,$af);
        $dt4=new JDateTime($aac,$aab,$aaa,$aad,$aae,$aaf);
        $dt5 = $dt3->durationTo($dt4);
        $durs=($dt5->seconds);
        $durd=($dt5->days)/86400;
        $durm=($dt5->months)/2592000;
        $dur=$durs+$durd+$durm;
        if ($record<=0 && $dur>3600)
            {$j=0;
             }
        else if ($record>0 && $dur>86400)
            {$j=0;
            }
     
           
              if ($j==0) {
                  
                if($record<=0 ){
                if($ad<23){$ad=$ad+1;}
                else if($ab==01 || $ab==03 || $ab==05 || $ab==07 || $ab==08 || $ab==10 || $ab==12)
                {if ($aa<31){$ad=0; $aa=$aa+1;}else {$ab=$ab+1; $aa=0;}$ad=0;}
                else if($ab==04 || $ab==06 || $ab==09 || $ab==11 )
                {if ($aa<30){$aa=$aa+1;$ad=0;}else {$ab=$ab+1; $aa=0;$ad=0;}}
                else if($ac%4==0){if ($aa<29){$aa=$aa+1;$ad=0;}else {$ab=$ab+1; $aa=0;$ad=0;}}
                else if ($aa<28){$aa=$aa+1;$ad=0;}else {$ab=$ab+1; $aa=0;$ad=0;}
                }
                else {
                if($ab==01 || $ab==03 || $ab==05 || $ab==07 || $ab==08 || $ab==10 || $ab==12)
                {if ($aa<31){$aa=$aa+1;}else {$ab=$ab+1; $aa=0;}}
                else if($ab==04 || $ab==06 || $ab==09 || $ab==11 )
                {if ($aa<30){$aa=$aa+1;}else {$ab=$ab+1; $aa=0;}}
                else if($ac%4==0){if ($aa<29){$aa=$aa+1;}else {$ab=$ab+1; $aa=0;}}
                else if ($aa<28){$aa=$aa+1;}else {$ab=$ab+1; $aa=0;}
                }
         
                $dt4=$ac.'-'.$ab.'-'.$aa.' '.$ad.':'.$ae.':'.$af;
                $meteo =  jDao::get("meteorologicaldata");
                $lastrecord1 = $meteo->getLastRecord1();
                $idd = $lastrecord1->IdData;
                jLog::dump($idd);
                $experiment5 = jDao::createRecord('ProjetWeb~meteorologicaldata'); 
                $experiment5-> idExperiment =$id;
                $experiment5-> Time =$dt4; 
                $experiment5-> IdData =$idd+1; 
                $experiment5-> temperature =0; 
                $experiment5-> InsolationTime =0; 
                $experiment5-> RainTime =0; 
                $data1 =  jDao::get("meteorologicaldata");
                $data1->insert($experiment5);
                
                $rep = $this->getResponse('redirect');
                $rep->action = 'ProjetWeb~default:data';
                                }
                
                else if ($j==1)
                    {
                $rep = $this->getResponse('redirect');
                $rep->action = 'ProjetWeb~default:retourMenu';
                    }  

        return rep;
    }  
function data(){
        $rep = $this->getResponse('html');
        $rep->addCssLink(jApp::config()->urlengine['basePath'].'css/mes_styles.css');
        $rep->body->assign('IMG',jApp::config()->urlengine['basePath'].'images/');
        $rep->addCssLink('http://code.jquery.com/ui/1.8.24/themes/base/jquery-ui.css');
        $rep->addJSLink('https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js');
        $rep->addJSLink('https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js');
        $meteo2 =  jDao::get("meteorologicaldata");
        $lastrecord2 = $meteo2->getLastRecord1();
        $formulaireexperiment4 = jForms::create("ProjetWeb~experiment4");
        $formulaireexperiment4->setData('idExperiment',$lastrecord2->idExperiment );
        $formulaireexperiment4->setData('IdData',$lastrecord2->IdData );
        $formulaireexperiment4->setData('Time',$lastrecord2->Time );
        $rep->body->assign('FORMULAIREEXPERIMENT4', $formulaireexperiment4);
        $rep->title = 'Complete fields of the experiment';
        $rep->bodyTpl = 'completer2';
    } 

  [Opened] Output function on non object. Problème URGENT

Reply #3 Posted by foxmask on 05/12/2013 20:03

c'est normal le return rep au lieu de return $rep ?


@GitHub - Forum HaveFnuBB! powered by Jelix - Le Booster Jelix !

  [Opened] Output function on non object. Problème URGENT

Reply #4 Posted by bdecaslou on 05/12/2013 20:10

Non ca ne l'est pas. Merci.

Passé sa journée à coder ca peut peut-être fatiguer la vue.

  [Opened] Output function on non object. Problème URGENT

Reply #5 Posted by foxmask on 05/12/2013 20:17

je l'avais vu depuis le début mais pensais a un malencontreux copier coller


@GitHub - Forum HaveFnuBB! powered by Jelix - Le Booster Jelix !

  [Opened] Output function on non object. Problème URGENT

Reply #6 Posted by laurentj on 05/13/2013 17:44

Je dirais que dans la deuxième action, tu ne rentre pas dans le if($j==0, et donc le formulaire n'est pas crée, et la variable de template $FORMULAIREEXPERIMENT4 n'existe donc pas. Et donc, quand formfull essaye d'afficher le formulaire, $FORMULAIREEXPERIMENT4 étant vide, ça fait boom.

 
Page
  1. Output function on non object. Problème URGENT