array(), 'cols' => array() ); //tableau de données public function __construct($datas,$id,$param=array()){ //on gère les propriétés communes dans la classe parente parent::__construct($datas,$id,$param); $this->set_param_tcd($param["tcd"]); $this->get_datas(); } public function get_datas(){ if(count($this->datas_tcd) && count($this->datas_tcd["values"])){ //Le calcule est déjà fait }elseif(!$this->my_param["tcd"]){ $this->datas_tcd=array( 'values' => array(), 'cols' => array() ); }else{ $value = explode("_",$this->my_param["tcd"]); for($i=1 ; $idatas) ; $i++){ if(!in_array($this->datas[$i][$value[1]],$this->datas_tcd['cols'])){ $this->datas_tcd['cols'][] = $this->datas[$i][$value[1]]; } $this->datas_tcd['values'][$this->datas[$i][$value[0]]][$this->datas[$i][$value[1]]]++; } } return $this->datas_tcd; } public function set_param_tcd($param=array()){ global $save_param; global $tcd; if($save_param == "tcd"){ global $tcd; }else{ $tcd=$param; } $this->my_param["tcd"]=$tcd; return; } public function get_form(){ global $charset,$msg; //document.forms.editions_state_tcd.submit() $form = "
"; return $form; } //un simple tableau pour la classe générique... public function show(){ global $charset,$msg; global $javascript_path; $html = $this->get_form(); if(count($this->datas_tcd['values'])){ $html.= "
"; foreach($this->datas_tcd['cols'] as $label){ $html.= " "; } $html.= " "; foreach($this->datas_tcd['values'] as $row => $cols){ $html.= " "; foreach($this->datas_tcd['cols'] as $key){ $html.= " "; } $html.= " "; } $html.="
".htmlentities($label,ENT_QUOTES,$charset)."
".htmlentities($row,ENT_QUOTES,$charset)."".htmlentities(($cols[$key] ? $cols[$key] : 0),ENT_QUOTES,$charset)."
"; } $html.="
"; return $html; } public function render_xls_file($name="state"){ $tmp_file = tempnam(sys_get_temp_dir(),"state_"); header("Content-Type: application/x-msexcel; name=\"".$name.".xls\""); header("Content-Disposition: inline; filename=\"".$name.".xls\""); $workbook = new writeexcel_workbook($tmp_file); $worksheet = &$workbook->addworksheet(); foreach($this->datas_tcd['cols'] as $key => $label){ $worksheet->write(0,$key+1,$label); } $nb_ligne=1; foreach($this->datas_tcd['values'] as $row => $cols){ $worksheet->write($nb_ligne,0,$row); $nb_col=1; foreach($this->datas_tcd['cols'] as $key){ $worksheet->write($nb_ligne,$nb_col,($cols[$key] ? $cols[$key] : 0)); $nb_col++; } $nb_ligne++; } $workbook->close(); $fh=fopen($tmp_file, "rb"); fpassthru($fh); unlink($tmp_file); } }