<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[8657] sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices: WordCamp: Add CampTix Invoices plugin to codebase</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/8657">8657</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/8657","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>coreymckrill</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-04-23 17:18:46 +0000 (Tue, 23 Apr 2019)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp: Add CampTix Invoices plugin to codebase

This adds CampTix Invoices directly to the WordCamp codebase in the Meta
repository, rather than as an external. There are a couple of reasons for this:

* The plugin relies on other code for generating PDFs that is specific to the
  WordCamp.org environment.
* WordCamp.org has a unified text domain and related project on the WordPress
  translation site. This version of CampTix Invoices uses the unified domain
  rather than its own.

The original plugin code is here:
https://github.com/wceu/camptix-invoices</pre>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/</li>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/</li>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadmincsscamptixinvoicescss">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/camptix-invoices.css</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadmincssindexphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/index.php</a></li>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminimageswpcommunitysupportpng">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/wp-community-support.png</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminindexphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/index.php</a></li>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminjscamptixinvoicesbackjs">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices-back.js</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminjscamptixinvoicesjs">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices.js</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminjsindexphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/index.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicescamptixinvoicesphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/camptix-invoices.php</a></li>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesclasscamptixaddoninvoicesphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/class-camptix-addon-invoices.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesindexphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/index.php</a></li>
<li>sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsdateformatfieldphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/date-format-field.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewseditableinvoicemetaboxphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/editable-invoice-metabox.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsinvoicedownloadbuttonphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-download-button.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsinvoiceformphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-form.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsinvoicetemplatephp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-template.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewslogofieldphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/logo-field.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewssentinvoicemetaboxphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/sent-invoice-metabox.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesindexphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/index.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesreadmetxt">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/readme.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadmincsscamptixinvoicescss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/camptix-invoices.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/camptix-invoices.css                           (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/camptix-invoices.css     2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,13 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.camptix-invoice-details{
+       display:none;
+}
+
+.camptix-invoice-toggle-wrapper {
+       display: inline-block;
+}
+
+.camptix-invoice-toggle-wrapper .camptix-need-invoice,
+.camptix-invoice-toggle-wrapper label[for="camptix-need-invoice"] {
+       display: inline-block;
+       margin-left: 5px;
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadmincssindexphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/index.php                              (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/css/index.php        2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php // Silence is golden
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminimageswpcommunitysupportpng"></a>
<div class="binary"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/wp-community-support.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx" style="display: block; padding: 0 10px">Index: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/wp-community-support.png
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/wp-community-support.png       2019-04-23 06:40:10 UTC (rev 8656)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/wp-community-support.png        2019-04-23 17:18:46 UTC (rev 8657)
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/images/wp-community-support.png
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:mime-type</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+application/octet-stream
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminindexphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/index.php                          (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/index.php    2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php // Silence is golden
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminjscamptixinvoicesbackjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices-back.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices-back.js                                (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices-back.js  2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,46 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+jQuery(document).ready(function($) {
+  var file_frame;
+  $('.camptix-media').on('click', 'input[data-set]', function(e) {
+    e.preventDefault();
+    var $field = $(this).parent('.camptix-media').find('input[data-field]').eq(0);
+    var $imageWrapper = $(this).parent('.camptix-media').find('div[data-imagewrapper]').eq(0);
+    var $delete = $(this).parent('.camptix-media').find('input[data-unset]').eq(0);
+    var set_to_post_id = $field.val();
+    if (file_frame) {
+      file_frame.open();
+      return;
+    }
+    file_frame = wp.media.frames.file_frame = wp.media({
+      title: camptixInvoiceBackVars.selectText,
+      button: {
+        text: camptixInvoiceBackVars.selectImage,
+      },
+      multiple: false,
+      library: {
+        type: 'image',
+      }
+    });
+    file_frame.on('select', function () {
+      attachment = file_frame.state().get('selection').first().toJSON();
+      $imageWrapper.html('<img src="' + attachment.sizes.thumbnail.url + '" width="' + attachment.sizes.thumbnail.width + '"/>' );
+      $field.val(attachment.id);
+      $delete.show();
+    });
+    file_frame.on('open',function() {
+      var selection = file_frame.state().get('selection');
+      attachment = wp.media.attachment(set_to_post_id);
+      attachment.fetch();
+      selection.add(attachment ? [attachment] : []);
+    });
+    file_frame.open();
+  });
+
+  $('.camptix-media').on('click', 'input[data-unset]', function(e) {
+    e.preventDefault();
+    var $field = $(this).parent('.camptix-media').find('input[data-field]').eq(0);
+    var $imageWrapper = $(this).parent('.camptix-media').find('div[data-imagewrapper]').eq(0);
+    $field.val('');
+    $imageWrapper.html('');
+    $(this).hide();
+  });
+});
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminjscamptixinvoicesjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices.js                             (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/camptix-invoices.js       2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,12 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+jQuery( document ).ready( function ($) {
+
+       $(document).on( 'change', '#camptix-need-invoice', toggleInvoiceDetailsForm );
+       function toggleInvoiceDetailsForm() {
+               var $camptixInvoiceDetailsForm = $( '.camptix-invoice-details' );
+               $camptixInvoiceDetailsForm.toggle();
+               var $camptixInvoiceDetailsFormFields = $camptixInvoiceDetailsForm.find( 'input,textarea,select' );
+               var required = $camptixInvoiceDetailsFormFields.eq(0).prop( 'required' );
+               $camptixInvoiceDetailsFormFields.prop( 'required', ! required );
+       }
+
+});
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesadminjsindexphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/index.php                               (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/admin/js/index.php 2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php // Silence is golden
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicescamptixinvoicesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/camptix-invoices.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/camptix-invoices.php                             (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/camptix-invoices.php       2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,655 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Plugin name: Camptix Invoices for WordCamp.org
+ * Description: Generate invoices for tickets.
+ * Version: 1.0.1
+ * Author: Willy Bahuaud, Simon Janin, Antonio Villegas, Mathieu Sarrasin
+ * Author URI: https://central.wordcamp.org/
+ *
+ * @package Camptix_Invoices
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+define( 'CTX_INV_VER', '1.0.1' );
+define( 'CTX_INV_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
+define( 'CTX_INV_DIR', untrailingslashit( dirname( __FILE__ ) ) );
+define( 'CTX_INV_ADMIN_URL', CTX_INV_URL . '/admin' );
+
+/**
+ * Loads WordCamp Docs PDF Generator.
+ */
+function ctx_load_docs_pdf_generator() {
+       if ( ! defined( 'WORDCAMP_DOCS__PLUGIN_DIR' ) ) {
+               return;
+       }//end if
+       require_once WORDCAMP_DOCS__PLUGIN_DIR . 'classes/class-wordcamp-docs-pdf-generator.php';
+}
+add_action( 'init', 'ctx_load_docs_pdf_generator' );
+
+/**
+ * Load invoice addon.
+ */
+function load_camptix_invoices() {
+       require plugin_dir_path( __FILE__ ) . 'includes/class-camptix-addon-invoices.php';
+       camptix_register_addon( 'CampTix_Addon_Invoices' );
+       add_action( 'init', 'register_tix_invoice' );
+}
+add_action( 'camptix_load_addons', 'load_camptix_invoices' );
+
+/**
+ * Register invoice CPT and custom statuses.
+ */
+function register_tix_invoice() {
+       register_post_type(
+               'tix_invoice',
+               array(
+                       'label'        => __( 'Invoices', 'wordcamporg' ),
+                       'labels'       => array(
+                               'name'           => __( 'Invoices', 'wordcamporg' ),
+                               'singular_name'  => _x( 'Invoice', 'Post Type Singular Name', 'wordcamporg' ),
+                               'menu_name'      => __( 'Invoices', 'wordcamporg' ),
+                               'name_admin_bar' => __( 'Invoice', 'wordcamporg' ),
+                               'archives'       => __( 'Invoice Archives', 'wordcamporg' ),
+                               'attributes'     => __( 'Invoice Attributes', 'wordcamporg' ),
+                               'add_new_item'   => __( 'Add New Invoice', 'wordcamporg' ),
+                               'add_new'        => __( 'Add New', 'wordcamporg' ),
+                               'new_item'       => __( 'New Invoice', 'wordcamporg' ),
+                               'edit_item'      => __( 'Edit Invoice', 'wordcamporg' ),
+                               'update_item'    => __( 'Update Invoice', 'wordcamporg' ),
+                               'view_item'      => __( 'View Invoice', 'wordcamporg' ),
+                               'view_items'     => __( 'View Invoices', 'wordcamporg' ),
+                               'search_items'   => __( 'Search Invoices', 'wordcamporg' ),
+                       ),
+                       'supports'     => array( 'title' ),
+                       'public'       => false,
+                       'show_ui'      => true,
+                       'show_in_menu' => 'edit.php?post_type=tix_ticket',
+               )
+       );
+
+       register_post_status( 'refunded',
+               array(
+                       'label'                     => _x( 'Refunded', 'post', 'wordcamporg' ),
+                       'public'                    => true,
+                       'show_in_admin_all_list'    => false,
+                       'show_in_admin_status_list' => true,
+                       'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'wordcamporg' ),
+               )
+       );
+
+       register_post_status( 'cancelled',
+               array(
+                       'label'                     => _x( 'Cancelled', 'post', 'wordcamporg' ),
+                       'public'                    => true,
+                       'show_in_admin_all_list'    => false,
+                       'show_in_admin_status_list' => true,
+                       'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'wordcamporg' ),
+               )
+       );
+}
+
+/**
+ * Register invoice CPT custom update messages.
+ */
+function ctx_set_invoice_updated_messages( $messages ) {
+
+       $messages['tix_invoice'] = array(
+               0  => '', // Unused. Messages start at index 1.
+               1  => __( 'Invoice updated.', 'wordcamporg' ),
+               2  => __( 'Custom field updated.', 'wordcamporg' ),
+               3  => __( 'Custom field deleted.', 'wordcamporg' ),
+               4  => __( 'Invoice updated.', 'wordcamporg' ),
+               5  => __( 'Invoice restored.', 'wordcamporg' ),
+               6  => __( 'Invoice saved.', 'wordcamporg' ),
+               7  => __( 'Invoice saved.', 'wordcamporg' ),
+               8  => __( 'Invoice submitted.', 'wordcamporg' ),
+               9  => __( 'Invoice saved.', 'wordcamporg' ),
+               10 => __( 'Invoice draft updated.', 'wordcamporg' ),
+       );
+       return $messages;
+}
+add_filter( 'post_updated_messages', 'ctx_set_invoice_updated_messages' );
+
+/**
+ * Display custom post statuses.
+ */
+function ctx_append_post_status_list() {
+
+       global $post;
+       $refunded_selected  = '';
+       $cancelled_selected = '';
+       $status             = '';
+       $refunded           = __( 'refunded', 'wordcamporg' );
+       $cancelled          = __( 'cancelled', 'wordcamporg' );
+       $refunded_status    = _x( 'Refunded', 'post', 'wordcamporg' );
+       $cancelled_status   = _x( 'Cancelled', 'post', 'wordcamporg' );
+
+       if ( 'tix_invoice' === $post->post_type ) {
+
+               if ( 'refunded' === $post->post_status ) {
+                       $refunded_selected = ' selected=\"selected\"';
+                       $status            = $refunded_status;
+               }
+
+               if ( 'cancelled' === $post->post_status ) {
+                       $cancelled_selected = ' selected=\"selected\"';
+                       $status             = $cancelled_status;
+               }
+
+               ?>
+               <script>
+                       jQuery( document ).ready( function($) {
+                               $( "select#post_status" ).append( "<option value=\"<?php echo esc_attr( $refunded ); ?>\" <?php echo esc_attr( $refunded_selected ); ?>><?php echo esc_html( $refunded_status ); ?></option>" );
+                               $( "select#post_status" ).append( "<option value=\"<?php echo esc_attr( $cancelled ); ?>\" <?php echo esc_attr( $cancelled_selected ); ?>><?php echo esc_html( $cancelled_status ); ?></option>" );
+                               <?php if ( ! empty( $status ) ) { ?>
+                                       $( ".misc-pub-post-status #post-status-display" ).html( '<?php echo esc_html( $status ); ?>' );
+                               <?php } ?>
+                       });
+               </script>
+               <?php
+       }
+}
+add_action( 'admin_footer-post.php', 'ctx_append_post_status_list' );
+
+/**
+ * Show custom statuses on invoices index.
+ */
+function ctx_display_custom_statuses( $states ) {
+
+       global $post;
+       $arg = get_query_var( 'post_status' );
+
+       if ( 'refunded' !== $arg ) {
+               if ( 'refunded' === $post->post_status ) {
+                       return array( _x( 'Refunded', 'post', 'wordcamporg' ) );
+               }
+       }
+
+       if ( 'cancelled' !== $arg ) {
+               if ( 'cancelled' === $post->post_status ) {
+                       return array( _x( 'Cancelled', 'post', 'wordcamporg' ) );
+               }
+       }
+
+       return $states;
+}
+add_filter( 'display_post_states', 'ctx_display_custom_statuses' );
+
+/**
+ * Adding custom post status to Bulk and Quick Edit boxes: Status dropdown
+ */
+function ctx_append_post_status_bulk_edit() {
+
+       ?>
+       <script>
+               jQuery( document ).ready( function($) {
+                       $( ".inline-edit-status select " ).append("<option value=\"<?php echo esc_attr( __( 'refunded', 'wordcamporg' ) ); ?>\"><?php echo esc_html_x( 'Refunded', 'post', 'wordcamporg' ); ?></option>" );
+                       $( ".inline-edit-status select " ).append("<option value=\"<?php echo esc_attr( __( 'cancelled', 'wordcamporg' ) ); ?>\"><?php echo esc_html_x( 'Cancelled', 'post', 'wordcamporg' ); ?></option>" );
+               });
+       </script>
+       <?php
+
+}
+
+add_action( 'admin_footer-edit.php', 'ctx_append_post_status_bulk_edit' );
+
+/**
+ * Display an invoice button.
+ *
+ * @param object $post The post.
+ */
+function ctx_invoice_link( $post ) {
+
+       if ( 'tix_invoice' !== $post->post_type ) {
+               return false;
+       }//end if
+
+       $invoice_number = get_post_meta( $post->ID, 'invoice_number', true );
+       if ( empty( $invoice_number ) ) {
+               return false;
+       }
+
+       $invoice_url = ctx_get_invoice_url( $post->ID );
+
+       include CTX_INV_DIR . '/includes/views/invoice-download-button.php';
+}
+add_action( 'post_submitbox_misc_actions', 'ctx_invoice_link' );
+
+/**
+ * Register metabox on invoices.
+ *
+ * @param object $post The post.
+ */
+function ctx_register_invoice_metabox( $post ) {
+
+       $non_editable_statuses = array( 'publish', 'cancelled', 'refunded' );
+       if ( in_array( $post->post_status, $non_editable_statuses, true ) ) {
+               add_meta_box(
+                       'ctx_invoice_metabox',
+                       esc_html__( 'Info', 'wordcamporg' ),
+                       'ctx_invoice_metabox_sent',
+                       'tix_invoice',
+                       'normal',
+                       'high'
+               );
+       } else {
+               add_meta_box(
+                       'ctx_invoice_metabox',
+                       esc_html__( 'Info', 'wordcamporg' ),
+                       'ctx_invoice_metabox_editable',
+                       'tix_invoice',
+                       'normal',
+                       'high'
+               );
+       }//end if
+}
+add_action( 'add_meta_boxes_tix_invoice', 'ctx_register_invoice_metabox' );
+
+/**
+ * Metabox for editable invoice (not published).
+ *
+ * @param object $args The args.
+ */
+function ctx_invoice_metabox_editable( $args ) {
+
+       $order              = get_post_meta( $args->ID, 'original_order', true );
+       $metas              = get_post_meta( $args->ID, 'invoice_metas', true );
+       $opt                = get_option( 'camptix_options' );
+       $invoice_vat_number = $opt['invoice-vat-number'];
+
+       if ( ! is_array( $order ) ) {
+               $order = array();
+       }//end if
+       if ( ! is_array( $metas ) ) {
+               $metas = array();
+       }//end if
+
+       if ( empty( $order['items'] ) || ! is_array( $order['items'] ) ) {
+               $order['items'] = array();
+       }//end if
+
+       wp_nonce_field( 'edit-invoice-' . get_current_user_id() . '-' . $args->ID, 'edit-invoice' );
+
+       include CTX_INV_DIR . '/includes/views/editable-invoice-metabox.php';
+}
+
+/**
+ * Metabox for published invoices.
+ *
+ * @param object $args The args.
+ */
+function ctx_invoice_metabox_sent( $args ) {
+
+       $order              = get_post_meta( $args->ID, 'original_order', true );
+       $metas              = get_post_meta( $args->ID, 'invoice_metas', true );
+       $opt                = get_option( 'camptix_options' );
+       $invoice_vat_number = $opt['invoice-vat-number'];
+       $txn_id             = isset( $metas['transaction_id'] ) ? $metas['transaction_id'] : '';
+
+       include CTX_INV_DIR . '/includes/views/sent-invoice-metabox.php';
+}
+
+/**
+ * Save invoice metabox.
+ *
+ * @param int $post_id The post ID.
+ */
+function ctx_save_invoice_details( $post_id ) {
+       if ( ! isset( $_POST['edit-invoice'], $_POST['user_ID'], $_POST['post_ID'], $_POST['order'], $_POST['invoice_metas'] ) ) {
+               return;
+       }//end if
+
+       check_admin_referer( 'edit-invoice-' . absint( $_POST['user_ID'] ) . '-' . absint( $_POST['post_ID'] ), 'edit-invoice' );
+
+       $order = wp_parse_args(
+               $_POST['order'],
+               array(
+                       'total'  => 0,
+                       'items'  => array(),
+                       'coupon' => '',
+               )
+       );
+
+       $final_order = array(
+               'total'  => floatval( $order['total'] ),
+               'items'  => array_filter( array_map( 'ctx_sanitize_order_item', $order['items'] ) ),
+               'coupon' => sanitize_text_field( $order['coupon'] ),
+       );
+
+       $default_metas = array(
+               'email'   => '',
+               'name'    => '',
+               'address' => '',
+       );
+
+       $opt = get_option( 'camptix_options' );
+       if ( ! empty( $opt['invoice-vat-number'] ) ) {
+               $default_metas['vat-number'] = '';
+       }//end if
+
+       $metas = wp_parse_args( $_POST['invoice_metas'], $default_metas );
+
+       $final_metas = array(
+               'email'   => sanitize_email( $metas['email'] ),
+               'name'    => sanitize_text_field( $metas['name'] ),
+               'address' => sanitize_textarea_field( $metas['address'] ),
+       );
+       if ( ! empty( $opt['invoice-vat-number'] ) ) {
+               $final_metas['vat-number'] = sanitize_text_field( $metas['vat-number'] );
+       }//end if
+
+       update_post_meta( $post_id, 'original_order', $final_order );
+       update_post_meta( $post_id, 'invoice_metas', $final_metas );
+}
+add_action( 'save_post_tix_invoice', 'ctx_save_invoice_details', 10, 2 );
+
+/**
+ * Sanitize order item.
+ */
+function ctx_sanitize_order_item( $item ) {
+
+       $item = wp_parse_args(
+               $item,
+               array(
+                       'id'          => 0,
+                       'name'        => '',
+                       'description' => '',
+                       'quantity'    => 0,
+                       'price'       => 0,
+               )
+       );
+
+       $item = array(
+               'id'          => absint( $item['id'] ),
+               'name'        => sanitize_text_field( $item['name'] ),
+               'description' => sanitize_text_field( $item['description'] ),
+               'quantity'    => absint( $item['quantity'] ),
+               'price'       => floatval( $item['price'] ),
+       );
+
+       if ( empty( $item['name'] ) ) {
+               return false;
+       }
+
+       if ( empty( $item['quantity'] ) ) {
+               return false;
+       }
+
+       return $item;
+}
+
+/**
+ * Mark an invoice as draft when incomplete.
+ *
+ * @param int $invoice_id The invoice id.
+ */
+function ctx_mark_incomplete_invoice_as_draft( $invoice_id ) {
+       if ( wp_is_post_revision( $invoice_id ) || wp_is_post_autosave( $invoice_id ) ) {
+               return;
+       }
+
+       if ( 'tix_invoice' !== get_post_type( $invoice_id ) ) {
+               return;
+       }
+
+       if ( in_array( get_post_status( $invoice_id ), array( 'trash', 'pending' ), true ) ) {
+               return;
+       }
+
+       if ( CampTix_Addon_Invoices::is_invoice_incomplete( $invoice_id ) ) {
+               remove_action( 'save_post', 'ctx_mark_incomplete_invoice_as_draft' );
+               wp_update_post(
+                       array(
+                               'ID'          => $invoice_id,
+                               'post_status' => 'draft',
+                       )
+               );
+               add_action( 'save_post', 'ctx_mark_incomplete_invoice_as_draft' );
+       }
+}
+add_action( 'save_post', 'ctx_mark_incomplete_invoice_as_draft' );
+
+/**
+ * Assign an invoice number.
+ *
+ * @param int $invoice_id The invoice id.
+ */
+function ctx_assign_invoice_number( $invoice_id ) {
+       if ( wp_is_post_revision( $invoice_id ) || wp_is_post_autosave( $invoice_id ) ) {
+               return;
+       }
+
+       if ( 'tix_invoice' !== get_post_type( $invoice_id ) ) {
+               return;
+       }
+
+       if ( ! get_post_meta( $invoice_id, 'invoice_number', true ) ) {
+               $number = CampTix_Addon_Invoices::create_invoice_number();
+               update_post_meta( $invoice_id, 'invoice_number', $number );
+       }
+}
+add_action( 'save_post', 'ctx_assign_invoice_number' );
+
+/**
+ * Generate the invoice document.
+ *
+ * @param int $invoice_id The invoice id.
+ */
+function ctx_generate_invoice_document( $invoice_id ) {
+       if ( wp_is_post_revision( $invoice_id ) || wp_is_post_autosave( $invoice_id ) ) {
+               return;
+       }
+
+       if ( 'tix_invoice' !== get_post_type( $invoice_id ) ) {
+               return;
+       }
+
+       if ( ! in_array( get_post_status( $invoice_id ), array( 'publish', 'cancelled', 'refunded' ), true ) ) {
+               return;
+       }
+
+       CampTix_Addon_Invoices::create_invoice_document( $invoice_id );
+}
+add_action( 'save_post', 'ctx_generate_invoice_document' );
+
+/**
+ * Remove the invoice document in drafts.
+ *
+ * @param int $invoice_id The invoice id.
+ */
+function ctx_remove_invoice_document_in_draft( $invoice_id ) {
+       if ( wp_is_post_revision( $invoice_id ) || wp_is_post_autosave( $invoice_id ) ) {
+               return;
+       }
+
+       if ( 'tix_invoice' !== get_post_type( $invoice_id ) ) {
+               return;
+       }
+
+       if ( ! in_array( get_post_status( $invoice_id ), array( 'draft', 'trash' ), true ) ) {
+               return;
+       }
+
+       CampTix_Addon_Invoices::delete_invoice_document( $invoice_id );
+}
+add_action( 'save_post', 'ctx_remove_invoice_document_in_draft' );
+
+/**
+ * Invoice form generator.
+ */
+function ctx_invoice_form( $order, $options ) {
+
+       if ( empty( $options['invoice-active'] ) ) {
+               return;
+       }
+
+       $invoice_vat_number = $options['invoice-vat-number'];
+       include CTX_INV_DIR . '/includes/views/invoice-form.php';
+
+}
+add_action( 'camptix_form_attendee_after_registration_information', 'ctx_invoice_form', 10, 2 );
+
+/**
+ * Recovers a path for a PDF invoice.
+ *
+ * @param int $invoice_id The invoice id.
+ */
+function ctx_get_invoice( $invoice_id ) {
+       $invoice_document = get_post_meta( $invoice_id, 'invoice_document', true );
+       $upload_dir       = wp_upload_dir();
+
+       if ( empty( $upload_dir['basedir'] ) ) {
+               wp_die( esc_html__( 'Base upload directory is empty.', 'wordcamporg' ) );
+       }
+
+       $invoices_dirname = $upload_dir['basedir'] . '/camptix-invoices';
+       $path             = $invoices_dirname . '/' . $invoice_document;
+
+       if ( ! file_exists( $path ) ) {
+               wp_die( esc_html__( 'Invoice document does not exist.', 'wordcamporg' ) );
+       }
+
+       return $path;
+}
+
+/**
+ * Recovers the URL for a PDF invoice.
+ *
+ * @param int $invoice_id The invoice id.
+ */
+function ctx_get_invoice_url( $invoice_id ) {
+
+       $invoice_document = get_post_meta( $invoice_id, 'invoice_document', true );
+       if ( empty( $invoice_document ) ) {
+               return false;
+       }
+
+       $upload_dir = wp_upload_dir();
+       if ( empty( $upload_dir['basedir'] ) ) {
+               return false;
+       }
+
+       $invoices_dirurl = $upload_dir['baseurl'] . '/camptix-invoices';
+       return $invoices_dirurl . '/' . $invoice_document;
+}
+
+/**
+ * Registers the personal data exporter for invoices.
+ *
+ * @param array $exporters
+ *
+ * @return array
+ */
+function ctx_register_invoice_data_exporter( $exporters ) {
+       $exporters['camptix-invoice'] = array(
+               'exporter_friendly_name' => __( 'CampTix Invoice Data', 'camptix' ),
+               'callback'               => 'ctx_invoice_data_exporter',
+       );
+
+       return $exporters;
+}
+add_filter( 'wp_privacy_personal_data_exporters', 'ctx_register_invoice_data_exporter' );
+
+/**
+ * Finds and exports invoice data associated with an email address.
+ *
+ * @param string $email_address
+ * @param int    $page
+ *
+ * @return array
+ */
+function ctx_invoice_data_exporter( $email_address, $page ) {
+       $page = (int) $page;
+
+       $data_to_export = array();
+
+       $post_query = get_invoice_posts( $email_address, $page );
+
+       foreach ( (array) $post_query->posts as $post ) {
+               $invoice_data_to_export = array();
+
+               $invoice_number = get_post_meta( $post->ID, 'invoice_number', true );
+               $invoice_metas  = get_post_meta( $post->ID, 'invoice_metas', true );
+
+               foreach ( $invoice_metas as $key => $value ) {
+
+                       switch ( $key ) {
+                               case 'email':
+                                       $label = __( 'Email', 'wordcamporg' );
+                                       break;
+
+                               case 'name':
+                                       $label = __( 'Name', 'wordcamporg' );
+                                       break;
+
+                               case 'address':
+                                       $label = __( 'Address', 'wordcamporg' );
+                                       break;
+
+                               case 'vat-number':
+                                       $label = __( 'VAT Number', 'wordcamporg' );
+                                       break;
+
+                               default:
+                                       continue;
+                       }
+
+                       if ( ! empty( $value ) ) {
+                               $invoice_data_to_export[] = array(
+                                       'name'  => $label,
+                                       'value' => $value,
+                               );
+                       }
+               }
+
+               if ( ! empty( $invoice_number ) ) {
+                       $invoice_data_to_export[] = array(
+                               'name'  => __( 'Invoice Number', 'wordcamporg' ),
+                               'value' => $invoice_number,
+                       );
+               }
+
+               if ( ! empty( $invoice_data_to_export ) ) {
+                       $data_to_export[] = array(
+                               'group_id'    => 'camptix-invoice',
+                               'group_label' => __( 'CampTix Invoice Data', 'wordcamporg' ),
+                               'item_id'     => "camptix-invoice-{$post->ID}",
+                               'data'        => $invoice_data_to_export,
+                       );
+               }
+       }
+
+       $done = $post_query->max_num_pages <= $page;
+
+       return array(
+               'data' => $data_to_export,
+               'done' => $done,
+       );
+}
+
+/**
+ * Get the list of invoice posts related to a particular email address.
+ *
+ * @param string $email_address
+ * @param int    $page
+ *
+ * @return WP_Query
+ */
+function get_invoice_posts( $email_address, $page ) {
+       $number = 20;
+
+       return new WP_Query(
+               array(
+                       'posts_per_page' => $number,
+                       'paged'          => $page,
+                       'post_type'      => 'tix_invoice',
+                       'post_status'    => 'any',
+                       'orderby'        => 'ID',
+                       'order'          => 'ASC',
+                       'meta_key'       => 'invoice_metas',
+                       'meta_compare'   => 'LIKE',
+                       'meta_value'     => $email_address,
+               )
+       );
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesclasscamptixaddoninvoicesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/class-camptix-addon-invoices.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/class-camptix-addon-invoices.php                                (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/class-camptix-addon-invoices.php  2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,641 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Addon class that extends Camptix with invoicing functionalities.
+ *
+ * @package    Camptix_Invoices
+ * @subpackage Camptix_invoices/includes
+ */
+
+/**
+ * This class defines all code necessary to include invoices into Camptix.
+ *
+ * @package    Camptix_Invoices
+ * @subpackage Camptix_invoices/includes
+ */
+class CampTix_Addon_Invoices extends \CampTix_Addon {
+
+       /**
+        * Init invoice addon
+        */
+       public function camptix_init() {
+               global $camptix;
+               global $camptix_invoice_custom_error;
+
+               $camptix_invoice_custom_error = false;
+
+               add_filter( 'camptix_setup_sections', array( __CLASS__, 'invoice_settings_tab' ) );
+               add_action( 'camptix_menu_setup_controls', array( __CLASS__, 'invoice_settings' ) );
+               add_filter( 'camptix_validate_options', array( __CLASS__, 'validate_options' ), 10, 2 );
+               add_action( 'camptix_payment_result', array( __CLASS__, 'maybe_create_invoice' ), 10, 3 );
+               add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
+               add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_assets' ) );
+               add_filter( 'camptix_checkout_attendee_info', array( __CLASS__, 'attendee_info' ) );
+               add_action( 'camptix_notices', array( __CLASS__, 'error_flag' ), 0 );
+               add_filter( 'camptix_form_register_complete_attendee_object', array( __CLASS__, 'attendee_object' ), 10, 2 );
+               add_action( 'camptix_checkout_update_post_meta', array( __CLASS__, 'add_meta_invoice_on_attendee' ), 10, 2 );
+               add_filter( 'camptix_metabox_attendee_info_additional_rows', array( __CLASS__, 'add_invoice_meta_on_attendee_metabox' ), 10, 2 );
+       }
+
+       /**
+        * Add a new tab in camptix settings.
+        *
+        * @param array $sections Sections of the Camptix settings.
+        */
+       public static function invoice_settings_tab( $sections ) {
+               $sections['invoice'] = __( 'Invoicing', 'wordcamporg' );
+               return $sections;
+       }
+
+       /**
+        * Tab content.
+        *
+        * @param string $section Section.
+        */
+       public static function invoice_settings( $section ) {
+               if ( 'invoice' !== $section ) {
+                       return false;
+               }//end if
+
+               $opt = get_option( 'camptix_options' );
+               add_settings_section( 'invoice', __( 'Invoices settings', 'wordcamporg' ), '__return_false', 'camptix_options' );
+               global $camptix;
+
+               $camptix->add_settings_field_helper(
+                       'invoice-active',
+                       __( 'Activate invoice requests', 'wordcamporg' ),
+                       'field_yesno',
+                       'invoice',
+                       // translators: %1$s is a date.
+                       sprintf( __( 'Allow ticket buyers to ask for an invoice when purchasing their tickets.', 'wordcamporg' ), date( 'Y' ) )
+               );
+
+               $camptix->add_settings_field_helper(
+                       'invoice-new-year-reset',
+                       __( 'Yearly reset', 'wordcamporg' ),
+                       'field_yesno',
+                       'invoice',
+                       // translators: %1$s is a date.
+                       sprintf( __( 'Invoice numbers are prefixed with the year, and will be reset on the 1st of January (e.g. %1$s-125)', 'wordcamporg' ), date( 'Y' ) )
+               );
+
+               add_settings_field(
+                       'invoice-date-format',
+                       __( 'Date format', 'wordcamporg' ),
+                       array( __CLASS__, 'date_format_callback' ),
+                       'camptix_options',
+                       'invoice',
+                       array(
+                               'id'    => 'invoice-date-format',
+                               'value' => ! empty( $opt['invoice-date-format'] ) ? $opt['invoice-date-format'] : 'd F Y',
+                       )
+               );
+
+               $camptix->add_settings_field_helper(
+                       'invoice-vat-number',
+                       __( 'VAT number', 'wordcamporg' ),
+                       'field_yesno',
+                       'invoice',
+                       // translators: %1$s is a date.
+                       sprintf( __( 'Add a "VAT Number" field to the invoice request form', 'wordcamporg' ), date( 'Y' ) )
+               );
+
+               add_settings_field(
+                       'invoice-logo',
+                       __( 'Logo', 'wordcamporg' ),
+                       array( __CLASS__, 'type_file_callback' ),
+                       'camptix_options',
+                       'invoice',
+                       array(
+                               'id'    => 'invoice-logo',
+                               'value' => ! empty( $opt['invoice-logo'] ) ? $opt['invoice-logo'] : '',
+                       )
+               );
+
+               $camptix->add_settings_field_helper( 'invoice-company', __( 'Company address', 'wordcamporg' ), 'field_textarea', 'invoice' );
+               $camptix->add_settings_field_helper( 'invoice-tac', __( 'Terms and Conditions', 'wordcamporg' ), 'field_textarea', 'invoice' );
+               $camptix->add_settings_field_helper( 'invoice-thankyou', __( 'Note below invoice total', 'wordcamporg' ), 'field_textarea', 'invoice' );
+       }
+
+       /**
+        * Date format setting callback.
+        *
+        * @param array $args Arguments.
+        */
+       public static function date_format_callback( $args ) {
+
+               $id          = $args['id'];
+               $value       = $args['value'];
+               $description = sprintf(
+                       // translators: %s is a date.
+                       __( 'Date format to use on the invoice, as a PHP Date formatting string (default \'d F Y\' formats dates as %s)', 'wordcamporg' ),
+                       date( 'd F Y' )
+               );
+
+               include CTX_INV_DIR . '/includes/views/date-format-field.php';
+       }
+
+       /**
+        * Input type file.
+        *
+        * @param object $args Arguments.
+        */
+       public static function type_file_callback( $args ) {
+               wp_enqueue_media();
+               wp_enqueue_script( 'admin-camptix-invoices' );
+               wp_localize_script(
+                       'admin-camptix-invoices',
+                       'camptixInvoiceBackVars',
+                       array(
+                               'selectText'  => __( 'Pick a logo to upload', 'wordcamporg' ),
+                               'selectImage' => __( 'Pick this logo', 'wordcamporg' ),
+                       )
+               );
+
+               $id    = $args['id'];
+               $value = $args['value'];
+
+               include CTX_INV_DIR . '/includes/views/logo-field.php';
+       }
+
+       /**
+        * Validate our custom options.
+        *
+        * @param object $output Output options.
+        * @param object $input  Input options.
+        */
+       public static function validate_options( $output, $input ) {
+               if ( isset( $input['invoice-active'] ) ) {
+                       $output['invoice-active'] = (int) $input['invoice-active'];
+               }//end if
+               if ( isset( $input['invoice-new-year-reset'] ) ) {
+                       $output['invoice-new-year-reset'] = (int) $input['invoice-new-year-reset'];
+               }//end if
+               if ( isset( $input['invoice-date-format'] ) ) {
+                       $output['invoice-date-format'] = $input['invoice-date-format'];
+               }//end if
+               if ( isset( $input['invoice-vat-number'] ) ) {
+                       $output['invoice-vat-number'] = (int) $input['invoice-vat-number'];
+               }//end if
+               if ( isset( $input['invoice-logo'] ) ) {
+                       $output['invoice-logo'] = (int) $input['invoice-logo'];
+               }//end if
+               if ( isset( $input['invoice-company'] ) ) {
+                       $output['invoice-company'] = sanitize_textarea_field( $input['invoice-company'] );
+               }//end if
+               if ( isset( $input['invoice-tac'] ) ) {
+                       $output['invoice-tac'] = sanitize_textarea_field( $input['invoice-tac'] );
+               }//end if
+               if ( isset( $input['invoice-thankyou'] ) ) {
+                       $output['invoice-thankyou'] = sanitize_textarea_field( $input['invoice-thankyou'] );
+               }//end if
+               return $output;
+       }
+
+       /**
+        * Listen payment result to create invoice.
+        *
+        * @param string $payment_token The payment token.
+        * @param int    $result        The result.
+        */
+       public static function maybe_create_invoice( $payment_token, $result ) {
+               if ( 2 !== $result ) {
+                       return;
+               }//end if
+
+               $attendees = get_posts(
+                       array(
+                               'posts_per_page' => -1,
+                               'post_type'      => 'tix_attendee',
+                               'post_status'    => 'any',
+                               'meta_query'     => array( // @codingStandardsIgnoreLine
+                                       array(
+                                               'key'     => 'tix_payment_token',
+                                               'compare' => ' = ',
+                                               'value'   => $payment_token,
+                                               'type'    => 'CHAR',
+                                       ),
+                               ),
+                       )
+               );
+               if ( ! $attendees ) {
+                       return;
+               }//end if
+
+               $metas = get_post_meta( $attendees[0]->ID, 'invoice_metas', true );
+               if ( $metas ) {
+                       $order      = get_post_meta( $attendees[0]->ID, 'tix_order', true );
+                       $invoice_id = self::create_invoice( $attendees[0], $order, $metas );
+                       if ( ! is_wp_error( $invoice_id ) && ! empty( $invoice_id ) ) {
+                               self::send_invoice( $invoice_id );
+                       }//end if
+               }//end if
+       }
+
+       /**
+        * Get, increment and return invoice number.
+        */
+       public static function create_invoice_number() {
+               $opt     = get_option( 'camptix_options' );
+               $current = get_option( 'invoice_current_number', 1 );
+
+               $year = date( 'Y' );
+               if ( ! empty( $opt['invoice-new-year-reset'] ) ) {
+                       if ( ! empty( $opt['invoice-current-year'] ) && $opt['invoice-current-year'] !== $year ) {
+                               $current                     = 1;
+                               $opt['invoice-current-year'] = $year;
+                               update_option( 'camptix_options', $opt );
+                       }//end if
+               }//end if
+
+               /**
+                * Sets the current invoice number.
+                *
+                * @param int $current current invoice number.
+                */
+               $current = apply_filters( 'tix_invoice_current_number', $current );
+               update_option( 'invoice_current_number', $current + 1 );
+
+               if ( empty( $opt['invoice-new-year-reset'] ) ) {
+                       return $current;
+               } else {
+                       return sprintf( '%s-%s', $year, $current );
+               }
+       }
+
+       /**
+        * Create invoice.
+        *
+        * @param object $attendee The attendee.
+        * @param object $order    The order.
+        * @param object $metas    The metas.
+        *
+        * @todo Link invoice and corresponding attendees
+        */
+       public static function create_invoice( $attendee, $order, $metas ) {
+               $number         = self::create_invoice_number();
+               $attendee_email = get_post_meta( $attendee->ID, 'tix_email', true );
+               $txn_id         = get_post_meta( $attendee->ID, 'tix_transaction_id', true );
+
+               // Prevent invoice_number from being assigned twice.
+               remove_action( 'publish_tix_invoice', 'ctx_assign_invoice_number', 10 );
+
+               // $txn_id may be null if no transaction was created (100% coupon used).
+               if ( $txn_id ) {
+                       $invoice_title = sprintf(
+                               // translators: 1: invoice number, 2: email, 3: transaction id, 4. date.
+                               __( 'Invoice #%1$s for %2$s (order #%3$s) on %4$s', 'wordcamporg' ),
+                               $number,
+                               $attendee_email,
+                               $txn_id,
+                               get_the_time( 'd/m/Y', $attendee )
+                       );
+               } else {
+                       $invoice_title = sprintf(
+                               // translators: 1: invoice number, 2: email, 3. date.
+                               __( 'Invoice #%1$s for %2$s on %3$s', 'wordcamporg' ),
+                               $number,
+                               $attendee_email,
+                               get_the_time( 'd/m/Y', $attendee )
+                       );
+               }//end if
+
+               $invoice = array(
+                       'post_type'   => 'tix_invoice',
+                       'post_status' => 'draft',
+                       'post_title'  => $invoice_title,
+                       'post_name'   => sprintf( 'invoice-%s', $number ),
+               );
+
+               $invoice_id = wp_insert_post( $invoice );
+               if ( ! $invoice_id || is_wp_error( $invoice_id ) ) {
+                       return;
+               }//end if
+               update_post_meta( $invoice_id, 'invoice_number', $number );
+               update_post_meta( $invoice_id, 'invoice_metas', $metas );
+               update_post_meta( $invoice_id, 'original_order', $order );
+               update_post_meta( $invoice_id, 'transaction_id', $txn_id );
+
+               wp_update_post(
+                       array(
+                               'ID'          => $invoice_id,
+                               'post_status' => 'publish',
+                       )
+               );
+
+               return $invoice_id;
+       }
+
+       /**
+        * Send invoice by mail.
+        *
+        * @param int $invoice_id The invoice ID.
+        *
+        * @todo Add a template for $message in the settings.
+        */
+       public static function send_invoice( $invoice_id ) {
+               $invoice_metas = get_post_meta( $invoice_id, 'invoice_metas', true );
+               if ( empty( $invoice_metas['email'] ) && is_email( $invoice_metas['email'] ) ) {
+                       return false;
+               }//end if
+               $invoice_pdf = ctx_get_invoice( $invoice_id );
+               $attachments = array( $invoice_pdf );
+               $opt         = get_option( 'camptix_options' );
+
+               /* translators: The name of the event */
+               $subject = apply_filters( 'camptix_invoices_mail_subject', sprintf( __( 'Your Invoice to %s', 'wordcamporg' ), $opt['event_name'] ), $opt['event_name'] );
+               $from    = apply_filters( 'camptix_invoices_mail_from', get_option( 'admin_email' ) );
+               $headers = apply_filters(
+                       'camptix_invoices_mail_headers',
+                       array(
+                               "From: {$opt['event_name']} <{$from}>",
+                               'Content-type: text/html; charset=UTF-8',
+                       )
+               );
+               $message = array(
+                       __( 'Hello,', 'wordcamporg' ),
+                       // translators: event name.
+                       sprintf( __( 'As requested during your purchase, please find attached an invoice for your tickets to "%s".', 'wordcamporg' ), sanitize_text_field( $opt['event_name'] ) ),
+                       // translators: email.
+                       sprintf( __( 'Please let us know if we can be of any further assistance at %s.', 'wordcamporg' ), $from ),
+                       __( 'Kind regards', 'wordcamporg' ),
+                       '',
+                       // translators: event name.
+                       sprintf( __( 'The %s team', 'wordcamporg' ), sanitize_text_field( $opt['event_name'] ) ),
+               );
+               $message = implode( PHP_EOL, $message );
+               $message = '<p>' . nl2br( $message ) . '</p>';
+               wp_mail( $invoice_metas['email'], $subject, $message, $headers, $attachments );
+       }
+
+       /**
+        * Create a PDF document for the given invoice.
+        *
+        * @param int $invoice_id The invoice ID.
+        */
+       public static function create_invoice_document( $invoice_id ) {
+
+               $camptix_opts   = get_option( 'camptix_options' );
+               $invoice_number = get_post_meta( $invoice_id, 'invoice_number', true );
+               $invoice_date   = get_the_date( $camptix_opts['invoice-date-format'], $invoice_id );
+               $invoice_metas  = get_post_meta( $invoice_id, 'invoice_metas', true );
+               $invoice_order  = get_post_meta( $invoice_id, 'original_order', true );
+
+               $logo = CTX_INV_DIR . '/admin/images/wp-community-support.png';
+               if ( ! empty( $camptix_opts['invoice-logo'] ) ) {
+                       $attachment = wp_get_attachment_image_src( $camptix_opts['invoice-logo'], 'full' );
+                       $logo       = $attachment[0];
+               }
+
+               $template = locate_template( 'invoice-template.php' ) ? locate_template( 'invoice-template.php' ) : CTX_INV_DIR . '/includes/views/invoice-template.php';
+
+               ob_start();
+               include $template;
+               $invoice_content = ob_get_clean();
+
+               if ( ! class_exists( 'WordCamp_Docs_PDF_Generator' ) ) {
+                       wp_die( esc_html__( 'WordCamp_Docs_PDF_Generator is missing', 'wordcamporg' ) );
+               }
+
+               $filename = get_post_meta( $invoice_id, 'invoice_document', true );
+               if ( empty( $filename ) ) {
+                       $filename = $invoice_number . '-' . wp_generate_password( 12, false, false ) . '.pdf';
+               }
+
+               $pdf_generator = new WordCamp_Docs_PDF_Generator();
+               $upload_dir    = wp_upload_dir();
+               $tmp_path      = $pdf_generator->generate_pdf_from_string( $invoice_content, $filename );
+
+               if ( ! empty( $upload_dir['basedir'] ) ) {
+                       $invoices_dirname = $upload_dir['basedir'] . '/camptix-invoices';
+                       if ( ! file_exists( $invoices_dirname ) ) {
+                               wp_mkdir_p( $invoices_dirname );
+                       }
+               }
+
+               rename( $tmp_path, $invoices_dirname . '/' . $filename );
+
+               update_post_meta( $invoice_id, 'invoice_document', $filename );
+       }
+
+       /**
+        * Check whether the invoice has the required fields or not.
+        *
+        * @param int $invoice_id The invoice ID.
+        */
+       public static function is_invoice_incomplete( $invoice_id ) {
+               $invoice_metas = get_post_meta( $invoice_id, 'invoice_metas', true );
+               $invoice_order = get_post_meta( $invoice_id, 'original_order', true );
+
+               if ( empty( $invoice_metas['name'] ) ) {
+                       return true;
+               }
+
+               if ( empty( $invoice_metas['address'] ) ) {
+                       return true;
+               }
+
+               if ( empty( $invoice_order['items'] ) ) {
+                       return true;
+               }
+
+               foreach ( $invoice_order['items'] as $item ) {
+                       if ( empty( $item['quantity'] ) ) {
+                               return true;
+                       }
+                       if ( empty( $item['name'] ) ) {
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
+       /**
+        * Delete the invoice document of a given invoice.
+        *
+        * @param int $invoice_id The invoice ID.
+        */
+       public static function delete_invoice_document( $invoice_id ) {
+               $filename = get_post_meta( $invoice_id, 'invoice_document', true );
+               if ( empty( $filename ) ) {
+                       return;
+               }
+
+               delete_post_meta( $invoice_id, 'invoice_document' );
+
+               $upload_dir = wp_upload_dir();
+               if ( ! empty( $upload_dir['basedir'] ) ) {
+                       $invoices_dirname = $upload_dir['basedir'] . '/camptix-invoices';
+                       $filename         = $invoices_dirname . '/' . $filename;
+                       if ( file_exists( $filename ) ) {
+                               wp_delete_file( $filename );
+                       }
+               }
+       }
+
+       /**
+        * Format currency to display in invoice.
+        */
+       public static function format_currency( $amount, $currency_key ) {
+
+               $camptix_currencies = CampTix_Currency::get_currency_list();
+               if ( isset( $camptix_currencies[ $currency_key ] ) === false ) {
+                       $currency_key = 'USD';
+               }
+
+               $currency = $camptix_currencies[ $currency_key ];
+
+               if ( isset( $currency['locale'] ) === true ) {
+                       setlocale( LC_MONETARY, $currency['locale'] );
+                       $formatted_amount = money_format( "%.{$currency['decimal_point']}n", $amount );
+               } elseif ( isset( $currency['format'] ) && $currency['format'] ) {
+                       $formatted_amount = sprintf( $currency['format'], number_format( $amount, $currency['decimal_point'] ) );
+               } else {
+                       $formatted_amount = $currency_key . ' ' . number_format( $amount, $currency['decimal_point'] );
+               }
+
+               return $formatted_amount;
+       }
+
+       /**
+        * Enqueue assets
+        *
+        * @todo enqueue only on [camptix] shortcode
+        */
+       public static function enqueue_assets() {
+
+               $opt = get_option( 'camptix_options' );
+               if ( ! empty( $opt['invoice-active'] ) ) {
+
+                       wp_register_script( 'camptix-invoices', CTX_INV_ADMIN_URL . '/js/camptix-invoices.js', array( 'jquery' ), CTX_INV_VER, true );
+                       wp_enqueue_script( 'camptix-invoices' );
+
+               }//end if
+
+               wp_register_style( 'camptix-invoices-css', CTX_INV_ADMIN_URL . '/css/camptix-invoices.css', array(), CTX_INV_VER );
+               wp_enqueue_style( 'camptix-invoices-css' );
+       }
+
+       /**
+        * Register assets on admin side
+        */
+       public static function admin_enqueue_assets() {
+               wp_register_script( 'admin-camptix-invoices', CTX_INV_ADMIN_URL . '/js/camptix-invoices-back.js', array( 'jquery' ), CTX_INV_VER, true );
+       }
+
+       /**
+        * Attendee invoice information
+        * (also check for missing invoice infos).
+        *
+        * @param array $attendee_info The attendee info.
+        */
+       public static function attendee_info( $attendee_info ) {
+
+               // phpcs:disable WordPress.Security.NonceVerification.Missing
+               global $camptix;
+               if ( empty( $_POST['camptix-need-invoice'] ) ) {
+                       return $attendee_info;
+               }//end if
+
+               if ( empty( $_POST['invoice-email'] )
+                       || empty( $_POST['invoice-name'] )
+                       || empty( $_POST['invoice-address'] )
+                       || ! is_email( wp_unslash( $_POST['invoice-email'] ) ) ) {
+
+                       $camptix->error_flag( 'nope' );
+
+               } else {
+
+                       $attendee_info['invoice-email']   = sanitize_email( wp_unslash( $_POST['invoice-email'] ) );
+                       $attendee_info['invoice-name']    = sanitize_text_field( wp_unslash( $_POST['invoice-name'] ) );
+                       $attendee_info['invoice-address'] = sanitize_textarea_field( wp_unslash( $_POST['invoice-address'] ) );
+
+                       $opt = get_option( 'camptix_options' );
+
+                       if ( ! empty( $opt['invoice-vat-number'] ) ) {
+                               $attendee_info['invoice-vat-number'] = sanitize_text_field( wp_unslash( $_POST['invoice-vat-number'] ) );
+                       }//end if
+               }//end if
+
+               // phpcs:enable
+               return $attendee_info;
+       }
+
+       /**
+        * Define custom attributes for an attendee object.
+        *
+        * @param object $attendee      The attendee.
+        * @param array  $attendee_info The attendee info.
+        */
+       public static function attendee_object( $attendee, $attendee_info ) {
+               if ( ! empty( $attendee_info['invoice-email'] ) ) {
+                       $attendee->invoice = array(
+                               'email'   => $attendee_info['invoice-email'],
+                               'name'    => $attendee_info['invoice-name'],
+                               'address' => $attendee_info['invoice-address'],
+                       );
+
+                       $opt = get_option( 'camptix_options' );
+                       if ( ! empty( $opt['invoice-vat-number'] ) ) {
+                               $attendee->invoice['vat-number'] = $attendee_info['invoice-vat-number'];
+                       }//end if
+               }//end if
+               return $attendee;
+       }
+
+       /**
+        * Add Invoice meta on an attendee post.
+        *
+        * @param int    $post_id  The post ID.
+        * @param object $attendee The attendee.
+        */
+       public static function add_meta_invoice_on_attendee( $post_id, $attendee ) {
+
+               if ( ! empty( $attendee->invoice ) ) {
+                       update_post_meta( $post_id, 'invoice_metas', $attendee->invoice );
+                       global $camptix;
+                       $camptix->log( __( 'This attendee requested an invoice.', 'wordcamporg' ), $post_id, $attendee->invoice );
+               }//end if
+       }
+
+       /**
+        * My custom errors flags.
+        */
+       public static function error_flag() {
+
+               global $camptix;
+               /**
+                * Hack
+                */
+               $rp = new ReflectionProperty( 'CampTix_Plugin', 'error_flags' );
+               $rp->setAccessible( true );
+               $error_flags = $rp->getValue( $camptix );
+               if ( ! empty( $error_flags['nope'] ) ) {
+                       $camptix->error( __( 'As you have requested an invoice, please fill in the required fields.', 'wordcamporg' ) );
+               }//end if
+       }
+
+       /**
+        * Display invoice meta on attendee admin page.
+        *
+        * @param array  $rows The rows.
+        * @param object $post The post.
+        */
+       public static function add_invoice_meta_on_attendee_metabox( $rows, $post ) {
+               $invoice_meta = get_post_meta( $post->ID, 'invoice_metas', true );
+               if ( ! empty( $invoice_meta ) ) {
+                       $rows[] = array( __( 'Requested an invoice', 'wordcamporg' ), __( 'Yes', 'wordcamporg' ) );
+                       $rows[] = array( __( 'Invoice recipient', 'wordcamporg' ), $invoice_meta['name'] );
+                       $rows[] = array( __( 'Invoice to be sent to', 'wordcamporg' ), $invoice_meta['email'] );
+                       $rows[] = array( __( 'Customer address', 'wordcamporg' ), $invoice_meta['address'] );
+
+                       $opt = get_option( 'camptix_options' );
+                       if ( ! empty( $opt['invoice-vat-number'] ) ) {
+                               $rows[] = array( __( 'VAT number', 'wordcamporg' ), $invoice_meta['vat-number'] );
+                       }//end if
+               } else {
+                       $rows[] = array( __( 'Requested an invoice', 'wordcamporg' ), __( 'No', 'wordcamporg' ) );
+               }//end if
+               return $rows;
+       }
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesindexphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/index.php                               (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/index.php 2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php // Silence is golden
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsdateformatfieldphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/date-format-field.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/date-format-field.php                             (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/date-format-field.php       2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,18 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WPINC' ) || die();
+
+/** @var string $id */
+/** @var string $value */
+/** @var string $description */
+
+?>
+
+<input type="text" value="<?php echo esc_attr( $value ); ?>" name="camptix_options[<?php echo esc_html( $id ); ?>]">
+<p class="description">
+       <?php echo esc_html( $description ); ?>
+       <br />
+       <a href="<?php esc_attr__( 'https://codex.wordpress.org/Formatting_Date_and_Time', 'wordcamporg' ); ?>">
+               <?php echo esc_html__( 'Documentation on date and time formatting', 'wordcamporg' ); ?>
+       </a>
+</p>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewseditableinvoicemetaboxphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/editable-invoice-metabox.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/editable-invoice-metabox.php                              (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/editable-invoice-metabox.php        2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,126 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WPINC' ) || die();
+
+/** @var array $order */
+/** @var array $metas */
+/** @var string $invoice_vat_number */
+
+?>
+
+<h3><?php echo esc_html__( 'Order details', 'wordcamporg' ); ?></h3>
+
+<table class="widefat">
+       <thead>
+               <tr>
+                       <th><?php echo esc_html__( 'Title', 'wordcamporg' ); ?></th>
+                       <th><?php echo esc_html__( 'Unit price', 'wordcamporg' ); ?></th>
+                       <th><?php echo esc_html__( 'Quantity', 'wordcamporg' ); ?></th>
+               </tr>
+       </thead>
+
+       <tbody>
+
+       <?php foreach ( $order['items'] as $k => $item ) : ?>
+
+               <tr>
+                       <td>
+                               <input type="text" value="<?php echo esc_html( $item['name'] ); ?>" name="order[items][<?php echo esc_attr( $k ); ?>][name]" class="widefat">
+                       </td><!-- name -->
+                       <td>
+                               <input type="number" min="0" step="0.01" value="<?php echo esc_attr( number_format_i18n( $item['price'], 2 ) ); ?>" name="order[items][<?php echo esc_attr( $k ); ?>][price]" class="widefat">
+                       </td><!-- price -->
+                       <td>
+                               <input type="number" min="0" value="<?php echo esc_attr( number_format_i18n( $item['quantity'] ) ); ?>" name="order[items][<?php echo esc_attr( $k ); ?>][quantity]" class="widefat">
+                       </td><!-- qty -->
+               </tr>
+
+       <?php endforeach; ?>
+
+               <tr>
+                       <td><input type="text" value="" name="order[items][<?php echo esc_attr( count( $order['items'] ) + 1 ); ?>][name]" class="widefat"></td><!-- name -->
+                       <td><input type="number" min="0" step="0.01" value="<?php echo esc_attr( number_format_i18n( 0, 2 ) ); ?>" name="order[items][<?php echo esc_attr( count( $order['items'] ) + 1 ); ?>][price]" class="widefat"></td><!-- price -->
+                       <td><input type="number" min="0" value="" name="order[items][<?php echo esc_attr( count( $order['items'] ) + 1 ); ?>][quantity]" class="widefat"></td><!-- qty -->
+               </tr>
+
+       </tbody>
+</table>
+
+<table class="form-table">
+       <tr>
+               <th scope="row">
+                       <label for="order[total]"><?php echo esc_html__( 'Total amount', 'wordcamporg' ); ?></label>
+               </th>
+               <td>
+                       <input
+                               type="number"
+                               min="0"
+                               step="0.01"
+                               value="<?php echo esc_attr( number_format_i18n( empty( $order['total'] ) ? '0' : $order['total'], 2 ) ); ?>"
+                               name="order[total]"
+                               id="order[total]"
+                       />
+               </td>
+       </tr>
+       <tr>
+               <th scope="row">
+                       <label for="invoice_metas[name]"><?php echo esc_html__( 'Customer', 'wordcamporg' ); ?> •</label>
+               </th>
+               <td>
+                       <input
+                               required
+                               name="invoice_metas[name]"
+                               id="invoice_metas[name]"
+                               value="<?php echo esc_attr( empty( $metas['name'] ) ? '' : $metas['name'] ); ?>"
+                               type="text"
+                               class="widefat"
+                       />
+               <td>
+       </tr>
+       <tr>
+               <th scope="row">
+                       <label for="invoice_metas[email]"><?php echo esc_html__( 'Contact email', 'wordcamporg' ); ?></label>
+               </th>
+               <td>
+                       <input
+                               name="invoice_metas[email]"
+                               id="invoice_metas[email]"
+                               value="<?php echo esc_attr( empty( $metas['email'] ) ? '' : $metas['email'] ); ?>"
+                               type="email"
+                               class="widefat"
+                       />
+               <td>
+       </tr>
+       <tr>
+               <th scope="row">
+                       <label for="invoice_metas[address]"><?php echo esc_html__( 'Customer Address', 'wordcamporg' ); ?> •</label>
+               </th>
+               <td>
+                       <textarea
+                               required
+                               name="invoice_metas[address]"
+                               id="invoice_metas[address]"
+                               class="widefat"
+                       ><?php
+                               echo esc_textarea( empty( $metas['address'] ) ? '' : $metas['address'] );
+                       ?></textarea>
+               <td>
+       </tr>
+
+       <?php if ( ! empty( $invoice_vat_number ) ) : ?>
+               <tr>
+                       <th scope="row">
+                               <label for="invoice_metas[vat-number]"><?php echo esc_html__( 'VAT number', 'wordcamporg' ); ?></label>
+                       </th>
+                       <td>
+                               <input
+                                       name="invoice_metas[vat-number]"
+                                       id="invoice_metas[vat-number]"
+                                       value="<?php echo esc_textarea( empty( $metas['vat-number'] ) ? '' : $metas['vat-number'] ); ?>"
+                                       type="text"
+                                       class="widefat"
+                               />
+                       <td>
+               </tr>
+       <?php endif; ?>
+</table>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsinvoicedownloadbuttonphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-download-button.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-download-button.php                               (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-download-button.php 2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,23 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WPINC' ) || die();
+
+/** @var string $invoice_number */
+/** @var string $invoice_url */
+
+?>
+
+<div class="misc-pub-section">
+       <p>
+               <?php echo esc_html__( 'Invoice number', 'wordcamporg' ); ?> <strong><?php echo esc_html( $invoice_number ); ?></strong>
+       </p>
+       <?php if ( ! empty( $invoice_url ) ) { ?>
+               <a
+                       href="<?php echo esc_attr( $invoice_url ); ?>"
+                       class="button button-secondary"
+                       target="_blank"
+               >
+                       <?php echo esc_html__( 'Download invoice', 'wordcamporg' ); ?>
+               </a>
+       <?php } ?>
+</div>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsinvoiceformphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-form.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-form.php                          (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-form.php    2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,67 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WPINC' ) || die();
+
+/** @var string $invoice_vat_number */
+
+?>
+
+<div class="camptix-invoice-toggle-wrapper">
+
+       <input type="checkbox" value="1" name="camptix-need-invoice" id="camptix-need-invoice"/>
+       <label for="camptix-need-invoice">
+               <?php echo esc_html__( 'I need an invoice', 'wordcamporg' ); ?>
+       </label>
+
+       <table class="camptix-invoice-details tix_tickets_table tix_invoice_table">
+               <tbody>
+
+                       <tr>
+                               <td class="tix-left">
+                                       <label for="invoice-email">
+                                               <?php echo esc_html__( 'Email for the invoice to be sent to', 'wordcamporg' ); ?><span class="tix-required-star">*</span>
+                                       </label>
+                               </td>
+                               <td class="tix-right">
+                                       <input type="text" name="invoice-email" id="invoice-email" pattern="^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$" />
+                               </td>
+                       </tr>
+
+                       <tr>
+                               <td class="tix-left">
+                                       <label for="invoice-name">
+                                               <?php echo esc_html__( 'Name or organisation that the invoice should be made out to', 'wordcamporg' ); ?><span class="tix-required-star">*</span>
+                                       </label>
+                               </td>
+                               <td class="tix-right">
+                                       <input type="text" name="invoice-name" id="invoice-name" />
+                               </td>
+                       </tr>
+
+                       <tr>
+                               <td class="tix-left">
+                                       <label for="invoice-address">
+                                               <?php echo esc_html__( 'Street address', 'wordcamporg' ); ?><span class="tix-required-star">*</span>
+                                       </label>
+                               </td>
+                               <td class="tix-right">
+                                       <textarea name="invoice-address" id="invoice-address" rows="2"></textarea>
+                               </td>
+                       </tr>
+
+                       <?php if ( ! empty( $invoice_vat_number ) ) : ?>
+                               <tr>
+                                       <td class="tix-left">
+                                               <label for="invoice-vat-number">
+                                                       <?php echo esc_html__( 'VAT number', 'wordcamporg' ); ?><span class="tix-required-star">*</span>
+                                               </label>
+                                       </td>
+                                       <td class="tix-right">
+                                               <input type="text" name="invoice-vat-number" id="invoice-vat-number" />
+                                       </td>
+                               </tr>
+                       <?php endif; ?>
+
+               </tbody>
+       </table>
+</div>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewsinvoicetemplatephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-template.php                              (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/invoice-template.php        2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,214 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined('WPINC') || die();
+
+/**
+ * @var array $camptix_opts
+ * @var string $invoice_number
+ * @var string $invoice_date
+ * @var array $invoice_metas
+ * @var array $invoice_order
+ * @var string $logo
+ */
+
+?>
+
+<html>
+<head>
+       <meta charset="UTF-8">
+       <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,600,700" rel="stylesheet" type="text/css"/>
+       <style type="text/css">
+               #camptix-invoice-page {
+                       margin: 5em;
+                       font-family: 'Open Sans', sans-serif;
+                       font-size: 14px;
+                       font-weight: 300;
+                       color: #222;
+               }
+
+               #camptix-invoice-page strong {
+                       font-weight: 700;
+               }
+
+               #camptix-invoice-page p {
+                       padding: 0;
+                       margin: 0;
+                       line-height: 1em;
+               }
+
+               #camptix-invoice-page .text-left {
+                       text-align: left;
+               }
+
+               #camptix-invoice-page .text-center {
+                       text-align: center;
+               }
+
+               #camptix-invoice-page .text-right {
+                       text-align: right;
+               }
+
+               #camptix-invoice-page .camptix-invoice-logo-holder {
+                       display: block;
+                       margin: 3em 0;
+                       padding-top: 3em;
+               }
+
+               #camptix-invoice-page .camptix-invoice-logo-holder img {
+                       max-width: 50%;
+               }
+
+               #camptix-invoice-page .camptix-inovice-header {
+                       padding-bottom: 1em;
+                       overflow: hidden;
+                       border-bottom: 1px solid #999;
+               }
+
+               #camptix-invoice-page .camptix-inovice-header .camptix-invoice-from-box {
+                       width: 48%;
+                       float: left;
+               }
+
+               #camptix-invoice-page .camptix-inovice-header .camptix-invoice-to-box {
+                       width: 48%;
+                       float: right;
+               }
+
+               #camptix-invoice-page .camptix-inovice-header .camptix-invoice-from-box p,
+               #camptix-invoice-page .camptix-inovice-header .camptix-invoice-to-box p {
+                       line-height: 2em;
+               }
+
+               #camptix-invoice-page .camptix-inovice-header .camptix-invoice-to-box p {
+                       margin-bottom: 2em;
+               }
+
+               #camptix-invoice-page .camptix-invoice-data {
+                       padding: 2.5em 0;
+               }
+
+               #camptix-invoice-page .camptix-invoice-data p {
+                       line-height: 1.5em;
+               }
+
+               #camptix-invoice-page .camptix-invoice-order table,
+               #camptix-invoice-page .camptix-invoice-order th,
+               #camptix-invoice-page .camptix-invoice-order td {
+                       border: 1px solid #999;
+               }
+
+               #camptix-invoice-page .camptix-invoice-order th,
+               #camptix-invoice-page .camptix-invoice-order td {
+                       line-height: 2.5em;
+                       padding: 0 0.5em;
+               }
+
+               #camptix-invoice-page .camptix-invoice-order table {
+                       width: 100%;
+                       border-collapse: collapse;
+               }
+
+               #camptix-invoice-page .camptix-invoice-order th {
+                       background: #BBBBBB;
+               }
+
+               #camptix-invoice-page .camptix-invoice-payment-status {
+                       padding: 3em 0;
+               }
+
+               #camptix-invoice-page .camptix-invoice-payment-status p {
+                       font-weight: 700;
+               }
+
+       </style>
+</head>
+<body>
+<div id="camptix-invoice-page">
+       <div class="camptix-invoice-logo-holder">
+               <img src="<?php echo esc_url($logo); ?>">
+       </div>
+       <div class="camptix-inovice-header">
+               <div class="camptix-invoice-from-box text-left">
+                       <strong><?php esc_html_e( 'From', 'wordcamporg' ); ?>:</strong>
+                       <p class="text-left">
+                               <?php echo nl2br( esc_html( $camptix_opts['invoice-company'] ) ); ?>
+                       </p>
+               </div>
+               <div class="camptix-invoice-to-box text-right">
+                       <strong><?php esc_html_e('To', 'wordcamporg'); ?>:</strong>
+                       <p class="text-right">
+                               <?php echo esc_html( $invoice_metas['name'] ); ?><br/>
+                               <?php echo esc_html( $invoice_metas['address'] ); ?><br/>
+                       </p>
+                       <?php if ( ! empty( $invoice_metas['vat-number'] ) ) { ?>
+                               <strong><?php esc_html_e('VAT no', 'wordcamporg'); ?>:</strong>
+                               <?php echo esc_html( $invoice_metas['vat-number'] ); ?>
+                       <?php } ?>
+               </div>
+       </div>
+       <div class="camptix-invoice-data text-right">
+               <p class="text-right">
+                       <strong><?php esc_html_e( 'Invoice no', 'wordcamporg' ); ?>:</strong>
+                               <?php echo esc_html( $invoice_number ); ?>
+               </p>
+               <p class="text-right">
+                       <strong><?php esc_html_e( 'Invoice Date', 'wordcamporg' ); ?>:</strong>
+                               <?php echo esc_html( $invoice_date ); ?>
+               </p>
+       </div>
+       <div class="camptix-invoice-order">
+               <table>
+                       <colgroup>
+                               <col style="width: 48%"/>
+                               <col style="width: 8%"/>
+                               <col style="width: 22%"/>
+                               <col style="width: 22%"/>
+                       </colgroup>
+                       <tr>
+                               <th class="text-left"><?php echo esc_html( $camptix_opts['event_name'] ); ?></th>
+                               <th class="text-center"><?php esc_html_e( 'Qty', 'wordcamporg' ); ?></th>
+                               <th class="text-right"><?php esc_html_e( 'Unit Price', 'wordcamporg' ); ?></th>
+                               <th class="text-right"><?php esc_html_e( 'Total Price', 'wordcamporg'); ?></th>
+                       </tr>
+                               <?php foreach ( $invoice_order['items'] as $item ) : ?>
+                                       <tr>
+                                               <td class="text-left"><?php echo esc_html( $item['name'] ); ?></td>
+                                               <td class="text-center"><?php echo esc_html( $item['quantity'] ); ?></td>
+                                               <td class="text-right">
+                                                       <?php echo esc_html( CampTix_Addon_Invoices::format_currency( $item['price'], $camptix_opts['currency'] ) ); ?>
+                                               </td>
+
+                                               <td class="text-right">
+                                                       <?php echo esc_html( CampTix_Addon_Invoices::format_currency( $item['price'] * $item['quantity'], $camptix_opts['currency'] ) ); ?>
+                                               </td>
+                                       </tr>
+                               <?php endforeach ?>
+                       <tr>
+                               <td class="text-right"><?php esc_html_e('VAT', 'wordcamporg'); ?></td>
+                               <td></td>
+                               <td></td>
+                               <td class="text-right">
+                                       <?php echo esc_html( CampTix_Addon_Invoices::format_currency( 0, $camptix_opts['currency'] ) ); ?>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td class="text-right"><?php esc_html_e( 'TOTAL', 'wordcamporg' ); ?></td>
+                               <td></td>
+                               <td></td>
+                               <td class="text-right">
+                                       <?php echo esc_html( CampTix_Addon_Invoices::format_currency( $invoice_order['total'], $camptix_opts['currency'] ) ); ?>
+                               </td>
+                       </tr>
+               </table>
+       </div>
+       <div class="camptix-invoice-payment-status">
+               <p>
+                       <?php esc_html_e( 'Paid in full.', 'wordcamporg' ); ?>
+               </p>
+       </div>
+       <div class="camptix-invoice-note">
+               <?php echo nl2br( esc_html( $camptix_opts['invoice-thankyou'] ) ); ?>
+       </div>
+</div>
+</body>
+</html>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewslogofieldphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/logo-field.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/logo-field.php                            (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/logo-field.php      2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,34 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WPINC' ) || die();
+
+/** @var string $id */
+/** @var string $value */
+
+?>
+
+<div class="camptix-media">
+       <div class="camptix-invoice-logo-preview-wrapper" data-imagewrapper>
+               <?php
+               if ( ! empty( $value ) ) {
+                       $attachment = wp_get_attachment_image_src( $value, 'full' );
+                       printf( '<img src="%s" style="max-width:250px;max-height:200px;">', esc_url( $attachment[0] ) );
+               }
+               ?>
+       </div>
+
+       <input data-set type="button" class="button button-secondary" value="<?php echo esc_attr__( 'Pick a logo', 'wordcamporg' ); ?>" />
+       <input
+               data-unset
+               type="button"
+               class="button button-secondary"
+               value="<?php echo esc_attr__( 'Remove logo', 'wordcamporg' ); ?>"
+               <?php
+               if ( empty( $value ) ) {
+                       echo 'style="display:none;"';
+               }
+               ?>
+       />
+       <input type="hidden" name=camptix_options[<?php echo esc_attr( $id ); ?>] data-field="image_attachment" value="<?php echo esc_attr( $value ); ?>">
+       <p class="description"><?php echo esc_html__( 'Expected image size: 250px width, 200px height', 'wordcamporg' ); ?></p>
+</div>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesincludesviewssentinvoicemetaboxphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/sent-invoice-metabox.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/sent-invoice-metabox.php                          (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/includes/views/sent-invoice-metabox.php    2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,66 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WPINC' ) || die();
+
+/** @var array $order */
+/** @var array $metas */
+/** @var string $invoice_vat_number */
+/** @var int $txn_id */
+
+?>
+
+<h3><?php echo esc_html__( 'Order details', 'wordcamporg' ); ?></h3>
+
+<table class="widefat">
+       <thead>
+               <tr>
+                       <th><?php echo esc_html__( 'Title', 'wordcamporg' ); ?></th>
+                       <th><?php echo esc_html__( 'Unit price', 'wordcamporg' ); ?></th>
+                       <th><?php echo esc_html__( 'Quantity', 'wordcamporg' ); ?></th>
+               </tr>
+       </thead>
+
+       <tbody>
+
+       <?php foreach ( $order['items'] as $k => $item ) : ?>
+
+               <tr>
+                       <td><?php echo esc_html( $item['name'] ); ?></td><!-- name -->
+                       <td><?php echo esc_html( number_format_i18n( $item['price'], 2 ) ); ?></td><!-- price -->
+                       <td><?php echo esc_html( number_format_i18n( $item['quantity'] ) ); ?></td><!-- qty -->
+               </tr>
+
+       <?php endforeach; ?>
+
+       </tbody>
+</table>
+
+<table class="form-table">
+       <tr>
+               <th scope="row"><?php echo esc_html__( 'Total amount', 'wordcamporg' ); ?></th>
+               <td><?php echo esc_html( number_format_i18n( $order['total'], 2 ) ); ?></td>
+       </tr>
+       <tr>
+               <th scope="row"><?php echo esc_html__( 'Customer', 'wordcamporg' ); ?></th>
+               <td><?php echo esc_html( $metas['name'] ); ?><td>
+       </tr>
+       <tr>
+               <th scope="row"><?php echo esc_html__( 'Contact email', 'wordcamporg' ); ?></th>
+               <td><?php echo esc_html( $metas['email'] ); ?><td>
+       </tr>
+       <tr>
+               <th scope="row"><?php echo esc_html__( 'Customer Address', 'wordcamporg' ); ?></th>
+               <td><?php echo wp_kses( nl2br( $metas['address'] ), array( 'br' => true ) ); ?><td>
+       </tr>
+       <tr>
+               <th scope="row"><?php echo esc_html__( 'Transaction ID', 'wordcamporg' ); ?></th>
+               <td><?php echo esc_html( $txn_id ); ?><td>
+       </tr>
+
+       <?php if ( ! empty( $invoice_vat_number ) ) : ?>
+               <tr>
+                       <th scope="row"><?php echo esc_html__( 'VAT number', 'wordcamporg' ); ?></th>
+                       <td><?php echo esc_html( $metas['vat-number'] ); ?><td>
+               </tr>
+       <?php endif; ?>
+</table>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesindexphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/index.php                                (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/index.php  2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php // Silence is golden
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/index.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:executable</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+*
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixinvoicesreadmetxt"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/readme.txt</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/readme.txt                               (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-invoices/readme.txt 2019-04-23 17:18:46 UTC (rev 8657)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,59 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+=== Camptix Invoices ===
+Contributors: willybahuaud, simonjanin, iceable, avillegasn, tfrommen, nem-c
+Tags: camptix, invoice, event, organizer, tickets, notes
+Requires at least: 3.0.1
+Tested up to: 5.0.3
+Requires PHP: 5.4
+Stable tag: 1.0.0
+License: GPLv2 or later
+License URI: http://www.gnu.org/licenses/gpl-2.0.html
+Text Domain: invoices-camptix
+
+Allow CampTix administrators to send invoices automatically when an attendee buys a ticket.
+
+== Description ==
+
+Allow CampTix administrators to send invoices automatically when an attendee buys a ticket.
+
+This plugin requires the installation of [Camptix Event Ticketing plugin](https://wordpress.org/plugins/camptix/).
+
+This plugin requires the WordCamp Docs plugin present in every WordCamp site.
+Alternatively, make sure you include the [WordCamp_Docs_PDF_Generator](https://meta.trac.wordpress.org/browser/sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-docs/classes/class-wordcamp-docs-pdf-generator.php).
+
+Your server must have [wkhtmltopdf](https://wkhtmltopdf.org/) installed.
+
+
+== Installation ==
+
+1. Install and configure CampTix plugin
+1. Download and activate CampTix Invoice through the 'Plugins' menu in WordPress
+1. Go to CampTix settings to define Event information (organiser name, logo, invoice name)
+
+
+== Frequently Asked Questions ==
+
+= Can I add a custom invoice? =
+
+Yes, you can create your own invoice (using the CampTix > Invoices submenu ).
+Be warned that you can't edit or delete a published invoice, so… save it as draft before every items/information are ok!
+
+= How can I customize Invoices template? =
+
+You can drop a copy of file `includes/views/invoice-template.php` into your theme folder and name it `invoice-template.php`.
+Then modify the HTML layout and styles as you want.
+
+== Changelog ==
+
+= 1.0.2 (March 2019)
+* **Improvement**. Use the PDF library already present in the WordCamp.org codebase
+
+= 1.0.1 (January 14, 2019) =
+* **Improvement**. Added an option in CampTix setting to enable invoicing
+* **Improvement**. Added a setting for the date format used on the invoices
+* **Improvement**. Modified invoice template to mimic WCEU 2019 styles
+* **Improvement**. Added a "VAT Number" field to the invoice request form
+* **Bug fix**. Users now can request an invoice if permalinks are set to "plain"
+* Several other improvements and bug fixes
+
+= 1.0.0 =
+* Initial release!
</ins></span></pre>
</div>
</div>

</body>
</html>