2016-08-19 10 views
0

私の最初の投稿ですので、間違いがありましたらごめんなさい。ため、私は、この関数のこの朝から怒っ取得しています:私はviewpdf0関数から計算を脱いで、create_remittance機能にそれを置くことを決めたときに問題が開始CakePhpを作成して見た後にPDFを表示してください。

public function viewpdf0($agent_id = null, $month = null, $year = null){ 

    if(!empty($agent_id)){ 

     $this->create_remittance($agent_id, $month, $year); 

     $this->layout = '/pdf/default'; 
     $this->render('/Pdf/remittance_0'); 
     sleep(1); 

     $this->redirect('/files/remittances/STAT_'.str_pad($month, 2, '0', STR_PAD_LEFT).'_'.str_pad($year, 0, '0', STR_PAD_LEFT).'_'.$agent['Registry']['hash'].'_TEMP.pdf'); 

    } 
} 

i "は印刷PDF" ボタンをクリックすると、私は次のエラーを取得:ファイルに対して

Missindコントローラを。これは、Cakephpがファイルと呼ばれるコントローラを見つけるためにリダイレクトの考えを処理していることを意味します。

私は、計算機能をviewpdf0関数の中に直接置くと非常に奇妙です。

create_remittance機能の一部下:

パブリック関数create_remittance($ AGENT_ID = nullを、$月= nullを、$年= NULL){ $エージェント=の$ this - > Registry-> findById($のAGENT_ID ); $ this-> set( 'agent'、$ agent);

 $conditions = array(); 

     array_push($conditions , array('Dossier.active' => '1')); 

     array_push($conditions , array('Edossier.active' => '1')); 

     array_push($conditions , array('OR' =>  
          array(
           array(
             'Dossier.item_parent_id' => '43' 
            ), 
           array(  
             'Dossier.item_parent_id' => '44' 
            ) 
          ) 

         )); 

     //20:POLIZZA EMESSA - 17:PERFEZIONATA - 14:ATTESA DOC. ORIGINALI - 18:CARICATA    
     array_push($conditions , array('Dossier.state_id' => array(20,17,14,18))); 

     array_push($conditions , array('EXTRACT(MONTH FROM "Edossier"."date_emissione") =' => $month)); 

     array_push($conditions , array('EXTRACT(YEAR FROM "Edossier"."date_emissione") =' => $year)); 

     array_push($conditions , array('Dossier.agent_id' => $agent_id)); 

     $query = array(
         'fields' => array( 'DISTINCT Dossier.id', 
              'Agent.surname'          
              ), 

         'joins' => array(           
             array('table' => 'items', 
               'alias' => 'Item', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.item_id = Item.id'), 
              ), 

             array('table' => 'edossiers', 
               'alias' => 'Edossier', 
               'type' => 'LEFT', 
               'conditions' => array('Edossier.dossier_id = Dossier.id'), 
              ), 

             array('table' => 'registries', 
               'alias' => 'Registry', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.registry_id = Registry.id'), 
              ), 

             array('table' => 'registries', 
               'alias' => 'Agency', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.insurance_agency_id = Agency.id'), 
              ), 

             array('table' => 'registries', 
               'alias' => 'Company', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.insurance_company_id = Company.id'), 
              ), 

             array('table' => 'states', 
               'alias' => 'State', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.state_id = State.id'), 
              ), 

             array('table' => 'categories', 
               'alias' => 'Product', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.item_parent_id = Product.id'), 
              ), 

             array('table' => 'registries', 
               'alias' => 'Agent', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.agent_id = Agent.id'), 
              ), 

             array('table' => 'states', 
               'alias' => 'RenewedState', 
               'type' => 'LEFT', 
               'conditions' => array('Dossier.renewed_state_id = RenewedState.id'), 
              ),         


             ), 
         'conditions' => $conditions, 
         'recursive' => -1   
        ); 

     $dossiers = $this->Dossier->find('all', $query); 

     $this->set('dossiers', $dossiers); 

     $debug_dossier = ''; 
     $edossiers = array(); 
     $edossiers3 = array(); 
     $dossier_ids = array(); 
     $total_gross = 0; 
     $total_taxes = 0; 
     $total_equity = 0; 
     $total_fees_gross = 0; 
     $total_bill_tax = 0; 

     foreach($dossiers as $dossier){ 

      // Query su type=1 ossia rata di pagamento 
      $edossier_all = $this->Edossier->find('all', array(
       'conditions' => array(
        'Edossier.active' => '1', 
        'Edossier.dossier_id' => $dossier['Dossier']['id'], 
        'Edossier.type' => '1', 
        'Edossier.month' => $month, 
        'Edossier.year' => $year 
       ), 
       'order' => array(
        'Edossier.id ASC' 
       ) 
      )); 

      // Query su type=2 ossia storno di pagamento 
      $edossier3_all = $this->Edossier->find('all', array(
       'conditions' => array(
        'Edossier.active' => '1', 
        'Edossier.dossier_id' => $dossier['Dossier']['id'], 
        'Edossier.type' => '2', 
        'Edossier.month' => $month, 
        'Edossier.year' => $year 
       ), 
       'order' => array(
        'Edossier.id ASC' 
       ) 
      )); 



      foreach($edossier_all as $edossier){ 
       if(!empty($edossier)){ 
        $item = $this->Item->findById($edossier['Dossier']['item_id']); 
        $agent_name = $this->Registry->findById($edossier['Dossier']['agent_id']); 
        $state = $this->State->findById($edossier['Dossier']['state_id']); 
        $registry = $this->Registry->findById($edossier['Dossier']['registry_id']); 
        $cashflow = $this->Cashflow->findByHash($edossier['Edossier']['cashflow_hash']); 
        $edossier['Agent'] = $agent_name; 
        $edossier['Item'] = $item; 
        $edossier['State'] = $state; 
        $edossier['Registry'] = $registry; 
        $edossier['Cashflow'] = $cashflow; 
        array_push($edossiers, $edossier); 
        $total_gross = $total_gross + $edossier['Edossier']['gross']; 
        $total_taxes = $total_taxes + $edossier['Edossier']['taxes']; 
        $total_equity = $total_equity + $edossier['Edossier']['equity']; 
        $total_fees_gross = $total_fees_gross + $edossier['Edossier']['fees_gross']; 
        $total_bill_tax = $total_bill_tax + $edossier['Edossier']['bill_tax']; 
       } 
      } 

      foreach($edossier3_all as $edossier3){ 
       if(!empty($edossier3)){ 

        $total_gross = $total_gross - $edossier3['Edossier']['value']; 
        $total_taxes = $total_taxes - $edossier3['Edossier']['taxes']; 
        $total_equity = $total_equity - $edossier3['Edossier']['equity']; 
        $total_fees_gross = $total_fees_gross - $edossier3['Edossier']['fees_gross']; 
        $total_bill_tax = $total_bill_tax - $edossier3['Edossier']['bill_tax']; 


        array_push($edossiers3, $edossier3); 
       } 
      }    

      array_push($dossier_ids, $dossier['Dossier']['id']); 
      $debug_dossier .= $dossier['Dossier']['id'] .','; 
     } 

     //Trovo tutte le rate pagate per conteggiare il totale pagato, nelle successive righe 
     $edossiers2 = $this->Edossier->find('all', array(
      'conditions' => array(
       'Edossier.active' => '1', 
       'Edossier.dossier_id' => $dossier_ids, 
       'Edossier.payed' => '1', 
       'Edossier.month' => $month, 
       'Edossier.year' => $year 
      ) 
     )); 

     $edossier_ids = array(); 
     foreach($edossiers as $edossier){ 
      array_push($edossier_ids, $edossier['Edossier']['id']); 
     } 


     $total_payed = 0; 
     foreach($edossiers2 as $edossier2){ 
      //$cashflow = $this->Cashflow->findByHash($edossier2['Edossier']['cashflow_hash']); 
      //$total_payed = $total_payed + $cashflow['Cashflow']['qty']; 

      $cashflows = $this->Cashflow->find('all', array(
       'conditions' => array(
        'Cashflow.edossier_id' => $edossier2['Edossier']['id'], 
        'Cashflow.active' => '1' 
        ) 
      )); 

      foreach ($cashflows as $cashflow) { 

       $total_payed = $total_payed + $cashflow['Cashflow']['qty']; 
      } 

     } 

     $this->set('total_gross', $total_gross); 
     $this->set('total_taxes', $total_taxes); 
     $this->set('total_equity', $total_equity); 
     $this->set('total_fees_gross', $total_fees_gross); 
     $this->set('total_bill_tax', $total_bill_tax); 

     $this->set('total_payed', $total_payed); 
     $this->set('edossiers3', $edossiers3); 
     $this->set('edossiers2', $edossiers2); 
     $this->set('edossiers', $edossiers); 
     $this->set('agent', $agent); 
     $this->set('dossier_ids', $dossier_ids); 
     $this->set('edossier_ids', $edossier_ids); 
     $this->set('month', $month); 
     $this->set('year', $year); 
     $this->set('debug_dossier', $debug_dossier); 
} 
+0

'Missing Controller'エラーが発生した場合は、ルーティングに問題があります。適切なルーティングを使用することをお勧めします。 [ドキュメントを参照](http://book.cakephp.org/2.0/ja/development/routing.html)。 – BadHorsie

+0

'create_remittance'関数の中で' $ agent'を定義していますが、リダイレクトを呼び出すときに関数の外でそれを使用しています。あなたが未定義のエラーなどを得ていないのは奇妙です – arilia

+0

これを書いた場合、$ this-> redirect( 'http://crm0.convieneonline.it/files/remittances/STAT_'.str_pad($ month、2、' ' 0 '、STR_PAD_LEFT)。' _ 'str_pad($ year、0、' 0 '、STR_PAD_LEFT).'_' $ agent ['Registry'] ['hash'] .'_ TEMP.pdf '); http://crm0.convieneonline.it/http://crm0.convieneonline.it ... – leele144

答えて

0

私はちょうど、機能create_remittanceに、私はこのように固定機能viewpdf0に配列リターンを挿入する問題を解決:

$送金=の$ this - > create_remittance($ AGENT_ID、$月、 $年);

ありがとうございます。

関連する問題