Changeset 474

Show
Ignore:
Timestamp:
05/12/08 14:02:03 (7 months ago)
Author:
aarkerio
Message:

Improved helper

Location:
trunk/app
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_model.php

    r339 r474  
    11<?php 
     2/**  
     3*   @author: Manuel Montoya  
     4*   Chipotle SoftwareTM 2002-2008   
     5*   GPLv3   
     6**/ 
    27class AppModel extends Model{ 
    38  
     
    3540        ( 
    3641                array($this->assocs[$assoc]['type'] => 
    37             array($assoc => $this->assocs[$assoc]))); 
    38             } 
    39      }  
     42            array($assoc => $this->assocs[$assoc])) 
     43            ); 
     44      } 
     45 } 
     46 
     47/**  
     48*   Unbinds all unneeded associations   
     49*   @author: Oth aka KrazyLegs 
     50*   @reference: http://othy.wordpress.com/2006/06/03/unbind-all-associations-except-some/  
     51**/ 
     52 
     53public function unbindAll($params = array()) 
     54{ 
     55  foreach($this->__associations as $ass) // this array returns hasOne, HasMany, etc    
     56  { 
     57     if (!empty($this->{$ass}))  // if hasMany assos exist, if HasOne exist, etce 
     58     { 
     59        $this->__backAssociation[$ass] = $this->{$ass}; 
     60 
     61    if ( isset($params[$ass]) ) 
     62    { 
     63           foreach ( $this->{$ass} as $model => $detail ) 
     64       { 
     65          if (!in_array($model,$params[$ass])) 
     66          { 
     67            $this->__backAssociation = array_merge($this->__backAssociation, $this->{$ass}); 
     68            unset($this->{$ass}[$model]); 
     69          } 
     70       } 
     71        } 
     72        else 
     73        { 
     74          $this->__backAssociation = array_merge($this->__backAssociation, $this->{$ass}); 
     75          $this->{$ass} = array(); 
     76        } 
     77       } 
     78     } 
     79    return true; 
     80  }   
    4081} 
    4182?> 
  • trunk/app/controllers/vclassrooms_controller.php

    r468 r474  
    161161 { 
    162162   $this->layout = 'pdf'; 
     163   $this->Vclassroom->unbindAll(); 
     164   $conditions              = array('Vclassroom.id'=>$vclassroom_id); 
     165   $fields                  = array('Vclassroom.name', 'Vclassroom.created'); //null; 
     166 
     167   $this->set('group',$this->Vclassroom->find($conditions, $fields)); 
     168 
    163169   $this->set('data', $this->Vclassroom->recordClass($vclassroom_id)); 
    164170 } 
  • trunk/app/models/vclassroom.php

    r471 r474  
    152152  $users      = array(); 
    153153  $records    = array(); 
    154      
     154    
    155155  $data  = $this->UsersVclassroom->findAll(array('UsersVclassroom.vclassroom_id'=>$vclassroom_id), array('user_id')); 
    156  
     156   
    157157  //die(debug($data));    
    158158  foreach ($data as $u): 
     159 
     160     $this->User->removeBinds();  // remove innecesaries user binds 
    159161      
    160162     $user_id = $u['UsersVclassroom']['user_id']; 
    161163 
    162      $conditions       = array('User.id'=>$user_id); 
    163      $fields           = array('User.name', 'User.email'); //null; 
     164     $conditions        = array('User.id'=>$user_id); 
     165     $fields            = array('User.name', 'User.email'); //null; 
    164166     $records[$user_id] = $this->User->find($conditions, $fields); 
    165167   
  • trunk/app/views/helpers/fpdf.php

    r456 r474  
    11<?php  
    2  
     2/** 
     3*    Chipotle Software TM 
     4*    Manuel Montoya 2002-2008 
     5*    GPLv3 manuel<arroba>mononeurona<punto>org 
     6*/ 
    37App::import('Vendor', 'fpdf/myfpdf'); 
    48 
     
    2226  public function setData($data) 
    2327  { 
    24     $this->pdf->Cell(0,10,$data,1,1,'L'); 
    25     $this->pdf->Ln(10); 
     28    $string  =  utf8_decode($data); 
     29    $this->pdf->Cell(0,5,$string,1,1,'L'); 
     30    $this->pdf->Ln(5); 
    2631  } 
    2732 
  • trunk/app/views/layouts/pdf.ctp

    r455 r474  
    11<?php 
    2 header("Content-type: application/pdf"); 
     2header('Content-type: application/pdf; charset="utf-8"',true); 
    33echo $content_for_layout; 
    44?>  
  • trunk/app/views/vclassrooms/admin_export.ctp

    r471 r474  
    11<?php 
    2 //die(debug($data)); 
     2// die(debug($data)); 
    33 
    44 foreach ($data as $u): 
    5  
     5     
    66    $fpdf->newPage(); 
    77 
    8     $fpdf->setData('Student '.$u['User']['name'] . ' '.$u['User']['email']); 
     8    $fpdf->setData('Group: ' . $group['Vclassroom']['name'] . '. Created '.$group['Vclassroom']['created']); 
     9    $fpdf->setData('Student '. $u['User']['name'] . ' '.$u['User']['email']); 
    910 
    1011    foreach ($u['tests'] as $te):