IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

[Blog] Code pour extraction de données


Sujet :

EDI, CMS, Outils, Scripts et API PHP

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Mars 2009
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 2
    Points : 1
    Points
    1
    Par défaut [Blog] Code pour extraction de données
    Bonjour,

    Je code une page en PHP afin de générer un document PDF interactif

    J'arrive à mettre un bouton permettant d'imprimer la page.

    J'aimerais remplacer la fonction d'impression par une fonction d'extraction des données vers un fichier plat (de type CSV ou texte) mais je n'y arrive pas

    Je vous joins le code de ma page...

    Merci pour votre aide !!!!
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    <?php
     
    require_once('../config/lang/eng.php');
    require_once('../tcpdf.php');
     
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
     
    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor('Pierre JOURDA');
    $pdf->SetTitle('Demande de Taxi Plage');
    $pdf->SetSubject('Demande de Taxi Plage');
     
    // set default header data
    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     
    // set header and footer fonts
    $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     
    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     
    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
     
    //set some language-dependent strings
    $pdf->setLanguageArray($l); 
     
    // ---------------------------------------------------------
     
    // set font
    $pdf->SetFont('helvetica', 'BI', 16);
     
    // add a page
    $pdf->AddPage();
     
    // Release User's Rights For PDF reader.
    // This is required to display and fill form fields on PDF Readers.
    $pdf->setUserRights();
     
    /*
    Caution: the generated PDF works only with Acrobat Reader 5.1.
    It is possible to create text fields, combo boxes, check boxes and buttons. Fields are created at the current position and are given a name. This name allows to manipulate them via JavaScript in order to perform some validation for instance.
    Upon field creation, an associative array can be passed to set a number of properties, among which:
    	rect: Position and size of field on page.
    	borderStyle: Rectangle border appearance.
    	strokeColor: Color of bounding rectangle.
    	lineWidth: Width of the edge of the surrounding rectangle.
    	rotation: Rotation of field in 90-degree increments.
    	fillColor: Background color of field (gray, transparent, RGB, or CMYK).
    	userName: Short description of field that appears on mouse-over.
    	readonly: Whether the user may change the field contents.
    	doNotScroll: Whether text fields may scroll.
    	display: Whether visible or hidden on screen or in print.
    	textFont: Text font.
    	textColor: Text color.
    	textSize: Text size.
    	richText: Rich text.
    	richValue: Text.
    	comb: Text comb format.
    	multiline: Text multiline.
    	charLimit: Text limit to number of characters.
    	fileSelect: Text file selection format.
    	password: Text password format.
    	alignment: Text layout in text fields.
    	buttonAlignX: X alignment of icon on button face.
    	buttonAlignY: Y alignment of icon on button face.
    	buttonFitBounds: Relative scaling of an icon to fit inside a button face.
    	buttonScaleHow: Relative scaling of an icon to fit inside a button face.
    	buttonScaleWhen: Relative scaling of an icon to fit inside a button face.
    	highlight: Appearance of a button when pushed.
    	style: Glyph style for checkbox and radio buttons.
    	numItems: Number of items in a combo box or list box.
    	editable: Whether the user can type in a combo box.
    	multipleSelection: Whether multiple list box items may be selected.
    Colors can be chosen in the following list (case sensitive): black white red green blue cyan magenta yellow dkGray gray ltGray or be in the form #RRGGBB.
    */
     
    $pdf->Cell(0, 5, 'Demande de Taxi Plage', 0, 1, 'C');
    $pdf->Ln(10);
    $pdf->SetFont('', '', 11);
     
    //Date of the day (determined and formatted by JS)
    $pdf->Write(5, 'Date');
    $pdf->Ln(6);
    $pdf->Write(5, 'de la demande :       ');
    $pdf->TextField('date', 25, 5);
    $pdf->IncludeJS("getField('date').value=util.printd('dd/mm/yyyy',new Date());\n");
    $pdf->Ln(10);
     
    //Prenom
    $pdf->Cell(35, 5, 'Prenom:');
    $pdf->TextField('firstname', 50, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(6);
     
    //Nom
    $pdf->Cell(35, 5, 'Nom:');
    $pdf->TextField('lastname', 50, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(10);
     
    //Date debut
    $pdf->Cell(35, 5, 'Date debut:');
    $pdf->ComboBox('datedebut', 10, 5, array('', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'), array('strokeColor'=>'ltGray'));
    $pdf->Cell(2, 2, '/');
    $pdf->ComboBox('datedebut2', 10, 5, array('', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'), array('strokeColor'=>'ltGray'));
    $pdf->Cell(2, 2, '/');
    $pdf->ComboBox('datedebut3', 14, 5, array('', '2009', '2010', '2011', '2012'), array('strokeColor'=>'ltGray'));
    $pdf->Ln(6);
     
    //Date fin
    $pdf->Cell(35, 5, 'Date fin:');
    $pdf->ComboBox('datefin', 10, 5, array('', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'), array('strokeColor'=>'ltGray'));
    $pdf->Cell(2, 2, '/');
    $pdf->ComboBox('datefin2', 10, 5, array('', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'), array('strokeColor'=>'ltGray'));
    $pdf->Cell(2, 2, '/');
    $pdf->ComboBox('datefin3', 14, 5, array('', '2009', '2010', '2011', '2012'), array('strokeColor'=>'ltGray'));
    $pdf->Ln(6);
     
    //Charge
    $pdf->Cell(35, 5, 'Charge en jours:');
    $pdf->TextField('charge', 6, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(10);
     
    //Code imputation
    //$pdf->Cell(35, 5, 'Type imputation :');
    //$pdf->ComboBox('type', 50, 5, array('', 'Commercial', 'Hors contrat', 'Client'), array('strokeColor'=>'ltGray'));
    //$pdf->Ln(6);
     
    //Code imputation 2
    //$pdf->Cell(35, 5, 'Imputation :');
    //$pdf->ComboBox('Imputation', 50, 5, array('', 'BDI', 'S&C', 'Perf&Co', 'Mindset', 'Support'), array('strokeColor'=>'ltGray'));
    //$pdf->Ln(6);
     
    //Code imputation
    $pdf->Cell(35, 5, 'Code imputation:');
    $pdf->TextField('type', 50, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(6);
     
    //Client
    $pdf->Cell(35, 5, 'Nom client:');
    $pdf->TextField('nomclient', 50, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(10);
     
    //Livrables
    $pdf->Cell(35, 5, 'Livrable 1:');
    $pdf->TextField('Livrables1', 140, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(6);
     
    $pdf->Cell(35, 5, 'Livrable 2:');
    $pdf->TextField('Livrables2', 140, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(6);
     
    $pdf->Cell(35, 5, 'Livrable 3:');
    $pdf->TextField('Livrables3', 140, 5, array('strokeColor'=>'ltGray'));
    $pdf->Ln(10);
     
    //Description de la demande
    $pdf->Cell(35, 5, 'Description');
    $pdf->TextField('demande', 140, 95, array('multiline'=>true,'strokeColor'=>'ltGray'));
    $pdf->Ln(6);
    $pdf->Cell(35, 5, 'de la demande :');
    $pdf->Ln(100);
     
    // 
     
    //Button to validate and print
    $pdf->SetX(95);
    $pdf->Button('print', 20, 8, 'Envoi', 'Print()', array('textColor'=>'yellow', 'fillColor'=>'#FF5050'));
     
    //Form validation functions
    $pdf->IncludeJS("
    function CheckField(name,message) {
    	var f = getField(name);
    	if(f.value == '') {
    	    app.alert(message);
    	    f.setFocus();
    	    return false;
    	}
    	return true;
    }
    
    function Print() {
    	//Validation
    	if(!CheckField('firstname','Le prenom est obligatoire'))
    		return;
    	if(!CheckField('lastname','Le nom est obligatoire'))
    		return;
    	if(!CheckField('demande','Merci de remplir la description de la demande'))
    		return;
    	if(!CheckField('datedebut','Merci de remplir la date de debut'))
    		return;
    	if(!CheckField('datedebut2','Merci de remplir la date de debut'))
    		return;
    	if(!CheckField('datedebut3','Merci de remplir la date de debut'))
    		return;
    	if(!CheckField('datefin','Merci de remplir la date de fin'))
    		return;
    	if(!CheckField('datefin2','Merci de remplir la date de fin'))
    		return;
    	if(!CheckField('datefin3','Merci de remplir la date de fin'))
    		return;
    	if(!CheckField('charge','Merci de remplir le nombre de jours de travail'))
    		return;
    	if(!CheckField('type','Merci de remplir le type d imputation'))
    		return;
    	if(!CheckField('Imputation','Merci de remplir la ligne d imputation'))
    		return;
    	//Print
    
    	print();
    }
    ");
     
    // ---------------------------------------------------------
     
    //Close and output PDF document
    $pdf->Output('DEMANDE_TAXI_PLAGE.pdf', 'I');
     
    //============================================================+
    // END OF FILE                                                 
    //============================================================+
    ?>

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Bonjour,

    Pourrais-tu plutot nous montrer ce que tu as commencé pour le csv que nous puissions le corriger ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Nouveau Candidat au Club
    Inscrit en
    Mars 2009
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    Re bonjour,

    J'ai essayé avec ce code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    // Création du fichier
    $pdf->fopen ("test.txt", "w");
    // Positionnement au début du fichier
    $pdf->fseek ($fp, 0);
    // ecriture dans la fichier 
    $pdf->fputs ($fp, $name.$firstname); 
    // Fermeture du fichier
    $pdf->fclose ($fp);
    Mais je n'arrive pas à le lier au bouton (est-ce du code PHP ou du Java qu'il faut utiliser) ???

Discussions similaires

  1. [RegEx] aide pour extraction de données
    Par Hotfirenet dans le forum Langage
    Réponses: 2
    Dernier message: 13/04/2008, 21h19
  2. Solution pour Extraction de données Excell ? Routines?
    Par ccbbrr172 dans le forum Alimentation
    Réponses: 8
    Dernier message: 28/03/2008, 16h37
  3. SAP et PL/SQL(Pour extraction de données)
    Par ricobye dans le forum SAP
    Réponses: 8
    Dernier message: 07/09/2007, 12h08
  4. code pour extraction ds une requete
    Par patgame dans le forum Modélisation
    Réponses: 3
    Dernier message: 11/08/2007, 14h28
  5. Réponses: 23
    Dernier message: 24/05/2007, 11h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo