Пример #1
0
header('Content-type: application/csv');
header('Content-Disposition: attachment;filename="fiche.csv"', FALSE);
include_once "ac_common.php";
include_once 'class_fiche.php';
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/class_dossier.php';
$gDossier = dossier::id();
$cn = new Database($gDossier);
require_once NOALYSS_INCLUDE . '/class_user.php';
if (isset($_GET['fd_id'])) {
    $fiche_def = new Fiche_Def($cn, $_GET['fd_id']);
    $fiche = new Fiche($cn);
    $e = $fiche_def->get_by_type();
    $o = 0;
    //  Heading
    $fiche_def->GetAttribut();
    foreach ($fiche_def->attribut as $attribut) {
        if ($o == 0) {
            printf("%s", $attribut->ad_text);
            $o = 1;
        } else {
            printf(";%s", $attribut->ad_text);
        }
    }
    printf("\n");
    $o = 0;
    // Details
    foreach ($e as $fiche) {
        $detail = new Fiche($cn, $fiche['f_id']);
        $detail->getAttribut();
        foreach ($detail->attribut as $dattribut) {
Пример #2
0
 /**
  *\brief  get all the attribute of a card, add missing ones
  *         and sort the array ($this-\>attribut) by ad_id
  */
 function getAttribut()
 {
     if ($this->id == 0) {
         return;
     }
     $sql = "select *\n             from\n                   fiche\n             natural join fiche_detail\n\t     join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and fiche_detail.ad_id=jnt_fic_attr.ad_id)\n             join attr_def on (attr_def.ad_id=fiche_detail.ad_id) where f_id=" . $this->id . " order by jnt_order";
     $Ret = $this->cn->exec_sql($sql);
     if (($Max = Database::num_row($Ret)) == 0) {
         return;
     }
     for ($i = 0; $i < $Max; $i++) {
         $row = Database::fetch_array($Ret, $i);
         $this->fiche_def = $row['fd_id'];
         $t = new Fiche_Attr($this->cn);
         $t->ad_id = $row['ad_id'];
         $t->ad_text = $row['ad_text'];
         $t->av_text = $row['ad_value'];
         $t->ad_type = $row['ad_type'];
         $t->ad_size = $row['ad_size'];
         $t->ad_extra = $row['ad_extra'];
         $t->jnt_order = $row['jnt_order'];
         $this->attribut[$i] = $t;
     }
     $e = new Fiche_Def($this->cn, $this->fiche_def);
     $e->GetAttribut();
     if (sizeof($this->attribut) != sizeof($e->attribut)) {
         /*
          * !! Missing attribute
          */
         foreach ($e->attribut as $f) {
             $flag = 0;
             foreach ($this->attribut as $g) {
                 if ($g->ad_id == $f->ad_id) {
                     $flag = 1;
                 }
             }
             if ($flag == 0) {
                 // there's a missing one, we insert it
                 $t = new Fiche_Attr($f->ad_id);
                 $t->av_text = "";
                 $t->ad_text = $f->ad_text;
                 $t->jnt_order = $f->jnt_order;
                 $t->ad_type = $f->ad_type;
                 $t->ad_size = $f->ad_size;
                 $t->ad_id = $f->ad_id;
                 $t->ad_extra = $f->ad_extra;
                 $this->attribut[$Max] = $t;
                 $Max++;
             }
             // if flag == 0
         }
         // foreach
     }
     //missing attribut
 }