PDF integreren in factuur plugin (wordpress)

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ellen Skapandi

Ellen Skapandi

23/06/2013 16:05:58
Quote Anchor link
Hallo.
Ik heb een script op Wordpress, wp-invoice-ultimate. waar je in de back-end informatie over een factuur (factuurnummer, contactgegevens, bedragen) in een template kan zetten. Als je op opslaan klikt, komen de factuurgegevens op een pagina op internet te staan en wordt die template verzonden naar de mail van de klant. Niet als bijlage, maar in de mail zelf.
Die plugin zit mooi in elkaar, ik wil er graag 4 functies aan toevoegen:

- De template die opgemaakt wordt in html, moet omgezet worden naar een pdf bestandje.

- De pdf moet automatisch verzonden worden als bijlage naar de klant.

- De titel uit de back-end moet het onderwerp van de mail worden, het factuurnummer daarachter.

- De back-end content moet de mail worden.

Zou iemand mij hiermee kunnen helpen? Ik heb zelf te weinig verstand van php om dit voor elkaar te krijgen..


Het php-bestandje die de gegevens uit de back-end laadt in de template, is dit:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<?php
if(have_posts()):
while(have_posts()):
the_post();
$meta = get_post_meta(get_the_ID(), '_wpiu_invoice_meta', true);
$trans = get_post_meta(get_the_ID(), '_wpiu_invoice_meta_trans', true);
$options = get_option(WPIU_OPTION);
$user = get_userdata($meta['_wpiu_invoice_meta_client']);

$currency = WPIU_Options::get_currency();
$tax = ($options['invoice_payment_tax'])?$options['invoice_payment_tax'].'%':'0%';
$balanceleft = $meta['_wpiu_invoice_meta_total'] - $meta['_wpiu_invoice_meta_paid'];

global $current_user;
get_currentuserinfo();

if($current_user->ID == $meta['_wpiu_invoice_meta_client']){$valid_user = true;}
elseif ( current_user_can('manage_options') ){$valid_user = true;}
else{$valid_user = false;}

if(isset($_GET['email']) && $_GET['email'] == 'true'){
    $valid_user = true;
}


?>

<!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 7]>
<html id="ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html id="ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8)  ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php echo wp_title('',false).' #'.$meta['_wpiu_invoice_meta_invoice_number'];?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" href="invoicestijl.css">
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js?ver=3.3'></script>
<script>
jQuery(document).ready(function() {
    jQuery('#invoice_trans .trans_show').click(function(){
        jQuery(this).next('div').slideToggle('slow');
    });
});
</script>
<style type="text/css">
body {
    background:#EEEEEE;
}

.container {
    width:680px;
}

#paypal {
    margin-left:8px;
}

.container.main {
    width:640px;
    margin: 80px auto 80px auto;
    padding:20px;
    background:#ffffff;

    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

#header td{
    border-top: none;
}

#header h1 {
    margin-bottom: 8px;
    text-align:center;
}

.alert-message{
    text-align:center;
}

#meta-info tr td{
    width: 50%;
    border:none;
    text-align: center;
    vertical-align: middle;
    line-height:15px;
}

#factuur-info tr td{
    border:none;
    text-align: center;
    line-height:15px;
}

#invoice-details tr td{
    border:none;
}

#invoice-details-items{
    margin-top:40px;
}

.item-centered {
    width:80px;
    text-align:center;
    line-height: 6px;
}

.totals {
    text-align:right;
}

.totals-tr td{
    font-weight:bold;
}

#invoice_trans td .details {
    display:none;
    font-size:10px;
}

#footer {
    margin-bottom:0px;
    margin-top:40px;
}

#footer tr td {
    border:none;
}

#lower_footer{
    font-size:10px;
    color:#666666;
}

.credit{
    text-align:center;
    margin-bottom:20px;
    font-size:11px;
}

<?php if(isset($_GET['email']) && $_GET['email'] == 'true'){?>
.topbar {
    display:none;
}
<?php }?>

#email_header{
    margin-bottom:-79px;
    background: #F9F9F9;
    padding:40px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    min-height:80px;
}
</style>
<style type="text/css" media="print">
.topbar{
    display:none;
}
.container {
    margin-top:0px;
    box-shadow:none;
    border:1px solid #cccccc;
}
.well {
    box-shadow:none;
    border:1px solid #cccccc;
}    
</style>
</head>
<body <?php body_class(); ?>>

<?php if(!$valid_user){?>
<div class="container main">
<p>Sorry you must be logged in to view invoices, please login:</p>
<form id="loginform" method="post" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) );?>" name="loginform" class="well">
<p class="login-username">
<label for="user_login">Username</label>
<input id="user_login" class="input" type="text" tabindex="10" size="20" value="" name="log">
</p>
<p class="login-password">
<label for="user_pass">Password</label>
<input id="user_pass" class="input" type="password" tabindex="20" size="20" value="" name="pwd">
</p>
<p class="login-submit">
<label for="wp-submit"> </label>
<input id="wp-submit" class="btn primary input" type="submit" tabindex="100" value="Log In" name="wp-submit">
<input type="hidden" value="<?php echo get_permalink();?>" name="redirect_to">
</p>
</form>
</div>
<div class="container credit"></div>
</body>
</html>
<?php
return;
}
?>




    <div class="topbar">
      <div class="fill">
        <div class="container">
          <a class="brand" href="<?php echo site_url();?>"><?php bloginfo('name');?></a>
        
        
        <form class="pull-right">
            <?php if($valid_user) {?>
                <button class="btn" onclick="window.print()"><?php _e('Print', WPIU_LANG);?></button>
        </form>
        

        
        <?php }else{?>
          <form action="<?php echo wp_login_url(get_permalink()); ?>" class="pull-right">
            <input class="input-small" type="text" placeholder="Username">
            <input class="input-small" type="password" placeholder="Password">
            <button class="btn primary" type="submit"><?php _e('Login', WPIU_LANG);?></button>
          </form>
        <?php } ?>
        </div>
      </div>
    </div>

    
<?php if(isset($_GET['email']) && $_GET['email'] == 'true'){?>
<div id="email_header">
<?php _e('Dear ', WPIU_LANG); echo $user->display_name;?>,<br/><br/>
<?php if(isset($_GET['proccessing']) && $_GET['proccessing'] == 'true'){?>
<?php _e('A payment has been made on your invoice and it is being proccessed.<br/><br/>', WPIU_LANG);?>
<?php }else{?>
<?php _e('Your invoice has been generated and is ready for your payment. You can view the details of the invoice below.<br/><br/>', WPIU_LANG);?>
<?php }?>
<?php _e('To pay/print your Invoice view it online <a href="'.get_permalink().'">here</a>', WPIU_LANG);?>

</div>
<?php }?>

<div class="container main">

<?php if(isset($_GET['proccessing']) && $_GET['proccessing'] == 'true' && !isset($_GET['email'])){?>
    <div class="container" style="margin-top:80px;">
    <div class="alert-message success">
    <?php _e('<p><strong>Please Wait</strong> We are just updating the invoice to contain the latest payment data. You will be redirected in a few seconds.</p>', WPIU_LANG);?>
    </div>
    </div>
    <meta http-equiv="refresh" content="5; url=<?php echo get_permalink();?>">
<?php }?>
    
<table id="meta-info">
<tr>
<td>
<?php
echo get_the_author_meta('company_name2',$user->ID).'<br/>';
echo 'tav ';
echo get_the_author_meta('first_name',$user->ID).' ';
echo get_the_author_meta('last_name',$user->ID).'<br />';
echo get_the_author_meta('company_street',$user->ID).'<br/>';
echo get_the_author_meta('company_zip',$user->ID).' ';
echo get_the_author_meta('company_city',$user->ID).'<br/>';
?>

</td>
<td>
<div class="well">
<?php
echo '<img src="images-ska/logo.png" width="130px"><br/>';
echo '<strong>Tel.nr:</strong> 000000<br/>';
echo '<strong>Email:</strong>  0000000';
?>

</div>
</td>
</tr>
</table>

<table id="factuur-info">
<tr>
<td colspan="2"></td>
<td colspan="2"><?php
echo '<p align="right"><font size="15px"><strong>factuur</strong></font></p>';
?>
</td>
</tr>
<tr>
<td><?php
echo '<strong>'.__('Klantnummer:', WPIU_LANG).'</strong><br/>';
?>
</td>
<td><?php
echo '<strong>'.__('Factuurnummer:', WPIU_LANG).'</strong><br/> '.$meta['_wpiu_invoice_meta_invoice_number'].'<br/>';
?>
</td>
<td><?php
echo '<strong>'.__('Factuurdatum:', WPIU_LANG).'</strong><br/> '.get_the_date().'<br/>';
?>
</td>
</tr>
</table>

<table id="invoice-details-items" class="zebra-striped">
<thead>
<tr>
<th style="background-color:#c0c0c0;"><?php _e('Omschrijving', WPIU_LANG);?></th>
<th style="background-color:#c0c0c0;" class="item-centered"><?php _e('Aantal', WPIU_LANG);?></th>
<th style="background-color:#c0c0c0;" class="item-centered"><?php _e('Prijs', WPIU_LANG);?></th>
<th style="background-color:#c0c0c0;" class="item-centered"><?php _e('Totaal', WPIU_LANG);?></th>
</tr>
</thead>

<?php

$index
= 0;

while($index < count($meta['_wpiu_invoice_meta_item']['title'])){
    if($meta['_wpiu_invoice_meta_item']['title'][$index] != ''){
        echo '<tr>';
        echo '<td>'.$meta['_wpiu_invoice_meta_item']['title'][$index].'</td>';
        echo '<td class="item-centered">'.$meta['_wpiu_invoice_meta_item']['qty'][$index].'</td>';
        echo '<td class="item-centered">'.$currency.$meta['_wpiu_invoice_meta_item']['unit_price'][$index].'</td>';    
        echo '<td class="item-centered">'.$currency.$meta['_wpiu_invoice_meta_item']['sub_total'][$index].'</td>';
        echo '</tr>';
    }
    
$index++;
}

?>


<tr class="totals-tr">
<td colspan="3" class="totals"><?php _e('Totaal excl. btw:', WPIU_LANG);?></td>
<td class="item-centered"><?php echo $currency.$meta['_wpiu_invoice_meta_sub_total'];?></td>
</tr>

<tr class="totals-tr">
<td colspan="3" class="totals"><?php _e('Totaal btw ('.$tax.'):', WPIU_LANG);?></td>
<td class="item-centered"><?php echo $currency.$meta['_wpiu_invoice_meta_tax'];?></td>
</tr>

<tr class="totals-tr">
<td colspan="3" class="totals"><?php _e('Te betalen:', WPIU_LANG);?></td>
<td class="item-centered"><?php echo $currency.$meta['_wpiu_invoice_meta_total'];?></td>
</tr>

</table>



<table id="footer">
<tr>
<td>
<div class="footertext">
<?php
echo $options['invoice_payment_details'];
?>

</div>
<div id="lower_footer">
<?php echo $options['invoice_payment_deadlines'];?>
</div>
</td>
</tr>
</table>



<table id="factuur-info">
<tr>
<td><?php
echo '<strong>'.__('Rekeningnummer:', WPIU_LANG).'</strong>';
?>
</td>
<td>
<?php
echo '0000000';
?>
</td>
</tr>
<tr>
<td><?php
echo '<strong>'.__('BTW-nummer:', WPIU_LANG).'</strong>';
?>
</td>
<td>
<?php
echo '000000000';
?>

</td>
</tr>
<tr>
<td><?php
echo '<strong>'.__('KVK-nummer:', WPIU_LANG).'</strong>';
?>
</td>
<td>
<?php
echo '000000';
?>

</td>
</tr>
</table>


</div>
<?php
    if($trans){
        echo '<div class="container main">';
        echo '<h4>'.__('Transaction History', WPIU_LANG).'</h4>';
        
        echo '<table class="widefat" id="invoice_trans">';
        
        echo '<thead><tr>';
            echo '<th>'.__('Amount', WPIU_LANG).'</th>';    
            echo '<th>'.__('Date', WPIU_LANG).'</th>';
            echo '<th>'.__('Transaction ID', WPIU_LANG).'</th>';
            echo '<th>'.__('Details', WPIU_LANG).'</th>';        
        echo '</tr></thead>';
        
        echo '<tbody>';
        
        foreach(array_reverse($trans) as $transaction){
            echo '<tr>';
                echo '<td>'.$currency.$transaction['mc_gross'].'</td>';
                echo '<td>'.$transaction['payment_date'].'</td>';
                echo '<td>'.$transaction['txn_id'].'</td>';
                echo '<td width="40%">';
                    echo '<a href="javascript:void(0);" class="trans_show">'.__('Show Details', WPIU_LANG).'</a>';
                    echo '<div class="details">';
                        foreach($transaction as $transk => $transv){
                            echo '<strong>'.$transk.': </strong> '.$transv.'<br/>';     
                        }

                    echo '</div>';
                echo '</td>';
            echo '</tr>';
        }
//foreach
        
        echo '</tbody>';

        echo '</table>';
        
        echo '</div>';                
    }
//meta
?>

<div class="container credit"></div>
</body>
</html>
<?php
endwhile;
endif;

?>
Gewijzigd op 23/06/2013 17:11:51 door Ellen Skapandi
 
PHP hulp

PHP hulp

19/04/2024 17:45:29
 
Ellen Skapandi

Ellen Skapandi

25/06/2013 15:43:33
Quote Anchor link
Kan iemand mij hiermee helpen, of in ieder geval tips geven hoe ik dit moet aanpakken?
 
Veur Heur

Veur Heur

25/06/2013 16:15:52
 
Ellen Skapandi

Ellen Skapandi

25/06/2013 16:34:42
Quote Anchor link
Ik had juist die andere plugin gekozen doordat ik een factuur kan opstellen, waar alle gegevens in worden gezet. Om die pdf-functie te krijgen, betaal ik in ieder geval 50 dollar. Ik wil proberen of ik het kan inbouwen in die andere plugin.

Voor in het vervolg sneller respons te krijgen op je vraag. Plaats minder code, enkel de relevante code. Zo is in dit geval 100 regels code te besparen door de css eruit te halen. En niet relevant voor dit onderwerp[/modedit]
Gewijzigd op 25/06/2013 18:06:28 door Bas IJzelendoorn
 
Ellen Skapandi

Ellen Skapandi

08/08/2013 02:42:46
Quote Anchor link
heeft iemand een idee hoe ik dit zelf kan inbouwen in de bestaande plugin?
 
Ozzie PHP

Ozzie PHP

08/08/2013 07:52:17
Quote Anchor link
Beste Ellen,

Zoals je zelf al aangeeft heb je te weinig verstand van PHP om dit voor elkaar te krijgen. Daarnaast is wat jij wil ook niet zomaar eventjes in te bouwen. Het lijkt me daarom handiger dat je een vacature plaatst zodat iemand met meer verstand van PHP dit voor jou kan doen.

Vacature plaatsen kan hier: http://www.phphulp.nl/php/forum/vacatures/26/

Wel eerst even de criteria doorlezen: http://www.phphulp.nl/php/forum/topic/criteria-php-vacature-berichten/16800/

Succes!
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.